From 8fe07ab4baddfece3441ae3335235f6424e3602b Mon Sep 17 00:00:00 2001 From: liushengsong <602726449@qq.com> Date: Thu, 14 Mar 2024 17:22:44 +0800 Subject: [PATCH] 1 --- gpMgmt/bin/gpexpand | 5 +--- src/test/regress/expected/shrink_table.out | 34 ++++++++++++++-------- src/test/regress/sql/shrink_table.sql | 5 ++++ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/gpMgmt/bin/gpexpand b/gpMgmt/bin/gpexpand index 71d18dba14e..128aa9db2fb 100755 --- a/gpMgmt/bin/gpexpand +++ b/gpMgmt/bin/gpexpand @@ -2075,10 +2075,7 @@ class ExecuteSQLStatementsCommand(SQLCommand): try: self.conn = dbconn.connect(self.url, utility=True, encoding='UTF8', allowSystemTableMods=True) for statement in self.sqlCommandList: - if not (statement is None): - dbconn.execSQL(self.conn, statement) - else: - logger.warning(" %s " % self.sqlCommandList) + dbconn.execSQL(self.conn, statement) except Exception as e: # traceback.print_exc() logger.error("Exception in ExecuteSQLStatements. URL = %s" % str(self.url)) diff --git a/src/test/regress/expected/shrink_table.out b/src/test/regress/expected/shrink_table.out index 5406a94abde..74ed3b6b80b 100644 --- a/src/test/regress/expected/shrink_table.out +++ b/src/test/regress/expected/shrink_table.out @@ -11,9 +11,9 @@ Update t1 set c = gp_segment_id; Select gp_segment_id, count(*) from t1 group by gp_segment_id; gp_segment_id | count ---------------+------- + 2 | 25 0 | 38 1 | 37 - 2 | 25 (3 rows) begin; @@ -55,9 +55,9 @@ Update t1 set c = gp_segment_id; Select gp_segment_id, count(*) from t1 group by gp_segment_id; gp_segment_id | count ---------------+------- + 2 | 37 0 | 33 1 | 30 - 2 | 37 (3 rows) begin; @@ -72,9 +72,9 @@ abort; Select gp_segment_id, count(*) from t1 group by gp_segment_id; gp_segment_id | count ---------------+------- - 2 | 37 0 | 33 1 | 30 + 2 | 37 (3 rows) Alter table t1 shrink table to 1; @@ -105,9 +105,9 @@ insert into t1 values Select gp_segment_id, count(*) from t1 group by gp_segment_id; gp_segment_id | count ---------------+------- + 0 | 3 1 | 1 2 | 4 - 0 | 3 (3 rows) begin; @@ -170,8 +170,8 @@ NOTICE: One or more columns in the following table(s) do not have statistics: t HINT: For non-partitioned tables, run analyze (). For partitioned tables, run analyze rootpartition (). See log for columns missing statistics. gp_segment_id | count ---------------+------- - 1 | 37 0 | 38 + 1 | 37 2 | 25 (3 rows) @@ -494,6 +494,7 @@ select gp_segment_id, count(*) from table_with_update_trigger group by 1 order b 1 | 47 (2 rows) +drop table table_with_update_trigger; -- -- Test shrinking inheritance parent table, parent table has different -- numsegments with child tables. @@ -543,6 +544,10 @@ select count(*) from mix_child_b where gp_segment_id = 2; 0 (1 row) +drop table mix_base_tbl cascade; +NOTICE: drop cascades to 2 other objects +DETAIL: drop cascades to table mix_child_a +drop cascades to table mix_child_b -- multi-level partition tables CREATE TABLE part_t1(a int, b int, c int, d int, e int) DISTRIBUTED BY(a) @@ -564,9 +569,9 @@ Update part_t1 set e = gp_segment_id; Select gp_segment_id, count(*) from part_t1 group by gp_segment_id; gp_segment_id | count ---------------+------- - 2 | 25 0 | 38 1 | 37 + 2 | 25 (3 rows) begin; @@ -700,11 +705,11 @@ Update part_t1 set e = gp_segment_id; select gp_segment_id, * from part_t1_1_prt_other_b_2_prt_2_3_prt_others_d; gp_segment_id | a | b | c | d | e ---------------+----+---+---+---+--- - 2 | 5 | 2 | 1 | 0 | 2 - 2 | 9 | 0 | 1 | 4 | 2 0 | 29 | 2 | 1 | 4 | 0 0 | 45 | 0 | 1 | 0 | 0 0 | 65 | 2 | 1 | 0 | 0 + 2 | 5 | 2 | 1 | 0 | 2 + 2 | 9 | 0 | 1 | 4 | 2 1 | 69 | 0 | 1 | 4 | 1 1 | 89 | 2 | 1 | 4 | 1 (7 rows) @@ -716,13 +721,13 @@ HINT: Call ALTER TABLE SHRINK TABLE on the root table instead select gp_segment_id, * from part_t1_1_prt_other_b_2_prt_2_3_prt_others_d; gp_segment_id | a | b | c | d | e ---------------+----+---+---+---+--- + 0 | 29 | 2 | 1 | 4 | 0 + 0 | 45 | 0 | 1 | 0 | 0 + 0 | 65 | 2 | 1 | 0 | 0 2 | 5 | 2 | 1 | 0 | 2 2 | 9 | 0 | 1 | 4 | 2 1 | 69 | 0 | 1 | 4 | 1 1 | 89 | 2 | 1 | 4 | 1 - 0 | 29 | 2 | 1 | 4 | 0 - 0 | 45 | 0 | 1 | 0 | 0 - 0 | 65 | 2 | 1 | 0 | 0 (7 rows) -- try to shrink root partition, should success @@ -807,6 +812,10 @@ ERROR: "shrink_table2" is not a table, materialized view, or foreign table ALTER TABLE shrink_view shrink TABLE to 2; ERROR: "shrink_view" is not a table, materialized view, or foreign table ALTER TABLE shrink_table1 shrink TABLE to 2; +drop table shrink_table1 cascade; +NOTICE: drop cascades to 2 other objects +DETAIL: drop cascades to view shrink_view +drop cascades to view shrink_table2 -- -- Test shrinking a table with a domain type as distribution key. -- @@ -817,9 +826,9 @@ update shrink_domain_tab set oldseg = gp_segment_id; select gp_segment_id, count(*) from shrink_domain_tab group by gp_segment_id; gp_segment_id | count ---------------+------- - 0 | 5 1 | 1 2 | 4 + 0 | 5 (3 rows) alter table shrink_domain_tab shrink table to 2; @@ -836,6 +845,7 @@ select numsegments from gp_distribution_policy where localoid='shrink_domain_tab 2 (1 row) +drop table shrink_domain_tab; -- start_ignore -- We need to do a cluster expansion which will check if there are partial -- tables, we need to drop the partial tables to keep the cluster expansion diff --git a/src/test/regress/sql/shrink_table.sql b/src/test/regress/sql/shrink_table.sql index c33b7127ed0..63fc5169d8c 100644 --- a/src/test/regress/sql/shrink_table.sql +++ b/src/test/regress/sql/shrink_table.sql @@ -234,6 +234,8 @@ update table_with_update_trigger set a = a + 1; -- data expansion should success and not hiting any triggers. Alter table table_with_update_trigger shrink table to 2; select gp_segment_id, count(*) from table_with_update_trigger group by 1 order by 1; +drop table table_with_update_trigger; + -- -- Test shrinking inheritance parent table, parent table has different -- numsegments with child tables. @@ -254,6 +256,7 @@ select count(*) from mix_child_b where gp_segment_id = 2; Alter table mix_base_tbl shrink table to 2; select count(*) from mix_child_a where gp_segment_id = 2; select count(*) from mix_child_b where gp_segment_id = 2; +drop table mix_base_tbl cascade; -- multi-level partition tables CREATE TABLE part_t1(a int, b int, c int, d int, e int) @@ -409,6 +412,7 @@ CREATE rule "_RETURN" AS ON SELECT TO shrink_table2 ALTER TABLE shrink_table2 shrink TABLE to 2; ALTER TABLE shrink_view shrink TABLE to 2; ALTER TABLE shrink_table1 shrink TABLE to 2; +drop table shrink_table1 cascade; -- -- Test shrinking a table with a domain type as distribution key. @@ -425,6 +429,7 @@ select gp_segment_id, count(*) from shrink_domain_tab group by gp_segment_id; alter table shrink_domain_tab shrink table to 2; select gp_segment_id, count(*) from shrink_domain_tab group by gp_segment_id; select numsegments from gp_distribution_policy where localoid='shrink_domain_tab'::regclass; +drop table shrink_domain_tab; -- start_ignore -- We need to do a cluster expansion which will check if there are partial