Compare commits

..

2 Commits
master ... glt

Author SHA1 Message Date
opengauss-bot 5e70d87b5c
!2612 openGauss端实现全局逻辑时钟功能
Merge pull request !2612 from 周聪/glt_20221213_cherrypick
2022-12-21 11:30:46 +00:00
congzhou2603 a14adeebf8 openGauss-server 实现全局逻辑时钟功能 2022-12-21 16:53:10 +08:00
1823 changed files with 85679 additions and 132860 deletions

View File

@ -16,8 +16,7 @@
1. 请附上自验结果(内容或者截图)
2. 是否可以添加fastcheck测试用例如是请补充fastcheck用例
3. 是否涉及资料修改如是在docs仓库补充资料
4. 是否考虑升级场景(系统表修改、日志持久化以及修改执行态数据格式)
5. 是否考虑在线扩容等扩展场景
4. 是否考虑支撑升级和在线扩容等扩展场景
5. 是否考虑异常场景/并发场景/前向兼容/性能场景
6. 是否对其他模块产生影响

24
.gitmodules vendored
View File

@ -1,24 +0,0 @@
[submodule "openGauss-Custom-function"]
path = openGauss-Custom-function
url = ../openGauss-Custom-function.git
[submodule "openGauss-Query-select"]
path = openGauss-Query-select
url = ../openGauss-Query-select.git
[submodule "openGauss-Security-control"]
path = openGauss-Security-control
url = ../openGauss-Security-control.git
[submodule "openGauss-Stored-Procedure"]
path = openGauss-Stored-Procedure
url = ../openGauss-Stored-Procedure.git
[submodule "openGauss-basic-operation"]
path = openGauss-basic-operation
url = ../openGauss-basic-operation.git
[submodule "openGauss-transaction"]
path = openGauss-transaction
url = ../openGauss-transaction.git
[submodule "openGauss-trigger"]
path = openGauss-trigger
url = ../openGauss-trigger.git
[submodule "openGauss-competition"]
path = openGauss-competition
url = ../openGauss-competition.git

View File

@ -93,7 +93,6 @@ install:
$(MAKE) install_pldebugger
$(MAKE) -C contrib/postgres_fdw $@
$(MAKE) -C contrib/hstore $@
$(MAKE) -C contrib/dblink $@
@if test -d contrib/dolphin; then $(MAKE) -C contrib/dolphin $@; fi
+@echo "openGauss installation complete."
endif

View File

@ -414,8 +414,6 @@ https://opengauss.org/zh/
| 2.1.0 | https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.1.0/openGauss-third_party_binarylibs.tar.gz |
| 3.0.0 | https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.0.0/openGauss-third_party_binarylibs.tar.gz |
| 3.1.0 | **openEuler_arm:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/openGauss-third_party_binarylibs_openEuler_arm.tar.gz <br/> **openEuler_x86:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz<br/> **Centos_x86:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz |
| 3.1.1 | **openEuler_arm:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.1.1/binarylibs/openGauss-third_party_binarylibs_openEuler_arm.tar.gz <br/> **openEuler_x86:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.1.1/binarylibs/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz<br/> **Centos_x86:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.1.1/binarylibs/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz |
| 5.0.0 | **openEuler_arm:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_openEuler_arm.tar.gz <br/> **openEuler_x86:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz<br/> **Centos_x86:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz |
| master | **openEuler_arm:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/openGauss-third_party_binarylibs_openEuler_arm.tar.gz <br/> **openEuler_x86:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/openGauss-third_party_binarylibs_openEuler_x86_64.tar.gz<br/> **Centos_x86:** https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/binarylibs/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz |
现在我们已经拥有完整的openGauss代码把它存储在以下目录中以sda为例

View File

@ -904,4 +904,4 @@
./include/pqcomm.h
./include/pqexpbuffer.h
[version]
5.0.0
3.1.0

View File

@ -40,6 +40,7 @@
./bin/kadmin.local
./bin/lz4
./bin/kadmind
./bin/dbmind
./bin/gs_dbmind
./bin/constant
./bin/server.key.cipher
@ -83,9 +84,6 @@
./share/postgresql/extension/mot_fdw.control
./share/postgresql/extension/postgres_fdw--1.0.sql
./share/postgresql/extension/postgres_fdw.control
./share/postgresql/extension/dblink--1.0.sql
./share/postgresql/extension/dblink--unpackaged--1.0.sql
./share/postgresql/extension/dblink.control
./share/postgresql/timezone/GB-Eire
./share/postgresql/timezone/Turkey
./share/postgresql/timezone/Kwajalein
@ -760,7 +758,6 @@
./lib/postgresql/pg_upgrade_support.so
./lib/postgresql/java/pljava.jar
./lib/postgresql/postgres_fdw.so
./lib/postgresql/dblink.so
./lib/postgresql/pgoutput.so
./lib/libpljava.so
./lib/libpq.a
@ -835,7 +832,6 @@
./lib/libpagecompression.so*
./lib/libdssapi.so
./lib/libdms.so
./lib/libodbc.so*
./include/postgresql/server/postgres_ext.h
./include/postgresql/server/pg_config_os.h

View File

@ -442,7 +442,6 @@ function install_gaussdb()
export BUILD_TUPLE=${PLATFORM_ARCH}
export THIRD_BIN_PATH="${binarylibs_path}"
export PREFIX_HOME="${BUILD_DIR}"
export ENABLE_LITE_MODE=ON
if [ "$version_mode"x == "release"x ]; then
CMAKE_OPT="-DENABLE_MULTIPLE_NODES=OFF -DENABLE_PRIVATEGAUSS=OFF -DENABLE_THREAD_SAFETY=ON -DENABLE_LITE_MODE=ON"
@ -455,10 +454,6 @@ function install_gaussdb()
export DEBUG_TYPE=debug
fi
if [[ -e "/etc/openEuler-release" && "$(cat /etc/openEuler-release | awk '{print $3}')" == "22.03" ]]; then
CMAKE_OPT="$CMAKE_OPT -DENABLE_OPENEULER_MAJOR=ON"
fi
echo "CMAKE_OPT----> $CMAKE_OPT"
echo "Begin run cmake for gaussdb server" >> "$LOG_FILE" 2>&1
echo "CMake options: ${CMAKE_OPT}" >> "$LOG_FILE" 2>&1
echo "CMake release: ${DEBUG_TYPE}" >> "$LOG_FILE" 2>&1

View File

@ -1,2 +1,2 @@
PRODUCT=openGauss
VERSION=5.0.0
VERSION=3.1.0

View File

@ -38,6 +38,7 @@
./bin/kadmin.local
./bin/lz4
./bin/kadmind
./bin/dbmind
./bin/server.key.cipher
./bin/server.key.rand
./etc/kerberos/kadm5.acl
@ -79,9 +80,6 @@
./share/postgresql/extension/gsredistribute--unpackaged--1.0.sql
./share/postgresql/extension/postgres_fdw--1.0.sql
./share/postgresql/extension/postgres_fdw.control
./share/postgresql/extension/dblink--1.0.sql
./share/postgresql/extension/dblink--unpackaged--1.0.sql
./share/postgresql/extension/dblink.control
./share/postgresql/timezone/GB-Eire
./share/postgresql/timezone/Turkey
./share/postgresql/timezone/Kwajalein
@ -755,7 +753,6 @@
./lib/postgresql/pg_upgrade_support.so
./lib/postgresql/java/pljava.jar
./lib/postgresql/postgres_fdw.so
./lib/postgresql/dblink.so
./lib/libpljava.so
./lib/libpq.a
./lib/libpq.so
@ -884,7 +881,6 @@
./lib/postgresql/latin2_and_win1250.so
./lib/postgresql/euc2004_sjis2004.so
./lib/libhll.so
./lib/libodbc.so*
./include/postgresql/server/postgres_ext.h
./include/postgresql/server/pg_config_os.h

View File

@ -37,7 +37,7 @@
./bin/kadmin.local
./bin/lz4
./bin/kadmind
./bin/gs_dbmind
./bin/dbmind
./bin/server.key.cipher
./bin/server.key.rand
./bin/gs_plan_simulator.sh
@ -82,9 +82,6 @@
./share/postgresql/extension/gsredistribute--unpackaged--1.0.sql
./share/postgresql/extension/postgres_fdw--1.0.sql
./share/postgresql/extension/postgres_fdw.control
./share/postgresql/extension/dblink--1.0.sql
./share/postgresql/extension/dblink--unpackaged--1.0.sql
./share/postgresql/extension/dblink.control
./share/postgresql/timezone/GB-Eire
./share/postgresql/timezone/Turkey
./share/postgresql/timezone/Kwajalein
@ -758,7 +755,6 @@
./lib/postgresql/pg_upgrade_support.so
./lib/postgresql/java/pljava.jar
./lib/postgresql/postgres_fdw.so
./lib/postgresql/dblink.so
./lib/libpljava.so
./lib/libpq.a
./lib/libpq.so
@ -887,7 +883,6 @@
./lib/postgresql/latin2_and_win1250.so
./lib/postgresql/euc2004_sjis2004.so
./lib/libhll.so
./lib/libodbc.so*
./include/postgresql/server/postgres_ext.h
./include/postgresql/server/pg_config_os.h

View File

@ -903,4 +903,4 @@
./include/pqcomm.h
./include/pqexpbuffer.h
[version]
5.0.0
3.1.0

View File

@ -40,6 +40,7 @@
./bin/kadmin.local
./bin/lz4
./bin/kadmind
./bin/dbmind
./bin/gs_dbmind
./bin/constant
./bin/server.key.cipher
@ -83,9 +84,6 @@
./share/postgresql/extension/mot_fdw.control
./share/postgresql/extension/postgres_fdw--1.0.sql
./share/postgresql/extension/postgres_fdw.control
./share/postgresql/extension/dblink--1.0.sql
./share/postgresql/extension/dblink--unpackaged--1.0.sql
./share/postgresql/extension/dblink.control
./share/postgresql/timezone/GB-Eire
./share/postgresql/timezone/Turkey
./share/postgresql/timezone/Kwajalein
@ -760,7 +758,6 @@
./lib/postgresql/pg_upgrade_support.so
./lib/postgresql/java/pljava.jar
./lib/postgresql/postgres_fdw.so
./lib/postgresql/dblink.so
./lib/postgresql/pgoutput.so
./lib/libpljava.so
./lib/libpq.a
@ -832,7 +829,6 @@
./lib/libpagecompression.so*
./lib/libdssapi.so
./lib/libdms.so
./lib/libodbc.so*
./include/postgresql/server/postgres_ext.h
./include/postgresql/server/pg_config_os.h

View File

@ -198,7 +198,7 @@ ENDMACRO(CHECK_CC_ENABLE)
function(GET_VERSIONSTR_FROMGIT ret)
set(PG_VERSION "9.2.4")
set(OPENGAUSS_VERSION "5.0.0")
set(OPENGAUSS_VERSION "3.1.0")
execute_process(
COMMAND ${CMAKE_SOURCE_DIR}/${openGauss}/cmake/src/buildfunction.sh --s ${PROJECT_TRUNK_DIR} OUTPUT_VARIABLE GS_VERSION_STR)
set(PG_VERSION "${PG_VERSION}" PARENT_SCOPE)

View File

@ -74,7 +74,7 @@ option(USE_BONJOUR "enable bonjour, the old is --with-bonjour" OFF)
option(USE_LDAP "build with ldap, the old is --with-ldap" OFF)#ON
option(USE_ETCD "build with etcd libs, new option for old mppdb, after 8.1 close it" OFF)
option(USE_PROTOBUF "build with with protobuf's libs, we must need it" ON)
option(USE_LIBXML "build with libxml, the old is --with-libxml" ON)
option(USE_LIBXML "build with libxml, the old is --with-libxml" OFF)
option(HAVE_LIBXML2 "build with libxml2, the old is --with-libxml2" OFF)
option(USE_LIBXSLT "build with libxslt, the old is --with-libxslt" OFF)
option(USE_PAM "build with pam, the old is --with-pam" OFF)
@ -94,7 +94,6 @@ option(HAVE_LIBM "enable -lm, this set to default -lm" ON)
option(HAVE_POSIX_SIGNALS "enable posix signals, this set to default" ON)
option(HAVE_GCC_INT_ATOMICS "enable gcc buildin atomics operations, this set to default" ON)
option(FLEXIBLE_ARRAY_MEMBER "pq_ce need" ON)
option(ENABLE_OPENEULER_MAJOR "support openEuler 22.03 LTS, this set to default" OFF)
# we will differ compile flags and definitions by different vars
set(DB_COMMON_DEFINE "")
@ -140,28 +139,23 @@ if(${ENABLE_LITE_MODE} STREQUAL "ON")
set(ENABLE_LLVM_COMPILE OFF)
set(ENABLE_GSS OFF)
set(KRB5 OFF)
set(USE_LIBXML OFF)
endif()
if(${ENABLE_OPENEULER_MAJOR} STREQUAL "ON")
add_definitions(-DOPENEULER_MAJOR)
endif()
set(PROTECT_OPTIONS -fwrapv -std=c++14 -fnon-call-exceptions ${OPTIMIZE_LEVEL})
set(WARNING_OPTIONS -Wall -Wendif-labels -Wformat-security)
set(WARNING_OPTIONS -Wall -Wendif-labels -Werror -Wformat-security)
set(OPTIMIZE_OPTIONS -pipe -pthread -fno-aggressive-loop-optimizations -fno-expensive-optimizations -fno-omit-frame-pointer -fno-strict-aliasing -freg-struct-return)
set(CHECK_OPTIONS -Wmissing-format-attribute -Wno-attributes -Wno-unused-but-set-variable -Wno-write-strings -Wpointer-arith)
set(MACRO_OPTIONS -D_GLIBCXX_USE_CXX11_ABI=0 -DENABLE_GSTRACE -D_GNU_SOURCE -DPGXC -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -DSTREAMPLAN -D_THREAD_SAFE ${DB_COMMON_DEFINE})
# Set MAX_ALLOC_SEGNUM size in extreme_rto
if(${WAL_SEGSIZE} LESS 256)
if(${WAL_SEGSIZE} LESS 512)
set(MAX_ALLOC_SEGNUM 4)
elseif(${WAL_SEGSIZE} GREATER_EQUAL 256 AND ${WAL_SEGSIZE} LESS 512)
elseif(${WAL_SEGSIZE} GREATER_EQUAL 512 AND ${WAL_SEGSIZE} LESS 1024)
set(MAX_ALLOC_SEGNUM 2)
elseif(${WAL_SEGSIZE} GREATER_EQUAL 512)
elseif(${WAL_SEGSIZE} GREATER_EQUAL 1024)
set(MAX_ALLOC_SEGNUM 1)
else()
message(FATAL_ERROR "error: Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64,128,256,512.")
message(FATAL_ERROR "error: Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64,128,256,512,1024.")
endif()
# libraries need secure options during compling
@ -231,7 +225,6 @@ if(${USE_LIBXML})
else()
set(LIBS "${LIBS} -lxml")
set(GAUSSDB_CONFIGURE "${GAUSSDB_CONFIGURE} -DUSE_LIBXML")
set(CMAKE_CXX_FLAGS -l:liblzma.so.5)
endif()
endif()

View File

@ -116,9 +116,6 @@ function get_gs_version()
debug_str="$DEBUG_TYPE"
product=$(cat build/script/gaussdb.ver | grep 'PRODUCT' | awk -F "=" '{print $2}')
version=$(cat build/script/gaussdb.ver | grep 'VERSION' | awk -F "=" '{print $2}')
if [ "${ENABLE_LITE_MODE}" == "ON" ]; then
product="$product-lite"
fi
if test "$enable_ccache" = yes; then
default_gs_version="(${product} ${version} build 1f1f1f1f) compiled at 2100-00-00 00:00:00 commit 9999 last mr 9999 debug"
else

View File

@ -714,7 +714,7 @@
#define PGXC_VERSION_NUM
/* openGauss version as a number string */
#define OPENGAUSS_VERSION_NUM_STR "5.0.0"
#define OPENGAUSS_VERSION_NUM_STR "3.1.0"
/* A string containing the version number, platform, and C compiler */
#define PG_VERSION_STR "@PG_VERSION_STR@"

View File

@ -695,7 +695,7 @@
#define PG_VERSION "9.2.4"
/* openGauss version as a string */
#define OPENGAUSS_VERSION "5.0.0"
#define OPENGAUSS_VERSION "3.1.0"
/* Gaussdb version as a string*/
#define DEF_GS_VERSION "(GaussDB A 8.0.0 build 21f07aff) compiled at 2020-03-17 10:59:07 commit 7431 last mr 12039 debug"

View File

@ -121,34 +121,6 @@ fi])# PGAC_C_FUNCNAME_SUPPORT
# PGAC_CHECK_BUILTIN_FUNC
# -----------------------
# This is similar to AC_CHECK_FUNCS(), except that it will work for compiler
# builtin functions, as that usually fails to.
# The first argument is the function name, eg [__builtin_clzl], and the
# second is its argument list, eg [unsigned long x]. The current coding
# works only for a single argument named x; we might generalize that later.
# It's assumed that the function's result type is coercible to int.
# On success, we define "HAVEfuncname" (there's usually more than enough
# underscores already, so we don't add another one).
AC_DEFUN([PGAC_CHECK_BUILTIN_FUNC],
[AC_CACHE_CHECK(for $1, pgac_cv$1,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
int
call$1($2)
{
return $1(x);
}], [])],
[pgac_cv$1=yes],
[pgac_cv$1=no])])
if test x"${pgac_cv$1}" = xyes ; then
AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE$1]), 1,
[Define to 1 if your compiler understands $1.])
fi])# PGAC_CHECK_BUILTIN_FUNC
# PGAC_PROG_CC_CFLAGS_OPT
# -----------------------
# Given a string, check if the compiler supports the string as a

308
configure vendored
View File

@ -709,7 +709,6 @@ with_selinux
krb_srvtab
with_python
with_openeuler_os
with_openeuler_major
enable_thread_safety
INCLUDES
TAS
@ -829,7 +828,6 @@ enable_nls
with_pgport
with_gs_version
with_openeuler_os
with_openeuler_major
enable_shared
enable_rpath
enable_jemalloc
@ -2197,7 +2195,7 @@ PACKAGE_VERSION='9.2.4'
# Postgres-XC 1.1devel is based on PostgreSQL 9.2.4
PACKAGE_XC_VERSION='1.1'
# openGauss is based on PostgreSQL 9.2.4 and it will be the Kernel of GaussDB database
OPENGAUSS_VERSION='5.0.0'
OPENGAUSS_VERSION='3.1.0'
cat >>confdefs.h <<_ACEOF
#define PG_VERSION "$PACKAGE_VERSION"
@ -3274,9 +3272,6 @@ _ACEOF
fi
if [ "$(cat /etc/system-release)" == "openEuler release 22.03 LTS" ]; then
with_openeuler_major=yes
fi
#
# --enable-coverage enables generation of code coverage metrics with gcov
@ -3718,8 +3713,9 @@ case ${wal_segsize} in
128) ;;
256) ;;
512) ;;
*) { { $as_echo "$as_me:$LINENO: error: Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64,128,256,512." >&5
$as_echo "$as_me: error: Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64,128,256,512." >&2;}
1024) ;;
*) { { $as_echo "$as_me:$LINENO: error: Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64,128,256,512,1024." >&5
$as_echo "$as_me: error: Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64,128,256,512,1024." >&2;}
{ (exit 1); exit 1; }; }
esac
{ $as_echo "$as_me:$LINENO: result: ${wal_segsize}MB" >&5
@ -3731,9 +3727,9 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
# Set number of MAX_ALLOC_SEGNUM in extreme_rto
if test "${wal_segsize}" -lt 256; then
if test "${wal_segsize}" -lt 512; then
MAX_ALLOC_SEGNUM=4
elif test "${wal_segsize}" -ge 256 -a "${wal_segsize}" -lt 512; then
elif test "${wal_segsize}" -ge 512 -a "${wal_segsize}" -lt 1024; then
MAX_ALLOC_SEGNUM=2
else
MAX_ALLOC_SEGNUM=1
@ -6481,11 +6477,7 @@ fi
# XML
#
if [[ "$enable_lite_mode" != yes ]]; then
with_libxml=yes
else
with_libxml=no
fi
# Check whether --with-libxml was given.
if test "${with_libxml+set}" = set; then
@ -6513,11 +6505,10 @@ else
fi
xml2_cflag=${with_3rdpartydir}/kernel/dependency/libxml2/comm/include/libxml2
xml2_lib=${with_3rdpartydir}/kernel/dependency/libxml2/comm/lib
xml2_config=${with_3rdpartydir}/kernel/dependency/libxml2/comm/bin/xml2-config
if test "$with_libxml" = yes ; then
for ac_prog in ${xml2_config}
for ac_prog in xml2-config
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
@ -6546,7 +6537,7 @@ IFS=$as_save_IFS
fi
fi
XML2_CONFIG=$xml2_config
XML2_CONFIG=$ac_cv_prog_XML2_CONFIG
if test -n "$XML2_CONFIG"; then
{ $as_echo "$as_me:$LINENO: result: $XML2_CONFIG" >&5
$as_echo "$XML2_CONFIG" >&6; }
@ -6562,12 +6553,12 @@ done
if test -n "$XML2_CONFIG"; then
for pgac_option in `$XML2_CONFIG --cflags`; do
case $pgac_option in
-I*|-D*) CPPFLAGS="$CPPFLAGS $pgac_option -I${xml2_cflag}";;
-I*|-D*) CPPFLAGS="$CPPFLAGS $pgac_option";;
esac
done
for pgac_option in `$XML2_CONFIG --libs`; do
case $pgac_option in
-L*) LDFLAGS="$LDFLAGS $pgac_option -L${xml2_lib}";;
-L*) LDFLAGS="$LDFLAGS $pgac_option";;
esac
done
fi
@ -9851,7 +9842,7 @@ if test "${ac_cv_lib_xml2_xmlSaveToBuffer+set}" = set; then
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-L${xml2_lib} -lxml2 -lm -ldl $LIBS"
LIBS="-lxml2 $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@ -13443,7 +13434,6 @@ done
fi
if test "$with_libxml" = yes ; then
CPPFLAGS="-I${xml2_cflag} $CPPFLAGS"
if test "${ac_cv_header_libxml_parser_h+set}" = set; then
{ $as_echo "$as_me:$LINENO: checking for libxml/parser.h" >&5
$as_echo_n "checking for libxml/parser.h... " >&6; }
@ -18226,47 +18216,9 @@ fi
# On PPC, check if assembler supports LWARX instruction's mutex hint bit
case $host_cpu in
x86_64)
# On x86_64, check if we can compile a popcntq instruction
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether assembler supports x86_64 popcntq" >&5
$as_echo_n "checking whether assembler supports x86_64 popcntq... " >&6; }
if ${pgac_cv_have_x86_64_popcntq+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
long long x = 1; long long r;
__asm__ __volatile__ (" popcntq %1,%0\n" : "=q"(r) : "rm"(x));
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
pgac_cv_have_x86_64_popcntq=yes
else
pgac_cv_have_x86_64_popcntq=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_have_x86_64_popcntq" >&5
$as_echo "$pgac_cv_have_x86_64_popcntq" >&6; }
if test x"$pgac_cv_have_x86_64_popcntq" = xyes ; then
$as_echo "#define HAVE_X86_64_POPCNTQ 1" >>confdefs.h
fi
;;
ppc*|powerpc*)
{ $as_echo "$as_me:$LINENO: checking whether assembler supports lwarx hint bit" >&5
$as_echo_n "checking whether assembler supports lwarx hint bit... " >&6; }
if ${pgac_cv_have_ppc_mutex_hint+:} false; then :
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@ -18310,7 +18262,6 @@ sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:$LINENO: result: $pgac_cv_have_ppc_mutex_hint" >&5
$as_echo "$pgac_cv_have_ppc_mutex_hint" >&6; }
if test x"$pgac_cv_have_ppc_mutex_hint" = xyes ; then
@ -24890,237 +24841,6 @@ cat >>confdefs.h <<_ACEOF
#define SIZEOF_VOID_P $ac_cv_sizeof_void_p
_ACEOF
# These typically are compiler builtins, for which AC_CHECK_FUNCS fails.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_bswap16" >&5
$as_echo_n "checking for __builtin_bswap16... " >&6; }
if ${pgac_cv__builtin_bswap16+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
call__builtin_bswap16(int x)
{
return __builtin_bswap16(x);
}
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
pgac_cv__builtin_bswap16=yes
else
pgac_cv__builtin_bswap16=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_bswap16" >&5
$as_echo "$pgac_cv__builtin_bswap16" >&6; }
if test x"${pgac_cv__builtin_bswap16}" = xyes ; then
cat >>confdefs.h <<_ACEOF
#define HAVE__BUILTIN_BSWAP16 1
_ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_bswap32" >&5
$as_echo_n "checking for __builtin_bswap32... " >&6; }
if ${pgac_cv__builtin_bswap32+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
call__builtin_bswap32(int x)
{
return __builtin_bswap32(x);
}
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
pgac_cv__builtin_bswap32=yes
else
pgac_cv__builtin_bswap32=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_bswap32" >&5
$as_echo "$pgac_cv__builtin_bswap32" >&6; }
if test x"${pgac_cv__builtin_bswap32}" = xyes ; then
cat >>confdefs.h <<_ACEOF
#define HAVE__BUILTIN_BSWAP32 1
_ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_bswap64" >&5
$as_echo_n "checking for __builtin_bswap64... " >&6; }
if ${pgac_cv__builtin_bswap64+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
call__builtin_bswap64(long int x)
{
return __builtin_bswap64(x);
}
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
pgac_cv__builtin_bswap64=yes
else
pgac_cv__builtin_bswap64=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_bswap64" >&5
$as_echo "$pgac_cv__builtin_bswap64" >&6; }
if test x"${pgac_cv__builtin_bswap64}" = xyes ; then
cat >>confdefs.h <<_ACEOF
#define HAVE__BUILTIN_BSWAP64 1
_ACEOF
fi
# We assume that we needn't test all widths of these explicitly:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_clz" >&5
$as_echo_n "checking for __builtin_clz... " >&6; }
if ${pgac_cv__builtin_clz+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
call__builtin_clz(unsigned int x)
{
return __builtin_clz(x);
}
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
pgac_cv__builtin_clz=yes
else
pgac_cv__builtin_clz=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_clz" >&5
$as_echo "$pgac_cv__builtin_clz" >&6; }
if test x"${pgac_cv__builtin_clz}" = xyes ; then
cat >>confdefs.h <<_ACEOF
#define HAVE__BUILTIN_CLZ 1
_ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_ctz" >&5
$as_echo_n "checking for __builtin_ctz... " >&6; }
if ${pgac_cv__builtin_ctz+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
call__builtin_ctz(unsigned int x)
{
return __builtin_ctz(x);
}
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
pgac_cv__builtin_ctz=yes
else
pgac_cv__builtin_ctz=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_ctz" >&5
$as_echo "$pgac_cv__builtin_ctz" >&6; }
if test x"${pgac_cv__builtin_ctz}" = xyes ; then
cat >>confdefs.h <<_ACEOF
#define HAVE__BUILTIN_CTZ 1
_ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_popcount" >&5
$as_echo_n "checking for __builtin_popcount... " >&6; }
if ${pgac_cv__builtin_popcount+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
call__builtin_popcount(unsigned int x)
{
return __builtin_popcount(x);
}
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
pgac_cv__builtin_popcount=yes
else
pgac_cv__builtin_popcount=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_popcount" >&5
$as_echo "$pgac_cv__builtin_popcount" >&6; }
if test x"${pgac_cv__builtin_popcount}" = xyes ; then
cat >>confdefs.h <<_ACEOF
#define HAVE__BUILTIN_POPCOUNT 1
_ACEOF
fi
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects

