From 5b5e66910b232b03212cdee52fc911e6f71e20b6 Mon Sep 17 00:00:00 2001 From: chenxiaobin19 <1025221611@qq.com> Date: Fri, 24 Feb 2023 19:37:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E8=AE=A2=E9=98=85=E8=87=AA?= =?UTF-8?q?=E6=B5=8B=E7=94=A8=E4=BE=8B=E5=A2=9E=E5=8A=A0database=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=80=A7=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/init/postinit.cpp | 2 ++ src/test/subscription/CMakeLists.txt | 2 +- src/test/subscription/GNUmakefile | 3 +- src/test/subscription/env_utils.sh | 1 + src/test/subscription/pubsub.py | 15 ++++---- src/test/subscription/run_check.sh | 2 +- src/test/subscription/testcase/binary.sh | 34 +++++++++---------- src/test/subscription/testcase/rep_changes.sh | 22 ++++++------ 8 files changed, 43 insertions(+), 38 deletions(-) diff --git a/src/common/backend/utils/init/postinit.cpp b/src/common/backend/utils/init/postinit.cpp index 2aa948f13..5814706eb 100644 --- a/src/common/backend/utils/init/postinit.cpp +++ b/src/common/backend/utils/init/postinit.cpp @@ -1569,6 +1569,8 @@ void PostgresInitializer::InitApplyWorker() InitSettings(); + InitExtensionVariable(); + FinishInit(); return; diff --git a/src/test/subscription/CMakeLists.txt b/src/test/subscription/CMakeLists.txt index 6a76ae1d0..50209f2b6 100644 --- a/src/test/subscription/CMakeLists.txt +++ b/src/test/subscription/CMakeLists.txt @@ -1 +1 @@ -add_custom_target(check COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/run_check.sh ${CMAKE_CURRENT_SOURCE_DIR} \$\(p\)) \ No newline at end of file +add_custom_target(check COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/run_check.sh ${CMAKE_CURRENT_SOURCE_DIR} \$\(p\) \$\(dbcompatibility\)) \ No newline at end of file diff --git a/src/test/subscription/GNUmakefile b/src/test/subscription/GNUmakefile index 4defbdf70..c94f66e98 100644 --- a/src/test/subscription/GNUmakefile +++ b/src/test/subscription/GNUmakefile @@ -17,6 +17,7 @@ include $(top_builddir)/src/Makefile.global # where to find psql for testing an existing installation PSQLDIR = $(bindir) p=25800 +dbcompatibility=A ## ## Run tests ## @@ -25,7 +26,7 @@ REGRESS_OPTS = --dlpath=. $(EXTRA_REGRESS_OPTS) REG_CONF = --regconf=regress.conf check: all - sh $(CURDIR)/run_check.sh $(CURDIR) $p + sh $(CURDIR)/run_check.sh $(CURDIR) $p $(dbcompatibility) ## ## Clean up diff --git a/src/test/subscription/env_utils.sh b/src/test/subscription/env_utils.sh index b29bc8479..356cbc3e1 100644 --- a/src/test/subscription/env_utils.sh +++ b/src/test/subscription/env_utils.sh @@ -8,6 +8,7 @@ export GAUSSHOME="$prefix" export LD_LIBRARY_PATH=$prefix/lib:$prefix/lib/libobs:$LD_LIBRARY_PATH export PATH="$prefix/bin":$PATH export g_local_ip="127.0.0.1" +export dbcompatibility=$3 db=postgres scripts_dir="$1" diff --git a/src/test/subscription/pubsub.py b/src/test/subscription/pubsub.py index 19d35fffa..37e290354 100644 --- a/src/test/subscription/pubsub.py +++ b/src/test/subscription/pubsub.py @@ -11,12 +11,13 @@ install_path = os.environ.get("install_path") g_local_ip = os.environ.get("g_local_ip") g_username = os.environ.get("g_username") g_passwd = "Gauss@123" -pub_node1_port = int(os.environ.get("pub_node1_port")); -pub_node2_port = int(os.environ.get("pub_node2_port")); -pub_node3_port = int(os.environ.get("pub_node3_port")); -sub_node1_port = int(os.environ.get("sub_node1_port")); -sub_node2_port = int(os.environ.get("sub_node2_port")); -sub_node3_port = int(os.environ.get("sub_node3_port")); +dbcompatibility = os.environ.get("dbcompatibility") +pub_node1_port = int(os.environ.get("pub_node1_port")) +pub_node2_port = int(os.environ.get("pub_node2_port")) +pub_node3_port = int(os.environ.get("pub_node3_port")) +sub_node1_port = int(os.environ.get("sub_node1_port")) +sub_node2_port = int(os.environ.get("sub_node2_port")) +sub_node3_port = int(os.environ.get("sub_node3_port")) class Pterodb(): @@ -30,7 +31,7 @@ class Pterodb(): self.heartbeat_port_arr = [port_arr[i] + 2 for i in range(data_node_num)] def real_init_env(self, i): - datanode_cmd_init = install_path + "/bin/gs_initdb -D " + self.data_dir + "/" + self.dname_prefix + str(i) + " --nodename=" + self.dname_prefix + str(i) + " -w " + g_passwd + datanode_cmd_init = install_path + "/bin/gs_initdb -D " + self.data_dir + "/" + self.dname_prefix + str(i) + " --nodename=" + self.dname_prefix + str(i) + " -w " + g_passwd + " --dbcompatibility=" + dbcompatibility print datanode_cmd_init os.system(datanode_cmd_init) diff --git a/src/test/subscription/run_check.sh b/src/test/subscription/run_check.sh index d6d7f1d7c..60c50d75d 100644 --- a/src/test/subscription/run_check.sh +++ b/src/test/subscription/run_check.sh @@ -1,7 +1,7 @@ #!/bin/sh count=0 -source $1/env_utils.sh $1 $2 +source $1/env_utils.sh $1 $2 $3 #clean temporary files generated after last check echo "removing $g_data_path" diff --git a/src/test/subscription/testcase/binary.sh b/src/test/subscription/testcase/binary.sh index 7835c32ca..e09329ba7 100644 --- a/src/test/subscription/testcase/binary.sh +++ b/src/test/subscription/testcase/binary.sh @@ -13,13 +13,13 @@ function test_1() { # Create tables on both sides of the replication ddl="CREATE TABLE public.test_numerical ( a INTEGER PRIMARY KEY, - b NUMERIC, + b NUMERIC(10,2), c FLOAT, d BIGINT ); CREATE TABLE public.test_arrays ( a INTEGER[] PRIMARY KEY, - b NUMERIC[], + b NUMERIC(10,2)[], c TEXT[] )" @@ -48,9 +48,9 @@ function test_1() { wait_for_catchup $case_db $pub_node1_port "tsub" - if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, b, c, d FROM test_numerical ORDER BY a")" = "1|1.2|1.3|10 -2|2.2|2.3|20 -3|3.2|3.3|30" ]; then + if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, b, c, d FROM test_numerical ORDER BY a")" = "1|1.20|1.3|10 +2|2.20|2.3|20 +3|3.20|3.3|30" ]; then echo "check replicated data on subscriber success" else echo "$failed_keyword when check replicated data on subscriber" @@ -63,17 +63,17 @@ function test_1() { wait_for_catchup $case_db $pub_node1_port "tsub" - if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, b, c FROM test_arrays ORDER BY a")" = "{1,2,3}|{42,1.2,1.3}| -{3,1,2}|{42,1.1,1.2}|" ]; then + if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, b, c FROM test_arrays ORDER BY a")" = "{1,2,3}|{42.00,1.20,1.30}| +{3,1,2}|{42.00,1.10,1.20}|" ]; then echo "check updated replicated data on subscriber success" else echo "$failed_keyword when check updated replicated data on subscriber" exit 1 fi - if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, b, c, d FROM test_numerical ORDER BY a")" = "1|42||10 -2|42||20 -3|42||30" ]; then + if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, b, c, d FROM test_numerical ORDER BY a")" = "1|42.00||10 +2|42.00||20 +3|42.00||30" ]; then echo "check updated replicated data on subscriber success" else echo "$failed_keyword when check updated replicated data on subscriber" @@ -87,10 +87,10 @@ function test_1() { wait_for_catchup $case_db $pub_node1_port "tsub" - if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, b, c, d FROM test_numerical ORDER BY a")" = "1|42||10 -2|42||20 -3|42||30 -4|4.2|4.3|40" ]; then + if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, b, c, d FROM test_numerical ORDER BY a")" = "1|42.00||10 +2|42.00||20 +3|42.00||30 +4|4.20|4.3|40" ]; then echo "check replicated data on subscriber success" else echo "$failed_keyword when check replicated data on subscriber" @@ -104,9 +104,9 @@ function test_1() { wait_for_catchup $case_db $pub_node1_port "tsub" - if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, b, c FROM test_arrays ORDER BY a")" = "{1,2,3}|{42,1.2,1.3}| -{2,3,1}|{1.2,1.3,1.1}|{two,three,one} -{3,1,2}|{42,1.1,1.2}|" ]; then + if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, b, c FROM test_arrays ORDER BY a")" = "{1,2,3}|{42.00,1.20,1.30}| +{2,3,1}|{1.20,1.30,1.10}|{two,three,one} +{3,1,2}|{42.00,1.10,1.20}|" ]; then echo "check replicated data on subscriber success" else echo "$failed_keyword when check replicated data on subscriber" diff --git a/src/test/subscription/testcase/rep_changes.sh b/src/test/subscription/testcase/rep_changes.sh index 6b2ec0da0..e3a5c63c6 100644 --- a/src/test/subscription/testcase/rep_changes.sh +++ b/src/test/subscription/testcase/rep_changes.sh @@ -15,7 +15,7 @@ function test_1() { exec_sql $case_db $pub_node1_port "CREATE TABLE tab_full2 (x text)" exec_sql $case_db $pub_node1_port "INSERT INTO tab_full2 VALUES ('a'), ('b'), ('b')" exec_sql $case_db $pub_node1_port "CREATE TABLE tab_rep (a int primary key)" - exec_sql $case_db $pub_node1_port "CREATE TABLE tab_mixed (a int primary key, b text, c numeric)" + exec_sql $case_db $pub_node1_port "CREATE TABLE tab_mixed (a int primary key, b text, c numeric(10,2))" exec_sql $case_db $pub_node1_port "INSERT INTO tab_mixed (a, b, c) VALUES (1, 'foo', 1.1)" exec_sql $case_db $pub_node1_port "CREATE TABLE tab_include (a int, b text) WITH (storage_type = ustore)" exec_sql $case_db $pub_node1_port "CREATE INDEX covering ON tab_include USING ubtree (a) INCLUDE(b)" @@ -40,7 +40,7 @@ function test_1() { exec_sql $case_db $sub_node1_port "CREATE TABLE tab_nothing (a int)" # different column count and order than on publisher - exec_sql $case_db $sub_node1_port "CREATE TABLE tab_mixed (d text default 'local', c numeric, b text, a int primary key)" + exec_sql $case_db $sub_node1_port "CREATE TABLE tab_mixed (d text default 'local', c numeric(10,2), b text, a int primary key)" # replication of the table with included index exec_sql $case_db $sub_node1_port "CREATE TABLE tab_include (a int, b text) WITH (storage_type = ustore)" @@ -106,8 +106,8 @@ function test_1() { exit 1 fi - if [ "$(exec_sql $case_db $sub_node1_port "SELECT * FROM tab_mixed")" = "local|1.1|foo|1 -local|2.2|bar|2" ]; then + if [ "$(exec_sql $case_db $sub_node1_port "SELECT * FROM tab_mixed")" = "local|1.10|foo|1 +local|2.20|bar|2" ]; then echo "check replicated changes with different column order success" else echo "$failed_keyword when check replicated changes with different column order" @@ -261,8 +261,8 @@ bb" ]; then exit 1 fi - if [ "$(exec_sql $case_db $sub_node1_port "SELECT * FROM tab_mixed ORDER BY a")" = "local|1.1|baz|1 -local|2.2|bar|2" ]; then + if [ "$(exec_sql $case_db $sub_node1_port "SELECT * FROM tab_mixed ORDER BY a")" = "local|1.10|baz|1 +local|2.20|bar|2" ]; then echo "check update works with different column order and subscriber local values success" else echo "$failed_keyword when check update works with different column order and subscriber local values" @@ -305,8 +305,8 @@ local|2.2|bar|2" ]; then wait_for_catchup $case_db $pub_node1_port "tap_sub" - if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, length(b), c, d FROM tab_mixed ORDER BY a")" = "1|3|1.1|local -2|500000|2.2|local" ]; then + if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, length(b), c, d FROM tab_mixed ORDER BY a")" = "1|3|1.10|local +2|500000|2.20|local" ]; then echo "check update transmits large column value success" else echo "$failed_keyword when check update transmits large column value" @@ -317,8 +317,8 @@ local|2.2|bar|2" ]; then wait_for_catchup $case_db $pub_node1_port "tap_sub" - if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, length(b), c, d FROM tab_mixed ORDER BY a")" = "1|3|1.1|local -2|500000|3.3|local" ]; then + if [ "$(exec_sql $case_db $sub_node1_port "SELECT a, length(b), c, d FROM tab_mixed ORDER BY a")" = "1|3|1.10|local +2|500000|3.30|local" ]; then echo "check update with non-transmitted large column value success" else echo "$failed_keyword when check update with non-transmitted large column value" @@ -335,7 +335,7 @@ local|2.2|bar|2" ]; then wait_for_catchup $case_db $pub_node1_port "tap_sub" if [ "$(exec_sql $case_db $sub_node1_port "SELECT * FROM tab_mixed ORDER BY a")" = "local|11.11|baz|1 -local|2.2|bar|2" ]; then +local|2.20|bar|2" ]; then echo "check update works with dropped publisher column success" else echo "$failed_keyword when check update works with dropped publisher column"