1.Introduce CustomScan into openGauss CustomScan is a powerful PostgreSQL feature that allows developers to extend the query executor by implementing custom scan providers. This enables integration of specialized data sources or optimization techniques that aren't natively supported by PostgreSQL. a. CustomScan node: A plan node that represents the custom scan operation b. CustomScan methods: Callbacks that implement the scan behavior c. CustomScan provider: The extension that registers the custom scan implementation CustomScan is an advanced feature primarily used by extension developers to deeply integrate specialized data processing capabilities with PostgreSQL's query executor. add transaction callbacks interface before commit and prepare stage. extenal extension can use those interface to participate opengauss's transaction model. 2.adapt bgworker for plugin. 3.Add spq build adaption 4.Fit for extensible plan/extensible node. 5.Allow auth logic to continue search after found an rule with remote trust but the connection is not from coordinator.
383 lines
15 KiB
Bash
383 lines
15 KiB
Bash
#!/bin/bash
|
|
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2025. All rights reserved.
|
|
# descript: Compile and pack openGauss
|
|
#######################################################################
|
|
## Check the installation package production environment
|
|
#######################################################################
|
|
function gaussdb_pkg_pre_clean()
|
|
{
|
|
if [ -d "$BUILD_DIR" ]; then
|
|
rm -rf $BUILD_DIR
|
|
fi
|
|
if [ -d "$LOG_FILE" ]; then
|
|
rm -rf $LOG_FILE
|
|
fi
|
|
}
|
|
###################################
|
|
|
|
#######################################################################
|
|
##read version from gaussdb.ver
|
|
#######################################################################
|
|
function read_gaussdb_version()
|
|
{
|
|
cd ${SCRIPT_DIR}
|
|
echo "${product_name}-Server-${version_number}" > version.cfg
|
|
#auto read the number from kernal globals.cpp, no need to change it here
|
|
}
|
|
|
|
PG_REG_TEST_ROOT="${ROOT_DIR}"
|
|
ROACH_DIR="${ROOT_DIR}/distribute/bin/roach"
|
|
MPPDB_DECODING_DIR="${ROOT_DIR}/contrib/mppdb_decoding"
|
|
XLOG_DUMP_DIR="${ROOT_DIR}/contrib/pg_xlogdump"
|
|
PAGE_HACK_DIR="${ROOT_DIR}/contrib/pagehack"
|
|
ARCH_CLEAN_DIR="${ROOT_DIR}/contrib/pg_archivecleanup"
|
|
|
|
|
|
###################################
|
|
# get version number from globals.cpp
|
|
##################################
|
|
function read_gaussdb_number()
|
|
{
|
|
global_kernal="${ROOT_DIR}/src/common/backend/utils/init/globals.cpp"
|
|
version_name="GRAND_VERSION_NUM"
|
|
version_num=""
|
|
line=$(cat $global_kernal | grep ^const* | grep $version_name)
|
|
version_num1=${line#*=}
|
|
#remove the symbol;
|
|
version_num=$(echo $version_num1 | tr -d ";")
|
|
#remove the blank
|
|
version_num=$(echo $version_num)
|
|
|
|
if echo $version_num | grep -qE '^92[0-9]+$'
|
|
then
|
|
# get the last three number
|
|
latter=${version_num:2}
|
|
echo "92.${latter}" >>${SCRIPT_DIR}/version.cfg
|
|
else
|
|
echo "Cannot get the version number from globals.cpp."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
#######################################################################
|
|
##insert the commitid to version.cfg as the upgrade app path specification
|
|
#######################################################################
|
|
function get_kernel_commitid()
|
|
{
|
|
export PATH=${BUILD_DIR}:$PATH
|
|
export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH
|
|
commitid=$(LD_PRELOAD='' ${BUILD_DIR}/bin/gaussdb -V | awk '{print $5}' | cut -d ")" -f 1)
|
|
echo "${commitid}" >>${SCRIPT_DIR}/version.cfg
|
|
echo "End insert commitid into version.cfg" >> "$LOG_FILE" 2>&1
|
|
}
|
|
|
|
#######################################################################
|
|
##insert the version mode to version.cfg
|
|
#######################################################################
|
|
function get_version_mode()
|
|
{
|
|
echo "$version_mode" >> ${SCRIPT_DIR}/version.cfg
|
|
echo "End insert version mode into version cfg" >> "$LOG_FILE" 2>&1
|
|
}
|
|
|
|
#######################################################################
|
|
## generate the version file.
|
|
#######################################################################
|
|
function make_license_control()
|
|
{
|
|
python_exec=$(which python 2>/dev/null)
|
|
|
|
if [ -x "$python_exec" ]; then
|
|
$python_exec ${binarylib_dir}/buildtools/license_control/encrypted_version_file.py >> "$LOG_FILE" 2>&1
|
|
fi
|
|
|
|
if [ $? -ne 0 ]; then
|
|
die "create ${binarylib_dir}/buildtools/license_control license file failed."
|
|
fi
|
|
|
|
if [ -f "$gaussdb_200_file" ] && [ -f "$gaussdb_300_file" ]; then
|
|
# Get the md5sum.
|
|
gaussdb_200_sha256sum=$(sha256sum $gaussdb_200_file | awk '{print $1}')
|
|
gaussdb_300_sha256sum=$(sha256sum $gaussdb_300_file | awk '{print $1}')
|
|
# Modify the source code.
|
|
sed -i "s/^[ \t]*const[ \t]\+char[ \t]*\*[ \t]*sha256_digests[ \t]*\[[ \t]*SHA256_DIGESTS_COUNT[ \t]*\][ \t]*=[ \t]*{[ \t]*NULL[ \t]*,[ \t]*NULL[ \t]*}[ \t]*;[ \t]*$/const char \*sha256_digests\[SHA256_DIGESTS_COUNT\] = {\"$gaussdb_200_sha256sum\", \"$gaussdb_300_sha256sum\"};/g" $gaussdb_version_file
|
|
fi
|
|
|
|
if [ $? -ne 0 ]; then
|
|
die "modify '$gaussdb_version_file' failed."
|
|
fi
|
|
}
|
|
|
|
#######################################################################
|
|
##back to separate_debug_symbol.sh dir
|
|
#######################################################################
|
|
function separate_symbol()
|
|
{
|
|
cd $SCRIPT_DIR
|
|
if [ "$version_mode" = "release" -a "$separate_symbol" = "on" ]; then
|
|
chmod +x ./separate_debug_information.sh
|
|
./separate_debug_information.sh
|
|
cd $SCRIPT_DIR
|
|
mkdir -p $package_path
|
|
mv symbols.tar.gz $package_path/$symbol_package_name
|
|
|
|
fi
|
|
}
|
|
|
|
#######################################################################
|
|
##install gaussdb database contained server,client and libpq
|
|
#######################################################################
|
|
function install_gaussdb()
|
|
{
|
|
# Generate the license control file, and set md5sum string to the code.
|
|
echo "Modify gaussdb_version.cpp file." >> "$LOG_FILE" 2>&1
|
|
make_license_control
|
|
echo "Modify gaussdb_version.cpp file success." >> "$LOG_FILE" 2>&1
|
|
#putinto to Code dir
|
|
cd "$ROOT_DIR"
|
|
#echo "$ROOT_DIR/Code"
|
|
if [ $? -ne 0 ]; then
|
|
die "change dir to $ROOT_DIR failed."
|
|
fi
|
|
|
|
if [ "$version_mode" = "debug" -a "$separate_symbol" = "on" ]; then
|
|
echo "WARNING: do not separate symbol in debug mode!"
|
|
fi
|
|
|
|
if [ "$product_mode" != "opengauss" -a "$product_mode" != "lite" -a "$product_mode" != "finance" ]; then
|
|
die "the product mode can only be opengauss, lite, finance!"
|
|
fi
|
|
|
|
#configure
|
|
make distclean -sj >> "$LOG_FILE" 2>&1
|
|
|
|
echo "Begin configure." >> "$LOG_FILE" 2>&1
|
|
chmod 755 configure
|
|
|
|
if [ "$product_mode"x == "opengauss"x -a "$PLATFORM_ARCH"x != "loongarch64"x ]; then
|
|
enable_readline="--with-readline"
|
|
else
|
|
enable_readline="--without-readline"
|
|
fi
|
|
|
|
if [ "$build_with_tassl"x == "YES"x ]; then
|
|
with_tassl="--with-tassl"
|
|
else
|
|
with_tassl=""
|
|
fi
|
|
|
|
shared_opt="--gcc-version=${gcc_version}.${gcc_sub_version} --prefix="${BUILD_DIR}" --3rd=${binarylib_dir} --enable-thread-safety ${enable_readline} ${with_tassl} --without-zlib"
|
|
if [ "$product_mode"x == "opengauss"x ]; then
|
|
GAUSSDB_EXTRA_FLAGS=" "
|
|
|
|
if [[ "$PLATFORM_ARCH"x == "x86_64"x || "$PLATFORM_ARCH"x == "aarch64"x ]] ; then
|
|
extra_config_opt+=" --enable-mot --enable-bbox "
|
|
fi
|
|
|
|
if [ "$PLATFORM_ARCH"x = "loongarch64"x ] ; then
|
|
GAUSSDB_EXTRA_FLAGS+=" -D__USE_SPINLOCK"
|
|
extra_config_opt+=" --enable-llvm=no --disable-jemalloc "
|
|
fi
|
|
|
|
if [ "$version_mode"x == "release"x ]; then
|
|
# configure -D__USE_NUMA -D__ARM_LSE with arm opengauss mode
|
|
if [ "$PLATFORM_ARCH"X == "aarch64"X ] ; then
|
|
echo "configure -D__USE_NUMA -D__ARM_LSE with arm opengauss mode"
|
|
GAUSSDB_EXTRA_FLAGS=" -D__USE_NUMA -D__ARM_LSE"
|
|
fi
|
|
|
|
./configure $shared_opt CFLAGS="-O2 -g3 ${GAUSSDB_EXTRA_FLAGS}" CC=g++ $extra_config_opt >> "$LOG_FILE" 2>&1
|
|
elif [ "$version_mode"x == "memcheck"x ]; then
|
|
./configure $shared_opt CFLAGS="-O0" --enable-debug --enable-cassert --enable-memory-check CC=g++ $extra_config_opt >> "$LOG_FILE" 2>&1
|
|
elif [ "$version_mode"x == "fiurelease"x ]; then
|
|
./configure $shared_opt CFLAGS="-O2 -g3 ${GAUSSDB_EXTRA_FLAGS}" --disable-jemalloc CC=g++ $extra_config_opt >> "$LOG_FILE" 2>&1
|
|
elif [ "$version_mode"x == "fiudebug"x ]; then
|
|
./configure $shared_opt CFLAGS="-O0 ${GAUSSDB_EXTRA_FLAGS}" --enable-debug --enable-cassert --disable-jemalloc CC=g++ $extra_config_opt >> "$LOG_FILE" 2>&1
|
|
else
|
|
./configure $shared_opt CFLAGS="-O0 ${GAUSSDB_EXTRA_FLAGS}" --enable-debug --enable-cassert CC=g++ $extra_config_opt >> "$LOG_FILE" 2>&1
|
|
fi
|
|
elif [ "$product_mode"x == "lite"x ]; then
|
|
shared_opt="--gcc-version=${gcc_version}.${gcc_sub_version} --prefix="${BUILD_DIR}" --3rd=${binarylib_dir} --enable-thread-safety ${enable_readline} ${with_tassl} --without-zlib --without-gssapi --without-krb5"
|
|
if [ "$version_mode"x == "release"x ]; then
|
|
# configure -D__USE_NUMA -D__ARM_LSE with arm single mode
|
|
if [ "$PLATFORM_ARCH"X == "aarch64"X ] ; then
|
|
echo "configure -D__USE_NUMA -D__ARM_LSE with arm single mode"
|
|
GAUSSDB_EXTRA_FLAGS=" -D__USE_NUMA -D__ARM_LSE"
|
|
fi
|
|
./configure $shared_opt CFLAGS="-O2 -g3 ${GAUSSDB_EXTRA_FLAGS}" CC=g++ $extra_config_opt --enable-lite-mode >> "$LOG_FILE" 2>&1
|
|
elif [ "$version_mode"x == "memcheck"x ]; then
|
|
./configure $shared_opt CFLAGS='-O0' --enable-debug --enable-cassert --enable-memory-check CC=g++ $extra_config_opt --enable-lite-mode >> "$LOG_FILE" 2>&1
|
|
else
|
|
./configure $shared_opt CFLAGS="-O0 ${GAUSSDB_EXTRA_FLAGS}" --enable-debug --enable-cassert CC=g++ $extra_config_opt --enable-lite-mode>> "$LOG_FILE" 2>&1
|
|
fi
|
|
elif [ "$product_mode"x == "finance"x ]; then
|
|
shared_opt="--gcc-version=${gcc_version}.${gcc_sub_version} --prefix="${BUILD_DIR}" --3rd=${binarylib_dir} --enable-thread-safety ${enable_readline} ${with_tassl} --without-zlib --without-gssapi --without-krb5"
|
|
if [ "$version_mode"x == "release"x ]; then
|
|
# configure -D__USE_NUMA -D__ARM_LSE with arm single mode
|
|
if [ "$PLATFORM_ARCH"X == "aarch64"X ] ; then
|
|
echo "configure -D__USE_NUMA -D__ARM_LSE with arm single mode"
|
|
GAUSSDB_EXTRA_FLAGS=" -D__USE_NUMA -D__ARM_LSE"
|
|
fi
|
|
./configure $shared_opt CFLAGS="-O2 -g3 ${GAUSSDB_EXTRA_FLAGS}" CC=g++ $extra_config_opt --enable-finance-mode >> "$LOG_FILE" 2>&1
|
|
elif [ "$version_mode"x == "memcheck"x ]; then
|
|
./configure $shared_opt CFLAGS='-O0' --enable-debug --enable-cassert --enable-memory-check CC=g++ $extra_config_opt --enable-finance-mode >> "$LOG_FILE" 2>&1
|
|
else
|
|
./configure $shared_opt CFLAGS="-O0 ${GAUSSDB_EXTRA_FLAGS}" --enable-debug --enable-cassert CC=g++ $extra_config_opt --enable-finance-mode>> "$LOG_FILE" 2>&1
|
|
fi
|
|
fi
|
|
|
|
if [ $? -ne 0 ]; then
|
|
die "configure failed."
|
|
fi
|
|
echo "End configure" >> "$LOG_FILE" 2>&1
|
|
|
|
echo "Begin make install MPPDB server" >> "$LOG_FILE" 2>&1
|
|
make clean >> "$LOG_FILE" 2>&1
|
|
|
|
export GAUSSHOME=${BUILD_DIR}
|
|
export LD_LIBRARY_PATH=${BUILD_DIR}/lib:${BUILD_DIR}/lib/postgresql:${LD_LIBRARY_PATH}
|
|
make -sj 20 >> "$LOG_FILE" 2>&1
|
|
make install -sj 8>> "$LOG_FILE" 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
make install -sj 8>> "$LOG_FILE" 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
make install -sj 8>> "$LOG_FILE" 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
die "make install failed."
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
cd "$ROOT_DIR/contrib/pg_upgrade_support"
|
|
make clean >> "$LOG_FILE" 2>&1
|
|
make -sj >> "$LOG_FILE" 2>&1
|
|
make install -sj >> "$LOG_FILE" 2>&1
|
|
echo "End make install MPPDB" >> "$LOG_FILE" 2>&1
|
|
|
|
ASSESSMENT_DIR=$ROOT_DIR/contrib/assessment
|
|
if [ -d $ASSESSMENT_DIR ]; then
|
|
cd $ASSESSMENT_DIR
|
|
make install >> "$LOG_FILE" 2>&1
|
|
echo "End make install assessment" >> "$LOG_FILE" 2>&1
|
|
fi
|
|
|
|
cd "$ROOT_DIR"
|
|
if [ "${make_check}" = 'on' ]; then
|
|
echo "Begin make check MPPDB..." >> "$LOG_FILE" 2>&1
|
|
cd ${PG_REG_TEST_ROOT}
|
|
make check -sj >> "$LOG_FILE" 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
die "make check MPPDB failed."
|
|
fi
|
|
echo "End make check MPPDB success." >> "$LOG_FILE" 2>&1
|
|
fi
|
|
|
|
echo "Begin make install mpp_decoding..." >> "$LOG_FILE" 2>&1
|
|
#copy mppdb_decoding form clienttools to bin
|
|
if [ "$version_mode"x == "release"x ]; then
|
|
cd "$MPPDB_DECODING_DIR"
|
|
make >> "$LOG_FILE" 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
die "make install mppdb_decoding failed."
|
|
fi
|
|
echo "End make install mppdb_decoding success." >> "$LOG_FILE" 2>&1
|
|
echo "Begin pack mppdb_decoding..." >> "$LOG_FILE" 2>&1
|
|
cp ${MPPDB_DECODING_DIR}/mppdb_decoding.so ${BUILD_DIR}/lib/postgresql/mppdb_decoding.so
|
|
elif [ "$version_mode"x == "memcheck"x ]; then
|
|
cd "$MPPDB_DECODING_DIR"
|
|
make >> "$LOG_FILE" 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
die "make install mppdb_decoding failed."
|
|
fi
|
|
echo "End make install mppdb_decoding success." >> "$LOG_FILE" 2>&1
|
|
echo "Begin pack mppdb_decoding..." >> "$LOG_FILE" 2>&1
|
|
cp ${MPPDB_DECODING_DIR}/mppdb_decoding.so ${BUILD_DIR}/lib/postgresql/mppdb_decoding.so
|
|
else
|
|
cd "$MPPDB_DECODING_DIR"
|
|
make >> "$LOG_FILE" 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
die "make install mppdb_decoding failed."
|
|
fi
|
|
echo "End make install mppdb_decoding success." >> "$LOG_FILE" 2>&1
|
|
echo "Begin pack mppdb_decoding..." >> "$LOG_FILE" 2>&1
|
|
cp ${MPPDB_DECODING_DIR}/mppdb_decoding.so ${BUILD_DIR}/lib/postgresql/mppdb_decoding.so
|
|
fi
|
|
if [ $? -ne 0 ]; then
|
|
if [ "$version_mode"x == "release"x ]; then
|
|
die "cp ${MPPDB_DECODING_DIR}/mppdb_decoding ${MPPDB_DECODING_DIR}/bin/mppdb_decoding failed"
|
|
else
|
|
die "cp ${MPPDB_DECODING_DIR}/mppdb_decoding ${MPPDB_DECODING_DIR}/bin/mppdb_decoding failed"
|
|
fi
|
|
fi
|
|
|
|
cd "$XLOG_DUMP_DIR"
|
|
make clean >> "$LOG_FILE" 2>&1
|
|
make -sj >> "$LOG_FILE" 2>&1
|
|
make install -sj >> "$LOG_FILE" 2>&1
|
|
echo "End make install xlog_dump" >> "$LOG_FILE" 2>&1
|
|
|
|
cd "$PAGE_HACK_DIR"
|
|
make clean >> "$LOG_FILE" 2>&1
|
|
make -sj >> "$LOG_FILE" 2>&1
|
|
make install -sj >> "$LOG_FILE" 2>&1
|
|
echo "End make install pagehack" >> "$LOG_FILE" 2>&1
|
|
|
|
cd "$ARCH_CLEAN_DIR"
|
|
make clean >> "$LOG_FILE" 2>&1
|
|
make -sj >> "$LOG_FILE" 2>&1
|
|
make install -sj >> "$LOG_FILE" 2>&1
|
|
echo "End make install archivecleanup" >> "$LOG_FILE" 2>&1
|
|
|
|
chmod 444 ${BUILD_DIR}/bin/cluster_guc.conf
|
|
dos2unix ${BUILD_DIR}/bin/cluster_guc.conf > /dev/null 2>&1
|
|
get_kernel_commitid
|
|
get_version_mode
|
|
}
|
|
|
|
function spq_build() {
|
|
if [ -z "${SPQ_ROOT}" ]; then
|
|
SPQ_ROOT="${ROOT_DIR}/../spq"
|
|
echo "INFO: Auto set SPQ_ROOT to ${SPQ_ROOT}"
|
|
fi
|
|
|
|
if [ ! -d "${SPQ_ROOT}" ]; then
|
|
echo "ERROR: Invalid SPQ_ROOT path '${SPQ_ROOT}'"
|
|
return
|
|
fi
|
|
|
|
echo "Building in ${SPQ_ROOT}..."
|
|
(
|
|
cd "${SPQ_ROOT}" && \
|
|
rm -rf build && \
|
|
mkdir build && \
|
|
cd build
|
|
../configure && \
|
|
make -sj && \
|
|
make install
|
|
) || {
|
|
echo "WARNING: Build spq failed, continuing other building steps..."
|
|
}
|
|
|
|
cd -
|
|
}
|
|
|
|
#######################################################################
|
|
##install gaussdb database and others
|
|
##select to install something according to variables package_type need
|
|
#######################################################################
|
|
function gaussdb_build()
|
|
{
|
|
case "$package_type" in
|
|
server)
|
|
install_gaussdb
|
|
;;
|
|
libpq)
|
|
install_gaussdb
|
|
;;
|
|
*)
|
|
echo "Internal Error: option processing error: $package_type"
|
|
echo "please input right paramenter values server or libpq "
|
|
exit 1
|
|
esac
|
|
}
|