View File

@ -384,7 +384,8 @@ case ${wal_segsize} in
128) ;;
256) ;;
512) ;;
*) AC_MSG_ERROR([Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64,128,256,512.])
1024) ;;
*) AC_MSG_ERROR([Invalid WAL segment size. Allowed values are 1,2,4,8,16,32,64,128,256,512,1024.])
esac
AC_MSG_RESULT([${wal_segsize}MB])
@ -397,9 +398,9 @@ AC_DEFINE_UNQUOTED([XLOG_SEG_SIZE], [(${wal_segsize} * 1024 * 1024)], [
])
# Set number of MAX_ALLOC_SEGNUM in extreme_rto
if test "${wal_segsize}" -lt 256; then
if test "${wal_segsize}" -lt 512; then
MAX_ALLOC_SEGNUM=4
elif test "${wal_segsize}" -ge 256 -a "${wal_segsize}" -lt 512; then
elif test "${wal_segsize}" -ge 512 -a "${wal_segsize}" -lt 1024; then
MAX_ALLOC_SEGNUM=2
else
MAX_ALLOC_SEGNUM=1
@ -1186,19 +1187,6 @@ fi
# On PPC, check if assembler supports LWARX instruction's mutex hint bit
case $host_cpu in
x86_64)
# On x86_64, check if we can compile a popcntq instruction
AC_CACHE_CHECK([whether assembler supports x86_64 popcntq],
[pgac_cv_have_x86_64_popcntq],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[long long x = 1; long long r;
__asm__ __volatile__ (" popcntq %1,%0\n" : "=q"(r) : "rm"(x));])],
[pgac_cv_have_x86_64_popcntq=yes],
[pgac_cv_have_x86_64_popcntq=no])])
if test x"$pgac_cv_have_x86_64_popcntq" = xyes ; then
AC_DEFINE(HAVE_X86_64_POPCNTQ, 1, [Define to 1 if the assembler supports X86_64's POPCNTQ instruction.])
fi
;;
ppc*|powerpc*)
AC_MSG_CHECKING([whether assembler supports lwarx hint bit])
AC_TRY_COMPILE([],
@ -1247,9 +1235,6 @@ LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat readlink setproctitle setsid sigprocmask symlink sync_file_range towlower utime utimes waitpid wcstombs wcstombs_l])
# We assume that we needn't test all widths of these explicitly:
PGAC_CHECK_BUILTIN_FUNC([__builtin_clz], [unsigned int x])
AC_REPLACE_FUNCS(fseeko)
case $host_os in
# NetBSD uses a custom fseeko/ftello built on fsetpos/fgetpos

View File

@ -3,7 +3,7 @@
MODULE_big = dblink
OBJS = dblink.o
PG_CPPFLAGS = -I$(libpq_srcdir)
SHLIB_LINK = $(libpq) -L$(LIBODBC_LIB_PATH) -lodbc
SHLIB_LINK = $(libpq)
SHLIB_PREREQS = submake-libpq
EXTENSION = dblink

View File

