declare -a pg_header_file_map=("visibilitymap.h""rewriteheap.h""heapam_xlog.h""hio.h""heapam.h""heaptoast.h")
declare -a tde_header_file_map=("pg_tde_visibilitymap.h""pg_tde_rewrite.h""pg_tdeam_xlog.h""pg_tde_io.h""pg_tdeam.h""pg_tdetoast.h")
declare -a pg_c_file_map=("heapam.c""heapam_handler.c""heapam_visibility.c""heaptoast.c""hio.c""pruneheap.c""rewriteheap.c""vacuumlazy.c""visibilitymap.c")
declare -a tde_c_file_map=("pg_tdeam.c""pg_tdeam_handler.c""pg_tdeam_visibility.c""pg_tdetoast.c""pg_tde_io.c""pg_tde_prune.c""pg_tde_rewrite.c""pg_tde_vacuumlazy.c""pg_tde_visibilitymap.c")
## USAGE
usage()
{
errorCode=${1:-0}
cat << EOF
usage: $0 OPTIONS
This script generates file-wise patches between two PG commits and applies it to
the TDE extension source.
By default, it only performs a dry run of the patch application. See the usage
options below for applying clean patches or forcefully applying all patches.
It clones both PG and TDE repositories in the working directory. If TDE path is
specified either with its usage option or via the environment variable, then
the script will use the given TDE source code.
* All working folders folders created will carry "$TDE" as part of the folder name.
* This simplies the manual cleanup process.
OPTIONS can be:
-h Show this message
-a The patches are not applied by default. Specify this to
apply the generated patches. Otherwise, the script will
only perform a dryrun.
-f Force apply patches.
-b [PG_COMMIT_BASE] PG base commit hash/branch/tag for patch [REQUIRED]
-l [PG_COMMIT_LATEST] PG lastest commit hash/branch/tag for patch [REQUIRED]
-x [TDE_COMMIT] TDE commit hash/branch/tag to apply patch on [REQUIRED]
-t [USER_TDE_DIR] Source directory for TDE [Default: Cloned under WORKING_DIR]
-w [WORKING_DIR] Script working folder [Default: $WORKING_DIR]
* a folder where patches and relevant log
files may be created. This folder will not be removed
by the script, so better to keep it in the temp folder.
EOF
if[[$errorCode -ne 0]];
then
exit_script $errorCode
fi
}
# Perform any required cleanup and exit with the given error/success code
exit_script()
{
# Reminder of manual cleanup
if[[ -d $WORKING_DIR]];
then
printf"\n%20s\n"| tr " ""-"
printf"The following folder was created by the script and may require manual removal.\n"
printf"* %s\n"$WORKING_DIR
printf"%20s\n"| tr " ""-"
fi
# Exit with a given return code or 0 if none are provided.
exit${1:-0}
}
# Raise the error for a failure to checkout required source
checkout_validate()
{
commit=$1
retval=$2
if[[$rteval -ne 0]];
then
printf"%s is not a valid commit hash/branch/tag.\n"$commit
exit_script $retval
fi
}
# Vaildate arguments to ensure that we can safely run the benchmark
validate_args()
{
localUSAGE_TEXT="See usage for details."
localPATH_ERROR_TEXT="path is not a valid directory."