@ -221,8 +221,3 @@ CREATE FUNCTION dblink_get_notify(
RETURNS setof record
AS 'MODULE_PATHNAME', 'dblink_get_notify'
LANGUAGE C STRICT;
CREATE FUNCTION dblink_get_drivername()
RETURNS text
AS 'MODULE_PATHNAME', 'dblink_get_drivername'
LANGUAGE C STRICT;

View File

@ -44,4 +44,3 @@ ALTER EXTENSION dblink ADD function dblink_cancel_query(text);
ALTER EXTENSION dblink ADD function dblink_error_message(text);
ALTER EXTENSION dblink ADD function dblink_get_notify();
ALTER EXTENSION dblink ADD function dblink_get_notify(text);
ALTER EXTENSION dblink ADD function dblink_get_drivername();

File diff suppressed because it is too large Load Diff

View File

@ -35,113 +35,6 @@
#define DBLINK_H
#include "fmgr.h"
#include "sql.h"
#include "sqlext.h"
typedef struct ODBCconn {
SQLHENV envHandle; /* Handle ODBC environment */
SQLHDBC connHandle; /* Handle connection */
SQLHSTMT stmt; /* Handle sql */
} ODBCconn;
typedef struct storeInfo {
FunctionCallInfo fcinfo;
Tuplestorestate* tuplestore;
AttInMetadata* attinmeta;
MemoryContext tmpcontext;
char** cstrs;
/* temp storage for results to avoid leaks on exception */
PGresult* last_res;
PGresult* cur_res;
} storeInfo;
typedef struct LinkInfo {
SQLCHAR* username; /* odbc username */
SQLCHAR* password; /* odbc password */
SQLCHAR* drivername; /* odbc driver name */
} LinkInfo;
class Linker : public BaseObject {
public:
virtual void finish() = 0;
virtual text* exec(char* conname, const char* sql, bool fail) = 0;
virtual char* errorMsg() = 0;
virtual int isBusy() = 0;
virtual char* cancel(PGcancel* cancel) = 0;
virtual int sendQuery(char* sql) = 0;
virtual char* open(char* conname, char* sql, bool fail) = 0;
virtual char* close(char* conname, char* sql, bool fail) = 0;
virtual void getResult(char* conname, FunctionCallInfo fcinfo, char* sql, bool fail) = 0;
virtual void queryResult(ReturnSetInfo* rsinfo, const char* conname, storeInfo* sinfo, const char* sql, bool fail) = 0;
virtual void fetch(char* conname, FunctionCallInfo fcinfo, const char* sql, bool fail, char* curname) = 0;
virtual void getNotify(ReturnSetInfo* rsinfo) = 0;
};
typedef struct remoteConn {
Linker* linker;
} remoteConn;
typedef struct dblink_session_context {
remoteConn* pconn;
HTAB* remoteConnHash;
} dblink_session_context;
/*
* Following is list that holds multiple remote connections.
* Calling convention of each dblink function changes to accept
* connection name as the first parameter. The connection list is
* much like ecpg e.g. a mapping between a name and a PGconn object.
*/
typedef struct remoteConnHashEnt {
char name[NAMEDATALEN];
remoteConn* rconn;
} remoteConnHashEnt;
class PQLinker : public Linker {
public:
PGconn* conn;
PGresult* res;
int openCursorCount; /* The number of open cursors */
bool newXactForCursor; /* Opened a transaction for a cursor */
public:
PQLinker(char* connstr);
void finish();
text* exec(char* conname, const char* sql, bool fail);
char* errorMsg();
int isBusy();
char* cancel(PGcancel* cancel);
int sendQuery(char* sql);
char* open(char* conname, char* sql, bool fail);
char* close(char* conname, char* sql, bool fail);
void getResult(char* conname, FunctionCallInfo fcinfo, char* sql, bool fail);
void queryResult(ReturnSetInfo* rsinfo, const char* conname, storeInfo* sinfo, const char* sql, bool fail);
void fetch(char* conname, FunctionCallInfo fcinfo, const char* sql, bool fail, char* curname);
void getNotify(ReturnSetInfo* rsinfo);
};
class ODBCLinker : public Linker {
public:
SQLHENV envHandle; /* Handle ODBC environment */
SQLHDBC connHandle; /* Handle connection */
SQLHSTMT stmt; /* Handle sql */
public:
ODBCLinker(char* connstr_or_name);
void finish();
text* exec(char* conname, const char* sql, bool fail);
char* errorMsg();
int isBusy();
char* cancel(PGcancel* cancel);
int sendQuery(char* sql);
char* open(char* conname, char* sql, bool fail);
char* close(char* conname, char* sql, bool fail);
void getResult(char* conname, FunctionCallInfo fcinfo, char* sql, bool fail);
void queryResult(ReturnSetInfo* rsinfo, const char* conname, storeInfo* sinfo, const char* sql, bool fail);
void fetch(char* conname, FunctionCallInfo fcinfo, const char* sql, bool fail, char* curname);
void getNotify(ReturnSetInfo* rsinfo);
};
/*
* External declarations
@ -165,7 +58,6 @@ extern "C" Datum dblink_build_sql_delete(PG_FUNCTION_ARGS);
extern "C" Datum dblink_build_sql_update(PG_FUNCTION_ARGS);
extern "C" Datum dblink_current_query(PG_FUNCTION_ARGS);
extern "C" Datum dblink_get_notify(PG_FUNCTION_ARGS);
extern "C" Datum dblink_get_drivername(PG_FUNCTION_ARGS);
extern "C" void set_extension_index(uint32 index);
extern "C" void init_session_vars(void);

View File

@ -375,7 +375,7 @@ static List* get_file_fdw_attribute_options(Oid relid)
/* Retrieve FDW options for all user-defined attributes. */
for (attnum = 1; attnum <= natts; attnum++) {
Form_pg_attribute attr = &tupleDesc->attrs[attnum - 1];
Form_pg_attribute attr = tupleDesc->attrs[attnum - 1];
List* options = NIL;
ListCell* lc = NULL;
@ -712,7 +712,7 @@ static void estimate_size(PlannerInfo* root, RelOptInfo* baserel, FileFdwPlanSta
*/
int tuple_width;
tuple_width = MAXALIGN(baserel->reltarget->width) + MAXALIGN(sizeof(HeapTupleHeaderData));
tuple_width = MAXALIGN(baserel->width) + MAXALIGN(sizeof(HeapTupleHeaderData));
ntuples = clamp_row_est((double)stat_buf.st_size / (double)tuple_width);
baserel->tuples = ntuples;

View File

@ -745,7 +745,7 @@ List* build_tlist_to_deparse(RelOptInfo* foreignrel)
* We require columns specified in foreignrel->reltarget->exprs and those
* required for evaluating the local conditions.
*/
tlist = foreignrel->reltarget->exprs;
tlist = foreignrel->reltargetlist;
foreach (lc, fpinfo->local_conds) {
RestrictInfo* rinfo = lfirst_node(RestrictInfo, lc);
@ -929,7 +929,7 @@ static void gcdeparseTargetList(StringInfo buf, PlannerInfo* root, Index rtindex
have_wholerow = bms_is_member(0 - FirstLowInvalidHeapAttributeNumber, attrs_used);
for (i = 1; i <= tupdesc->natts; i++) {
Form_pg_attribute attr = &tupdesc->attrs[i - 1];
Form_pg_attribute attr = tupdesc->attrs[i - 1];
/* Ignore dropped attributes. */
if (attr->attisdropped)
@ -1122,7 +1122,7 @@ static void gcDeparseSubqueryTargetList(deparse_expr_cxt* context)
/* Should only be called in these cases. */
Assert(IS_SIMPLE_REL(foreignrel) || IS_JOIN_REL(foreignrel));
foreach (lc, foreignrel->reltarget->exprs) {
foreach (lc, foreignrel->reltargetlist) {
Node* node = (Node*)lfirst(lc);
if (!first)
@ -2213,7 +2213,7 @@ static void get_relation_column_alias_ids(Var* node, RelOptInfo* foreignrel, int
/* Get the column alias ID */
i = 1;
foreach (lc, foreignrel->reltarget->exprs) {
foreach (lc, foreignrel->reltargetlist) {
if (equal(lfirst(lc), (Node*)node)) {
*colno = i;
return;

View File

@ -348,7 +348,7 @@ static void gcGetForeignRelSize(PlannerInfo* root, RelOptInfo* baserel, Oid fore
* columns used in them. Doesn't seem worth detecting that case though.)
*/
fpinfo->attrs_used = NULL;
pull_varattnos((Node*)baserel->reltarget->exprs, baserel->relid, &fpinfo->attrs_used);
pull_varattnos((Node*)baserel->reltargetlist, baserel->relid, &fpinfo->attrs_used);
foreach (lc, fpinfo->local_conds) {
RestrictInfo* rinfo = lfirst_node(RestrictInfo, lc);
@ -390,7 +390,7 @@ static void gcGetForeignRelSize(PlannerInfo* root, RelOptInfo* baserel, Oid fore
baserel->pages = 10;
const int BLOCK_NUM = 10;
baserel->tuples =
(double)(BLOCK_NUM * BLCKSZ) / (baserel->reltarget->width + MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)));
(double)(BLOCK_NUM * BLCKSZ) / (baserel->width + MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)));
}
/* Estimate baserel size as best we can with local statistics. */
@ -702,7 +702,7 @@ static void gcBeginForeignScan(ForeignScanState* node, int eflags)
for (int i = 0; i < list_length(fsstate->retrieved_attrs); i++) {
int attidx = list_nth_int(fsstate->retrieved_attrs, i);
Form_pg_attribute attr = &slot->tts_tupleDescriptor->attrs[attidx - 1];
Form_pg_attribute attr = slot->tts_tupleDescriptor->attrs[attidx - 1];
const char* attname = (const char*)(attr->attname.data);
TupleDescInitEntry(scan_desc, i + 1, attname, attr->atttypid, attr->atttypmod, 0);
}
@ -747,8 +747,8 @@ static void gcBeginForeignScan(ForeignScanState* node, int eflags)
fsstate->resultSlot->tts_isnull[i] = true;
}
fsstate->resultSlot->tts_flags &= ~TTS_FLAG_EMPTY;
fsstate->scanSlot->tts_flags &= ~TTS_FLAG_EMPTY;
fsstate->resultSlot->tts_isempty = false;
fsstate->scanSlot->tts_isempty = false;
fsstate->attinmeta = TupleDescGetAttInMetadata(fsstate->tupdesc);
@ -864,7 +864,7 @@ static void postgresConstructResultSlotWithArray(ForeignScanState* node)
for (scanAttr = 0, resultAttr = 0; resultAttr < resultDesc->natts; resultAttr++, scanAttr += map) {
Assert(list_length(colmap) == resultDesc->natts);
Oid typoid = resultDesc->attrs[resultAttr].atttypid;
Oid typoid = resultDesc->attrs[resultAttr]->atttypid;
Value* val = (Value*)list_nth(colmap, resultAttr);
map = val->val.ival;
@ -919,7 +919,7 @@ static void postgresConstructResultSlotWithArray(ForeignScanState* node)
}
resultSlot->tts_nvalid = resultDesc->natts;
resultSlot->tts_flags &= ~TTS_FLAG_EMPTY;
resultSlot->tts_isempty = false;
}
static void postgresMapResultFromScanSlot(ForeignScanState* node)
@ -958,7 +958,7 @@ static TupleTableSlot* gcIterateNormalForeignScan(ForeignScanState* node)
/* reset tupleslot on the begin */
(void)ExecClearTuple(fsstate->resultSlot);
fsstate->resultSlot->tts_flags &= ~TTS_FLAG_EMPTY;
fsstate->resultSlot->tts_isempty = false;
TupleTableSlot* slot = node->ss.ss_ScanTupleSlot;
@ -1469,7 +1469,7 @@ static void gc_estimate_path_cost_size(PlannerInfo* root, RelOptInfo* foreignrel
* between foreign relations.
*/
rows = foreignrel->rows;
width = foreignrel->reltarget->width;
width = foreignrel->width;
/* Back into an estimate of the number of retrieved rows. */
retrieved_rows = clamp_row_est(rows / fpinfo->local_conds_sel);
@ -1813,17 +1813,17 @@ static void gcfdw_fetch_remote_table_info(
pq_sendint(&retbuf, tupdesc->natts, 4);
for (int i = 0; i < tupdesc->natts; i++) {
att_name_len = strlen(tupdesc->attrs[i].attname.data);
att_name_len = strlen(tupdesc->attrs[i]->attname.data);
pq_sendint(&retbuf, att_name_len, 4);
pq_sendbytes(&retbuf, tupdesc->attrs[i].attname.data, att_name_len);
pq_sendbytes(&retbuf, tupdesc->attrs[i]->attname.data, att_name_len);
Assert(InvalidOid != tupdesc->attrs[i].atttypid);
Assert(InvalidOid != tupdesc->attrs[i]->atttypid);
type_name = get_typename(tupdesc->attrs[i].atttypid);
type_name = get_typename(tupdesc->attrs[i]->atttypid);
type_name_len = strlen(type_name);
pq_sendint(&retbuf, type_name_len, 4);
pq_sendbytes(&retbuf, type_name, type_name_len);
pq_sendint(&retbuf, tupdesc->attrs[i].atttypmod, 4);
pq_sendint(&retbuf, tupdesc->attrs[i]->atttypmod, 4);
pfree(type_name);
}
@ -2368,7 +2368,7 @@ static void conversion_error_callback(void *arg)
TupleDesc tupdesc = RelationGetDescr(errpos->rel);
if (errpos->cur_attno > 0 && errpos->cur_attno <= tupdesc->natts) {
attname = NameStr(tupdesc->attrs[errpos->cur_attno - 1].attname);
attname = NameStr(tupdesc->attrs[errpos->cur_attno - 1]->attname);
} else if (errpos->cur_attno == SelfItemPointerAttributeNumber) {
attname = "ctid";
} else if (errpos->cur_attno == ObjectIdAttributeNumber) {
@ -2588,7 +2588,7 @@ static void GcFdwCopyRemoteInfo(PgFdwRemoteInfo* new_remote_info, PgFdwRemoteInf
bool hasSpecialArrayType(TupleDesc desc)
{
for (int i = 0; i < desc->natts; i++) {
Oid typoid = desc->attrs[i].atttypid;
Oid typoid = desc->attrs[i]->atttypid;
if (INT8ARRAYOID == typoid || FLOAT8ARRAYOID == typoid || FLOAT4ARRAYOID == typoid || NUMERICARRAY == typoid) {
return true;

View File

@ -702,15 +702,15 @@ Datum hstore_from_record(PG_FUNCTION_ARGS)
for (i = 0, j = 0; i < ncolumns; ++i) {
ColumnIOData* column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i].atttypid;
Oid column_type = tupdesc->attrs[i]->atttypid;
char* value = NULL;
/* Ignore dropped columns in datatype */
if (tupdesc->attrs[i].attisdropped)
if (tupdesc->attrs[i]->attisdropped)
continue;
pairs[j].key = NameStr(tupdesc->attrs[i].attname);
pairs[j].keylen = hstoreCheckKeyLen(strlen(NameStr(tupdesc->attrs[i].attname)));
pairs[j].key = NameStr(tupdesc->attrs[i]->attname);
pairs[j].keylen = hstoreCheckKeyLen(strlen(NameStr(tupdesc->attrs[i]->attname)));
if (nulls == NULL || nulls[i]) {
pairs[j].val = NULL;
@ -864,18 +864,18 @@ Datum hstore_populate_record(PG_FUNCTION_ARGS)
for (i = 0; i < ncolumns; ++i) {
ColumnIOData* column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i].atttypid;
Oid column_type = tupdesc->attrs[i]->atttypid;
char* value = NULL;
int idx;
int vallen;
/* Ignore dropped columns in datatype */
if (tupdesc->attrs[i].attisdropped) {
if (tupdesc->attrs[i]->attisdropped) {
nulls[i] = true;
continue;
}
idx = hstoreFindKey(hs, 0, NameStr(tupdesc->attrs[i].attname), strlen(NameStr(tupdesc->attrs[i].attname)));
idx = hstoreFindKey(hs, 0, NameStr(tupdesc->attrs[i]->attname), strlen(NameStr(tupdesc->attrs[i]->attname)));
/*
* we can't just skip here if the key wasn't found since we might have
@ -903,7 +903,7 @@ Datum hstore_populate_record(PG_FUNCTION_ARGS)
* checks are done
*/
values[i] =
InputFunctionCall(&column_info->proc, NULL, column_info->typioparam, tupdesc->attrs[i].atttypmod);
InputFunctionCall(&column_info->proc, NULL, column_info->typioparam, tupdesc->attrs[i]->atttypmod);
nulls[i] = true;
} else {
vallen = HS_VALLEN(entries, idx);
@ -913,7 +913,7 @@ Datum hstore_populate_record(PG_FUNCTION_ARGS)
value[vallen] = 0;
values[i] =
InputFunctionCall(&column_info->proc, value, column_info->typioparam, tupdesc->attrs[i].atttypmod);
InputFunctionCall(&column_info->proc, value, column_info->typioparam, tupdesc->attrs[i]->atttypmod);
nulls[i] = false;
}
}

View File

@ -6,7 +6,6 @@
#include "access/gist.h"
#include "access/skey.h"
#include "port/pg_bitutils.h"
#include "_int.h"
@ -30,6 +29,264 @@ extern "C" Datum g_intbig_picksplit(PG_FUNCTION_ARGS);
extern "C" Datum g_intbig_union(PG_FUNCTION_ARGS);
extern "C" Datum g_intbig_same(PG_FUNCTION_ARGS);
/* Number of one-bits in an unsigned byte */
static const uint8 number_of_ones[256] = {0,
1,
1,
2,
1,
2,
2,
3,
1,
2,
2,
3,
2,
3,
3,
4,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
4,
5,
5,
6,
5,
6,
6,
7,
5,
6,
6,
7,
6,
7,
7,
8};
PG_FUNCTION_INFO_V1(_intbig_in);
extern "C" Datum _intbig_in(PG_FUNCTION_ARGS);
@ -171,7 +428,11 @@ Datum g_intbig_compress(PG_FUNCTION_ARGS)
static int4 sizebitvec(BITVECP sign)
{
return pg_popcount(sign, SIGLEN);
int4 size = 0, i;
LOOPBYTE
size += number_of_ones[(unsigned char)sign[i]];
return size;
}
static int hemdistsign(BITVECP a, BITVECP b)
@ -181,8 +442,7 @@ static int hemdistsign(BITVECP a, BITVECP b)
LOOPBYTE
{
diff = (unsigned char)(a[i] ^ b[i]);
/* Using the popcount functions here isn't likely to win */
dist += pg_number_of_ones[diff];
dist += number_of_ones[diff];
}
return dist;
}

View File

@ -1530,7 +1530,7 @@ static void fill_pglog_planstate_from_logft_rel(pglogPlanState* pg_log, Relation
Assert(PGLOG_ATTR_MAX == tupdesc->natts);
for (int i = 0; i < PGLOG_ATTR_MAX; ++i) {
Form_pg_attribute att = &tupdesc->attrs[i];
Form_pg_attribute att = tupdesc->attrs[i];
pg_log->allattr_typmod[i] = att->atttypmod;
getTypeInputInfo(att->atttypid, &in_func_oid, &pg_log->allattr_typioparam[i]);
fmgr_info(in_func_oid, &pg_log->allattr_fmgrinfo[i]);

View File

@ -10,7 +10,6 @@
#include "access/gist.h"
#include "access/skey.h"
#include "port/pg_bitutils.h"
#include "crc32.h"
#include "ltree.h"
@ -35,6 +34,264 @@ extern "C" Datum _ltree_consistent(PG_FUNCTION_ARGS);
#define GETENTRY(vec, pos) ((ltree_gist*)DatumGetPointer((vec)->vector[(pos)].key))
#define NEXTVAL(x) ((ltree*)((char*)(x) + INTALIGN(VARSIZE(x))))
/* Number of one-bits in an unsigned byte */
static const uint8 number_of_ones[256] = {0,
1,
1,
2,
1,
2,
2,
3,
1,
2,
2,
3,
2,
3,
3,
4,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
4,
5,
5,
6,
5,
6,
6,
7,
5,
6,
6,
7,
6,
7,
7,
8};
#define WISH_F(a, b, c) (double)(-(double)(((a) - (b)) * ((a) - (b)) * ((a) - (b))) * (c))
static void hashing(BITVECP sign, ltree* t)
@ -174,7 +431,11 @@ Datum _ltree_union(PG_FUNCTION_ARGS)
static int4 sizebitvec(BITVECP sign)
{
return pg_popcount((const char *) sign, ASIGLEN);
int4 size = 0, i;
ALOOPBYTE
size += number_of_ones[(unsigned char)sign[i]];
return size;
}
static int hemdistsign(BITVECP a, BITVECP b)
@ -184,8 +445,7 @@ static int hemdistsign(BITVECP a, BITVECP b)
ALOOPBYTE
{
diff = (unsigned char)(a[i] ^ b[i]);
/* Using the popcount functions here isn't likely to win */
dist += pg_number_of_ones[diff];
dist += number_of_ones[diff];
}
return dist;
}

View File

@ -226,8 +226,8 @@ static bool pg_decode_filter(LogicalDecodingContext* ctx, RepOriginId origin_id)
}
/* print the tuple 'tuple' into the StringInfo s */
static void TupleToJsoninfo(Relation relation, cJSON* cols_name, cJSON* cols_type, cJSON* cols_val, TupleDesc tupdesc,
HeapTuple tuple, bool isOld)
static void TupleToJsoninfo(
cJSON* cols_name, cJSON* cols_type, cJSON* cols_val, TupleDesc tupdesc, HeapTuple tuple, bool skip_nulls)
{
if ((tuple->tupTableType == HEAP_TUPLE) && (HEAP_TUPLE_IS_COMPRESSED(tuple->t_data) ||
(int)HeapTupleHeaderGetNatts(tuple->t_data, tupdesc) > tupdesc->natts)) {
@ -241,7 +241,7 @@ static void TupleToJsoninfo(Relation relation, cJSON* cols_name, cJSON* cols_typ
Datum origval = 0; /* possibly toasted Datum */
bool isnull = false; /* column is null? */
Form_pg_attribute attr = &tupdesc->attrs[natt]; /* the attribute itself */
Form_pg_attribute attr = tupdesc->attrs[natt]; /* the attribute itself */
/*
* don't print dropped columns, we can't be sure everything is
@ -254,7 +254,7 @@ static void TupleToJsoninfo(Relation relation, cJSON* cols_name, cJSON* cols_typ
* Don't print system columns, oid will already have been printed if
* present.
*/
if (attr->attnum < 0 || (isOld && !IsRelationReplidentKey(relation, attr->attnum)))
if (attr->attnum < 0)
continue;
Oid typid = attr->atttypid; /* type of current attribute */
@ -265,6 +265,8 @@ static void TupleToJsoninfo(Relation relation, cJSON* cols_name, cJSON* cols_typ
} else {
origval = uheap_getattr((UHeapTuple)tuple, natt + 1, tupdesc, &isnull);
}
if (isnull && skip_nulls)
continue;
/* print attribute name */
@ -353,53 +355,53 @@ static void pg_decode_change(
case REORDER_BUFFER_CHANGE_INSERT:
op_type = cJSON_CreateString("INSERT");
if (change->data.tp.newtuple != NULL) {
TupleToJsoninfo(relation, columns_name, columns_type, columns_val, tupdesc,
&change->data.tp.newtuple->tuple, false);
TupleToJsoninfo(
columns_name, columns_type, columns_val, tupdesc, &change->data.tp.newtuple->tuple, false);
}
break;
case REORDER_BUFFER_CHANGE_UPDATE:
op_type = cJSON_CreateString("UPDATE");
if (change->data.tp.oldtuple != NULL) {
TupleToJsoninfo(relation, old_keys_name, old_keys_type, old_keys_val, tupdesc,
&change->data.tp.oldtuple->tuple, true);
TupleToJsoninfo(
old_keys_name, old_keys_type, old_keys_val, tupdesc, &change->data.tp.oldtuple->tuple, true);
}
if (change->data.tp.newtuple != NULL) {
TupleToJsoninfo(relation, columns_name, columns_type, columns_val, tupdesc,
&change->data.tp.newtuple->tuple, false);
TupleToJsoninfo(
columns_name, columns_type, columns_val, tupdesc, &change->data.tp.newtuple->tuple, false);
}
break;
case REORDER_BUFFER_CHANGE_DELETE:
op_type = cJSON_CreateString("DELETE");
if (change->data.tp.oldtuple != NULL) {
TupleToJsoninfo(relation, old_keys_name, old_keys_type, old_keys_val, tupdesc,
&change->data.tp.oldtuple->tuple, true);
TupleToJsoninfo(
old_keys_name, old_keys_type, old_keys_val, tupdesc, &change->data.tp.oldtuple->tuple, true);
}
/* if there was no PK, we only know that a delete happened */
break;
case REORDER_BUFFER_CHANGE_UINSERT:
op_type = cJSON_CreateString("INSERT");
if (change->data.utp.newtuple != NULL) {
TupleToJsoninfo(relation, columns_name, columns_type, columns_val, tupdesc,
TupleToJsoninfo(columns_name, columns_type, columns_val, tupdesc,
(HeapTuple)(&change->data.utp.newtuple->tuple), false);
}
break;
case REORDER_BUFFER_CHANGE_UDELETE:
op_type = cJSON_CreateString("DELETE");
if (change->data.utp.oldtuple != NULL) {
TupleToJsoninfo(relation, old_keys_name, old_keys_type, old_keys_val, tupdesc,
TupleToJsoninfo(old_keys_name, old_keys_type, old_keys_val, tupdesc,
(HeapTuple)(&change->data.utp.oldtuple->tuple), true);
}
break;
case REORDER_BUFFER_CHANGE_UUPDATE:
op_type = cJSON_CreateString("UPDATE");
if (change->data.utp.oldtuple != NULL) {
TupleToJsoninfo(relation, old_keys_name, old_keys_type, old_keys_val, tupdesc,
TupleToJsoninfo(old_keys_name, old_keys_type, old_keys_val, tupdesc,
(HeapTuple)(&change->data.utp.oldtuple->tuple), true);
}
if (change->data.utp.newtuple != NULL) {
TupleToJsoninfo(relation, columns_name, columns_type, columns_val, tupdesc,
TupleToJsoninfo(columns_name, columns_type, columns_val, tupdesc,
(HeapTuple)&change->data.utp.newtuple->tuple, false);
}
break;

View File

@ -3160,9 +3160,8 @@ static int parse_page_file(const char *filename, SegmentType type, const uint32
char decompressed[BLCKSZ];
while (start < number) {
size_t compressedSize = pageCompression->ReadCompressedBuffer(start, compressed, BLCKSZ);
if (compressedSize > MIN_COMPRESS_ERROR_RT) {
fprintf(stderr, "read block %u failed, filename: %s: code: %lu %s\n",
start, filename, compressedSize, strerror(errno));
if (compressedSize == 0) {
fprintf(stderr, "read block %u failed, filename: %s: %s\n", start, filename, strerror(errno));
delete pageCompression;
return false;
}
@ -5436,7 +5435,6 @@ static void fill_filenode_map(char** class_map)
{"pg_cast_source_target_index", 2661},
{"pg_class_oid_index", 2662},
{"pg_class_relname_nsp_index", 2663},
{"pg_collation_enc_def_index", 3147},
{"pg_collation_name_enc_nsp_index", 3164},
{"pg_collation_oid_index", 3085},
{"pg_constraint_conname_nsp_index", 2664},

View File

@ -435,7 +435,7 @@ static void parse_compress_meta(StringInfo outputBuf, char* page_content, Relati
int size = PageGetSpecialSize(page_header);
TupleDesc desc = RelationGetDescr(rel);
FormData_pg_attribute* att = desc->attrs;
Form_pg_attribute* att = desc->attrs;
int attrno;
int attrnum = desc->natts;
@ -444,7 +444,7 @@ static void parse_compress_meta(StringInfo outputBuf, char* page_content, Relati
char mode = 0;
for (attrno = 0; attrno < attrnum && cmprsOff < size; ++attrno) {
Form_pg_attribute thisatt = &att[attrno];
Form_pg_attribute thisatt = att[attrno];
int metaSize = 0;
metaInfo = PageCompress::FetchAttrCmprMeta(start + cmprsOff, thisatt->attlen, &metaSize, &mode);

View File

@ -223,14 +223,12 @@ static void pgss_ExecutorStart(QueryDesc* queryDesc, int eflags);
static void pgss_ExecutorRun(QueryDesc* queryDesc, ScanDirection direction, long count);
static void pgss_ExecutorFinish(QueryDesc* queryDesc);
static void pgss_ExecutorEnd(QueryDesc* queryDesc);
static void pgss_ProcessUtility(processutility_context* processutility_cxt,
static void pgss_ProcessUtility(Node* parsetree, const char* queryString, ParamListInfo params, bool isTopLevel,
DestReceiver* dest,
#ifdef PGXC
bool sentToRemote,
#endif /* PGXC */
char* completionTag,
ProcessUtilityContext context,
bool isCTAS);
char* completionTag);
static uint32 pgss_hash_fn(const void* key, Size keysize);
static int pgss_match_fn(const void* key1, const void* key2, Size keysize);
static uint32 pgss_hash_string(const char* str);
@ -724,17 +722,13 @@ static void pgss_ExecutorEnd(QueryDesc* queryDesc)
/*
* ProcessUtility hook
*/
static void pgss_ProcessUtility(processutility_context* processutility_cxt,
static void pgss_ProcessUtility(Node* parsetree, const char* queryString, ParamListInfo params, bool isTopLevel,
DestReceiver* dest,
#ifdef PGXC
bool sentToRemote,
#endif /* PGXC */
char* completionTag,
ProcessUtilityContext context,
bool isCTAS)
char* completionTag)
{
Node* parsetree = processutility_cxt->parse_tree;
const char* queryString = processutility_cxt->query_string;
/*
* If it's an EXECUTE statement, we don't track it and don't increment the
* nesting level. This allows the cycles to be charged to the underlying
@ -760,23 +754,25 @@ static void pgss_ProcessUtility(processutility_context* processutility_cxt,
PG_TRY();
{
if (prev_ProcessUtility)
prev_ProcessUtility(processutility_cxt,
prev_ProcessUtility(parsetree,
queryString,
params,
isTopLevel,
dest,
#ifdef PGXC
sentToRemote,
#endif /* PGXC */
completionTag,
context,
isCTAS);
completionTag);
else
standard_ProcessUtility(processutility_cxt,
standard_ProcessUtility(parsetree,
queryString,
params,
isTopLevel,
dest,
#ifdef PGXC
sentToRemote,
#endif /* PGXC */
completionTag,
context,
isCTAS);
completionTag);
nested_level--;
}
PG_CATCH();
@ -821,23 +817,25 @@ static void pgss_ProcessUtility(processutility_context* processutility_cxt,
pgss_store(queryString, queryId, INSTR_TIME_GET_MILLISEC(duration), rows, &bufusage, NULL);
} else {
if (prev_ProcessUtility)
prev_ProcessUtility(processutility_cxt,
prev_ProcessUtility(parsetree,
queryString,
params,
isTopLevel,
dest,
#ifdef PGXC
sentToRemote,
#endif /* PGXC */
completionTag,
context,
isCTAS);
completionTag);
else
standard_ProcessUtility(processutility_cxt,
standard_ProcessUtility(parsetree,
queryString,
params,
isTopLevel,
dest,
#ifdef PGXC
sentToRemote,
#endif /* PGXC */
completionTag,
context,
isCTAS);
completionTag);
}
}
@ -1860,7 +1858,7 @@ static void fill_in_constant_lengths(pgssJumbleState* jstate, const char* query)
locs = jstate->clocations;
/* initialize the flex scanner --- should match raw_parser() */
yyscanner = scanner_init(query, &yyextra, &ScanKeywords, ScanKeywordTokens);
yyscanner = scanner_init(query, &yyextra, ScanKeywords, NumScanKeywords);
/* Search for each constant, in sequence */
for (i = 0; i < jstate->clocations_count; i++) {

View File

@ -3,7 +3,6 @@
*/
#include "postgres.h"
#include "knl/knl_variable.h"
#include "port/pg_bitutils.h"
#include "trgm.h"
@ -41,6 +40,264 @@ extern "C" Datum gtrgm_picksplit(PG_FUNCTION_ARGS);
#define GETENTRY(vec, pos) ((TRGM*)DatumGetPointer((vec)->vector[(pos)].key))
/* Number of one-bits in an unsigned byte */
static const uint8 number_of_ones[256] = {0,
1,
1,
2,
1,
2,
2,
3,
1,
2,
2,
3,
2,
3,
3,
4,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
1,
2,
2,
3,
2,
3,
3,
4,
2,
3,
3,
4,
3,
4,
4,
5,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
2,
3,
3,
4,
3,
4,
4,
5,
3,
4,
4,
5,
4,
5,
5,
6,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
3,
4,
4,
5,
4,
5,
5,
6,
4,
5,
5,
6,
5,
6,
6,
7,
4,
5,
5,
6,
5,
6,
6,
7,
5,
6,
6,
7,
6,
7,
7,
8};
Datum gtrgm_in(PG_FUNCTION_ARGS)
{
elog(ERROR, "not implemented");
@ -420,7 +677,11 @@ Datum gtrgm_same(PG_FUNCTION_ARGS)
static int4 sizebitvec(BITVECP sign)
{
return pg_popcount(sign, SIGLEN);
int4 size = 0, i;
LOOPBYTE
size += number_of_ones[(unsigned char)sign[i]];
return size;
}
static int hemdistsign(BITVECP a, BITVECP b)
@ -430,8 +691,7 @@ static int hemdistsign(BITVECP a, BITVECP b)
LOOPBYTE
{
diff = (unsigned char)(a[i] ^ b[i]);
/* Using the popcount functions here isn't likely to win */
dist += pg_number_of_ones[diff];
dist += number_of_ones[diff];
}
return dist;
}

View File

@ -1038,9 +1038,6 @@ int main(int argc, char** argv)
}
}
if (dumpprivate.enable_dss)
XLogSegmentSize = DSS_XLOG_SEG_SIZE;
/* parse files as start/end boundaries, extract path if not specified */
if (optind < argc) {
char* directory = NULL;

View File

@ -121,7 +121,7 @@ static bool foreign_expr_walker(Node *node, foreign_glob_cxt *glob_cxt, foreign_
static void deparseTargetList(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, bool is_returning,
Bitmapset *attrs_used, bool qualify_col, List **retrieved_attrs);
static void deparseReturningList(StringInfo buf, RangeTblEntry *root, Index rtindex, Relation rel, bool trig_after_row,
List *withCheckOptionList, List *returningList, List **retrieved_attrs);
List *returningList, List **retrieved_attrs);
static void deparseColumnRef(StringInfo buf, int varno, int varattno, RangeTblEntry *rte, bool qualify_col);
static void deparseRelation(StringInfo buf, Relation rel);
static void deparseStringLiteral(StringInfo buf, const char *val);
@ -1158,7 +1158,7 @@ List *build_tlist_to_deparse(RelOptInfo *foreignrel)
* We require columns specified in foreignrel->reltarget->exprs and those
* required for evaluating the local conditions.
*/
tlist = add_to_flat_tlist(tlist, pull_var_clause((Node *)foreignrel->reltarget->exprs, PVC_RECURSE_AGGREGATES, PVC_RECURSE_PLACEHOLDERS));
tlist = add_to_flat_tlist(tlist, pull_var_clause((Node *)foreignrel->reltargetlist, PVC_RECURSE_AGGREGATES, PVC_RECURSE_PLACEHOLDERS));
foreach (lc, fpinfo->local_conds) {
RestrictInfo *rinfo = (RestrictInfo *)lfirst_node(RestrictInfo, lc);
@ -1548,7 +1548,7 @@ static void deparseSubqueryTargetList(deparse_expr_cxt *context)
Assert(IS_SIMPLE_REL(foreignrel) || IS_JOIN_REL(foreignrel));
first = true;
foreach (lc, foreignrel->reltarget->exprs) {
foreach (lc, foreignrel->reltargetlist) {
Node *node = (Node *)lfirst(lc);
if (!first) {
@ -1821,7 +1821,7 @@ static void deparseRangeTblRef(StringInfo buf, PlannerInfo *root, RelOptInfo *fo
* expressions specified in the relation's reltarget (see
* deparseSubqueryTargetList).
*/
ncols = list_length(foreignrel->reltarget->exprs);
ncols = list_length(foreignrel->reltargetlist);
if (ncols > 0) {
int i;
@ -1844,11 +1844,11 @@ static void deparseRangeTblRef(StringInfo buf, PlannerInfo *root, RelOptInfo *fo
* deparse remote INSERT statement
*
* The statement text is appended to buf, and we also create an integer List
* of the columns being retrieved by WITH CHECK OPTION or RETURNING (if any),
* which is returned to *retrieved_attrs.
* of the columns being retrieved by RETURNING (if any), which is returned
* to *retrieved_attrs.
*/
void deparseInsertSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *targetAttrs,
List *withCheckOptionList, List *returningList, List **retrieved_attrs)
List *returningList, List **retrieved_attrs)
{
AttrNumber pindex;
ListCell *lc = NULL;
@ -1890,19 +1890,19 @@ void deparseInsertSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relatio
appendStringInfoString(buf, " DEFAULT VALUES");
}
deparseReturningList(buf, rte, rtindex, rel, rel->trigdesc && rel->trigdesc->trig_insert_after_row,
withCheckOptionList, returningList, retrieved_attrs);
deparseReturningList(buf, rte, rtindex, rel, rel->trigdesc && rel->trigdesc->trig_insert_after_row, returningList,
retrieved_attrs);
}
/*
* deparse remote UPDATE statement
*
* The statement text is appended to buf, and we also create an integer List
* of the columns being retrieved by WITH CHECK OPTION or RETURNING (if any),
* which is returned to *retrieved_attrs.
* of the columns being retrieved by RETURNING (if any), which is returned
* to *retrieved_attrs.
*/
void deparseUpdateSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *targetAttrs,
List *withCheckOptionList, List *returningList, List **retrieved_attrs)
List *returningList, List **retrieved_attrs)
{
AttrNumber pindex;
ListCell *lc = NULL;
@ -1927,8 +1927,8 @@ void deparseUpdateSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relatio
}
appendStringInfoString(buf, " WHERE ctid = $1 and tableoid = $2");
deparseReturningList(buf, rte, rtindex, rel, rel->trigdesc && rel->trigdesc->trig_update_after_row,
withCheckOptionList, returningList, retrieved_attrs);
deparseReturningList(buf, rte, rtindex, rel, rel->trigdesc && rel->trigdesc->trig_update_after_row, returningList,
retrieved_attrs);
}
/*
@ -1945,15 +1945,15 @@ void deparseDeleteSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relatio
deparseRelation(buf, rel);
appendStringInfoString(buf, " WHERE ctid = $1 and tableoid = $2");
deparseReturningList(buf, rte, rtindex, rel, rel->trigdesc && rel->trigdesc->trig_delete_after_row, NIL,
returningList, retrieved_attrs);
deparseReturningList(buf, rte, rtindex, rel, rel->trigdesc && rel->trigdesc->trig_delete_after_row, returningList,
retrieved_attrs);
}
/*
* Add a RETURNING clause, if needed, to an INSERT/UPDATE/DELETE.
*/
static void deparseReturningList(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, bool trig_after_row,
List *withCheckOptionList, List *returningList, List **retrieved_attrs)
List *returningList, List **retrieved_attrs)
{
Bitmapset *attrs_used = NULL;
@ -1962,19 +1962,6 @@ static void deparseReturningList(StringInfo buf, RangeTblEntry *rte, Index rtind
attrs_used = bms_make_singleton(0 - FirstLowInvalidHeapAttributeNumber);
}
if (withCheckOptionList != NIL) {
/*
* We need the attrs, non-system and system, mentioned in the local
* query's WITH CHECK OPTION list.
*
* Note: we do this to ensure that WCO constraints will be evaluated
* on the data actually inserted/updated on the remote side, which
* might differ from the data supplied by the core code, for example
* as a result of remote triggers.
*/
pull_varattnos((Node*)withCheckOptionList, rtindex, &attrs_used);
}
if (returningList != NIL) {
/*
* We need the attrs, non-system and system, mentioned in the local
@ -2030,7 +2017,7 @@ void deparseAnalyzeSql(StringInfo buf, Relation rel, List **retrieved_attrs)
appendStringInfoString(buf, "SELECT ");
for (i = 0; i < tupdesc->natts; i++) {
/* Ignore dropped columns. */
if (tupdesc->attrs[i].attisdropped) {
if (tupdesc->attrs[i]->attisdropped) {
continue;
}
@ -2040,7 +2027,7 @@ void deparseAnalyzeSql(StringInfo buf, Relation rel, List **retrieved_attrs)
first = false;
/* Use attribute name or column_name option. */
char *colname = NameStr(tupdesc->attrs[i].attname);
char *colname = NameStr(tupdesc->attrs[i]->attname);
List *options = GetForeignColumnOptions(relid, i + 1);
foreach (lc, options) {
@ -3398,7 +3385,7 @@ static void get_relation_column_alias_ids(Var *node, RelOptInfo *foreignrel, int
/* Get the column alias ID */
i = 1;
foreach (lc, foreignrel->reltarget->exprs) {
foreach (lc, foreignrel->reltargetlist) {
if (equal(lfirst(lc), (Node *)node)) {
*colno = i;
return;

View File

@ -1394,18 +1394,18 @@ SELECT * FROM ft1 t1 WHERE t1.c1 === t1.c2 order by t1.c2 limit 1;
-- case when expr
explain (verbose, costs off) select * from ft1 where case c1 when 1 then 0 end = 0;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan on public.ft1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Node ID: 1
Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" WHERE (((CASE "C 1" WHEN 1 THEN 0 ELSE NULL::integer END) = 0))
Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" WHERE (((CASE "C 1" WHEN 1 THEN 0::numeric ELSE NULL::numeric END) = 0::numeric))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" WHERE (((CASE "C 1" WHEN 1 THEN 0 ELSE NULL::integer END) = 0))
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" WHERE (((CASE "C 1" WHEN 1 THEN 0::numeric ELSE NULL::numeric END) = 0::numeric))
Seq Scan on "S 1"."T 1"
Output: "C 1", c2, c3, c4, c5, c6, c7, c8
Filter: (CASE "T 1"."C 1" WHEN 1 THEN 0 ELSE NULL::integer END = 0)
Filter: (CASE "T 1"."C 1" WHEN 1 THEN 0::numeric ELSE NULL::numeric END = 0::numeric)
(11 rows)
@ -4698,6 +4698,7 @@ create operator public.>^ (
procedure = int4gt
);
create operator family my_op_family using btree;
ERROR: user defined operator is not yet supported.
create function my_op_cmp(a int, b int) returns int as
$$begin return btint4cmp(a, b); end $$ language plpgsql;
create operator class my_op_class for type int using btree family my_op_family as
@ -4705,34 +4706,23 @@ create operator class my_op_class for type int using btree family my_op_family a
operator 3 public.=^,
operator 5 public.>^,
function 1 my_op_cmp(int, int);
ERROR: operator family "my_op_family" does not exist for access method "btree"
-- NOTICES:
-- openGauss not support create operator class. remove the case. If you want to restore the test case later, refer to README in the file header.
-- This will not be pushed as sort operator is now removed from the extension.
explain (verbose, costs off)
select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 and c1 < 100 group by c2;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: array_agg(c1 ORDER BY c1 USING <^ NULLS LAST), c2
Group By Key: ft2.c2
-> Foreign Scan on public.ft2
Output: c2, c1
Node ID: 1
Remote SQL: SELECT "C 1", c2 FROM "S 1"."T 1" WHERE (("C 1" < 100)) AND ((c2 = 6))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT "C 1", c2 FROM "S 1"."T 1" WHERE (("C 1" < 100)) AND ((c2 = 6))
Index Scan using t1_pkey on "S 1"."T 1"
Output: "C 1", c2
Index Cond: ("T 1"."C 1" < 100)
Filter: ("T 1".c2 = 6)
(15 rows)
ERROR: operator <^ is not a valid ordering operator
LINE 2: select array_agg(c1 order by c1 using operator(public.<^)) f...
^
HINT: Ordering operators must be "<" or ">" members of btree operator families.
CONTEXT: referenced column: array_agg
-- Cleanup
drop operator class my_op_class using btree;
ERROR: operator class "my_op_class" does not exist for access method "btree"
drop function my_op_cmp(a int, b int);
drop operator family my_op_family using btree;
ERROR: operator family "my_op_family" does not exist for access method "btree"
drop operator public.>^(int, int);
drop operator public.=^(int, int);
drop operator public.<^(int, int);
@ -8391,348 +8381,22 @@ UPDATE ft1 SET c2 = c2 + 1 WHERE c1 = 1;
ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2negative;
ERROR: constraint "ft1_c2negative" of relation "ft1" does not exist
-- ======================================================================================================================================
-- TEST-MODULE: IUD VIEW and WITH CHECK OPTION constraints
-- TEST-MODULE: WITH CHECK OPTION constraints
-- --------------------------------------
-- openGauss not support WITH CHECK OPTION, so this test module is unuseful and cannot be fixed, remove it.
-- ======================================================================================================================================
CREATE TABLE base_tbl (id int, a int, b int);
ALTER TABLE base_tbl SET (autovacuum_enabled = 'false');
CREATE FOREIGN TABLE foreign_tbl (id int, a int, b int) SERVER loopback OPTIONS (table_name 'base_tbl');
CREATE VIEW rw_view1 AS SELECT * FROM foreign_tbl WHERE a < b and id = 1;
CREATE VIEW rw_view2 AS SELECT * FROM foreign_tbl WHERE a < b and id = 2 WITH CHECK OPTION;
\d+ rw_view1
View "public.rw_view1"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+---------+-------------
id | integer | | plain |
a | integer | | plain |
b | integer | | plain |
View definition:
SELECT *
FROM foreign_tbl
WHERE foreign_tbl.a < foreign_tbl.b AND foreign_tbl.id = 1;
\d+ rw_view2
View "public.rw_view2"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+---------+-------------
id | integer | | plain |
a | integer | | plain |
b | integer | | plain |
View definition:
SELECT *
FROM foreign_tbl
WHERE foreign_tbl.a < foreign_tbl.b AND foreign_tbl.id = 2;
Options: check_option=cascaded
CREATE OR REPLACE FUNCTION checkdata(out tbname text, out id int, out a int, out b int) RETURNS SETOF record as $$
select * from (
(select 'rw_view1', * from rw_view1 where id = 1) union all
(select 'rw_view2', * from rw_view2 where id = 2) union all
(select 'base_tbl', * from base_tbl) union all
(select 'foreign_tbl', * from foreign_tbl)
) data(tbname, id, a, b)
order by 1,2,3,4;
$$ language sql;
-- simple case
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 5); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 1, 0, 5
(3 rows)
INSERT INTO rw_view1 VALUES (1, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 10, 5); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 1, 10, 5
(3 rows)
INSERT INTO rw_view1 VALUES (1, 10, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 5); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 2, 0, 5
(3 rows)
INSERT INTO rw_view2 VALUES (2, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 10, 5); -- should failed
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 2, 10, 5
(3 rows)
INSERT INTO rw_view2 VALUES (2, 10, 5);
ERROR: new row violates WITH CHECK OPTION for view "rw_view2"
DETAIL: Failing row contains (2, 10, 5).
select * from checkdata();
tbname | id | a | b
-------------+----+----+---
base_tbl | 1 | 0 | 5
base_tbl | 1 | 10 | 5
base_tbl | 2 | 0 | 5
foreign_tbl | 1 | 0 | 5
foreign_tbl | 1 | 10 | 5
foreign_tbl | 2 | 0 | 5
rw_view1 | 1 | 0 | 5
rw_view2 | 2 | 0 | 5
(8 rows)
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 20), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 1))
(12 rows)
UPDATE rw_view1 SET a = a + 20 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 20 where id = 2; -- should failed
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 20), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 2))
(12 rows)
UPDATE rw_view2 SET a = a + 20 where id = 2;
ERROR: new row violates WITH CHECK OPTION for view "rw_view2"
DETAIL: Failing row contains (2, 20, 5).
select * from checkdata();
tbname | id | a | b
-------------+----+----+---
base_tbl | 1 | 10 | 5
base_tbl | 1 | 20 | 5
base_tbl | 2 | 0 | 5
foreign_tbl | 1 | 10 | 5
foreign_tbl | 1 | 20 | 5
foreign_tbl | 2 | 0 | 5
rw_view2 | 2 | 0 | 5
(7 rows)
insert into base_tbl values(1,100,99),(2,100,99);
EXPLAIN (VERBOSE, COSTS OFF) delete from rw_view1 where id = 1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------
Delete on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
Seq Scan on public.base_tbl
Output: ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 1))
(12 rows)
delete from rw_view1 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) delete from rw_view2 where id = 2;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------
Delete on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
Seq Scan on public.base_tbl
Output: ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 2))
(12 rows)
delete from rw_view2 where id = 2;
select * from checkdata();
tbname | id | a | b
-------------+----+-----+----
base_tbl | 1 | 10 | 5
base_tbl | 1 | 20 | 5
base_tbl | 1 | 100 | 99
base_tbl | 2 | 100 | 99
foreign_tbl | 1 | 10 | 5
foreign_tbl | 1 | 20 | 5
foreign_tbl | 1 | 100 | 99
foreign_tbl | 2 | 100 | 99
(8 rows)
delete from base_tbl;
-- with trigger
CREATE FUNCTION row_before_insupd_trigfunc() RETURNS trigger AS $$BEGIN NEW.a := NEW.a + 10; RETURN NEW; END$$ LANGUAGE plpgsql;
CREATE TABLE base_tbl (a int, b int);
ALTER TABLE base_tbl SET (autovacuum_enabled = 'false');
CREATE TRIGGER row_before_insupd_trigger BEFORE INSERT OR UPDATE ON base_tbl FOR EACH ROW EXECUTE PROCEDURE row_before_insupd_trigfunc();
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 5); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 1, 0, 5
(3 rows)
INSERT INTO rw_view1 VALUES (1, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 16); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 1, 0, 16
(3 rows)
INSERT INTO rw_view1 VALUES (1, 0, 16);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 5); -- should failed
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 2, 0, 5
(3 rows)
INSERT INTO rw_view2 VALUES (2, 0, 5);
ERROR: new row violates WITH CHECK OPTION for view "rw_view2"
DETAIL: Failing row contains (2, 10, 5).
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 16); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 2, 0, 16
(3 rows)
INSERT INTO rw_view2 VALUES (2, 0, 16);
select * from checkdata();
tbname | id | a | b
-------------+----+----+----
base_tbl | 1 | 10 | 5
base_tbl | 1 | 10 | 16
base_tbl | 2 | 10 | 16
foreign_tbl | 1 | 10 | 5
foreign_tbl | 1 | 10 | 16
foreign_tbl | 2 | 10 | 16
rw_view1 | 1 | 10 | 16
rw_view2 | 2 | 10 | 16
(8 rows)
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a - 1 where id = 1;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a - 1), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 1))
(12 rows)
UPDATE rw_view1 SET a = a - 1 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 1 where id = 1;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 1), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 1))
(12 rows)
UPDATE rw_view1 SET a = a + 1 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a - 10 where id = 2;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a - 10), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 2))
(12 rows)
UPDATE rw_view2 SET a = a - 10 where id = 2;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 10 where id = 2;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 10), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 2))
(12 rows)
UPDATE rw_view2 SET a = a + 10 where id = 2;
ERROR: new row violates WITH CHECK OPTION for view "rw_view2"
DETAIL: Failing row contains (2, 30, 16).
select * from checkdata();
tbname | id | a | b
-------------+----+----+----
base_tbl | 1 | 10 | 5
base_tbl | 1 | 19 | 16
base_tbl | 2 | 10 | 16
foreign_tbl | 1 | 10 | 5
foreign_tbl | 1 | 19 | 16
foreign_tbl | 2 | 10 | 16
rw_view2 | 2 | 10 | 16
(7 rows)
DROP TRIGGER row_before_insupd_trigger ON base_tbl;
DROP FUNCTION row_before_insupd_trigfunc;
DROP FUNCTION checkdata;
DROP VIEW rw_view1 cascade;
DROP VIEW rw_view2 cascade;
CREATE FOREIGN TABLE foreign_tbl (a int, b int)
SERVER loopback OPTIONS (table_name 'base_tbl');
-- CREATE VIEW rw_view AS SELECT * FROM foreign_tbl
-- WHERE a < b WITH CHECK OPTION;
-- \d+ rw_view
DROP FOREIGN TABLE foreign_tbl CASCADE;
DROP TABLE base_tbl CASCADE;
DROP TRIGGER row_before_insupd_trigger ON base_tbl;
DROP TABLE base_tbl;
-- ======================================================================================================================================
-- TEST-MODULE: test serial columns (ie, sequence-based defaults)
-- --------------------------------------

View File

@ -1365,20 +1365,20 @@ SELECT * FROM ft1 t1 WHERE t1.c1 === t1.c2 order by t1.c2 limit 1;
-- case when expr
explain (verbose, costs off) select * from ft1 where case c1 when 1 then 0 end = 0;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan on public.ft1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Node ID: 1
Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" WHERE (((CASE "C 1" WHEN 1 THEN 0 ELSE NULL::integer END) = 0))
Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" WHERE (((CASE "C 1" WHEN 1 THEN 0::numeric ELSE NULL::numeric END) = 0::numeric))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" WHERE (((CASE "C 1" WHEN 1 THEN 0 ELSE NULL::integer END) = 0))
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" WHERE (((CASE "C 1" WHEN 1 THEN 0::numeric ELSE NULL::numeric END) = 0::numeric))
Row Adapter
Output: "C 1", c2, c3, c4, c5, c6, c7, c8
-> CStore Scan on "S 1"."T 1"
Output: "C 1", c2, c3, c4, c5, c6, c7, c8
Filter: (CASE "T 1"."C 1" WHEN 1 THEN 0 ELSE NULL::integer END = 0)
Filter: (CASE "T 1"."C 1" WHEN 1 THEN 0::numeric ELSE NULL::numeric END = 0::numeric)
(13 rows)
@ -7089,166 +7089,25 @@ CONTEXT: Remote SQL command: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8, ctid, ta
ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2negative;
ERROR: constraint "ft1_c2negative" of relation "ft1" does not exist
-- ======================================================================================================================================
-- TEST-MODULE: IUD VIEW and WITH CHECK OPTION constraints
-- TEST-MODULE: WITH CHECK OPTION constraints
-- --------------------------------------
-- openGauss not support WITH CHECK OPTION, so this test module
-- is unuseful.
-- ======================================================================================================================================
CREATE TABLE base_tbl (id int, a int, b int) with (orientation=column);
ALTER TABLE base_tbl SET (autovacuum_enabled = 'false');
CREATE FOREIGN TABLE foreign_tbl (id int, a int, b int) SERVER loopback OPTIONS (table_name 'base_tbl');
CREATE VIEW rw_view1 AS SELECT * FROM foreign_tbl WHERE a < b and id = 1;
CREATE VIEW rw_view2 AS SELECT * FROM foreign_tbl WHERE a < b and id = 2 WITH CHECK OPTION;
\d+ rw_view1
View "public.rw_view1"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+---------+-------------
id | integer | | plain |
a | integer | | plain |
b | integer | | plain |
View definition:
SELECT *
FROM foreign_tbl
WHERE foreign_tbl.a < foreign_tbl.b AND foreign_tbl.id = 1;
\d+ rw_view2
View "public.rw_view2"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+---------+-------------
id | integer | | plain |
a | integer | | plain |
b | integer | | plain |
View definition:
SELECT *
FROM foreign_tbl
WHERE foreign_tbl.a < foreign_tbl.b AND foreign_tbl.id = 2;
Options: check_option=cascaded
CREATE OR REPLACE FUNCTION checkdata(out tbname text, out id int, out a int, out b int) RETURNS SETOF record as $$
select * from (
(select 'rw_view1', * from rw_view1 where id = 1) union all
(select 'rw_view2', * from rw_view2 where id = 2) union all
(select 'base_tbl', * from base_tbl) union all
(select 'foreign_tbl', * from foreign_tbl)
) data(tbname, id, a, b)
order by 1,2,3,4;
$$ language sql;
-- simple case
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 5); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 1, 0, 5
(3 rows)
INSERT INTO rw_view1 VALUES (1, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 10, 5); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 1, 10, 5
(3 rows)
INSERT INTO rw_view1 VALUES (1, 10, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 5); -- should failed
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 2, 0, 5
(3 rows)
INSERT INTO rw_view2 VALUES (2, 0, 5);
ERROR: Un-support feature
DETAIL: column stored relation doesn't support INSERT returning
CONTEXT: Remote SQL command: INSERT INTO public.base_tbl(id, a, b) VALUES ($1, $2, $3) RETURNING id, a, b
select * from checkdata();
tbname | id | a | b
-------------+----+----+---
base_tbl | 1 | 0 | 5
base_tbl | 1 | 10 | 5
foreign_tbl | 1 | 0 | 5
foreign_tbl | 1 | 10 | 5
rw_view1 | 1 | 0 | 5
(5 rows)
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 20), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
Row Adapter
Output: id, a, b, ctid, tableoid
-> CStore Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 1))
(14 rows)
UPDATE rw_view1 SET a = a + 20 where id = 1;
select * from checkdata();
tbname | id | a | b
-------------+----+----+---
base_tbl | 1 | 10 | 5
base_tbl | 1 | 20 | 5
foreign_tbl | 1 | 10 | 5
foreign_tbl | 1 | 20 | 5
(4 rows)
insert into base_tbl values(1,100,99),(2,100,99);
EXPLAIN (VERBOSE, COSTS OFF) delete from rw_view1 where id = 1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------
Delete on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
Row Adapter
Output: ctid, tableoid
-> CStore Scan on public.base_tbl
Output: ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 1))
(14 rows)
delete from rw_view1 where id = 1;
select * from checkdata();
tbname | id | a | b
-------------+----+-----+----
base_tbl | 1 | 10 | 5
base_tbl | 1 | 20 | 5
base_tbl | 1 | 100 | 99
base_tbl | 2 | 100 | 99
foreign_tbl | 1 | 10 | 5
foreign_tbl | 1 | 20 | 5
foreign_tbl | 1 | 100 | 99
foreign_tbl | 2 | 100 | 99
(8 rows)
delete from base_tbl;
-- with trigger
CREATE FUNCTION row_before_insupd_trigfunc() RETURNS trigger AS $$BEGIN NEW.a := NEW.a + 10; RETURN NEW; END$$ LANGUAGE plpgsql;
CREATE TABLE base_tbl (a int, b int) with (orientation=column);
ALTER TABLE base_tbl SET (autovacuum_enabled = 'false');
CREATE TRIGGER row_before_insupd_trigger BEFORE INSERT OR UPDATE ON base_tbl FOR EACH ROW EXECUTE PROCEDURE row_before_insupd_trigfunc();
ERROR: Only support CREATE TRIGGER on regular row table.
-- not support, do nothing
CREATE FOREIGN TABLE foreign_tbl (a int, b int)
SERVER loopback OPTIONS (table_name 'base_tbl');
-- CREATE VIEW rw_view AS SELECT * FROM foreign_tbl
-- WHERE a < b WITH CHECK OPTION;
-- \d+ rw_view
DROP FOREIGN TABLE foreign_tbl CASCADE;
DROP TRIGGER row_before_insupd_trigger ON base_tbl;
ERROR: trigger "row_before_insupd_trigger" for table "base_tbl" does not exist
DROP FUNCTION row_before_insupd_trigfunc;
DROP FUNCTION checkdata;
DROP VIEW rw_view1 cascade;
DROP VIEW rw_view2 cascade;
DROP FOREIGN TABLE foreign_tbl CASCADE;
DROP TABLE base_tbl CASCADE;
DROP TABLE base_tbl;
-- ======================================================================================================================================
-- TEST-MODULE: test serial columns (ie, sequence-based defaults)
-- --------------------------------------

View File

@ -252,6 +252,12 @@ EXPLAIN (COSTS OFF) SELECT * FROM ft6; --err
SELECT * FROM ft6;
c1 | c2 | c3
----+-----+--------
12 | 13 | AAA012
18 | 19 | AAA018
27 | 28 | AAA027
39 | 40 | AAA039
45 | 46 | AAA045
48 | 49 | AAA048
3 | 4 | AAA003
6 | 7 | AAA006
9 | 10 | AAA009
@ -262,12 +268,12 @@ SELECT * FROM ft6;
33 | 34 | AAA033
36 | 37 | AAA036
42 | 43 | AAA042
12 | 13 | AAA012
18 | 19 | AAA018
27 | 28 | AAA027
39 | 40 | AAA039
45 | 46 | AAA045
48 | 49 | AAA048
51 | 52 | AAA051
63 | 64 | AAA063
66 | 67 | AAA066
69 | 70 | AAA069
75 | 76 | AAA075
84 | 85 | AAA084
54 | 55 | AAA054
57 | 58 | AAA057
60 | 61 | AAA060
@ -279,12 +285,6 @@ SELECT * FROM ft6;
93 | 94 | AAA093
96 | 97 | AAA096
99 | 100 | AAA099
51 | 52 | AAA051
63 | 64 | AAA063
66 | 67 | AAA066
69 | 70 | AAA069
75 | 76 | AAA075
84 | 85 | AAA084
(33 rows)
SHOW sql_beta_feature;
@ -313,6 +313,12 @@ EXPLAIN (COSTS OFF) SELECT * FROM ft6; --suc
SELECT * FROM ft6;
c1 | c2 | c3
----+-----+--------
12 | 13 | AAA012
18 | 19 | AAA018
27 | 28 | AAA027
39 | 40 | AAA039
45 | 46 | AAA045
48 | 49 | AAA048
3 | 4 | AAA003
6 | 7 | AAA006
9 | 10 | AAA009
@ -323,12 +329,12 @@ SELECT * FROM ft6;
33 | 34 | AAA033
36 | 37 | AAA036
42 | 43 | AAA042
12 | 13 | AAA012
18 | 19 | AAA018
27 | 28 | AAA027
39 | 40 | AAA039
45 | 46 | AAA045
48 | 49 | AAA048
51 | 52 | AAA051
63 | 64 | AAA063
66 | 67 | AAA066
69 | 70 | AAA069
75 | 76 | AAA075
84 | 85 | AAA084
54 | 55 | AAA054
57 | 58 | AAA057
60 | 61 | AAA060
@ -340,12 +346,6 @@ SELECT * FROM ft6;
93 | 94 | AAA093
96 | 97 | AAA096
99 | 100 | AAA099
51 | 52 | AAA051
63 | 64 | AAA063
66 | 67 | AAA066
69 | 70 | AAA069
75 | 76 | AAA075
84 | 85 | AAA084
(33 rows)
-- ======================================================================================================================================
@ -1931,10 +1931,10 @@ SELECT t1.c1, t1.c2, t2.c1, t2.c2 FROM ft4 t1 LEFT JOIN (SELECT * FROM ft5 WHERE
SELECT t1.c1, t1.c2, t2.c1, t2.c2 FROM ft4 t1 LEFT JOIN (SELECT * FROM ft5 WHERE c1 < 10) t2 ON (t1.c1 = t2.c1) WHERE t1.c1 < 10;
c1 | c2 | c1 | c2
----+----+----+----
4 | 5 | |
2 | 3 | |
6 | 7 | 6 | 7
8 | 9 | |
4 | 5 | |
(4 rows)
-- clauses within the nullable side are not pulled up, but the top level clause
@ -1980,10 +1980,10 @@ SELECT t1.c1, t1.c2, t2.c1, t2.c2 FROM ft4 t1 LEFT JOIN (SELECT * FROM ft5 WHERE
WHERE (t2.c1 < 10 OR t2.c1 IS NULL) AND t1.c1 < 10;
c1 | c2 | c1 | c2
----+----+----+----
4 | 5 | |
2 | 3 | |
6 | 7 | 6 | 7
8 | 9 | |
4 | 5 | |
(4 rows)
-- right outer join
@ -2492,7 +2492,7 @@ SELECT t1.c1, ss.a, ss.b FROM (SELECT c1 FROM "S 1"."T 3" WHERE c1 = 50) t1 INNE
-> Partitioned Index Scan using t3_pkey on "S 1"."T 3"
Output: "T 3".c1, "T 3".ctid, "T 3".tableoid
Index Cond: ("T 3".c1 = 50)
Selected Partitions: 2
Selected Partitions: 1
-> Hash Full Join
Output: ft4.c1, ft4.*, ft5.c1, ft5.*
Hash Cond: (ft4.c1 = ft5.c1)
@ -4058,9 +4058,9 @@ SELECT ft4.c1, q.* FROM ft4 LEFT JOIN (SELECT 13, ft1.c1, ft2.c1 FROM ft1 RIGHT
SELECT ft4.c1, q.* FROM ft4 LEFT JOIN (SELECT 13, ft1.c1, ft2.c1 FROM ft1 RIGHT JOIN ft2 ON (ft1.c1 = ft2.c1) WHERE ft1.c1 = 12) q(a, b, c) ON (ft4.c1 = q.b) WHERE ft4.c1 BETWEEN 10 AND 15;
c1 | a | b | c
----+----+----+----
12 | 13 | 12 | 12
10 | | |
14 | | |
12 | 13 | 12 | 12
(3 rows)
-- join with nullable side with some columns with null values
@ -5547,6 +5547,7 @@ create operator public.>^ (
procedure = int4gt
);
create operator family my_op_family using btree;
ERROR: user defined operator is not yet supported.
create function my_op_cmp(a int, b int) returns int as
$$begin return btint4cmp(a, b); end $$ language plpgsql;
create operator class my_op_class for type int using btree family my_op_family as
@ -5554,35 +5555,23 @@ create operator class my_op_class for type int using btree family my_op_family a
operator 3 public.=^,
operator 5 public.>^,
function 1 my_op_cmp(int, int);
ERROR: operator family "my_op_family" does not exist for access method "btree"
-- NOTICES:
-- openGauss not support create operator class. remove the case. If you want to restore the test case later, refer to README in the file header.
-- This will not be pushed as sort operator is now removed from the extension.
explain (verbose, costs off)
select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 and c1 < 100 group by c2;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------
GroupAggregate
Output: array_agg(c1 ORDER BY c1 USING <^ NULLS LAST), c2
Group By Key: ft2.c2
-> Foreign Scan on public.ft2
Output: c2, c1
Node ID: 1
Remote SQL: SELECT "C 1", c2 FROM "S 1"."T 1" WHERE (("C 1" < 100)) AND ((c2 = 6))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT "C 1", c2 FROM "S 1"."T 1" WHERE (("C 1" < 100)) AND ((c2 = 6))
Partitioned Index Scan using t1_pkey on "S 1"."T 1"
Output: "C 1", c2
Index Cond: ("T 1"."C 1" < 100)
Filter: ("T 1".c2 = 6)
Selected Partitions: 1
(16 rows)
ERROR: operator <^ is not a valid ordering operator
LINE 2: select array_agg(c1 order by c1 using operator(public.<^)) f...
^
HINT: Ordering operators must be "<" or ">" members of btree operator families.
CONTEXT: referenced column: array_agg
-- Cleanup
drop operator class my_op_class using btree;
ERROR: operator class "my_op_class" does not exist for access method "btree"
drop function my_op_cmp(a int, b int);
drop operator family my_op_family using btree;
ERROR: operator family "my_op_family" does not exist for access method "btree"
drop operator public.>^(int, int);
drop operator public.=^(int, int);
drop operator public.<^(int, int);
@ -6799,459 +6788,6 @@ SELECT f_test(100);
DROP FUNCTION f_test(int);
-- ======================================================================================================================================
-- TEST-MODULE: IUD VIEW and WITH CHECK OPTION constraints
-- --------------------------------------
-- ======================================================================================================================================
CREATE TABLE base_tbl (id int, a int, b int)
partition by range(a) (partition a1 values less than(100), partition a2 values less than(200));
ALTER TABLE base_tbl SET (autovacuum_enabled = 'false');
CREATE FOREIGN TABLE foreign_tbl (id int, a int, b int) SERVER loopback OPTIONS (table_name 'base_tbl');
CREATE VIEW rw_view1 AS SELECT * FROM foreign_tbl WHERE a < b and id = 1;
CREATE VIEW rw_view2 AS SELECT * FROM foreign_tbl WHERE a < b and id = 2 WITH CHECK OPTION;
\d+ rw_view1
View "public.rw_view1"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+---------+-------------
id | integer | | plain |
a | integer | | plain |
b | integer | | plain |
View definition:
SELECT *
FROM foreign_tbl
WHERE foreign_tbl.a < foreign_tbl.b AND foreign_tbl.id = 1;
\d+ rw_view2
View "public.rw_view2"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+---------+-------------
id | integer | | plain |
a | integer | | plain |
b | integer | | plain |
View definition:
SELECT *
FROM foreign_tbl
WHERE foreign_tbl.a < foreign_tbl.b AND foreign_tbl.id = 2;
Options: check_option=cascaded
CREATE OR REPLACE FUNCTION checkdata(out tbname text, out id int, out a int, out b int) RETURNS SETOF record as $$
select * from (
(select 'rw_view1', * from rw_view1 where id = 1) union all
(select 'rw_view2', * from rw_view2 where id = 2) union all
(select 'base_tbl p1', * from base_tbl) union all
(select 'base_tbl p2', * from base_tbl) union all
(select 'foreign_tbl', * from foreign_tbl)
) data(tbname, id, a, b)
order by 1,2,3,4;
$$ language sql;
-- simple case
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 5); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 1, 0, 5
(3 rows)
INSERT INTO rw_view1 VALUES (1, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 100, 5); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 1, 100, 5
(3 rows)
INSERT INTO rw_view1 VALUES (1, 100, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 1000, 5000); -- should failed
QUERY PLAN
-------------------------------
Insert on public.foreign_tbl
-> Result
Output: 1, 1000, 5000
(3 rows)
INSERT INTO rw_view1 VALUES (1, 1000, 5000);
ERROR: inserted partition key does not map to any table partition
CONTEXT: Remote SQL command: INSERT INTO public.base_tbl(id, a, b) VALUES ($1, $2, $3)
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 5); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 2, 0, 5
(3 rows)
INSERT INTO rw_view2 VALUES (2, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 100, 5); -- should failed
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 2, 100, 5
(3 rows)
INSERT INTO rw_view2 VALUES (2, 100, 5);
ERROR: new row violates WITH CHECK OPTION for view "rw_view2"
DETAIL: Failing row contains (2, 100, 5).
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 1000, 5000); -- should failed
QUERY PLAN
-------------------------------
Insert on public.foreign_tbl
-> Result
Output: 2, 1000, 5000
(3 rows)
INSERT INTO rw_view2 VALUES (2, 1000, 5000);
ERROR: inserted partition key does not map to any table partition
CONTEXT: Remote SQL command: INSERT INTO public.base_tbl(id, a, b) VALUES ($1, $2, $3) RETURNING id, a, b
select * from checkdata();
tbname | id | a | b
-------------+----+-----+---
base_tbl p1 | 1 | 0 | 5
base_tbl p1 | 1 | 100 | 5
base_tbl p1 | 2 | 0 | 5
base_tbl p2 | 1 | 0 | 5
base_tbl p2 | 1 | 100 | 5
base_tbl p2 | 2 | 0 | 5
foreign_tbl | 1 | 0 | 5
foreign_tbl | 1 | 100 | 5
foreign_tbl | 2 | 0 | 5
rw_view1 | 1 | 0 | 5
rw_view2 | 2 | 0 | 5
(11 rows)
delete from base_tbl;
insert into base_tbl values(1, 65, 100), (2, 85, 100); -- in and cross partition update
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 20), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
Partition Iterator
Output: id, a, b, ctid, tableoid
Iterations: 2
-> Partitioned Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 1))
Selected Partitions: 1..2
(16 rows)
UPDATE rw_view1 SET a = a + 10 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 20), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
Partition Iterator
Output: id, a, b, ctid, tableoid
Iterations: 2
-> Partitioned Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 1))
Selected Partitions: 1..2
(16 rows)
UPDATE rw_view1 SET a = a + 10 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 20 where id = 2; -- should failed
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 20), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
Partition Iterator
Output: id, a, b, ctid, tableoid
Iterations: 2
-> Partitioned Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 2))
Selected Partitions: 1..2
(16 rows)
UPDATE rw_view2 SET a = a + 20 where id = 2;
ERROR: new row violates WITH CHECK OPTION for view "rw_view2"
DETAIL: Failing row contains (2, 105, 100).
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 20, b = 200 where id = 2; -- should success
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 20), 200, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
Partition Iterator
Output: id, a, ctid, tableoid
Iterations: 2
-> Partitioned Seq Scan on public.base_tbl
Output: id, a, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 2))
Selected Partitions: 1..2
(16 rows)
UPDATE rw_view2 SET a = a + 20, b = 200 where id = 2;
select * from checkdata();
tbname | id | a | b
-------------+----+-----+-----
base_tbl p1 | 1 | 85 | 100
base_tbl p1 | 2 | 105 | 200
base_tbl p2 | 1 | 85 | 100
base_tbl p2 | 2 | 105 | 200
foreign_tbl | 1 | 85 | 100
foreign_tbl | 2 | 105 | 200
rw_view1 | 1 | 85 | 100
rw_view2 | 2 | 105 | 200
(8 rows)
delete from base_tbl;
insert into base_tbl values(1, 100, 99),(2, 100, 99);
EXPLAIN (VERBOSE, COSTS OFF) delete from rw_view1 where id = 1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------
Delete on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
Partition Iterator
Output: ctid, tableoid
Iterations: 2
-> Partitioned Seq Scan on public.base_tbl
Output: ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 1))
Selected Partitions: 1..2
(16 rows)
delete from rw_view1 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) delete from rw_view2 where id = 2;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------
Delete on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
Partition Iterator
Output: ctid, tableoid
Iterations: 2
-> Partitioned Seq Scan on public.base_tbl
Output: ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 2))
Selected Partitions: 1..2
(16 rows)
delete from rw_view2 where id = 2;
select * from checkdata();
tbname | id | a | b
-------------+----+-----+----
base_tbl p1 | 1 | 100 | 99
base_tbl p1 | 2 | 100 | 99
base_tbl p2 | 1 | 100 | 99
base_tbl p2 | 2 | 100 | 99
foreign_tbl | 1 | 100 | 99
foreign_tbl | 2 | 100 | 99
(6 rows)
delete from base_tbl;
-- with trigger
CREATE FUNCTION row_before_insupd_trigfunc() RETURNS trigger AS $$BEGIN NEW.a := NEW.a + 10; RETURN NEW; END$$ LANGUAGE plpgsql;
CREATE TRIGGER row_before_insupd_trigger BEFORE INSERT OR UPDATE ON base_tbl FOR EACH ROW EXECUTE PROCEDURE row_before_insupd_trigfunc();
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 5); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 1, 0, 5
(3 rows)
INSERT INTO rw_view1 VALUES (1, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 80, 16); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 1, 80, 16
(3 rows)
INSERT INTO rw_view1 VALUES (1, 80, 16);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 5); -- should failed
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 2, 0, 5
(3 rows)
INSERT INTO rw_view2 VALUES (2, 0, 5);
ERROR: new row violates WITH CHECK OPTION for view "rw_view2"
DETAIL: Failing row contains (2, 10, 5).
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 16); -- should success
QUERY PLAN
------------------------------
Insert on public.foreign_tbl
-> Result
Output: 2, 0, 16
(3 rows)
INSERT INTO rw_view2 VALUES (2, 0, 16);
select * from checkdata();
tbname | id | a | b
-------------+----+----+----
base_tbl p1 | 1 | 10 | 5
base_tbl p1 | 1 | 90 | 16
base_tbl p1 | 2 | 10 | 16
base_tbl p2 | 1 | 10 | 5
base_tbl p2 | 1 | 90 | 16
base_tbl p2 | 2 | 10 | 16
foreign_tbl | 1 | 10 | 5
foreign_tbl | 1 | 90 | 16
foreign_tbl | 2 | 10 | 16
rw_view2 | 2 | 10 | 16
(10 rows)
delete from base_tbl;
insert into base_tbl values(1, 50, 101), (2, 50, 120); -- in and cross partition update
-- (1, 60, 101), (2, 60, 120)
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 20), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
Partition Iterator
Output: id, a, b, ctid, tableoid
Iterations: 2
-> Partitioned Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 1))
Selected Partitions: 1..2
(16 rows)
UPDATE rw_view1 SET a = a +20 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 20), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 1))
Partition Iterator
Output: id, a, b, ctid, tableoid
Iterations: 2
-> Partitioned Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 1))
Selected Partitions: 1..2
(16 rows)
UPDATE rw_view1 SET a = a +20 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 55 where id = 2; -- should failed
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 55), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
Partition Iterator
Output: id, a, b, ctid, tableoid
Iterations: 2
-> Partitioned Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 2))
Selected Partitions: 1..2
(16 rows)
UPDATE rw_view2 SET a = a + 55 where id = 2;
ERROR: new row violates WITH CHECK OPTION for view "rw_view2"
DETAIL: Failing row contains (2, 125, 120).
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 45 where id = 2; -- should success
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Update on public.foreign_tbl
-> Foreign Scan on public.foreign_tbl
Output: foreign_tbl.id, (foreign_tbl.a + 45), foreign_tbl.b, foreign_tbl.ctid, foreign_tbl.tableoid
Node ID: 1
Remote SQL: SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
FDW remote plans:
Node 1: EXPLAIN (VERBOSE ON, COSTS OFF) SELECT id, a, b, ctid, tableoid FROM public.base_tbl WHERE ((a < b)) AND ((id = 2))
Partition Iterator
Output: id, a, b, ctid, tableoid
Iterations: 2
-> Partitioned Seq Scan on public.base_tbl
Output: id, a, b, ctid, tableoid
Filter: ((base_tbl.a < base_tbl.b) AND (base_tbl.id = 2))
Selected Partitions: 1..2
(16 rows)
UPDATE rw_view2 SET a = a + 45 where id = 2;
select * from checkdata();
tbname | id | a | b
-------------+----+-----+-----
base_tbl p1 | 1 | 120 | 101
base_tbl p1 | 2 | 115 | 120
base_tbl p2 | 1 | 120 | 101
base_tbl p2 | 2 | 115 | 120
foreign_tbl | 1 | 120 | 101
foreign_tbl | 2 | 115 | 120
rw_view2 | 2 | 115 | 120
(7 rows)
DROP TRIGGER row_before_insupd_trigger ON base_tbl;
DROP FUNCTION row_before_insupd_trigfunc;
DROP FUNCTION checkdata;
DROP VIEW rw_view1 cascade;
DROP VIEW rw_view2 cascade;
DROP FOREIGN TABLE foreign_tbl CASCADE;
DROP TABLE base_tbl CASCADE;
-- ======================================================================================================================================
-- TEST-MODULE: test writable foreign table stuff
-- --------------------------------------
-- ======================================================================================================================================
@ -9647,6 +9183,12 @@ EXPLAIN (VERBOSE, COSTS OFF)select * from ftx;
select * from ftx;
c1 | c2 | c3
----+-----+--------
12 | 13 | AAA012
39 | 40 | AAA039
48 | 49 | AAA048
18 | 19 |
27 | 28 |
45 | 46 |
3 | 4 | AAA003
6 | 7 | AAA006
15 | 16 | AAA015
@ -9657,12 +9199,12 @@ select * from ftx;
42 | 43 | AAA042
9 | 10 |
36 | 37 |
12 | 13 | AAA012
39 | 40 | AAA039
48 | 49 | AAA048
18 | 19 |
27 | 28 |
45 | 46 |
51 | 52 | AAA051
66 | 67 | AAA066
69 | 70 | AAA069
75 | 76 | AAA075
84 | 85 | AAA084
63 | 64 |
57 | 58 | AAA057
60 | 61 | AAA060
78 | 79 | AAA078
@ -9674,12 +9216,6 @@ select * from ftx;
81 | 82 |
90 | 91 |
99 | 100 |
51 | 52 | AAA051
66 | 67 | AAA066
69 | 70 | AAA069
75 | 76 | AAA075
84 | 85 | AAA084
63 | 64 |
(33 rows)
EXPLAIN (VERBOSE, COSTS OFF)select * from ftx partition(ptb1); --ERR

View File

@ -274,7 +274,6 @@ ForeignPath *create_foreign_join_path(PlannerInfo *root, RelOptInfo *rel, List *
pathnode->path.pathtype = T_ForeignScan;
pathnode->path.parent = rel;
pathnode->path.pathtarget = rel->reltarget;
pathnode->path.param_info = NULL; /* XXX see above */
pathnode->path.rows = rows;
pathnode->path.startup_cost = startup_cost;
@ -347,7 +346,7 @@ RelOptInfo *fetch_upper_rel(FDWUpperRelCxt *ufdwCxt, UpperRelationKind kind)
upperrel->reloptkind = RELOPT_UPPER_REL;
upperrel->relids = NULL;
upperrel->reltarget = makeNode(PathTarget);
upperrel->reltargetlist = NIL;
upperrel->pathlist = NIL;
upperrel->cheapest_startup_path = NULL;
upperrel->cheapest_total_path = NULL;
@ -407,7 +406,7 @@ RelOptInfo *make_upper_rel(FDWUpperRelCxt *ufdwCxt, PgFdwRelationInfo *fpinfo)
RelOptInfo *upper_rel = fetch_upper_rel(ufdwCxt, fpinfo->stage);
/* Set target. */
upper_rel->reltarget->exprs = extract_target_from_tel(ufdwCxt, fpinfo);
upper_rel->reltargetlist = extract_target_from_tel(ufdwCxt, fpinfo);
/*
* If the input rel belongs to a single FDW, so does the grouped rel.
@ -464,7 +463,6 @@ ForeignPath *create_foreign_upper_path(PlannerInfo *root, RelOptInfo *rel, List
pathnode->path.pathtype = T_ForeignScan;
pathnode->path.parent = rel;
pathnode->path.pathtarget = rel->reltarget;
pathnode->path.param_info = NULL;
pathnode->path.rows = rows;
pathnode->path.startup_cost = startup_cost;

View File

@ -420,7 +420,7 @@ static void postgresGetForeignRelSize(PlannerInfo *root, RelOptInfo *baserel, Oi
* columns used in them. Doesn't seem worth detecting that case though.)
*/
fpinfo->attrs_used = NULL;
pull_varattnos((Node *)baserel->reltarget->exprs, baserel->relid, &fpinfo->attrs_used);
pull_varattnos((Node *)baserel->reltargetlist, baserel->relid, &fpinfo->attrs_used);
foreach (lc, fpinfo->local_conds) {
RestrictInfo *rinfo = (RestrictInfo *)lfirst(lc);
@ -463,7 +463,7 @@ static void postgresGetForeignRelSize(PlannerInfo *root, RelOptInfo *baserel, Oi
/* Report estimated baserel size to planner. */
baserel->rows = fpinfo->rows;
baserel->reltarget->width = fpinfo->width;
baserel->width = fpinfo->width;
} else {
/*
* If the foreign table has never been ANALYZEd, it will have relpages
@ -476,7 +476,7 @@ static void postgresGetForeignRelSize(PlannerInfo *root, RelOptInfo *baserel, Oi
*/
if (baserel->pages == 0 && baserel->tuples == 0) {
baserel->pages = 10;
baserel->tuples = (double)(10 * BLCKSZ) / (baserel->reltarget->width + sizeof(HeapTupleHeaderData));
baserel->tuples = (double)(10 * BLCKSZ) / (baserel->width + sizeof(HeapTupleHeaderData));
}
/* Estimate baserel size as best we can with local statistics. */
@ -1300,7 +1300,6 @@ static List *postgresPlanForeignModify(PlannerInfo *root, ModifyTable *plan, Ind
RangeTblEntry *rte = planner_rt_fetch(resultRelation, root);
StringInfoData sql;
List *targetAttrs = NIL;
List *withCheckOptionList = NIL;
List *returningList = NIL;
List *retrieved_attrs = NIL;
@ -1328,7 +1327,7 @@ static List *postgresPlanForeignModify(PlannerInfo *root, ModifyTable *plan, Ind
int attnum;
for (attnum = 1; attnum <= tupdesc->natts; attnum++) {
Form_pg_attribute attr = &tupdesc->attrs[attnum - 1];
Form_pg_attribute attr = tupdesc->attrs[attnum - 1];
if (!attr->attisdropped) {
targetAttrs = lappend_int(targetAttrs, attnum);
@ -1348,13 +1347,6 @@ static List *postgresPlanForeignModify(PlannerInfo *root, ModifyTable *plan, Ind
}
}
/*
* Extract the relevant WITH CHECK OPTION list if any.
*/
if (plan->withCheckOptionLists) {
withCheckOptionList = (List*)list_nth(plan->withCheckOptionLists, subplan_index);
}
/*
* Extract the relevant RETURNING list if any.
*/
@ -1367,12 +1359,10 @@ static List *postgresPlanForeignModify(PlannerInfo *root, ModifyTable *plan, Ind
*/
switch (operation) {
case CMD_INSERT:
deparseInsertSql(&sql, rte, resultRelation, rel, targetAttrs, withCheckOptionList, returningList,
&retrieved_attrs);
deparseInsertSql(&sql, rte, resultRelation, rel, targetAttrs, returningList, &retrieved_attrs);
break;
case CMD_UPDATE:
deparseUpdateSql(&sql, rte, resultRelation, rel, targetAttrs, withCheckOptionList, returningList,
&retrieved_attrs);
deparseUpdateSql(&sql, rte, resultRelation, rel, targetAttrs, returningList, &retrieved_attrs);
break;
case CMD_DELETE:
deparseDeleteSql(&sql, rte, resultRelation, rel, returningList, &retrieved_attrs);
@ -1502,7 +1492,7 @@ static PgFdwModifyState *createForeignModify(EState *estate, RangeTblEntry *rte,
/* Set up for remaining transmittable parameters */
foreach (lc, fmstate->target_attrs) {
int attnum = lfirst_int(lc);
Form_pg_attribute attr = &tupdesc->attrs[attnum - 1];
Form_pg_attribute attr = tupdesc->attrs[attnum - 1];
Assert(!attr->attisdropped);
@ -1539,13 +1529,13 @@ static TupleTableSlot *postgresExecForeignInsert(EState *estate, ResultRelInfo *
initStringInfo(&sql);
/* We transmit all columns that are defined in the foreign table. */
for (int attnum = 1; attnum <= tupdesc->natts; attnum++) {
Form_pg_attribute attr = &tupdesc->attrs[attnum - 1];
Form_pg_attribute attr = tupdesc->attrs[attnum - 1];
if (!attr->attisdropped) {
targetAttrs = lappend_int(targetAttrs, attnum);
}
}
deparseInsertSql(&sql, rte, resultRelation, rel, targetAttrs, NULL, NULL, &retrieved_attrs);
deparseInsertSql(&sql, rte, resultRelation, rel, targetAttrs, NULL, &retrieved_attrs);
fmstate = createForeignModify(estate, rte, resultRelInfo, CMD_INSERT, NULL, sql.data, targetAttrs,
retrieved_attrs != NIL, retrieved_attrs);
@ -2108,7 +2098,7 @@ static void estimate_path_cost_size(PlannerInfo *root, RelOptInfo *foreignrel, L
/* Use rows/width estimates made by the core code. */
rows = foreignrel->rows;
width = foreignrel->reltarget->width;
width = foreignrel->width;
/* For join we expect inner and outer relations set */
Assert(fpinfo->innerrel && fpinfo->outerrel);
@ -2199,7 +2189,7 @@ static void estimate_path_cost_size(PlannerInfo *root, RelOptInfo *foreignrel, L
/* Collect statistics about aggregates for estimating costs. */
MemSet(&aggcosts, 0, sizeof(AggClauseCosts));
if (root->parse->hasAggs) {
count_agg_clauses(root, (Node*)foreignrel->reltarget->exprs, &aggcosts);
count_agg_clauses(root, (Node*)foreignrel->reltargetlist, &aggcosts);
count_agg_clauses(root, root->parse->havingQual, &aggcosts);
}
@ -2226,7 +2216,7 @@ static void estimate_path_cost_size(PlannerInfo *root, RelOptInfo *foreignrel, L
}
/* Use width estimate made by the core code. */
width = foreignrel->reltarget->width;
width = foreignrel->width;
/* -----
* Startup cost includes:
@ -2269,7 +2259,7 @@ static void estimate_path_cost_size(PlannerInfo *root, RelOptInfo *foreignrel, L
/* Use rows/width estimates made by set_baserel_size_estimates. */
rows = foreignrel->rows;
width = foreignrel->reltarget->width;
width = foreignrel->width;
/*
* Back into an estimate of the number of retrieved rows. Just in
@ -3963,7 +3953,7 @@ static void postgresGetForeignJoinPaths(PlannerInfo *root, RelOptInfo *joinrel,
estimate_path_cost_size(root, joinrel, NIL, NIL, NULL, &rows, &width, &startup_cost, &total_cost);
/* Now update this information in the joinrel */
joinrel->rows = rows;
joinrel->reltarget->width = width;
joinrel->width = width;
fpinfo->rows = rows;
fpinfo->width = width;
fpinfo->startup_cost = startup_cost;
@ -4228,7 +4218,7 @@ static void init_upperrel_paths_context(FDWUpperRelCxt* ufdwCxt, Plan* mainPlan)
fpinfo->stage = UPPERREL_INIT;
/* the reltargetlist may bave been evaluted, we shoule adept it. */
ufdwCxt->currentRel->reltarget->exprs = extract_target_from_tel(ufdwCxt, fpinfo);
ufdwCxt->currentRel->reltargetlist = extract_target_from_tel(ufdwCxt, fpinfo);
ufdwCxt->state = FDW_UPPER_REL_INIT;
}
@ -4398,7 +4388,7 @@ static void add_foreign_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
fpinfo->total_cost = total_cost;
/* Create and add foreign path to the grouping relation. */
grouppath = create_foreign_upper_path(root, grouped_rel, grouped_rel->reltarget->exprs, rows, startup_cost, total_cost,
grouppath = create_foreign_upper_path(root, grouped_rel, grouped_rel->reltargetlist, rows, startup_cost, total_cost,
NIL, /* no pathkeys */
NULL, NIL); /* no fdw_private */
@ -4501,7 +4491,7 @@ static void add_foreign_ordered_paths(PlannerInfo *root, RelOptInfo *input_rel,
/* Construct PgFdwPathExtraData */
fpextra = (PgFdwPathExtraData *)palloc0(sizeof(PgFdwPathExtraData));
fpextra->target = ordered_rel->reltarget->exprs;
fpextra->target = ordered_rel->reltargetlist;
fpextra->has_final_sort = true;
/* Estimate the costs of performing the final sort remotely */
@ -4515,7 +4505,7 @@ static void add_foreign_ordered_paths(PlannerInfo *root, RelOptInfo *input_rel,
fdw_private = list_make2(makeInteger(1), makeInteger(0));
/* Create foreign ordering path */
ordered_path = create_foreign_upper_path(root, input_rel, ordered_rel->reltarget->exprs, rows, startup_cost,
ordered_path = create_foreign_upper_path(root, input_rel, ordered_rel->reltargetlist, rows, startup_cost,
total_cost, root->sort_pathkeys, NULL, /* no extra plan */
fdw_private);

View File

@ -151,9 +151,9 @@ extern void classifyConditions(PlannerInfo *root, RelOptInfo *baserel, List *inp
extern bool is_foreign_expr(PlannerInfo *root, RelOptInfo *baserel, Expr *expr);
extern bool is_foreign_pathkey(PlannerInfo *root, RelOptInfo *baserel, PathKey *pathkey);
extern void deparseInsertSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *targetAttrs,
List *withCheckOptionList, List *returningList, List **retrieved_attrs);
List *returningList, List **retrieved_attrs);
extern void deparseUpdateSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *targetAttrs,
List *withCheckOptionList, List *returningList, List **retrieved_attrs);
List *returningList, List **retrieved_attrs);
extern void deparseDeleteSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *returningList,
List **retrieved_attrs);
extern void deparseAnalyzeSizeSql(StringInfo buf, Relation rel);

View File

@ -1371,85 +1371,24 @@ UPDATE ft1 SET c2 = c2 + 1 WHERE c1 = 1;
ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2negative;
-- ======================================================================================================================================
-- TEST-MODULE: IUD VIEW and WITH CHECK OPTION constraints
-- TEST-MODULE: WITH CHECK OPTION constraints
-- --------------------------------------
-- openGauss not support WITH CHECK OPTION, so this test module is unuseful and cannot be fixed, remove it.
-- ======================================================================================================================================
CREATE TABLE base_tbl (id int, a int, b int);
ALTER TABLE base_tbl SET (autovacuum_enabled = 'false');
CREATE FOREIGN TABLE foreign_tbl (id int, a int, b int) SERVER loopback OPTIONS (table_name 'base_tbl');
CREATE VIEW rw_view1 AS SELECT * FROM foreign_tbl WHERE a < b and id = 1;
CREATE VIEW rw_view2 AS SELECT * FROM foreign_tbl WHERE a < b and id = 2 WITH CHECK OPTION;
\d+ rw_view1
\d+ rw_view2
CREATE OR REPLACE FUNCTION checkdata(out tbname text, out id int, out a int, out b int) RETURNS SETOF record as $$
select * from (
(select 'rw_view1', * from rw_view1 where id = 1) union all
(select 'rw_view2', * from rw_view2 where id = 2) union all
(select 'base_tbl', * from base_tbl) union all
(select 'foreign_tbl', * from foreign_tbl)
) data(tbname, id, a, b)
order by 1,2,3,4;
$$ language sql;
-- simple case
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 5); -- should success
INSERT INTO rw_view1 VALUES (1, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 10, 5); -- should success
INSERT INTO rw_view1 VALUES (1, 10, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 5); -- should success
INSERT INTO rw_view2 VALUES (2, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 10, 5); -- should failed
INSERT INTO rw_view2 VALUES (2, 10, 5);
select * from checkdata();
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
UPDATE rw_view1 SET a = a + 20 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 20 where id = 2; -- should failed
UPDATE rw_view2 SET a = a + 20 where id = 2;
select * from checkdata();
insert into base_tbl values(1,100,99),(2,100,99);
EXPLAIN (VERBOSE, COSTS OFF) delete from rw_view1 where id = 1;
delete from rw_view1 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) delete from rw_view2 where id = 2;
delete from rw_view2 where id = 2;
select * from checkdata();
delete from base_tbl;
-- with trigger
CREATE FUNCTION row_before_insupd_trigfunc() RETURNS trigger AS $$BEGIN NEW.a := NEW.a + 10; RETURN NEW; END$$ LANGUAGE plpgsql;
CREATE TABLE base_tbl (a int, b int);
ALTER TABLE base_tbl SET (autovacuum_enabled = 'false');
CREATE TRIGGER row_before_insupd_trigger BEFORE INSERT OR UPDATE ON base_tbl FOR EACH ROW EXECUTE PROCEDURE row_before_insupd_trigfunc();
CREATE FOREIGN TABLE foreign_tbl (a int, b int)
SERVER loopback OPTIONS (table_name 'base_tbl');
-- CREATE VIEW rw_view AS SELECT * FROM foreign_tbl
-- WHERE a < b WITH CHECK OPTION;
-- \d+ rw_view
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 5); -- should success
INSERT INTO rw_view1 VALUES (1, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 16); -- should success
INSERT INTO rw_view1 VALUES (1, 0, 16);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 5); -- should failed
INSERT INTO rw_view2 VALUES (2, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 16); -- should success
INSERT INTO rw_view2 VALUES (2, 0, 16);
select * from checkdata();
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a - 1 where id = 1;
UPDATE rw_view1 SET a = a - 1 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 1 where id = 1;
UPDATE rw_view1 SET a = a + 1 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a - 10 where id = 2;
UPDATE rw_view2 SET a = a - 10 where id = 2;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 10 where id = 2;
UPDATE rw_view2 SET a = a + 10 where id = 2;
select * from checkdata();
DROP TRIGGER row_before_insupd_trigger ON base_tbl;
DROP FUNCTION row_before_insupd_trigfunc;
DROP FUNCTION checkdata;
DROP VIEW rw_view1 cascade;
DROP VIEW rw_view2 cascade;
DROP FOREIGN TABLE foreign_tbl CASCADE;
DROP TABLE base_tbl CASCADE;
DROP TRIGGER row_before_insupd_trigger ON base_tbl;
DROP TABLE base_tbl;
-- ======================================================================================================================================

View File

@ -1008,59 +1008,26 @@ UPDATE ft1 SET c2 = c2 + 1 WHERE c1 = 1;
ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2negative;
-- ======================================================================================================================================
-- TEST-MODULE: IUD VIEW and WITH CHECK OPTION constraints
-- TEST-MODULE: WITH CHECK OPTION constraints
-- --------------------------------------
-- openGauss not support WITH CHECK OPTION, so this test module
-- is unuseful.
-- ======================================================================================================================================
CREATE TABLE base_tbl (id int, a int, b int) with (orientation=column);
ALTER TABLE base_tbl SET (autovacuum_enabled = 'false');
CREATE FOREIGN TABLE foreign_tbl (id int, a int, b int) SERVER loopback OPTIONS (table_name 'base_tbl');
CREATE VIEW rw_view1 AS SELECT * FROM foreign_tbl WHERE a < b and id = 1;
CREATE VIEW rw_view2 AS SELECT * FROM foreign_tbl WHERE a < b and id = 2 WITH CHECK OPTION;
\d+ rw_view1
\d+ rw_view2
CREATE OR REPLACE FUNCTION checkdata(out tbname text, out id int, out a int, out b int) RETURNS SETOF record as $$
select * from (
(select 'rw_view1', * from rw_view1 where id = 1) union all
(select 'rw_view2', * from rw_view2 where id = 2) union all
(select 'base_tbl', * from base_tbl) union all
(select 'foreign_tbl', * from foreign_tbl)
) data(tbname, id, a, b)
order by 1,2,3,4;
$$ language sql;
-- simple case
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 5); -- should success
INSERT INTO rw_view1 VALUES (1, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 10, 5); -- should success
INSERT INTO rw_view1 VALUES (1, 10, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 5); -- should failed
INSERT INTO rw_view2 VALUES (2, 0, 5);
select * from checkdata();
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
UPDATE rw_view1 SET a = a + 20 where id = 1;
select * from checkdata();
insert into base_tbl values(1,100,99),(2,100,99);
EXPLAIN (VERBOSE, COSTS OFF) delete from rw_view1 where id = 1;
delete from rw_view1 where id = 1;
select * from checkdata();
delete from base_tbl;
-- with trigger
CREATE FUNCTION row_before_insupd_trigfunc() RETURNS trigger AS $$BEGIN NEW.a := NEW.a + 10; RETURN NEW; END$$ LANGUAGE plpgsql;
CREATE TABLE base_tbl (a int, b int) with (orientation=column);
ALTER TABLE base_tbl SET (autovacuum_enabled = 'false');
CREATE TRIGGER row_before_insupd_trigger BEFORE INSERT OR UPDATE ON base_tbl FOR EACH ROW EXECUTE PROCEDURE row_before_insupd_trigfunc();
-- not support, do nothing
CREATE FOREIGN TABLE foreign_tbl (a int, b int)
SERVER loopback OPTIONS (table_name 'base_tbl');
-- CREATE VIEW rw_view AS SELECT * FROM foreign_tbl
-- WHERE a < b WITH CHECK OPTION;
-- \d+ rw_view
DROP TRIGGER row_before_insupd_trigger ON base_tbl;
DROP FUNCTION row_before_insupd_trigfunc;
DROP FUNCTION checkdata;
DROP VIEW rw_view1 cascade;
DROP VIEW rw_view2 cascade;
DROP FOREIGN TABLE foreign_tbl CASCADE;
DROP TABLE base_tbl CASCADE;
DROP TRIGGER row_before_insupd_trigger ON base_tbl;
DROP TABLE base_tbl;
-- ======================================================================================================================================
-- TEST-MODULE: test serial columns (ie, sequence-based defaults)

View File

@ -1053,101 +1053,6 @@ $$ LANGUAGE plpgsql;
SELECT f_test(100);
DROP FUNCTION f_test(int);
-- ======================================================================================================================================
-- TEST-MODULE: IUD VIEW and WITH CHECK OPTION constraints
-- --------------------------------------
-- ======================================================================================================================================
CREATE TABLE base_tbl (id int, a int, b int)
partition by range(a) (partition a1 values less than(100), partition a2 values less than(200));
ALTER TABLE base_tbl SET (autovacuum_enabled = 'false');
CREATE FOREIGN TABLE foreign_tbl (id int, a int, b int) SERVER loopback OPTIONS (table_name 'base_tbl');
CREATE VIEW rw_view1 AS SELECT * FROM foreign_tbl WHERE a < b and id = 1;
CREATE VIEW rw_view2 AS SELECT * FROM foreign_tbl WHERE a < b and id = 2 WITH CHECK OPTION;
\d+ rw_view1
\d+ rw_view2
CREATE OR REPLACE FUNCTION checkdata(out tbname text, out id int, out a int, out b int) RETURNS SETOF record as $$
select * from (
(select 'rw_view1', * from rw_view1 where id = 1) union all
(select 'rw_view2', * from rw_view2 where id = 2) union all
(select 'base_tbl p1', * from base_tbl) union all
(select 'base_tbl p2', * from base_tbl) union all
(select 'foreign_tbl', * from foreign_tbl)
) data(tbname, id, a, b)
order by 1,2,3,4;
$$ language sql;
-- simple case
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 5); -- should success
INSERT INTO rw_view1 VALUES (1, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 100, 5); -- should success
INSERT INTO rw_view1 VALUES (1, 100, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 1000, 5000); -- should failed
INSERT INTO rw_view1 VALUES (1, 1000, 5000);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 5); -- should success
INSERT INTO rw_view2 VALUES (2, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 100, 5); -- should failed
INSERT INTO rw_view2 VALUES (2, 100, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 1000, 5000); -- should failed
INSERT INTO rw_view2 VALUES (2, 1000, 5000);
select * from checkdata();
delete from base_tbl;
insert into base_tbl values(1, 65, 100), (2, 85, 100); -- in and cross partition update
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
UPDATE rw_view1 SET a = a + 10 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
UPDATE rw_view1 SET a = a + 10 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 20 where id = 2; -- should failed
UPDATE rw_view2 SET a = a + 20 where id = 2;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 20, b = 200 where id = 2; -- should success
UPDATE rw_view2 SET a = a + 20, b = 200 where id = 2;
select * from checkdata();
delete from base_tbl;
insert into base_tbl values(1, 100, 99),(2, 100, 99);
EXPLAIN (VERBOSE, COSTS OFF) delete from rw_view1 where id = 1;
delete from rw_view1 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) delete from rw_view2 where id = 2;
delete from rw_view2 where id = 2;
select * from checkdata();
delete from base_tbl;
-- with trigger
CREATE FUNCTION row_before_insupd_trigfunc() RETURNS trigger AS $$BEGIN NEW.a := NEW.a + 10; RETURN NEW; END$$ LANGUAGE plpgsql;
CREATE TRIGGER row_before_insupd_trigger BEFORE INSERT OR UPDATE ON base_tbl FOR EACH ROW EXECUTE PROCEDURE row_before_insupd_trigfunc();
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 0, 5); -- should success
INSERT INTO rw_view1 VALUES (1, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view1 VALUES (1, 80, 16); -- should success
INSERT INTO rw_view1 VALUES (1, 80, 16);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 5); -- should failed
INSERT INTO rw_view2 VALUES (2, 0, 5);
EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view2 VALUES (2, 0, 16); -- should success
INSERT INTO rw_view2 VALUES (2, 0, 16);
select * from checkdata();
delete from base_tbl;
insert into base_tbl values(1, 50, 101), (2, 50, 120); -- in and cross partition update
-- (1, 60, 101), (2, 60, 120)
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
UPDATE rw_view1 SET a = a +20 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET a = a + 20 where id = 1; -- should success
UPDATE rw_view1 SET a = a +20 where id = 1;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 55 where id = 2; -- should failed
UPDATE rw_view2 SET a = a + 55 where id = 2;
EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view2 SET a = a + 45 where id = 2; -- should success
UPDATE rw_view2 SET a = a + 45 where id = 2;
select * from checkdata();
DROP TRIGGER row_before_insupd_trigger ON base_tbl;
DROP FUNCTION row_before_insupd_trigfunc;
DROP FUNCTION checkdata;
DROP VIEW rw_view1 cascade;
DROP VIEW rw_view2 cascade;
DROP FOREIGN TABLE foreign_tbl CASCADE;
DROP TABLE base_tbl CASCADE;
-- ======================================================================================================================================
-- TEST-MODULE: test writable foreign table stuff
-- --------------------------------------

View File

@ -515,6 +515,30 @@ void set_result_set_function(const PolicyLabelItem &func)
}
}
/*
* check exchange partition list contains masked table.
* For given AlterTableCmd list, check whether ordinary
* tables have bound masking policies.
*/
static bool exchange_partition_with_masked_table(List *cmds)
{
if (cmds == NIL) {
return false;
}
ListCell *lc = NULL;
foreach (lc, cmds) {
AlterTableCmd *cmd = (AlterTableCmd*)lfirst(lc);
if (cmd->subtype == AT_ExchangePartition && cmd->exchange_with_rel != NULL) {
Oid relid = RangeVarGetRelid(cmd->exchange_with_rel, NoLock, true);
if (is_masked_relation(relid)) {
return true;
}
}
}
return false;
}
static void gsaudit_next_PostParseAnalyze_hook(ParseState *pstate, Query *query)
{
/* do nothing when enable_security_policy is off */
@ -628,24 +652,9 @@ static void gsaudit_next_PostParseAnalyze_hook(ParseState *pstate, Query *query)
/* For ALTER TABLE EXCHANGE, will not allowed if the ordinary table(it's columns) has masking policy.*/
if (query->utilityStmt != NULL && nodeTag(query->utilityStmt) == T_AlterTableStmt) {
AlterTableStmt *alter_table = (AlterTableStmt *)(query->utilityStmt);
Oid relid = RangeVarGetRelid(alter_table->relation, NoLock, true);
ListCell *lc = NULL;
foreach (lc, alter_table->cmds) {
AlterTableCmd *cmd = (AlterTableCmd *)lfirst(lc);
if (cmd->subtype == AT_ExchangePartition) {
Assert(PointerIsValid(cmd->exchange_with_rel));
if (is_masked_relation(relid)) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("ALTER TABLE EXCHANGE can not execute with masked partition table.")));
}
Oid ordTableOid = RangeVarGetRelid(cmd->exchange_with_rel, NoLock, true);
if (is_masked_relation(ordTableOid)) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("ALTER TABLE EXCHANGE can not execute with masked ordinary table.")));
}
}
if (exchange_partition_with_masked_table(alter_table->cmds)) {
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("ALTER TABLE EXCHANGE can not execute with masked ordinary table.")));
}
}
break;
@ -805,19 +814,19 @@ static void light_unified_audit_executor(const Query *query)
access_audit_policy_run(query->rtable, query->commandType);
}
static void gsaudit_ProcessUtility_hook(processutility_context* processutility_cxt,
DestReceiver *dest, bool sentToRemote, char *completionTag, ProcessUtilityContext context,bool isCTAS = false)
static void gsaudit_ProcessUtility_hook(Node *parsetree, const char *queryString, ParamListInfoData *params,
bool isTopLevel, DestReceiver *dest, bool sentToRemote, char *completionTag, bool isCTAS = false)
{
/* do nothing when enable_security_policy is off */
if (!u_sess->attr.attr_security.Enable_Security_Policy || !IsConnFromApp() ||
u_sess->proc_cxt.IsInnerMaintenanceTools || IsConnFromCoord() ||
!is_audit_policy_exist_load_policy_info()) {
if (next_ProcessUtility_hook) {
next_ProcessUtility_hook(processutility_cxt, dest, sentToRemote, completionTag,
context, false);
next_ProcessUtility_hook(parsetree, queryString, params, isTopLevel, dest, sentToRemote, completionTag,
false);
} else {
standard_ProcessUtility(processutility_cxt, dest, sentToRemote, completionTag,
context, false);
standard_ProcessUtility(parsetree, queryString, params, isTopLevel, dest, sentToRemote, completionTag,
false);
}
return;
}
@ -831,7 +840,6 @@ static void gsaudit_ProcessUtility_hook(processutility_context* processutility_c
checkSecurityPolicyFilter_hook(filter_item, &security_policy_ids);
}
RenameMap renamed_objects;
Node* parsetree = processutility_cxt->parse_tree;
if (parsetree != NULL) {
switch (nodeTag(parsetree)) {
case T_PlannedStmt: {
@ -1610,11 +1618,11 @@ static void gsaudit_ProcessUtility_hook(processutility_context* processutility_c
PG_TRY();
{
if (next_ProcessUtility_hook) {
next_ProcessUtility_hook(processutility_cxt, dest, sentToRemote, completionTag,
context, false);
next_ProcessUtility_hook(parsetree, queryString, params, isTopLevel, dest, sentToRemote, completionTag,
false);
} else {
standard_ProcessUtility(processutility_cxt, dest, sentToRemote, completionTag,
context, false);
standard_ProcessUtility(parsetree, queryString, params, isTopLevel, dest, sentToRemote, completionTag,
false);
}
flush_access_logs(AUDIT_OK);
send_mng_events(AUDIT_OK);

View File

@ -242,7 +242,7 @@ static void sepgsql_executor_start(QueryDesc* queryDesc, int eflags)
* It tries to rough-grained control on utility commands; some of them can
* break whole of the things if nefarious user would use.
*/
static void sepgsql_utility_command(processutility_context* processutility_cxt,
static void sepgsql_utility_command(Node* parsetree, const char* queryString, ParamListInfo params, bool isTopLevel,
DestReceiver* dest,
#ifdef PGXC
bool sentToRemote,
@ -251,7 +251,6 @@ static void sepgsql_utility_command(processutility_context* processutility_cxt,
{
sepgsql_context_info_t saved_context_info = sepgsql_context_info;
ListCell* cell = NULL;
Node* parsetree = processutility_cxt->parse_tree;
PG_TRY();
{
@ -301,14 +300,20 @@ static void sepgsql_utility_command(processutility_context* processutility_cxt,
}
if (next_ProcessUtility_hook)
(*next_ProcessUtility_hook)(processutility_cxt,
(*next_ProcessUtility_hook)(parsetree,
queryString,
params,
isTopLevel,
dest,
#ifdef PGXC
sentToRemote,
#endif
completionTag);
else
standard_ProcessUtility(processutility_cxt,
standard_ProcessUtility(parsetree,
queryString,
params,
isTopLevel,
dest,
#ifdef PGXC
sentToRemote,

View File

@ -312,7 +312,7 @@ Datum /* have to return HeapTuple to Executor */
snprintf(sql, sizeof(sql), "INSERT INTO %s VALUES (", relname);
for (i = 1; i <= natts; i++) {
ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
if (!(tupdesc->attrs[i - 1].attisdropped)) /* skip dropped columns */
if (!(tupdesc->attrs[i - 1]->attisdropped)) /* skip dropped columns */
{
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "%c$%d", separ, i);
separ = ',';

View File

@ -286,7 +286,7 @@ static void print_literal(StringInfo s, Oid typid, char* outputstr)
/*
* Decode tuple into stringinfo.
*/
static void TupleToStringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple)
static void TupleToStringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple, bool skip_nulls)
{
Assert(tuple != NULL);
if ((tuple->tupTableType == HEAP_TUPLE) && (HEAP_TUPLE_IS_COMPRESSED(tuple->t_data) ||
@ -302,7 +302,7 @@ static void TupleToStringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple)
Oid typoutput = 0; /* output function */
Datum origval = 0; /* possibly toasted Datum */
Form_pg_attribute attr = &tupdesc->attrs[natt]; /* the attribute itself */
Form_pg_attribute attr = tupdesc->attrs[natt]; /* the attribute itself */
if (attr->attisdropped || attr->attnum < 0) {
continue;
@ -315,6 +315,10 @@ static void TupleToStringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple)
origval = uheap_getattr((UHeapTuple)tuple, natt + 1, tupdesc, &isnull);
}
if (skip_nulls && isnull) {
continue;
}
/* query output function */
Oid typid = attr->atttypid; /* type of current attribute */
getTypeOutputInfo(typid, &typoutput, &typisvarlena);
@ -339,7 +343,7 @@ static void TupleToStringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple)
* Decode tuple into stringinfo.
* This function is used for UPDATE or DELETE statements.
*/
static void TupleToStringinfoUpd(Relation relation, StringInfo s, TupleDesc tupdesc, HeapTuple tuple)
static void TupleToStringinfoUpd(StringInfo s, TupleDesc tupdesc, HeapTuple tuple, bool skip_nulls)
{
if ((tuple->tupTableType == HEAP_TUPLE) && (HEAP_TUPLE_IS_COMPRESSED(tuple->t_data) ||
(int)HeapTupleHeaderGetNatts(tuple->t_data, tupdesc) > tupdesc->natts)) {
@ -354,9 +358,9 @@ static void TupleToStringinfoUpd(Relation relation, StringInfo s, TupleDesc tupd
bool isnull = false; /* column is null? */
bool typisvarlena = false;
Form_pg_attribute attr = &tupdesc->attrs[natt]; /* the attribute itself */
Form_pg_attribute attr = tupdesc->attrs[natt]; /* the attribute itself */
if (attr->attisdropped || attr->attnum < 0 || !IsRelationReplidentKey(relation, attr->attnum)) {
if (attr->attisdropped || attr->attnum < 0) {
continue;
}
@ -367,6 +371,10 @@ static void TupleToStringinfoUpd(Relation relation, StringInfo s, TupleDesc tupd
origval = uheap_getattr((UHeapTuple)tuple, natt + 1, tupdesc, &isnull);
}
if (isnull && skip_nulls) {
continue;
}
if (!isFirstAtt) {
appendStringInfoString(s, " and ");
} else {
@ -395,32 +403,31 @@ static void TupleToStringinfoUpd(Relation relation, StringInfo s, TupleDesc tupd
* Callback for handle decoded tuple.
* Additional info will be added if the tuple is found null.
*/
static void TupleHandler(Relation relation, StringInfo s, TupleDesc tupdesc, ReorderBufferChange* change,
bool isHeap, bool isNewTuple)
static void TupleHandler(StringInfo s, TupleDesc tupdesc, ReorderBufferChange* change, bool isHeap, bool isNewTuple)
{
if (isHeap && isNewTuple) {
if (change->data.tp.newtuple == NULL) {
appendStringInfoString(s, " (no-tuple-data)");
} else {
TupleToStringinfo(s, tupdesc, &change->data.tp.newtuple->tuple);
TupleToStringinfo(s, tupdesc, &change->data.tp.newtuple->tuple, false);
}
} else if (isHeap && !isNewTuple) {
if (change->data.tp.oldtuple == NULL) {
appendStringInfoString(s, " (no-tuple-data)");
} else {
TupleToStringinfoUpd(relation, s, tupdesc, &change->data.tp.oldtuple->tuple);
TupleToStringinfoUpd(s, tupdesc, &change->data.tp.oldtuple->tuple, true);
}
} else if (!isHeap && isNewTuple) {
if (change->data.utp.newtuple == NULL) {
appendStringInfoString(s, " (no-tuple-data)");
} else {
TupleToStringinfo(s, tupdesc, (HeapTuple)(&change->data.utp.newtuple->tuple));
TupleToStringinfo(s, tupdesc, (HeapTuple)(&change->data.utp.newtuple->tuple), false);
}
} else {
if (change->data.utp.oldtuple == NULL) {
appendStringInfoString(s, " (no-tuple-data)");
} else {
TupleToStringinfoUpd(relation, s, tupdesc, (HeapTuple)(&change->data.utp.oldtuple->tuple));
TupleToStringinfoUpd(s, tupdesc, (HeapTuple)(&change->data.utp.oldtuple->tuple), true);
}
}
}
@ -465,7 +472,7 @@ static void pg_decode_change(
isHeap = false;
}
appendStringInfoString(ctx->out, " values ");
TupleHandler(relation, ctx->out, tupdesc, change, isHeap, true);
TupleHandler(ctx->out, tupdesc, change, isHeap, true);
break;
case REORDER_BUFFER_CHANGE_UPDATE:
case REORDER_BUFFER_CHANGE_UUPDATE:
@ -476,12 +483,12 @@ static void pg_decode_change(
isHeap = false;
}
appendStringInfoString(ctx->out, " where ");
TupleHandler(relation, ctx->out, tupdesc, change, isHeap, false);
TupleHandler(ctx->out, tupdesc, change, isHeap, false);
appendStringInfoChar(ctx->out, ';');
appendStringInfoString(ctx->out, "insert into ");
appendStringInfoString(ctx->out, quote_qualified_identifier(schema, table));
appendStringInfoString(ctx->out, " values ");
TupleHandler(relation, ctx->out, tupdesc, change, isHeap, true);
TupleHandler(ctx->out, tupdesc, change, isHeap, true);
break;
@ -495,7 +502,7 @@ static void pg_decode_change(
}
appendStringInfoString(ctx->out, " where ");
TupleHandler(relation, ctx->out, tupdesc, change, isHeap, false);
TupleHandler(ctx->out, tupdesc, change, isHeap, false);
break;
default:
Assert(false);

View File

@ -1337,35 +1337,35 @@ static void validateConnectbyTupleDesc(TupleDesc tupdesc, bool show_branch, bool
}
/* check that the types of the first two columns match */
if (tupdesc->attrs[0].atttypid != tupdesc->attrs[1].atttypid)
if (tupdesc->attrs[0]->atttypid != tupdesc->attrs[1]->atttypid)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid return type"),
errdetail("First two columns must be the same type.")));
/* check that the type of the third column is INT4 */
if (tupdesc->attrs[2].atttypid != INT4OID)
if (tupdesc->attrs[2]->atttypid != INT4OID)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid return type"),
errdetail("Third column must be type %s.", format_type_be(INT4OID))));
/* check that the type of the fourth column is TEXT if applicable */
if (show_branch && tupdesc->attrs[3].atttypid != TEXTOID)
if (show_branch && tupdesc->attrs[3]->atttypid != TEXTOID)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("invalid return type"),
errdetail("Fourth column must be type %s.", format_type_be(TEXTOID))));
/* check that the type of the fifth column is INT4 */
if (show_branch && show_serial && tupdesc->attrs[4].atttypid != INT4OID)
if (show_branch && show_serial && tupdesc->attrs[4]->atttypid != INT4OID)
elog(ERROR,
"query-specified return tuple not valid for Connectby: "
"fifth column must be type %s",
format_type_be(INT4OID));
/* check that the type of the fifth column is INT4 */
if (!show_branch && show_serial && tupdesc->attrs[3].atttypid != INT4OID)
if (!show_branch && show_serial && tupdesc->attrs[3]->atttypid != INT4OID)
elog(ERROR,
"query-specified return tuple not valid for Connectby: "
"fourth column must be type %s",
@ -1383,8 +1383,8 @@ static bool compatConnectbyTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupde
Oid sql_atttypid;
/* check the key_fld types match */
ret_atttypid = ret_tupdesc->attrs[0].atttypid;
sql_atttypid = sql_tupdesc->attrs[0].atttypid;
ret_atttypid = ret_tupdesc->attrs[0]->atttypid;
sql_atttypid = sql_tupdesc->attrs[0]->atttypid;
if (ret_atttypid != sql_atttypid)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@ -1393,8 +1393,8 @@ static bool compatConnectbyTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupde
"not match return key field datatype.")));
/* check the parent_key_fld types match */
ret_atttypid = ret_tupdesc->attrs[1].atttypid;
sql_atttypid = sql_tupdesc->attrs[1].atttypid;
ret_atttypid = ret_tupdesc->attrs[1]->atttypid;
sql_atttypid = sql_tupdesc->attrs[1]->atttypid;
if (ret_atttypid != sql_atttypid)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@ -1421,8 +1421,8 @@ static bool compatCrosstabTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdes
return false;
/* check the rowid types match */
ret_atttypid = ret_tupdesc->attrs[0].atttypid;
sql_atttypid = sql_tupdesc->attrs[0].atttypid;
ret_atttypid = ret_tupdesc->attrs[0]->atttypid;
sql_atttypid = sql_tupdesc->attrs[0]->atttypid;
if (ret_atttypid != sql_atttypid)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),

View File

@ -199,13 +199,15 @@ static bool pg_decode_filter(LogicalDecodingContext* ctx, RepOriginId origin_id)
return true;
return false;
}
static void tuple_to_stringinfo(Relation relation, StringInfo s, TupleDesc tupdesc, HeapTuple tuple, bool isOld)
static void tuple_to_stringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple, bool skip_nulls)
{
if ((tuple->tupTableType == HEAP_TUPLE) && (HEAP_TUPLE_IS_COMPRESSED(tuple->t_data) ||
(int)HeapTupleHeaderGetNatts(tuple->t_data, tupdesc) > tupdesc->natts)) {
if (HEAP_TUPLE_IS_COMPRESSED(tuple->t_data))
return;
}
if ((int)HeapTupleHeaderGetNatts(tuple->t_data, tupdesc) != tupdesc->natts)
return;
int natt;
Oid oid;
/* print oid of tuple, it's not included in the TupleDesc */
@ -214,14 +216,15 @@ static void tuple_to_stringinfo(Relation relation, StringInfo s, TupleDesc tupde
}
/* print all columns individually */
for (int natt = 0; natt < tupdesc->natts; natt++) {
for (natt = 0; natt < tupdesc->natts; natt++) {
Form_pg_attribute attr; /* the attribute itself */
Oid typid; /* type of current attribute */
Oid typoutput; /* output function */
bool typisvarlena = false;
Datum origval; /* possibly toasted Datum */
bool isnull = true; /* column is null? */
attr = &tupdesc->attrs[natt];
attr = tupdesc->attrs[natt];
/*
* don't print dropped columns, we can't be sure everything is
@ -234,17 +237,16 @@ static void tuple_to_stringinfo(Relation relation, StringInfo s, TupleDesc tupde
* Don't print system columns, oid will already have been printed if
* present.
*/
if (attr->attnum < 0 || (isOld && !IsRelationReplidentKey(relation, attr->attnum)))
if (attr->attnum < 0)
continue;
Oid typid = attr->atttypid; /* type of current attribute */
typid = attr->atttypid;
/* get Datum from tuple */
if (tuple->tupTableType == HEAP_TUPLE) {
origval = heap_getattr(tuple, natt + 1, tupdesc, &isnull);
} else {
origval = uheap_getattr((UHeapTuple)tuple, natt + 1, tupdesc, &isnull);
}
origval = heap_getattr(tuple, natt + 1, tupdesc, &isnull);
if (isnull && skip_nulls)
continue;
/* print attribute name */
appendStringInfoChar(s, ' ');
@ -325,40 +327,20 @@ static void pg_decode_change(
if (change->data.tp.newtuple == NULL)
appendStringInfoString(ctx->out, " (no-tuple-data)");
else
tuple_to_stringinfo(relation, ctx->out, tupdesc, &change->data.tp.newtuple->tuple, false);
break;
case REORDER_BUFFER_CHANGE_UINSERT:
appendStringInfoString(ctx->out, " INSERT:");
if (change->data.utp.newtuple == NULL)
appendStringInfoString(ctx->out, " (no-tuple-data)");
else
tuple_to_stringinfo(relation, ctx->out, tupdesc, (HeapTuple)(&change->data.utp.newtuple->tuple), false);
tuple_to_stringinfo(ctx->out, tupdesc, &change->data.tp.newtuple->tuple, false);
break;
case REORDER_BUFFER_CHANGE_UPDATE:
appendStringInfoString(ctx->out, " UPDATE:");
if (change->data.tp.oldtuple != NULL) {
appendStringInfoString(ctx->out, " old-key:");
tuple_to_stringinfo(relation, ctx->out, tupdesc, &change->data.tp.oldtuple->tuple, true);
tuple_to_stringinfo(ctx->out, tupdesc, &change->data.tp.oldtuple->tuple, true);
appendStringInfoString(ctx->out, " new-tuple:");
}
if (change->data.tp.newtuple == NULL)
appendStringInfoString(ctx->out, " (no-tuple-data)");
else
tuple_to_stringinfo(relation, ctx->out, tupdesc, &change->data.tp.newtuple->tuple, false);
break;
case REORDER_BUFFER_CHANGE_UUPDATE:
appendStringInfoString(ctx->out, " UPDATE:");
if (change->data.utp.oldtuple != NULL) {
appendStringInfoString(ctx->out, " old-key:");
tuple_to_stringinfo(relation, ctx->out, tupdesc, (HeapTuple)(&change->data.utp.oldtuple->tuple), true);
appendStringInfoString(ctx->out, " new-tuple:");
}
if (change->data.utp.newtuple == NULL)
appendStringInfoString(ctx->out, " (no-tuple-data)");
else
tuple_to_stringinfo(relation, ctx->out, tupdesc, (HeapTuple)(&change->data.utp.newtuple->tuple), false);
tuple_to_stringinfo(ctx->out, tupdesc, &change->data.tp.newtuple->tuple, false);
break;
case REORDER_BUFFER_CHANGE_DELETE:
appendStringInfoString(ctx->out, " DELETE:");
@ -368,15 +350,7 @@ static void pg_decode_change(
appendStringInfoString(ctx->out, " (no-tuple-data)");
/* In DELETE, only the replica identity is present; display that */
else
tuple_to_stringinfo(relation, ctx->out, tupdesc, &change->data.tp.oldtuple->tuple, true);
break;
case REORDER_BUFFER_CHANGE_UDELETE:
appendStringInfoString(ctx->out, " DELETE:");
if (change->data.utp.oldtuple == NULL)
appendStringInfoString(ctx->out, " (no-tuple-data)");
else
tuple_to_stringinfo(relation, ctx->out, tupdesc, (HeapTuple)(&change->data.utp.oldtuple->tuple), true);
tuple_to_stringinfo(ctx->out, tupdesc, &change->data.tp.oldtuple->tuple, true);
break;
default:
Assert(false);

View File

@ -1186,7 +1186,7 @@ su - gaussdb
the size of each individual file in the WAL log. It may be useful
to adjust this size to control the granularity of WAL log shipping.
The default size is 16 megabytes.
The value must be a power of 2 between 1 and 512 (megabytes).
The value must be a power of 2 between 1 and 1024 (megabytes).
Note that changing this value requires an gs_initdb.
</para>
</listitem>

View File

@ -12,7 +12,6 @@ Complete list of usable sgml source files in this directory.
<!ENTITY alterDatabase SYSTEM "alter_database.sgml">
<!ENTITY alterDefaultPrivileges SYSTEM "alter_default_privileges.sgml">
<!ENTITY alterDomain SYSTEM "alter_domain.sgml">
<!ENTITY alterEventTrigger SYSTEM "alter_event_trigger.sgml">
<!ENTITY alterExtension SYSTEM "alter_extension.sgml">
<!ENTITY alterForeignDataWrapper SYSTEM "alter_foreign_data_wrapper.sgml">
<!ENTITY alterForeignTable SYSTEM "alter_foreign_table.sgml">
@ -65,7 +64,6 @@ Complete list of usable sgml source files in this directory.
<!ENTITY createConversion SYSTEM "create_conversion.sgml">
<!ENTITY createDatabase SYSTEM "create_database.sgml">
<!ENTITY createDomain SYSTEM "create_domain.sgml">
<!ENTITY createEventTrigger SYSTEM "create_event_trigger.sgml">
<!ENTITY createExtension SYSTEM "create_extension.sgml">
<!ENTITY createForeignDataWrapper SYSTEM "create_foreign_data_wrapper.sgml">
<!ENTITY createForeignTable SYSTEM "create_foreign_table.sgml">
@ -110,7 +108,6 @@ Complete list of usable sgml source files in this directory.
<!ENTITY dropConversion SYSTEM "drop_conversion.sgml">
<!ENTITY dropDatabase SYSTEM "drop_database.sgml">
<!ENTITY dropDomain SYSTEM "drop_domain.sgml">
<!ENTITY dropEventTrigger SYSTEM "drop_event_trigger.sgml">
<!ENTITY dropExtension SYSTEM "drop_extension.sgml">
<!ENTITY dropForeignDataWrapper SYSTEM "drop_foreign_data_wrapper.sgml">
<!ENTITY dropForeignTable SYSTEM "drop_foreign_table.sgml">

View File

@ -1,23 +0,0 @@
<refentry id="SQL-ALTEREVENTTRIGGER">
<refmeta>
<refentrytitle>ALTER EVENT TRIGGER</refentrytitle>
<manvolnum>7</manvolnum>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>ALTER EVENT TRIGGER</refname>
<refpurpose>change the definition of an event trigger</refpurpose>
</refnamediv>
<refsynopsisdiv>
<indexterm zone="sql-altereventtrigger">
<primary>ALTER EVENT TRIGGER</primary>
</indexterm>
<refsynopsisdiv>
<synopsis>
ALTER EVENT TRIGGER name DISABLE
ALTER EVENT TRIGGER name ENABLE [ REPLICA | ALWAYS ]
ALTER EVENT TRIGGER name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
ALTER EVENT TRIGGER name RENAME TO new_name
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -15,9 +15,6 @@ ALTER SCHEMA schema_name
ALTER SCHEMA schema_name
OWNER TO new_owner;
ALTER SCHEMA schema_name {WITH | WITHOUT} BLOCKCHAIN;
ALTER SCHEMA schema_name
[ [ DEFAULT ] CHARACTER SET | CHARSET [ = ] charset ] [ [ DEFAULT ] COLLATE [ = ] collation ];
NOTICE: '[ [ DEFAULT ] CHARACTER SET | CHARSET [ = ] charset ] [ [ DEFAULT ] COLLATE [ = ] collation ]' is only available in CENTRALIZED mode and B-format database!
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -52,18 +52,11 @@ column_clause
| NO FORCE ROW LEVEL SECURITY
| ENCRYPTION KEY ROTATION
| AUTO_INCREMENT [ = ] value
| ALTER INDEX index_name [ VISBLE | INVISIBLE ]
| [ [ DEFAULT ] CHARACTER SET | CHARSET [ = ] charset ] [ [ DEFAULT ] COLLATE [ = ] collation ]
| CONVERT TO CHARACTER SET | CHARSET charset [ COLLATE collation ]
NOTICE: '[ CHARACTER SET | CHARSET ]' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ COLLATE ]' is only available in CENTRALIZED mode and B-format database!
where column_clause can be:
ADD [ COLUMN ] column_name data_type [ CHARACTER SET | CHARSET charset ] [ compress_mode ] [ COLLATE collation ] [ column_constraint [ ... ] ] [ FIRST | AFTER column_name ]
ADD [ COLUMN ] column_name data_type [ compress_mode ] [ COLLATE collation ] [ column_constraint [ ... ] ]
| MODIFY column_name data_type
| MODIFY column_name [ CONSTRAINT constraint_name ] NOT NULL [ ENABLE ]
| MODIFY column_name [ CONSTRAINT constraint_name ] NULL
| MODIFY [ COLUMN ] column_name data_type [ CHARACTER SET | CHARSET charset ] [ COLLATE collation ] [ column_constraint [ ... ] ] [FIRST | AFTER column_name]
| CHANGE [ COLUMN ] column_name new_column_name data_type [ CHARACTER SET | CHARSET charset ] [ COLLATE collation ] [ column_constraint [ ... ] ] [FIRST | AFTER column_name]
| DROP [ COLUMN ] [ IF EXISTS ] column_name [ RESTRICT | CASCADE ]
| ALTER [ COLUMN ] column_name [ SET DATA ] TYPE data_type [ COLLATE collation ] [ USING expression ]
| ALTER [ COLUMN ] column_name { SET DEFAULT expression | DROP DEFAULT }
@ -74,30 +67,27 @@ ADD [ COLUMN ] column_name data_type [ CHARACTER SET | CHARSET charset ] [ compr
| ALTER [ COLUMN ] column_name SET ( {attribute_option = value} [, ... ] )
| ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] )
| ALTER [ COLUMN ] column_name SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
NOTICE: 'MODIFY [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!
NOTICE: 'CHANGE [ COLUMN ] ...' action is only available in CENTRALIZED mode and B-format database!
where column_constraint can be:
[ CONSTRAINT constraint_name ]
{ NOT NULL |
NULL |
CHECK ( expression ) |
DEFAULT default_expr |
GENERATED ALWAYS AS ( generation_expr ) [STORED] |
GENERATED ALWAYS AS ( generation_expr ) STORED |
AUTO_INCREMENT |
UNIQUE [KEY] index_parameters |
UNIQUE index_parameters |
PRIMARY KEY index_parameters |
ENCRYPTED WITH ( COLUMN_ENCRYPTION_KEY = column_encryption_key, ENCRYPTION_TYPE = encryption_type_value ) |
REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ]
[ ON DELETE action ] [ ON UPDATE action ] }
[ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!
where compress_mode can be:
{ DELTA | PREFIX | DICTIONARY | NUMSTR | NOCOMPRESS }
where table_constraint can be:
[ CONSTRAINT [ constraint_name ] ]
{ CHECK ( expression ) |
UNIQUE [ idx_name ] [ USING method ] ( { { column_name | ( expression ) } [ ASC | DESC ] } [, ... ] ) index_parameters [ VISIBLE | INVISIBLE ] |
PRIMARY KEY [ USING method ] ( { column_name [ ASC | DESC ] }[, ... ] ) index_parameters [ VISIBLE | INVISIBLE ] |
UNIQUE [ idx_name ] [ USING method ] ( { { column_name | ( expression ) } [ ASC | DESC ] } [, ... ] ) index_parameters |
PRIMARY KEY [ USING method ] ( { column_name [ ASC | DESC ] }[, ... ] ) index_parameters |
PARTIAL CLUSTER KEY ( column_name [, ... ] ) |
FOREIGN KEY [ idx_name ] ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ]
[ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON UPDATE action ] }
@ -111,15 +101,11 @@ where table_constraint_using_index can be:
[ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.
NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ USING method ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ ASC | DESC ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: '( expression )' in 'UNIQUE' clause of table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: 'AUTO_INCREMENT' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ FIRST | AFTER column_name ]' clause is only available in CENTRALIZED mode!
NOTICE: '[ FIRST | AFTER column_name ]' in 'MODIFY | CHANGE [ COLUMN ] ...' clause is only available in B-format database!
NOTICE: '[ CHARACTER SET | CHARSET charset ]' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ VISIBLE | INVISIBLE ]' is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '[ index_name ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '[ USING method ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '[ ASC | DESC ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '( expression )' in 'UNIQUE' clause of table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: 'AUTO_INCREMENT' is only avaliable in CENTRALIZED mode and B-format database!
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -11,7 +11,9 @@
<refsynopsisdiv>
<synopsis>
ALTER TABLE [ IF EXISTS ] { table_name [*] | ONLY table_name | ONLY ( table_name )}
{ action [, ... ] | rename_clause | reset_clause };
action [, ... ];
ALTER TABLE [ IF EXISTS ] { table_name [*] | ONLY table_name | ONLY ( table_name )}
RENAME PARTITION { partion_name | FOR ( partition_value [, ...] ) } TO partition_new_name;
where action can be:
move_clause |
@ -28,16 +30,16 @@ MOVE PARTITION { partion_name | FOR ( partition_value [, ...] ) } TABLESPACE tab
where exchange_clause can be:
EXCHANGE PARTITION { ( partition_name ) | FOR ( partition_value [, ...] ) }
WITH TABLE {[ ONLY ] ordinary_table_name | ordinary_table_name * | ONLY ( ordinary_table_name )}
[ { WITH | WITHOUT } VALIDATION ] [ VERBOSE ] [ UPDATE GLOBAL INDEX ]
[ { WITH | WITHOUT } VALIDATION ] [ VERBOSE ]
where row_clause can be:
{ ENABLE | DISABLE } ROW MOVEMENT
where merge_clause can be:
MERGE PARTITIONS { partition_name } [, ...] INTO PARTITION partition_name
[ TABLESPACE tablespacename ] [ UPDATE GLOBAL INDEX ]
[ TABLESPACE tablespacename ]
where modify_clause can be:
MODIFY PARTITION partition_name { UNUSABLE LOCAL INDEXES | REBUILD UNUSABLE LOCAL INDEXES }
where split_clause can be:
SPLIT PARTITION { partition_name | FOR ( partition_value [, ...] ) } { split_point_clause | no_split_point_clause } [ UPDATE GLOBAL INDEX ]
SPLIT PARTITION { partition_name | FOR ( partition_value [, ...] ) } { split_point_clause | no_split_point_clause }
where split_point_clause can be:
AT ( partition_value ) INTO ( PARTITION partition_name [ TABLESPACE tablespacename ] , PARTITION partition_name [ TABLESPACE tablespacename ] )
where no_split_point_clause can be:
@ -58,13 +60,10 @@ PARTITION partition_name {
{END({partition_value | MAXVALUE})}
} [TABLESPACE tablespace_name]
where drop_clause can be:
DROP PARTITION { partition_name | FOR ( partition_value [, ...] ) } [ UPDATE GLOBAL INDEX ]
DROP PARTITION { partition_name | FOR ( partition_value [, ...] ) }
where truncate_clause can be:
TRUNCATE PARTITION { partition_name | FOR ( partition_value [, ...] ) } [ UPDATE GLOBAL INDEX ]
where rename_clause can be:
RENAME PARTITION { partion_name | FOR ( partition_value [, ...] ) } TO partition_new_name;
where reset_clause can be:
RESET PARTITION;
NOTICE: 'truncate_clause' is only avaliable in CENTRALIZED mode!
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -11,16 +11,13 @@
<refsynopsisdiv>
<synopsis>
ALTER TABLE [ IF EXISTS ] { table_name [*] | ONLY table_name | ONLY ( table_name )}
{ action [, ... ] | reset_clause };
action [, ... ];
where action can be:
row_clause |
add_clause |
drop_clause |
split_clause |
truncate_clause
where row_clause can be:
{ ENABLE | DISABLE } ROW MOVEMENT
where add_clause can be:
ADD { partition_less_than_item | partition_list_item } [ ( subpartition_definition_list ) ]
MODIFY PARTITION partition_name ADD subpartition_definition
@ -29,7 +26,7 @@ PARTITION partition_name VALUES LESS THAN ( partition_value | MAXVALUE ) [ TABLE
where partition_list_item can be:
PARTITION partition_name VALUES ( partition_value [, ...] | DEFAULT ) [ TABLESPACE tablespacename ]
where subpartition_definition_list can be:
SUBPARTITION subpartition_name { VALUES LESS THAN ( partition_value | MAXVALUE ) | VALUES ( partition_value [, ...] | DEFAULT ) } [ TABLESPACE tablespace ]
SUBPARTITION subpartition_name [ VALUES LESS THAN ( partition_value | MAXVALUE ) | VALUES ( partition_value [, ...] | DEFAULT )] [ TABLESPACE tablespace ]
where drop_clause can be:
DROP PARTITION { partition_name | FOR ( partition_value ) } [ UPDATE GLOBAL INDEX ]
DROP SUBPARTITION { subpartition_name | FOR ( partition_value, subpartition_value ) } [ UPDATE GLOBAL INDEX ]
@ -40,8 +37,7 @@ AT ( subpartition_value ) INTO ( SUBPARTITION subpartition_name [ TABLESPACE tab
VALUES ( subpartition_value ) INTO ( SUBPARTITION subpartition_name [ TABLESPACE tablespacename ] , SUBPARTITION subpartition_name [ TABLESPACE tablespacename ] )
where truncate_clause can be:
TRUNCATE SUBPARTITION { subpartition_name } [ UPDATE GLOBAL INDEX ]
where reset_clause can be:
RESET PARTITION;
NOTICE: 'ALTER TABLE SUBPARTITION' is only avaliable in CENTRALIZED mode!
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -14,7 +14,7 @@
[ table_name [ ( column_name [, ...] ) ] ];
{ANALYZE | ANALYSE} [ VERBOSE ]
[ table_name [ ( column_name [, ...] ) ] ]
PARTITION (partition_name);
PARTITION patrition_name;
{ANALYZE | ANALYSE} [ VERBOSE ]
{ foreign_table_name | FOREIGN TABLES };
{ANALYZE | ANALYSE} [ VERBOSE ]
@ -23,7 +23,7 @@
{ANALYZE | ANALYSE} VERIFY {FAST|COMPLETE}
table_name|index_name [CASCADE];
{ANALYZE | ANALYSE} VERIFY {FAST|COMPLETE}
table_name PARTITION (partition_name) [CASCADE];
table_name PARTITION (patrition_name) [CASCADE];
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -14,7 +14,7 @@
[ table_name [ ( column_name [, ...] ) ] ];
{ ANALYZE | ANALYSE } [ VERBOSE ]
[ table_name [ ( column_name [, ...] ) ] ]
PARTITION (partition_name);
PARTITION patrition_name;
{ ANALYZE | ANALYSE } [ VERBOSE ]
{ foreign_table_name | FOREIGN TABLES };
{ ANALYZE | ANALYSE } [ VERBOSE ]
@ -22,7 +22,7 @@
{ ANALYZE | ANALYSE } VERIFY { FAST | COMPLETE };
{ ANALYZE | ANALYSE } VERIFY { FAST | COMPLETE } table_name | index_name [ CASCADE ];
{ ANALYZE | ANALYSE } VERIFY { FAST | COMPLETE }
table_name PARTITION (partition_name) [ CASCADE ];
table_name PARTITION (patrition_name) [ CASCADE ];
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -1,23 +0,0 @@
<refentry id="SQL-CREATEEVENTTRIGGER">
<refmeta>
<refentrytitle>CREATE EVENT TRIGGER</refentrytitle>
<manvolnum>7</manvolnum>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>CREATE EVENT TRIGGER</refname>
<refpurpose>define a new event trigger</refpurpose>
</refnamediv>
<refsynopsisdiv>
<indexterm zone="sql-createeventtrigger">
<primary>CREATE EVENT TRIGGER</primary>
</indexterm>
<refsynopsisdiv>
<synopsis>
CREATE EVENT TRIGGER name
ON event
[ WHEN filter_variable IN (filter_value [, ... ]) [ AND ... ] ]
EXECUTE PROCEDURE function name()
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -10,24 +10,21 @@
</refnamediv>
<refsynopsisdiv>
<synopsis>
CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ IF NOT EXISTS ] [ [schema_name.] index_name ] ON table_name [ USING method ]
CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [schema_name.] index_name ] ON table_name [ USING method ]
({ { column_name [ ( length ) ] | ( expression ) } [ COLLATE collation ] [ opclass ] [ ASC | DESC ] [ NULLS { FIRST | LAST } ] }[, ...] )
[ INCLUDE ( { column_name | ( expression ) }[, ...] ) ]
[ WITH ( {storage_parameter = value} [, ... ] ) ]
[ TABLESPACE tablespace_name ]
[ VISIBLE | INVISIBLE ]
[ WHERE predicate ];
CREATE [ UNIQUE ] INDEX [ IF NOT EXISTS ] [ [schema_name.] index_name ] ON table_name [ USING method ]
CREATE [ UNIQUE ] INDEX [ [schema_name.] index_name ] ON table_name [ USING method ]
( { { column_name | ( expression ) } [ COLLATE collation ] [ opclass ] [ ASC | DESC ] [ NULLS LAST ] } [, ...] )
[ LOCAL [ ( { PARTITION index_partition_name | SUBPARTITION index_subpartition_name [ TABLESPACE index_partition_tablespace ] } [, ...] ) ] | GLOBAL ]
[ INCLUDE ( { column_name | ( expression ) }[, ...] ) ]
[ WITH ( { storage_parameter = value } [, ...] ) ]
[ TABLESPACE tablespace_name ]
[ VISIBLE | INVISIBLE ];
[ TABLESPACE tablespace_name ];
NOTICE: 'SUBPARTITION index_subpartition_name' is only avaliable in CENTRALIZED mode!
NOTICE: 'column_name ( length )' is only avaliable in B-format database!
NOTICE: '[ VISIBLE | INVISIBLE ]' is only avaliable in CENTRALIZED mode and B-format database!
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -12,9 +12,6 @@
<synopsis>
CREATE SCHEMA [ IF NOT EXISTS ] schema_name
[ AUTHORIZATION user_name ] [WITH BLOCKCHAIN] [ schema_element [ ... ] ];
CREATE SCHEMA schema_name
[ [ DEFAULT ] CHARACTER SET | CHARSET [ = ] charset ] [ [ DEFAULT ] COLLATE [ = ] collation ];
NOTICE: '[ [ DEFAULT ] CHARACTER SET | CHARSET [ = ] charset ] [ [ DEFAULT ] COLLATE [ = ] collation ]' is only available in CENTRALIZED mode and B-format database!
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -11,13 +11,11 @@
<refsynopsisdiv>
<synopsis>
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] table_name
( { column_name data_type [ CHARACTER SET | CHARSET charset ]
[ compress_mode ] [ COLLATE collation ] [ column_constraint [ ... ] ]
( { column_name data_type [ compress_mode ] [ COLLATE collation ] [ column_constraint [ ... ] ]
| table_constraint
| LIKE source_table [ like_option [...] ] }
[, ... ])
[ AUTO_INCREMENT [ = ] value ]
[ [ DEFAULT ] CHARACTER SET | CHARSET [ = ] charset ] [ [ DEFAULT ] COLLATE [ = ] collation ]
[ WITH ( {storage_parameter = value} [, ... ] ) ]
[ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
[ COMPRESS | NOCOMPRESS ]
@ -29,20 +27,19 @@ where column_constraint can be:
NULL |
CHECK ( expression ) |
DEFAULT default_expr |
GENERATED ALWAYS AS ( generation_expr ) [STORED] |
GENERATED ALWAYS AS ( generation_expr ) STORED |
AUTO_INCREMENT |
UNIQUE [KEY] index_parameters |
UNIQUE index_parameters |
PRIMARY KEY index_parameters |
ENCRYPTED WITH ( COLUMN_ENCRYPTION_KEY = column_encryption_key, ENCRYPTION_TYPE = encryption_type_value ) |
REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ]
[ ON DELETE action ] [ ON UPDATE action ] }
[ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!
where table_constraint can be:
[ CONSTRAINT [ constraint_name ] ]
{ CHECK ( expression ) |
UNIQUE [ index_name ] [ USING method ] ( { { column_name | ( expression ) } [ ASC | DESC ] } [, ... ] ) index_parameters [ VISIBLE | INVISIBLE ] |
PRIMARY KEY [ USING method ] ( { column_name [ ASC | DESC ] } [, ... ] ) index_parameters [ VISIBLE | INVISIBLE ] |
UNIQUE [ index_name ] [ USING method ] ( { { column_name | ( expression ) } [ ASC | DESC ] } [, ... ] ) index_parameters |
PRIMARY KEY [ USING method ] ( { column_name [ ASC | DESC ] } [, ... ] ) index_parameters |
PARTIAL CLUSTER KEY ( column_name [, ... ] ) |
FOREIGN KEY [ index_name ] ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ]
[ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON UPDATE action ] }
@ -69,14 +66,11 @@ where list_distribution_rules can be:
]
NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.
NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ USING method ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ ASC | DESC ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: '( expression )' in 'UNIQUE' clause of table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: 'AUTO_INCREMENT' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ CHARACTER SET | CHARSET ]' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ COLLATE [ = ] collation ]' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ VISIBLE | INVISIBLE ]' is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '[ index_name ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '[ USING method ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '[ ASC | DESC ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '( expression )' in 'UNIQUE' clause of table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: 'AUTO_INCREMENT' is only avaliable in CENTRALIZED mode and B-format database!
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -12,46 +12,38 @@
<synopsis>
CREATE TABLE [ IF NOT EXISTS ] partition_table_name
( [
{ column_name data_type [ CHARACTER SET | CHARSET charset ]
[ COLLATE collation ] [ column_constraint [ ... ] ]
{ column_name data_type [ COLLATE collation ] [ column_constraint [ ... ] ]
| table_constraint
| LIKE source_table [ like_option [...] ] }
[, ... ]
] )
[ AUTO_INCREMENT [ = ] value ]
[ [ DEFAULT ] CHARACTER SET | CHARSET [ = ] charset ][ [ DEFAULT ] COLLATE [ = ] collation ]
[ WITH ( {storage_parameter = value} [, ... ] ) ]
[ COMPRESS | NOCOMPRESS ]
[ TABLESPACE tablespace_name ]
[ DISTRIBUTE BY { REPLICATION | { [ HASH ] ( column_name ) } } ]
NOTICE: DISTRIBUTE BY is only avaliable in DISTRIBUTED mode!
[ TO { GROUP groupname | NODE ( nodename [, ... ] ) } ]
PARTITION BY {
{VALUES (partition_key)} |
{RANGE [ COLUMNS ] (partition_key) [ INTERVAL ('interval_expr') [ STORE IN ( tablespace_name [, ...] ) ] ] [ PARTITIONS integer ] ( partition_less_than_item [, ... ] )} |
{RANGE [ COLUMNS ] (partition_key) [ INTERVAL ('interval_expr') [ STORE IN ( tablespace_name [, ...] ) ] ] [ PARTITIONS integer ] ( partition_start_end_item [, ... ] )} |
{{{LIST [ COLUMNS ]} | HASH | KEY} (partition_key) [ PARTITIONS integer ] (PARTITION partition_name [ VALUES [ IN ] (list_values_clause) ] opt_table_space ) }
{RANGE (partition_key) [ INTERVAL ('interval_expr') [ STORE IN ( tablespace_name [, ...] ) ] ] ( partition_less_than_item [, ... ] )} |
{RANGE (partition_key) [ INTERVAL ('interval_expr') [ STORE IN ( tablespace_name [, ...] ) ] ] ( partition_start_end_item [, ... ] )} |
{LIST | HASH (partition_key) (PARTITION partition_name [ VALUES (list_values_clause) ] opt_table_space ) }
NOTICE: LIST/HASH partition is only avaliable in CENTRALIZED mode!
} [ { ENABLE | DISABLE } ROW MOVEMENT ];
NOTICE: [ COLUMNS ] is only available in B-format database!
NOTICE: [ PARTITIONS integer ] in RANGE/LIST partition is only available in B-format database!
NOTICE: [ IN ] is only available in B-format database!
NOTICE: KEY is only available in B-format database!
where column_constraint can be:
[ CONSTRAINT constraint_name ]
{ NOT NULL |
NULL |
CHECK ( expression ) |
DEFAULT default_expr |
GENERATED ALWAYS AS ( generation_expr ) [STORED] |
GENERATED ALWAYS AS ( generation_expr ) STORED |
AUTO_INCREMENT |
UNIQUE [KEY] index_parameters |
UNIQUE index_parameters |
PRIMARY KEY index_parameters |
REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ]
[ ON DELETE action ] [ ON UPDATE action ] }
[ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!
where table_constraint can be:
[ CONSTRAINT [ constraint_name ] ]
{ CHECK ( expression ) |
@ -66,8 +58,7 @@ where index_parameters can be:
where like_option can be:
{ INCLUDING | EXCLUDING } { DEFAULTS | GENERATED | CONSTRAINTS | INDEXES | STORAGE | COMMENTS | RELOPTIONS | DISTRIBUTION | ALL }
where partition_less_than_item can be:
PARTITION partition_name VALUES LESS THAN { ( { partition_value | MAXVALUE } [, ... ] ) | MAXVALUE } [TABLESPACE [=] tablespace_name]
NOTICE: MAXVALUE without parentheses is only available in B-format database!
PARTITION partition_name VALUES LESS THAN ( { partition_value | MAXVALUE } ) [TABLESPACE tablespace_name]
where partition_start_end_item can be:
PARTITION partition_name {
{START(partition_value) END (partition_value) EVERY (interval_value)} |
@ -77,12 +68,10 @@ PARTITION partition_name {
} [TABLESPACE tablespace_name]
NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.
NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ USING method ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ ASC | DESC ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: 'AUTO_INCREMENT' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ CHARACTER SET | CHARSET ]' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ COLLATE [ = ] collation ]' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ index_name ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '[ USING method ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '[ ASC | DESC ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: 'AUTO_INCREMENT' is only avaliable in CENTRALIZED mode and B-format database!
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -11,30 +11,23 @@
<refsynopsisdiv>
<synopsis>
CREATE TABLE [ IF NOT EXISTS ] subpartition_table_name
( { column_name data_type [ CHARACTER SET | CHARSET charset ]
[ COLLATE collation ] [ column_constraint [ ... ] ]
( { column_name data_type [ COLLATE collation ] [ column_constraint [ ... ] ]
| table_constraint
| LIKE source_table [ like_option [...] ] }
[, ... ]
)
[ AUTO_INCREMENT [ = ] value ]
[ [ DEFAULT ] CHARACTER SET | CHARSET [ = ] charset ][ [ DEFAULT ] COLLATE [ = ] collation ]
[ WITH ( {storage_parameter = value} [, ... ] ) ]
[ COMPRESS | NOCOMPRESS ]
[ TABLESPACE tablespace_name ]
PARTITION BY {RANGE [ COLUMNS ] | LIST [ COLUMNS ] | HASH | KEY} (partition_key) [ PARTITIONS integer ] SUBPARTITION BY {RANGE | LIST | HASH | KEY} (subpartition_key) [ SUBPARTITIONS integer ]
PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST | HASH} (subpartition_key)
(
PARTITION partition_name1 [ VALUES LESS THAN { (val1 | MAXVALUE) | MAXVALUE } | VALUES [ IN ] (val1[, ...]) ] [ TABLESPACE [=] tablespace ]
PARTITION partition_name1 [ VALUES LESS THAN (val1) | VALUES (val1[, ...]) ] [ TABLESPACE tablespace ]
(
{ SUBPARTITION subpartition_name1 [ VALUES LESS THAN (val1_1) | VALUES (val1_1[, ...])] [ TABLESPACE [=] tablespace ] } [, ...]
{ SUBPARTITION subpartition_name1 [ VALUES LESS THAN (val1_1) | VALUES (val1_1[, ...])] [ TABLESPACE tablespace ] } [, ...]
)
[, ...]
) [ { ENABLE | DISABLE } ROW MOVEMENT ];
NOTICE: [ COLUMNS ] is only available in B-format database!
NOTICE: [ PARTITIONS integer ] in RANGE/LIST partition is only available in B-format database!
NOTICE: [ IN ] is only available in B-format database!
NOTICE: KEY is only available in B-format database!
NOTICE: MAXVALUE without parentheses is only available in B-format database!
where column_constraint can be:
[ CONSTRAINT constraint_name ]
@ -42,14 +35,13 @@ where column_constraint can be:
NULL |
CHECK ( expression ) |
DEFAULT default_expr |
GENERATED ALWAYS AS ( generation_expr ) [STORED] |
GENERATED ALWAYS AS ( generation_expr ) STORED |
AUTO_INCREMENT |
UNIQUE [KEY] index_parameters |
UNIQUE index_parameters |
PRIMARY KEY index_parameters |
REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ]
[ ON DELETE action ] [ ON UPDATE action ] }
[ DEFERRABLE | NOT DEFERRABLE | INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
NOTICE: 'UNIQUE KEY' in table_constraint is only available in CENTRALIZED mode and B-format database!
where table_constraint can be:
[ CONSTRAINT [ constraint_name ] ]
{ CHECK ( expression ) |
@ -64,14 +56,12 @@ where index_parameters can be:
[ WITH ( {storage_parameter = value} [, ... ] ) ]
[ USING INDEX TABLESPACE tablespace_name ]
NOTICE: 'CREATE TABLE SUBPARTITION' is only available in CENTRALIZED mode!
NOTICE: 'CREATE TABLE SUBPARTITION' is only avaliable in CENTRALIZED mode!
NOTICE: '[ constraint_name ]' in table_constraint is optional in CENTRALIZED mode and B-format database, it is mandatory in other scenarios.
NOTICE: '[ index_name ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ USING method ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ ASC | DESC ]' in table_constraint is only available in CENTRALIZED mode and B-format database!
NOTICE: 'AUTO_INCREMENT' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ CHARACTER SET | CHARSET ]' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ COLLATE [ = ] collation ]' is only available in CENTRALIZED mode and B-format database!
NOTICE: '[ index_name ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '[ USING method ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: '[ ASC | DESC ]' in table_constraint is only avaliable in CENTRALIZED mode and B-format database!
NOTICE: 'AUTO_INCREMENT' is only avaliable in CENTRALIZED mode and B-format database!
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -1,20 +0,0 @@
<refentry id="SQL-DROPEVENTTRIGGER">
<refmeta>
<refentrytitle>DROP EVENT TRIGGER</refentrytitle>
<manvolnum>7</manvolnum>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>DROP EVENT TRIGGER</refname>
<refpurpose>remove an event trigger</refpurpose>
</refnamediv>
<refsynopsisdiv>
<indexterm zone="sql-dropeventtrigger">
<primary>DROP EVENT TRIGGER</primary>
</indexterm>
<refsynopsisdiv>
<synopsis>
DROP EVENT TRIGGER [ IF EXISTS ] name [ CASCADE | RESTRICT ]
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -13,7 +13,6 @@
[ WITH [ RECURSIVE ] with_query [, ...] ]
SELECT [/*+ plan_hint */] [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
{ * | {expression [ [ AS ] output_name ]} [, ...] }
[into_option]
[ FROM from_item [, ...] ]
[ WHERE condition ]
[ [ START WITH condition ] CONNECT BY condition [ ORDER SIBLINGS BY expression ] ]
@ -25,27 +24,9 @@ SELECT [/*+ plan_hint */] [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
[ LIMIT { [offset,] count | ALL } ]
[ OFFSET start [ ROW | ROWS ] ]
[ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ]
[into_option]
[ {FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF table_name [, ...] ] [ NOWAIT | WAIT N | SKIP LOCKED]} [...] ]
[into_option]
TABLE { ONLY { (table_name) | table_name } | table_name [ * ]};
where into_option can be:
INTO var_name [, var_name] ...
| INTO OUTFILE 'file_name'
[CHARACTER SET charset_name]
export_options
| INTO DUMPFILE 'file_name'
where export_options can be:
[FIELDS
[TERMINATED BY 'string']
[[OPTIONALLY] ENCLOSED BY 'char']
[ESCAPED BY 'char' ]
]
[LINES
[STARTING BY 'string']
[TERMINATED BY 'string']
]
where from_item can be:
[ ONLY ] table_name [ * ] [ partition_clause ] [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
[ TABLESAMPLE sampling_method ( argument [, ...] ) [ REPEATABLE ( seed ) ] ]
@ -69,7 +50,6 @@ PARTITION { ( partition_name ) | FOR ( partition_value [, ...] ) }
SUBPARTITION { ( subpartition_name ) | FOR ( subpartition_value [, ...] )}
where nlssort_expression_clause can be:
NLSSORT ( column_name, ' NLS_SORT = { SCHINESE_PINYIN_M | generic_m_ci } ' )
NOTICE: [into_option] is only available in CENTRALIZED mode and B-format database.
NOTICE: '[ [ START WITH condition ] CONNECT BY condition [ ORDER SIBLINGS BY expression ] ]' is only avaliable in CENTRALIZED mode!
NOTICE: 'SUBPARTITION { ( subpartition_name ) | FOR ( subpartition_value [, ...] )}' is only avaliable in CENTRALIZED mode!
</synopsis>

View File

@ -24,8 +24,6 @@ SET [ SESSION | @@SESSION. | @@]
{ {config_parameter = { expr | DEFAULT }}};
SET @var_name := expr [, @var_name := expr] ...
SET @var_name = expr [, @var_name = expr] ...
NOTICE: '@var_name' are only available in CENTRALIZED mode and B-format database.
NOTICE: '{ GLOBAL | @@GLOBAL.}' are only available in CENTRALIZED mode and B-format database.
NOTICE: '[ @@SESSION. | @@]' are only available in CENTRALIZED mode and B-format database.
NOTICE: '@var_name','{ GLOBAL | @@GLOBAL.}', '[ SESSION | @@SESSION. | @@]' are only avaiable in CENTRALIZED mode and B-format database, and enable_set_variable_b_format = on.
</synopsis>
</refsynopsisdiv>

View File

@ -10,12 +10,11 @@
</refnamediv>
<refsynopsisdiv>
<synopsis>
{SET [ LOCAL | SESSION | GLOBAL ] TRANSACTION|SET SESSION CHARACTERISTICS AS TRANSACTION}
{SET [ LOCAL ] TRANSACTION|SET SESSION CHARACTERISTICS AS TRANSACTION}
{ ISOLATION LEVEL { READ COMMITTED | READ UNCOMMITTED }
| { READ WRITE | READ ONLY | SERIALIZABLE | REPEATABLE READ }
} [, ...]
SET TRANSACTION SNAPSHOT snapshot_id;
NOTICE: SET GLOBAL TRANSACTION is only available in CENTRALIZED mode and B-format database!
</synopsis>
</refsynopsisdiv>
</refentry>

View File

@ -310,7 +310,7 @@ docker_temp_server_start() {
# internal start of server in order to allow setup using gsql client
# does not listen on external TCP/IP and waits until start finishes
set -- "$@" -c "listen_addresses='*'" -p "${PGPORT:-5432}"
set -- "$@" -c listen_addresses='' -p "${PGPORT:-5432}"
PGUSER="${PGUSER:-$GS_USER}" \
gs_ctl -D "$PGDATA" \

View File

@ -1,31 +0,0 @@
容器化升级操作指南
前置条件:
旧版本容器集群状态正常
容器化升级操作步骤:
1. 准备升级工具、新版本容器和包
(1) 新版本容器镜像需载入到环境
(2) 将升级工具和新版本包放入升级路径
相关路径说明:
GAUSSDATA数据库数据目录默认为/var/lib/opengauss/data升级工具中可以通过-D指定
GAUSS_UPGRADE_BASE_PATH升级根路径默认为$GAUSSDATA/upgrade升级工具中可以通过-B指定
UPGRADE_NEW_PKG_PATH新包路径默认为$GAUSS_UPGRADE_BASE_PATH/pkg_new升级工具中可以通过-N指定
新版本包中必须包含version.cfg、upgrade_sql.tar.gz和upgrade_sql.sha256
2. 在**所有旧版本主备机容器**中执行前置升级动作
sh upgrade.sh -t upgrade_pre
3. 停掉所有旧版本库
4. 启动所有新版本库并在所有新版本主备机容器中执行upgrade_bin、upgrade_post和upgrade_commit动作
sh upgrade.sh -t upgrade_bin
sh upgrade.sh -t upgrade_post
sh upgrade.sh -t upgrade_commit
回退操作步骤:
case 1: 已切换到新二进制
sh upgrade.sh -t rollback_post (已执行upgrade_post动作)
sh upgrade.sh -t rollback_bin (已执行upgrade_bin动作)
退出新版本容器
case 2: 仅执行了upgrade_pre动作
sh upgrade.sh -t rollback_pre
**注意:**
如果升级路径和新包路径自行规划,则需要在新旧容器中做着两个路径的卷映射

View File

@ -1,61 +0,0 @@
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2010-2022. All rights reserved.
# date: 2021-12-22
# version: 1.0
CURRENT_DIR=$(
cd $(dirname $0)
pwd
)
source ${CURRENT_DIR}/upgrade_common.sh
function main() {
parse_cmd_line $@
init_config
check_and_init
case "${action}" in
upgrade_pre)
upgrade_pre
exit 0
;;
upgrade_bin)
upgrade_bin
exit 0
;;
upgrade_post)
upgrade_post
exit 0
;;
rollback_pre)
rollback_pre
exit 0
;;
rollback_bin)
rollback_bin
exit 0
;;
rollback_post)
rollback_post
exit 0
;;
upgrade_commit)
upgrade_commit
exit 0
;;
query_start_mode)
query_start_mode
exit 0
;;
switch_over)
switch_over
exit 0
;;
*)
log "please input right parameter, the following command may help you"
log "sh upgrade_GAUSSV5.sh --help or sh upgrade_GAUSSV5.sh -h"
die "Must input parameter -t action" ${err_parameter}
;;
esac
}
main $@

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +0,0 @@
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2010-2022. All rights reserved.
# date: 2021-12-22
# version: 1.0
err_upgrade_pre=201
err_upgrade_bin=202
err_upgrade_post=203
err_rollback_pre=204
err_rollback_bin=205
err_rollback_post=206
err_check_init=207
err_parameter=208
err_upgrade_commit=209
err_version_same=210
err_no_need_commit=211
err_inner_sys=212
err_dn_role_null=213

@ -1 +0,0 @@
Subproject commit f2a09ee9e98b3c0ed1ec26da6f1c3ddacece41b1

@ -1 +0,0 @@
Subproject commit ba09836e0bb59243426a28b79c260570ec87e78e

@ -1 +0,0 @@
Subproject commit 5c3a84bd0c656ef7529a8fcd806e07f24560b415

@ -1 +0,0 @@
Subproject commit 22959853b32c2653c6dc663fb236329680847ed6

@ -1 +0,0 @@
Subproject commit 26e5d6310154258393807b95336c04b2eda991ce

@ -1 +0,0 @@
Subproject commit a8f2377a242dbdb6a8366738c85d365bef478477

@ -1 +0,0 @@
Subproject commit d037643b5dfb030eb8b0da4ecb22b0bd6a51a8b1

@ -1 +0,0 @@
Subproject commit f7a9a3b2e2c28a4f045a857debcaea372273826d

View File

@ -88,19 +88,11 @@ function check_install_env() {
fi
# check pid port and lock file
portlist=($(netstat -nutl | grep $port))
i=3
while ((i < ${#portlist[*]}))
do
listen_addr=${portlist[((i))]}
p=${listen_addr##*:}
echo $p
if [ X"$p" == X"$port" ]; then
error "Error: The port $port has been occupied, please use -p to set a new port."
exit 1
fi
((i += 6))
done
port_occupied=$(netstat -ntul | grep $port)
if [ X"$port_occupied" != X"" ]; then
error "Error: The port $port has been occupied, please use -p to set a new port."
exit 1
fi
local delete_slave_lock=""
local delete_master_lock=""

1
src/.gitignore vendored
View File

@ -86,6 +86,7 @@
/common/backend/utils/misc/guc-file.cpp
/common/backend/utils/pg_builtin_proc.h
/common/backend/utils/probes.h
/common/backend/utils/sort/qsort_tuple.cpp
/common/interfaces/ecpg/compatlib/exports.list
/common/interfaces/ecpg/ecpglib/exports.list
/common/interfaces/ecpg/ecpglib/path.cpp

View File

@ -193,7 +193,7 @@ endif()
if("${ENABLE_MULTIPLE_NODES}" STREQUAL "OFF")
install(DIRECTORY ${DCF_LIB_PATH} DESTINATION .)
endif()
if(${ENABLE_MULTIPLE_NODES}_${ENABLE_PRIVATEGAUSS} STREQUAL OFF_OFF AND NOT ${ENABLE_LITE_MODE} STREQUAL ON)
if(${ENABLE_MULTIPLE_NODES}_${ENABLE_PRIVATEGAUSS} STREQUAL OFF_OFF)
if(EXISTS ${DMS_LIB_PATH})
install(DIRECTORY ${DMS_LIB_PATH} DESTINATION .)
endif()

View File

@ -211,7 +211,6 @@ TCL_SHLIB_LD_LIBS = @TCL_SHLIB_LD_LIBS@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
with_openeuler_os = @with_openeuler_os@
with_openeuler_major = @with_openeuler_major@
#############################################################################
@ -729,11 +728,6 @@ endif
ifeq ($(with_openeuler_os), yes)
override CPPFLAGS := $(CPPFLAGS) -DWITH_OPENEULER_OS
endif
ifeq ($(with_openeuler_major), yes)
override CPPFLAGS := $(CPPFLAGS) -DOPENEULER_MAJOR
endif
CC = @CC@
GCC = @GCC@
C = gcc

View File

@ -69,11 +69,3 @@ endif
$(recurse)
$(recurse_always)
# psql and pg_dump need to make subtarget: libpq-ce, if these two targets make parallel, it
# may cause frontend_parser/gram.o: file not recognized: file truncated.
# I'm not sure why this happen, and since we use $(recurse) to make install and make all.
# I have no idea how to forbide psql and pg_dump to make parallel.
# So try to use NOTPARALLEL to avoid make parallel in this makefile. This will forbide all
# SUBDIRS make in parallel, which will decrease the compile speed...
.NOTPARALLEL:

View File

@ -58,13 +58,10 @@ audit_resource_policy|bool|0,0|NULL|NULL|
audit_rotation_interval|int|1,35791394|min|NULL|
audit_rotation_size|int|1024,1048576|kB|NULL|
audit_space_limit|int|1024,1073741824|kB|NULL|
audit_system_object|int|0,268435455|NULL|NULL|
audit_system_object|int|0,134217727|NULL|NULL|
audit_user_locked|int|0,1|NULL|NULL|
audit_user_violation|int|0,1|NULL|NULL|
audit_set_parameter|int|0,1|NULL|NULL|
no_audit_client|string|0,0|NULL|NULL|
full_audit_users|string|0,0|NULL|NULL|
audit_system_function_exec|int|0,1|NULL|NULL|
authentication_timeout|int|1,600|s|NULL|
autoanalyze|bool|0,0|NULL|NULL|
autovacuum|bool|0,0|NULL|Even if this parameter is set to off, when a transaction ID wraparound imminent, the database will automatically start the cleanup process automatically.|
@ -85,7 +82,6 @@ backslash_quote|enum|safe_encoding,on,off,true,false,yes,no,1,0|NULL|NULL|
backtrace_min_messages|enum|debug,debug5,debug4,debug3,debug2,debug1,log,info,notice,warning,error,fatal,panic|NULL|It will increase the cost of the system, when print the function stack information frequently. Therefore, when analyzing the problem, avoid setting the value of backtrace_min_messages for fatal following levels.|
bbox_dump_count|int|1,20|NULL|NULL|
bbox_dump_path|string|0,0|NULL|NULL|
b_format_behavior_compat_options|string|0,0|NULL|NULL|
behavior_compat_options|string|0,0|NULL|NULL|
plsql_compile_check_options|string|0,0|NULL|NULL|
bgwriter_delay|int|10,10000|ms|NULL|
@ -157,7 +153,6 @@ instr_unique_sql_count|int|0,2147483647|NULL|NULL|
track_stmt_session_slot|int|0,2147483647|NULL|NULL|
track_stmt_details_size|int64|0,100000000|NULL|NULL|
track_stmt_stat_level|string|0,0|NULL|NULL|
enable_availablezone|bool|0,0|NULL|NULL|
enable_instr_cpu_timer|bool|0,0|NULL|NULL|
enable_instr_rt_percentile|bool|0,0|NULL|NULL|
enable_instr_track_wait|bool|0,0|NULL|NULL|
@ -175,7 +170,6 @@ enable_codegen_print|bool|0,0|NULL|Enable dump for llvm function|
enable_delta_store|bool|0,0|NULL|NULL|
enable_default_cfunc_libpath|bool|0,0|NULL|NULL|
enable_defer_calculate_snapshot|bool|0,0|NULL|NULL|
enable_expr_fusion|bool|0,0|NULL|NULL|
codegen_cost_threshold|int|0,2147483647|NULL|Decided to use LLVM optimization or not|
codegen_strategy|enum|partial,pure|NULL|NULL|
enable_compress_spill|bool|0,0|NULL|NULL|
@ -200,7 +194,6 @@ enable_hdfs_predicate_pushdown|bool|0,0|NULL|NULL|
enable_hypo_index|bool|0,0|NULL|NULL|
enable_indexonlyscan|bool|0,0|NULL|NULL|
enable_indexscan|bool|0,0|NULL|NULL|
enable_inner_unique_opt|bool|0,0|NULL|NULL|
enable_kill_query|bool|0,0|NULL|NULL|
enable_material|bool|0,0|NULL|NULL|
enable_memory_limit|bool|0,0|NULL|NULL|
@ -445,7 +438,7 @@ ha_module_debug|bool|0,0|NULL|NULL|
require_ssl|bool|0,0|NULL|NULL|
resource_track_log|enum|summary,detail|NULL|NULL|
restart_after_crash|bool|0,0|NULL|NULL|
rewrite_rule|enum|lazyagg,magicset,partialpush,uniquecheck,disablerep,intargetlist,predpush,predpushforce,predpushnormal,disable_pullup_expr_sublink,enable_sublink_pullup_enhanced,none|NULL|NULL|
rewrite_rule|enum|lazyagg,magicset,partialpush,uniquecheck,disablerep,intargetlist,predpush,predpushforce,predpushnormal,disable_pullup_expr_sublink,none|NULL|NULL|
safe_data_path|string|0,0|NULL|NULL|
search_path|string|0,0|NULL|NULL|
session_replication_role|enum|origin,replica,local|NULL|When this parameter is set, any cached query plan will be lost before.|
@ -679,7 +672,6 @@ sql_beta_feature|enum|partition_fdw_on,partition_opfusion,index_cost_with_leaf_p
partition_iterator_elimination|bool|0,0|NULL|NULL|
enable_functional_dependency|bool|0,0|NULL|NULL|
enable_seqscan_fusion|bool|0,0|NULL|NULL|
enable_indexscan_optimization|bool|0,0|NULL|NULL|
max_logical_replication_workers|int|0,262143|NULL|Maximum number of logical replication worker processes.|
max_sync_workers_per_subscription|int|0,262143|NULL|Maximum number of table synchronization workers per subscription.|
walwriter_sleep_threshold|int64|1,50000|NULL|NULL|
@ -713,14 +705,12 @@ ss_enable_dms|bool|0,0|NULL|NULL|
ss_enable_catalog_centralized|bool|0,0|NULL|NULL|
ss_enable_reform|bool|0,0|NULL|NULL|
ss_enable_ssl|bool|0,0|NULL|NULL|
ss_enable_log_level|bool|0,0|NULL|NULL|
ss_enable_aio|bool|0,0|NULL|NULL|
ss_interconnect_channel_count|int|1,32|NULL|NULL|
ss_work_thread_count|int|16,128|NULL|NULL|
ss_recv_msg_pool_size|int|1024,1048576|kB|NULL|
ss_interconnect_type|string|0,0|NULL|NULL|
ss_log_level|int|0,887|NULL|NULL|
ss_log_backup_file_count|int|0,1024|NULL|NULL|
ss_log_max_file_size|int|1024,4194304|kB|NULL|
ss_instance_id|int|0,63|NULL|NULL|
ss_interconnect_url|string|0,0|NULL|NULL|
ss_rdma_work_config|string|0,0|NULL|NULL|
@ -733,8 +723,6 @@ ss_scrlock_worker_bind_core|string|0,0|NULL|NULL|
ss_scrlock_server_bind_core|string|0,0|NULL|NULL|
dolphin_server_port|int|1024,65535|NULL|NULL|
enable_dolphin_proto|bool|0,0|NULL|NULL|
enable_remote_excute|bool|0,0|NULL|NULL|
light_comm|bool|0,0|NULL|NULL|
[cmserver]
log_dir|string|0,0|NULL|NULL|
log_file_size|int|0,2047|MB|NULL|

View File

@ -1093,63 +1093,6 @@ int validate_node_instance_name(char* nodename, int type, char* instance_name)
return 0;
}
#ifndef ENABLE_MULTIPLE_NODES
/*
******************************************************************************
Function : gsguc_precheck_forbid_parameters
Description : Forbid reload/set/check GUC parameters in list for ALL node type
Input : nodename(indicates node name)
Output : none
Return : bool
******************************************************************************
*/
/* Forbid parameters for method "reload" with "all" nodes */
char *gsguc_forbid_list_reload[] = {
"listen_addresses",
NULL
};
bool gsguc_precheck_forbid_parameters(char *nodename)
{
/* If set pg_hba, just pass */
if (is_hba_conf) {
return true;
}
switch (ctl_command) {
case SET_CONF_COMMAND:
/* process checking parameters for SET mode */
break;
case RELOAD_CONF_COMMAND:
/* process checking parameters for RELOAD mode */
if (strncmp(nodename, "all", strlen("all")) != 0) {
break;
}
/* parameters not support '-N all' */
for (int i = 0; i < config_param_number && config_param[i] != NULL; i++) {
for (int j = 0; gsguc_forbid_list_reload[j] != NULL; j++) {
if (strcmp(config_param[i], gsguc_forbid_list_reload[j]) == 0) {
write_stderr(_("ERROR: \"%s\" can not \"%s\" with \"%s\" method.\n"),
gsguc_forbid_list_reload[j],
get_ctl_command_type(),
nodename);
return false;
}
}
}
break;
case CHECK_CONF_COMMAND:
/* process checking parameters for CHECK mode */
break;
default:
break;
}
return true;
}
#endif
/*
******************************************************************************
Function : validate_cluster_guc_options
@ -1428,16 +1371,10 @@ void process_cluster_guc_option(char* nodename, int type, char* instance_name, c
}
else
{
if (0 == strncmp(nodename, "all", strlen("all"))) {
#ifndef ENABLE_MULTIPLE_NODES
if (!gsguc_precheck_forbid_parameters(nodename)) {
exit(1);
}
#endif
if (0 == strncmp(nodename, "all", sizeof("all")))
do_all_nodes_instance(instance_name, indatadir);
} else {
else
do_remote_instance(nodename, instance_name, indatadir);
}
}
}

View File

@ -2634,8 +2634,6 @@ int main(int argc, char** argv)
char* pgdata_C = NULL;
char* nodename = NULL;
char* instance_name = NULL;
int nodeNum = 0;
int instanceNum = 0;
int nRet = 0;
errno_t rc = 0;
progname = PROG_NAME;
@ -2755,13 +2753,11 @@ int main(int argc, char** argv)
case 'N': {
GS_FREE(nodename);
nodename = xstrdup(optarg);
nodeNum++;
break;
}
case 'I': {
GS_FREE(instance_name);
instance_name = xstrdup(optarg);
instanceNum++;
break;
}
case 'M': {
@ -2913,11 +2909,6 @@ int main(int argc, char** argv)
return 0;
}
if (nodeNum > 1 || instanceNum > 1) {
write_stderr(_("ERROR: The number of -I or -N must less than 2.\n"));
exit(1);
}
if (false == allocate_memory_list()) {
write_stderr(_("ERROR: Failed to allocate memory to list.\n"));
exit(1);

View File

@ -584,15 +584,6 @@ function check_param_exists()
unique_params[$param_name]="true"
}
function isValidPort()
{
string=$1
if [[ ! $string =~ ^[0-9]+$ ]]; then
echo "ERROR: '"$string"' is not a valid port number"
exit 1
fi
}
function parse_cmd_params()
{
while [[ $# -gt 0 ]]; do
@ -612,14 +603,12 @@ function parse_cmd_params()
port=*)
check_param_exists "port"
cmd_param_port=$(get_value $1)
isValidPort $cmd_param_port
shift # past value
;;
-p)
check_param_exists "port"
shift
cmd_param_port=$1
isValidPort $cmd_param_port
shift
;;
user=*)

View File

@ -88,7 +88,7 @@ function logo()
echo " | | | | (_| | | | | ____) | | | | | | | |_| | | (_| | || (_) | | "
echo " |_| |_|\__,_|_| |_| |_____/|_|_| |_| |_|\__,_|_|\__,_|\__|___/|_| "
echo " "
echo " Version 5.0.0"
echo " Version 3.1.0"
echo "--------------------------------------------------------------------------"
}

View File

@ -207,6 +207,7 @@ static char* snapshot_names[] = { "schema", "create", "prepare", "sample", "publ
static char* snapshot_files[SNAPSHOT_LEN];
static bool enableDCF = false;
#endif
static bool enableGLT = false;
static bool made_new_pgdata = false;
static bool found_existing_pgdata = false;
static bool made_new_xlogdir = false;
@ -1594,6 +1595,12 @@ static void setup_config(void)
conflines = ss_addnodeparmater(conflines);
}
if (enableGLT) {
nRet = strcpy_s(repltok, sizeof(repltok), "enable_glt = on");
securec_check_ss_c(nRet, "\0", "\0");
conflines = replace_token(conflines, "#enable_glt = off", repltok);
}
nRet = sprintf_s(path, sizeof(path), "%s/postgresql.conf", pg_data);
securec_check_ss_c(nRet, "\0", "\0");
@ -3797,9 +3804,7 @@ static void usage(const char* prog_name)
#ifndef ENABLE_MULTIPLE_NODES
printf(_(" -c, --enable-dcf enable DCF mode\n"));
#endif
#ifndef ENABLE_LITE_MODE
printf(_(" --enable-dss enable shared storage mode\n"));
#endif
printf(_(" [-D, --pgdata=]DATADIR location for this database cluster\n"));
#ifdef ENABLE_MULTIPLE_NODES
printf(_(" --nodename=NODENAME name of openGauss node initialized\n"));
@ -3807,12 +3812,9 @@ static void usage(const char* prog_name)
#else
printf(_(" --nodename=NODENAME name of single node initialized\n"));
#endif
#ifndef ENABLE_LITE_MODE
printf(_(" --vgname=VGNAME name of dss volume group\n"));
printf(_(" --socketpath=SOCKETPATH\n"
" dss connect socket file path\n"));
printf(_(" --dms_url=URL message communication url between nodes\n"));
#endif
printf(_(" -E, --encoding=ENCODING set default encoding for new databases\n"));
printf(_(" --locale=LOCALE set default locale for new databases\n"));
printf(_(" --dbcompatibility=DBCOMPATIBILITY set default dbcompatibility for new database\n"));
@ -3896,7 +3898,6 @@ static bool is_file_exist(const char* path)
return isExist;
}
#ifndef ENABLE_LITE_MODE
static void parse_vgname_args(char* args)
{
vgname = xstrdup(args);
@ -3926,7 +3927,6 @@ static void parse_vgname_args(char* args)
exit(1);
}
}
#endif
int main(int argc, char* argv[])
{
@ -3976,6 +3976,7 @@ int main(int argc, char* argv[])
{"socketpath", required_argument, NULL, 16},
{"enable-dss", no_argument, NULL, 17},
{"dms_url", required_argument, NULL, 18},
{"enable-glt", no_argument, NULL, 19},
{NULL, 0, NULL, 0}};
int c, i, ret;
@ -4205,7 +4206,7 @@ int main(int argc, char* argv[])
break;
case 8:
FREE_NOT_STATIC_ZERO_STRING(locale);
locale = xstrdup("C");
locale = "C";
break;
case 9:
FREE_NOT_STATIC_ZERO_STRING(pwfilename);
@ -4262,7 +4263,6 @@ int main(int argc, char* argv[])
}
g_bucket_len = atoi(optarg);
break;
#ifndef ENABLE_LITE_MODE
case 15:
FREE_NOT_STATIC_ZERO_STRING(vgname);
FREE_NOT_STATIC_ZERO_STRING(vgdata);
@ -4282,7 +4282,10 @@ int main(int argc, char* argv[])
check_input_spec_char(optarg);
ss_nodedatainfo = xstrdup(optarg);
break;
#endif
case 19:
enableGLT = true;
break;
default:
/* getopt_long already emitted a complaint */
write_stderr(_("Try \"%s --help\" for more information.\n"), progname);

View File

@ -153,17 +153,6 @@ static void TablespaceValueCheck(TablespaceListCell* cell, const char* arg)
}
}
static void isPortNumber(const char *portarg)
{
int len = strlen(portarg);
for (int i = 0; i < len; i++) {
if (!(portarg[i] >= '0' && portarg[i] <= '9')) {
fprintf(stderr, _("invalid port number \"%s\"\n"), portarg);
exit(1);
}
}
}
/*
* Split argument into old_dir and new_dir and append to tablespace mapping
* list.
@ -279,8 +268,6 @@ static void GsTarUsage(void)
printf(_("\nOptions controlling the output:\n"));
printf(_(" -D, --destination=DIRECTORY untar files into directory\n"));
printf(_(" -F, --filename=FILENAME filename to be untar\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" -?, --help show this help, then exit\n"));
}
static void tablespace_list_create()
@ -1154,6 +1141,8 @@ static void BaseBackup(void)
/* Error message already written in GetConnection() */
exit(1);
ClearAndFreePasswd();
/*
* Run IDENTIFY_SYSTEM so we can get the timeline
*/
@ -1333,7 +1322,6 @@ static void BaseBackup(void)
StartLogStreamer((const char *)xlogstart, timeline, sysidentifier);
}
ClearAndFreePasswd();
/* free sysidentifier after use */
PQfreemem(sysidentifier);
sysidentifier = NULL;
@ -1584,7 +1572,7 @@ static void GsTarHelp(int argc, char** argv) {
GsTarUsage();
exit(0);
} else if (strcmp(argv[1], "-V") == 0 || strcmp(argv[1], "--version") == 0) {
puts("gs_tar " DEF_GS_VERSION);
puts("gs_basebackup " DEF_GS_VERSION);
exit(0);
}
}
@ -1935,46 +1923,6 @@ static int GsBaseBackup(int argc, char** argv)
}
}
char optstring[] = "D:l:c:h:p:U:s:X:F:T:Z:t:wWvPxz";
/* check if a required_argument option has a void argument */
int i;
for (i = 0; i < argc; i++) {
char *optstr = argv[i];
int is_only_shortbar;
if (strlen(optstr) == 1) {
is_only_shortbar = optstr[0] == '-' ? 1 : 0;
} else {
is_only_shortbar = 0;
}
if (is_only_shortbar) {
fprintf(stderr, _("%s: The option '-' is not a valid option.\n"), progname);
exit(1);
}
char *oli = strchr(optstring, optstr[1]);
int is_shortopt_with_space;
if (oli != NULL && strlen(optstr) >= 1 && strlen(oli) >= 2) {
is_shortopt_with_space =
optstr[0] == '-' && oli != NULL && oli[1] == ':' && oli[2] != ':' && optstr[2] == '\0';
} else {
is_shortopt_with_space = 0;
}
if (is_shortopt_with_space) {
if (i == argc - 1) {
fprintf(stderr, _("%s: The option '-%c' need a parameter.\n"), progname, optstr[1]);
exit(1);
}
char *next_optstr = argv[i + 1];
char *next_oli = strchr(optstring, next_optstr[1]);
int is_arg_optionform = next_optstr[0] == '-' && next_oli != NULL;
if (is_arg_optionform) {
fprintf(stderr, _("%s: The option '-%c' need a parameter.\n"), progname, optstr[1]);
exit(1);
}
}
}
while ((c = getopt_long(argc, argv, "D:l:c:h:p:U:s:X:F:T:Z:t:wWvPxz", long_options, &option_index)) != -1) {
switch (c) {
case 'D': {
@ -2069,7 +2017,6 @@ static int GsBaseBackup(int argc, char** argv)
case 'p':
GS_FREE(dbport);
check_env_value_c(optarg);
isPortNumber(optarg);
dbport = inc_dbport(optarg);
break;
case 'U':
@ -2113,7 +2060,7 @@ static int GsBaseBackup(int argc, char** argv)
break;
}
}
/* If port is not specified by using -p, obtain the port through environment variables */
if (dbport == NULL) {
char *value = NULL;
@ -2124,7 +2071,6 @@ static int GsBaseBackup(int argc, char** argv)
} else {
fprintf(stderr, _("%s:The specified port is missing, it can be specified by -p parameter "
"or import environment variables PGPORT.\n"), progname);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
}
}

View File

@ -494,12 +494,12 @@ static int DoWALWrite(const char* wal_buf, int len, XLogRecPtr& block_pos, const
suspendHeartBeatTimer();
return DO_WAL_DATA_WRITE_ERROR;
}
/* Write was successful, advance our position */
bytes_written += bytes_to_write;
bytes_left -= bytes_to_write;
XLByteAdvance(block_pos, bytes_to_write);
xlogoff += bytes_to_write;
lastFlushPosition = block_pos;
/* Did we reach the end of a WAL segment? */
if (block_pos % XLogSegSize == 0) {
@ -586,12 +586,14 @@ bool ReceiveXlogStream(PGconn* conn, XLogRecPtr startpos, uint32 timeline, const
* so that the master can remove WAL.
*/
reportFlushPosition = true;
ss_c = snprintf_s(slotcmd, MAXPGPATH, MAXPGPATH - 1, "SLOT \"%s\" ", replication_slot);
securec_check_ss_c(ss_c, "", "");
} else {
reportFlushPosition = false;
slotcmd[0] = 0;
}
reportFlushPosition = true;
if (sysidentifier != NULL) {
/* Validate system identifier and timeline hasn't changed */
res = PQexec(conn, "IDENTIFY_SYSTEM");

View File

@ -297,7 +297,7 @@ static void show_version(int alls)
if (alls) {
printf("OPENGAUSS_VERSION = ");
}
printf("openGauss 5.0.0\n");
printf("openGauss 3.1.0\n");
#endif
}

Some files were not shown because too many files have changed in this diff Show More