From d0502bb669d39018be8cdf2732c0b6594c69752e Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Fri, 15 Sep 2023 09:19:05 +0500 Subject: [PATCH 01/40] New GUC to inherit storage options with ALTER TABLE ADD PARTITION When a new partitioned table is created, its partitions inherit storage options (appendonly, orientation, compresstype, compresslevel and blocksize) from the parent table. But when adding partitions using the ALTER TABLE ADD PARTITION command, new partitions are added with storage options as specified in gp_default_storage_options (unless these options are explicitly specified in the DDL or subpartition template). This patch adds a new GUC gp_add_partition_inherits_table_setting with the default value false. When set to true, the ALTER TABLE ADD PARTITION command will add new partitions with storage options inherited from the parent table (unless these options are explicitly specified in the DDL or subpartition template). --- .../dita/ref_guide/config_params/guc-list.xml | 56 +++++ .../config_params/guc_category-list.xml | 2 + .../config_params/guc_config.ditamap | 1 + .../ref_guide/sql_commands/ALTER_TABLE.xml | 27 +++ .../ref_guide/config_params/guc-list.html.md | 22 ++ .../config_params/guc_category-list.html.md | 1 + src/backend/commands/tablecmds.c | 8 + src/backend/utils/misc/guc_gp.c | 13 + src/include/cdb/cdbvars.h | 3 + src/include/utils/sync_guc_name.h | 1 + src/test/regress/expected/alter_table_ao.out | 225 ++++++++++++++++++ .../regress/expected/alter_table_aocs.out | 179 ++++++++++++++ src/test/regress/sql/alter_table_ao.sql | 33 +++ src/test/regress/sql/alter_table_aocs.sql | 33 +++ 14 files changed, 604 insertions(+) diff --git a/gpdb-doc/dita/ref_guide/config_params/guc-list.xml b/gpdb-doc/dita/ref_guide/config_params/guc-list.xml index 1b22beeee87d..8d1ce1e4bc95 100644 --- a/gpdb-doc/dita/ref_guide/config_params/guc-list.xml +++ b/gpdb-doc/dita/ref_guide/config_params/guc-list.xml @@ -157,6 +157,8 @@
  • +
  • +
  • @@ -2255,6 +2257,60 @@ + + gp_add_partition_inherits_table_setting + +

    When adding a partition to an append-optimized, row-oriented or column-oriented table with the ALTER TABLE command, this + parameter controls whether the table's parameters (appendonly, orientation, + compresstype, compresslevel, and + blocksize) can be inherited from the table values. The default is + off, the table's settings are not considered when adding + a partition to the table. If the value is on, the table's settings are + considered.

    +

    When you create an append-optimized row-oriented or column-oriented table, you can set the table's + parameters appendonly, orientation, compresstype, compresslevel, and + blocksize for the table in the WITH clause. When you add + a partition, Greenplum Database sets each parameter based on one of the + following settings, in order of preference.

      +
    1. The setting specified in the ALTER TABLE command + WITH clause.
    2. +
    3. If this server configuration parameter is set to on, the table's + setting specified in the WITH clause when the table was + created. Otherwise, the table's setting is ignored.
    4. +
    5. The setting specified in the server configuration parameter + gp_default_storage_options.
    6. +

    +

    You must specify --skipvalidation when modifying this parameter as it is a + restricted configuration parameter. Use extreme caution when setting configuration + parameters with this option. For + example:gpconfig --skipvalidation -c gp_add_partition_inherits_table_setting -v on

    +

    For information about the storage parameters, see CREATE TABLE.

    + + + + + + + + Value Range + Default + Set Classifications + + + + + Boolean + off + master

    session

    reload

    +
    + + +
    + +
    gp_adjust_selectivity_for_outerjoins diff --git a/gpdb-doc/dita/ref_guide/config_params/guc_category-list.xml b/gpdb-doc/dita/ref_guide/config_params/guc_category-list.xml index b21f923fbbc9..4290f9222693 100644 --- a/gpdb-doc/dita/ref_guide/config_params/guc_category-list.xml +++ b/gpdb-doc/dita/ref_guide/config_params/guc_category-list.xml @@ -1358,6 +1358,8 @@ >max_appendonly_tables

    gp_add_column_inherits_table_setting +

    gp_add_partition_inherits_table_setting

    gp_appendonly_compaction diff --git a/gpdb-doc/dita/ref_guide/config_params/guc_config.ditamap b/gpdb-doc/dita/ref_guide/config_params/guc_config.ditamap index 2f1cb467a852..25f531b02754 100644 --- a/gpdb-doc/dita/ref_guide/config_params/guc_config.ditamap +++ b/gpdb-doc/dita/ref_guide/config_params/guc_config.ditamap @@ -77,6 +77,7 @@ + diff --git a/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml b/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml index d44f63b5c7ea..82aa15cc397a 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml @@ -787,6 +787,33 @@ where action is one of: using a subpartition template, then the template will be used to generate the subpartitions automatically. +

    When you add a partition to an + append-optimized, row-oriented or column-oriented table, Greenplum + Database sets each parameter (appendonly, orientation, + compresstype, + compresslevel, and + blocksize) based on the following + setting, in order of preference.

      +
    1. The parameter setting specified in + the ALTER TABLE command + WITH clause.
    2. +
    3. If the server configuration parameter + gp_add_partition_inherits_table_setting + is on, use the table's + parameters specified in the + WITH clause when the table was + created. The default server configuration + parameter default is off, the + WITH clause parameters are + ignored.
    4. +
    5. The parameter setting specified in + the server configuration parameter gp_default_storage_option.
    6. +

    EXCHANGE [DEFAULT] PARTITION diff --git a/gpdb-doc/markdown/ref_guide/config_params/guc-list.html.md b/gpdb-doc/markdown/ref_guide/config_params/guc-list.html.md index bc89f15fef03..23f2bd4e1bcd 100644 --- a/gpdb-doc/markdown/ref_guide/config_params/guc-list.html.md +++ b/gpdb-doc/markdown/ref_guide/config_params/guc-list.html.md @@ -437,6 +437,28 @@ For information about the data storage compression parameters, see [CREATE TABLE |-----------|-------|-------------------| |Boolean|off|master, session, reload| +## gp\_add\_partition\_inherits\_table\_setting + +When adding a partition to an append-optimized, row-oriented or column-oriented table with the [ALTER TABLE](../sql_commands/ALTER_TABLE.html) command, this parameter controls whether the table's parameters \(`appendonly`, `orientation`, `compresstype`, `compresslevel`, and `blocksize`\) can be inherited from the table. The default is `off`, the table's settings are not considered when adding a partition to the table. If the value is `on`, the table's settings are considered. + +When you create an append-optimized row-oriented or column-oriented table, you can set the table's parameters `appendonly`, `orientation`, `compresstype`, `compresslevel`, and `blocksize` for the table in the `WITH` clause. When you add a partition, Greenplum Database sets each parameter based on one of the following settings, in order of preference. + +1. The setting specified in the `ALTER TABLE` command `WITH` clause. +2. If this server configuration parameter is set to `on`, the table's setting specified in the `WITH` clause when the table was created. Otherwise, the table's setting is ignored. +3. The setting specified in the server configuration parameter [gp\_default\_storage\_options](#gp_default_storage_options). + +You must specify `--skipvalidation` when modifying this parameter as it is a restricted configuration parameter. Use extreme caution when setting configuration parameters with this option. For example: + +``` +gpconfig --skipvalidation -c gp_add_partition_inherits_table_setting -v on +``` + +For information about the storage parameters, see [CREATE TABLE](../sql_commands/CREATE_TABLE.html). + +|Value Range|Default|Set Classifications| +|-----------|-------|-------------------| +|Boolean|off|master, session, reload| + ## gp\_adjust\_selectivity\_for\_outerjoins Enables the selectivity of NULL tests over outer joins. diff --git a/gpdb-doc/markdown/ref_guide/config_params/guc_category-list.html.md b/gpdb-doc/markdown/ref_guide/config_params/guc_category-list.html.md index d667d948fbe7..92804f9dec7d 100644 --- a/gpdb-doc/markdown/ref_guide/config_params/guc_category-list.html.md +++ b/gpdb-doc/markdown/ref_guide/config_params/guc_category-list.html.md @@ -446,6 +446,7 @@ The following parameters configure the append-optimized tables feature of Greenp - [max_appendonly_tables](guc-list.html#max_appendonly_tables) - [gp_add_column_inherits_table_setting](guc-list.html) [gp_appendonly_compaction](guc-list.html#gp_add_column_inherits_table_setting](guc-list.html) [gp_appendonly_compaction) +- [gp_add_partition_inherits_table_setting](guc-list.html) [gp_appendonly_compaction](guc-list.html#gp_add_partition_inherits_table_setting](guc-list.html) [gp_appendonly_compaction) - [gp_appendonly_compaction_threshold](guc-list.html#gp_appendonly_compaction_threshold) - [validate_previous_free_tid](guc-list.html#validate_previous_free_tid) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 680516a7585e..e79525c8d6b2 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -16166,6 +16166,14 @@ ATPExecPartAdd(AlteredTableInfo *tab, } pelem = (PartitionElem *) pc->arg1; + if (gp_add_partition_inherits_table_setting && !pelem->storeAttr) + { + AlterPartitionCmd *storenode = makeNode(AlterPartitionCmd); + storenode->arg1 = (Node *)reloptions_list(RelationGetRelid(rel)); + storenode->location = -1; + pelem->storeAttr = (Node *)storenode; + } + locPid = wack_pid_relname(pid, &pNode, diff --git a/src/backend/utils/misc/guc_gp.c b/src/backend/utils/misc/guc_gp.c index c3bf077111a5..6fa36a7a6636 100644 --- a/src/backend/utils/misc/guc_gp.c +++ b/src/backend/utils/misc/guc_gp.c @@ -455,6 +455,8 @@ char *gp_default_storage_options = NULL; bool gp_add_column_inherits_table_setting = false; +bool gp_add_partition_inherits_table_setting = false; + int writable_external_table_bufsize = 1024; bool gp_external_enable_filter_pushdown = true; @@ -3298,6 +3300,17 @@ struct config_bool ConfigureNamesBool_gp[] = NULL, NULL, NULL }, + { + {"gp_add_partition_inherits_table_setting", PGC_USERSET, CUSTOM_OPTIONS, + gettext_noop("Alter table add partition inherits storage setting from the table."), + NULL, + GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE + }, + &gp_add_partition_inherits_table_setting, + false, + NULL, NULL, NULL + }, + /* End-of-list marker */ { {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL diff --git a/src/include/cdb/cdbvars.h b/src/include/cdb/cdbvars.h index 88d99280b891..8199259581bb 100644 --- a/src/include/cdb/cdbvars.h +++ b/src/include/cdb/cdbvars.h @@ -755,6 +755,9 @@ extern bool gp_enable_motion_mk_sort; /* Alter table add column inherits storage setting from the table */ extern bool gp_add_column_inherits_table_setting; +/* Alter table add partition inherits storage setting from the table */ +extern bool gp_add_partition_inherits_table_setting; + #ifdef USE_ASSERT_CHECKING extern bool gp_mk_sort_check; #endif diff --git a/src/include/utils/sync_guc_name.h b/src/include/utils/sync_guc_name.h index 4b9a23665477..5ddcec907ead 100644 --- a/src/include/utils/sync_guc_name.h +++ b/src/include/utils/sync_guc_name.h @@ -124,3 +124,4 @@ "gp_add_column_inherits_table_setting", "gp_resgroup_debug_wait_queue", "gp_log_resqueue_priority_sleep_time", + "gp_add_partition_inherits_table_setting", diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index 6c44730939f3..901b38348d0e 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -734,3 +734,228 @@ SELECT * FROM gp_toolkit.__gp_aoseg('ao_insert_empty_row'::regclass); -------+-----+----------+---------------+------------------+----------+---------------+------- (0 rows) +-- test case: alter AO table add partition, the preference of the storage setting is: the encoding clause > table setting > gp_default_storage_options +SET gp_add_partition_inherits_table_setting = on; +CREATE TABLE ao_alter_add_part(a int, b int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) + (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, + PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_10" for table "ao_alter_add_part" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_20" for table "ao_alter_add_part" +SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype=zlib, compresslevel=2'; +-- use statement encoding +ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_30" for table "ao_alter_add_part" +-- use table setting +ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_40" for table "ao_alter_add_part" +RESET gp_default_storage_options; +-- use table setting +ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50" for table "ao_alter_add_part" +\d+ ao_alter_add_part* + Append-Only Table "public.ao_alter_add_part" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: zstd +Compression Level: 4 +Block Size: 65536 +Checksum: t +Child tables: ao_alter_add_part_1_prt_10, + ao_alter_add_part_1_prt_20, + ao_alter_add_part_1_prt_30, + ao_alter_add_part_1_prt_40, + ao_alter_add_part_1_prt_50 +Distributed by: (a) +Partition by: (b) +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 + + Append-Only Table "public.ao_alter_add_part_1_prt_10" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: zstd +Compression Level: 4 +Block Size: 65536 +Checksum: t +Check constraints: + "ao_alter_add_part_1_prt_10_check" CHECK (b >= 1 AND b < 10) +Inherits: ao_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 + + Append-Only Table "public.ao_alter_add_part_1_prt_20" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: zstd +Compression Level: 4 +Block Size: 65536 +Checksum: t +Check constraints: + "ao_alter_add_part_1_prt_20_check" CHECK (b >= 11 AND b < 20) +Inherits: ao_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 + + Append-Only Table "public.ao_alter_add_part_1_prt_30" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: zlib +Compression Level: 3 +Block Size: 16384 +Checksum: t +Check constraints: + "ao_alter_add_part_1_prt_30_check" CHECK (b >= 20 AND b < 30) +Inherits: ao_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384 + + Append-Only Table "public.ao_alter_add_part_1_prt_40" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: zstd +Compression Level: 4 +Block Size: 65536 +Checksum: t +Check constraints: + "ao_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) +Inherits: ao_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 + + Append-Only Table "public.ao_alter_add_part_1_prt_50" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: zstd +Compression Level: 4 +Block Size: 65536 +Checksum: t +Check constraints: + "ao_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) +Inherits: ao_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 + +DROP TABLE ao_alter_add_part; +CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) + (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, + PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10" for table "ao_alter_add_part_no_compress" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_20" for table "ao_alter_add_part_no_compress" +SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype=zlib, compresslevel=2, blocksize=8192'; +-- use statement encoding +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_30" for table "ao_alter_add_part_no_compress" +-- use gp_default_storage_options +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_40" for table "ao_alter_add_part_no_compress" +RESET gp_default_storage_options; +-- use default value +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50" for table "ao_alter_add_part_no_compress" +\d+ ao_alter_add_part_no_compress* + Append-Only Table "public.ao_alter_add_part_no_compress" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: None +Compression Level: 0 +Block Size: 32768 +Checksum: t +Child tables: ao_alter_add_part_no_compress_1_prt_10, + ao_alter_add_part_no_compress_1_prt_20, + ao_alter_add_part_no_compress_1_prt_30, + ao_alter_add_part_no_compress_1_prt_40, + ao_alter_add_part_no_compress_1_prt_50 +Distributed by: (a) +Partition by: (b) +Options: appendonly=true, orientation=row + + Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_10" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: None +Compression Level: 0 +Block Size: 32768 +Checksum: t +Check constraints: + "ao_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 1 AND b < 10) +Inherits: ao_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=row + + Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_20" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: None +Compression Level: 0 +Block Size: 32768 +Checksum: t +Check constraints: + "ao_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 11 AND b < 20) +Inherits: ao_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=row + + Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_30" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: zstd +Compression Level: 3 +Block Size: 16384 +Checksum: t +Check constraints: + "ao_alter_add_part_no_compress_1_prt_30_check" CHECK (b >= 20 AND b < 30) +Inherits: ao_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384 + + Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_40" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: zlib +Compression Level: 2 +Block Size: 8192 +Checksum: t +Check constraints: + "ao_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) +Inherits: ao_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 + + Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_50" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: None +Compression Level: 0 +Block Size: 32768 +Checksum: t +Check constraints: + "ao_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) +Inherits: ao_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=row + +DROP TABLE ao_alter_add_part_no_compress; +RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index 7c98505f679f..e2b2268a9b2f 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -852,6 +852,185 @@ Options: appendonly=true, orientation=column, compresstype=rle_type, compresslev DROP TABLE aocs_alter_add_col_reorganize; RESET gp_add_column_inherits_table_setting; +-- test case: alter AOCS table add partition, the preference of the storage setting is: the encoding clause > table setting > gp_default_storage_options +SET gp_add_partition_inherits_table_setting = on; +CREATE TABLE aocs_alter_add_part(a int, b int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) + (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, + PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); +SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; +-- use statement encoding +ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); +-- use table setting +ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; +RESET gp_default_storage_options; +-- use table setting +ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +\d+ aocs_alter_add_part* + Append-Only Columnar Table "public.aocs_alter_add_part" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | rle_type | 4 | 65536 | + b | integer | | plain | | rle_type | 4 | 65536 | +Checksum: t +Child tables: aocs_alter_add_part_1_prt_10, + aocs_alter_add_part_1_prt_20, + aocs_alter_add_part_1_prt_30, + aocs_alter_add_part_1_prt_40, + aocs_alter_add_part_1_prt_50 +Distributed by: (a) +Partition by: (b) +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 + + Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_10" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | rle_type | 4 | 65536 | + b | integer | | plain | | rle_type | 4 | 65536 | +Checksum: t +Check constraints: + "aocs_alter_add_part_1_prt_10_check" CHECK (b >= 1 AND b < 10) +Inherits: aocs_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 + + Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_20" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | rle_type | 4 | 65536 | + b | integer | | plain | | rle_type | 4 | 65536 | +Checksum: t +Check constraints: + "aocs_alter_add_part_1_prt_20_check" CHECK (b >= 11 AND b < 20) +Inherits: aocs_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 + + Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_30" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | zlib | 3 | 16384 | + b | integer | | plain | | zlib | 3 | 16384 | +Checksum: t +Check constraints: + "aocs_alter_add_part_1_prt_30_check" CHECK (b >= 20 AND b < 30) +Inherits: aocs_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384 + + Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_40" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | rle_type | 4 | 65536 | + b | integer | | plain | | rle_type | 4 | 65536 | +Checksum: t +Check constraints: + "aocs_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) +Inherits: aocs_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 + + Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_50" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | rle_type | 4 | 65536 | + b | integer | | plain | | rle_type | 4 | 65536 | +Checksum: t +Check constraints: + "aocs_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) +Inherits: aocs_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 + +DROP TABLE aocs_alter_add_part; +CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) + (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, + PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); +SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; +-- use statement encoding +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); +-- use gp_default_storage_options +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; +RESET gp_default_storage_options; +-- use default value +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +\d+ aocs_alter_add_part_no_compress* + Append-Only Columnar Table "public.aocs_alter_add_part_no_compress" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | none | 0 | 32768 | + b | integer | | plain | | none | 0 | 32768 | +Checksum: t +Child tables: aocs_alter_add_part_no_compress_1_prt_10, + aocs_alter_add_part_no_compress_1_prt_20, + aocs_alter_add_part_no_compress_1_prt_30, + aocs_alter_add_part_no_compress_1_prt_40, + aocs_alter_add_part_no_compress_1_prt_50 +Distributed by: (a) +Partition by: (b) +Options: appendonly=true, orientation=column + + Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_10" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | none | 0 | 32768 | + b | integer | | plain | | none | 0 | 32768 | +Checksum: t +Check constraints: + "aocs_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 1 AND b < 10) +Inherits: aocs_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=column + + Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_20" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | none | 0 | 32768 | + b | integer | | plain | | none | 0 | 32768 | +Checksum: t +Check constraints: + "aocs_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 11 AND b < 20) +Inherits: aocs_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=column + + Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_30" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | rle_type | 3 | 16384 | + b | integer | | plain | | rle_type | 3 | 16384 | +Checksum: t +Check constraints: + "aocs_alter_add_part_no_compress_1_prt_30_check" CHECK (b >= 20 AND b < 30) +Inherits: aocs_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384 + + Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_40" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | zlib | 2 | 8192 | + b | integer | | plain | | zlib | 2 | 8192 | +Checksum: t +Check constraints: + "aocs_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) +Inherits: aocs_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 + + Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_50" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | none | 0 | 32768 | + b | integer | | plain | | none | 0 | 32768 | +Checksum: t +Check constraints: + "aocs_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) +Inherits: aocs_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=column + +DROP TABLE aocs_alter_add_part_no_compress; +RESET gp_add_partition_inherits_table_setting; -- -- Test case: validate pg_aocsseg consistency after alter table -- add column with rollback. diff --git a/src/test/regress/sql/alter_table_ao.sql b/src/test/regress/sql/alter_table_ao.sql index 39fa520e5b96..ceca8ece7db1 100644 --- a/src/test/regress/sql/alter_table_ao.sql +++ b/src/test/regress/sql/alter_table_ao.sql @@ -447,3 +447,36 @@ CREATE table ao_insert_empty_row (a integer, b text, c integer) WITH (APPENDONLY INSERT INTO ao_insert_empty_row SELECT 1,'a',1 FROM gp_id WHERE dbid=-999; -- assert non-empty seg entries SELECT * FROM gp_toolkit.__gp_aoseg('ao_insert_empty_row'::regclass); + +-- test case: alter AO table add partition, the preference of the storage setting is: the encoding clause > table setting > gp_default_storage_options +SET gp_add_partition_inherits_table_setting = on; + +CREATE TABLE ao_alter_add_part(a int, b int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) + (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, + PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); +SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype=zlib, compresslevel=2'; +-- use statement encoding +ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); +-- use table setting +ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; +RESET gp_default_storage_options; +-- use table setting +ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +\d+ ao_alter_add_part* +DROP TABLE ao_alter_add_part; + +CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) + (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, + PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); +SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype=zlib, compresslevel=2, blocksize=8192'; +-- use statement encoding +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); +-- use gp_default_storage_options +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; +RESET gp_default_storage_options; +-- use default value +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +\d+ ao_alter_add_part_no_compress* +DROP TABLE ao_alter_add_part_no_compress; + +RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/sql/alter_table_aocs.sql b/src/test/regress/sql/alter_table_aocs.sql index abe732a55c59..c773135137ae 100644 --- a/src/test/regress/sql/alter_table_aocs.sql +++ b/src/test/regress/sql/alter_table_aocs.sql @@ -489,6 +489,39 @@ DROP TABLE aocs_alter_add_col_reorganize; RESET gp_add_column_inherits_table_setting; +-- test case: alter AOCS table add partition, the preference of the storage setting is: the encoding clause > table setting > gp_default_storage_options +SET gp_add_partition_inherits_table_setting = on; + +CREATE TABLE aocs_alter_add_part(a int, b int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) + (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, + PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); +SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; +-- use statement encoding +ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); +-- use table setting +ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; +RESET gp_default_storage_options; +-- use table setting +ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +\d+ aocs_alter_add_part* +DROP TABLE aocs_alter_add_part; + +CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) + (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, + PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); +SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; +-- use statement encoding +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); +-- use gp_default_storage_options +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; +RESET gp_default_storage_options; +-- use default value +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +\d+ aocs_alter_add_part_no_compress* +DROP TABLE aocs_alter_add_part_no_compress; + +RESET gp_add_partition_inherits_table_setting; + -- -- Test case: validate pg_aocsseg consistency after alter table -- add column with rollback. From 4194c7edae253f0eed93f3aeef6bed08ddbc8453 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 26 Sep 2023 08:32:15 +0500 Subject: [PATCH 02/40] move logic from exec to plan and fix tests --- src/backend/commands/tablecmds.c | 8 -------- src/backend/parser/parse_utilcmd.c | 13 +++++++++++++ src/test/regress/expected/alter_table_ao.out | 16 ++++++++-------- src/test/regress/expected/alter_table_aocs.out | 12 ++++++------ 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index e79525c8d6b2..680516a7585e 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -16166,14 +16166,6 @@ ATPExecPartAdd(AlteredTableInfo *tab, } pelem = (PartitionElem *) pc->arg1; - if (gp_add_partition_inherits_table_setting && !pelem->storeAttr) - { - AlterPartitionCmd *storenode = makeNode(AlterPartitionCmd); - storenode->arg1 = (Node *)reloptions_list(RelationGetRelid(rel)); - storenode->location = -1; - pelem->storeAttr = (Node *)storenode; - } - locPid = wack_pid_relname(pid, &pNode, diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index b95ff4bb7085..4de105dc502c 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -4883,6 +4883,19 @@ transformAlterTable_all_PartitionStmt( /* No need to hold onto the lock -- see above */ heap_close(rel, AccessShareLock); } /* end if alter */ + else if (gp_add_partition_inherits_table_setting && atc1->subtype == AT_PartAdd && RelationIsAppendOptimized(pCxt->rel)) + { + PartitionElem *pelem = (PartitionElem *) pc->arg1; + + if (pelem->storeAttr == NULL) + { + AlterPartitionCmd *storenode = makeNode(AlterPartitionCmd); + + storenode->arg1 = (Node *)build_ao_rel_storage_opts(list_make1(makeDefElem("appendonly", (Node *) makeString("true"))), pCxt->rel); + storenode->location = -1; + pelem->storeAttr = (Node *)storenode; + } + } switch (atc1->subtype) { diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index 901b38348d0e..471cdb8a1350 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -829,7 +829,7 @@ Check constraints: "ao_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 +Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=zstd, orientation=row Append-Only Table "public.ao_alter_add_part_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Description @@ -844,7 +844,7 @@ Check constraints: "ao_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 +Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=zstd, orientation=row DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -932,22 +932,22 @@ Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, b --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: zlib -Compression Level: 2 -Block Size: 8192 +Compression Type: none +Compression Level: 0 +Block Size: 32768 Checksum: t Check constraints: "ao_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 +Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=row Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: None +Compression Type: none Compression Level: 0 Block Size: 32768 Checksum: t @@ -955,7 +955,7 @@ Check constraints: "ao_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row +Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=row DROP TABLE ao_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index e2b2268a9b2f..910678b6b377 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -927,7 +927,7 @@ Check constraints: "aocs_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 +Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=rle_type, orientation=column Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -939,7 +939,7 @@ Check constraints: "aocs_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 +Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=rle_type, orientation=column DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -1008,14 +1008,14 @@ Options: appendonly=true, orientation=column, compresstype=rle_type, compresslev Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description --------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | zlib | 2 | 8192 | - b | integer | | plain | | zlib | 2 | 8192 | + a | integer | | plain | | none | 0 | 32768 | + b | integer | | plain | | none | 0 | 32768 | Checksum: t Check constraints: "aocs_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 +Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=column Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -1027,7 +1027,7 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column +Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=column DROP TABLE aocs_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; From 350bee9be2d5dd288e317fa1e8b92a5caa6aa7eb Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 26 Sep 2023 08:39:56 +0500 Subject: [PATCH 03/40] apply pgindent to changes --- src/backend/parser/parse_utilcmd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 4de105dc502c..b22f9bc20651 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -4883,17 +4883,20 @@ transformAlterTable_all_PartitionStmt( /* No need to hold onto the lock -- see above */ heap_close(rel, AccessShareLock); } /* end if alter */ - else if (gp_add_partition_inherits_table_setting && atc1->subtype == AT_PartAdd && RelationIsAppendOptimized(pCxt->rel)) + else if (gp_add_partition_inherits_table_setting && + atc1->subtype == AT_PartAdd && + RelationIsAppendOptimized(pCxt->rel)) { PartitionElem *pelem = (PartitionElem *) pc->arg1; if (pelem->storeAttr == NULL) { AlterPartitionCmd *storenode = makeNode(AlterPartitionCmd); + List *opts = list_make1(makeDefElem("appendonly", (Node *) makeString("true"))); - storenode->arg1 = (Node *)build_ao_rel_storage_opts(list_make1(makeDefElem("appendonly", (Node *) makeString("true"))), pCxt->rel); + storenode->arg1 = (Node *) build_ao_rel_storage_opts(opts, pCxt->rel); storenode->location = -1; - pelem->storeAttr = (Node *)storenode; + pelem->storeAttr = (Node *) storenode; } } From 6ef7fdd9bff04f06aa478e8a2e2379772f3fb825 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 10 Oct 2023 17:17:01 +0500 Subject: [PATCH 04/40] move logic --- src/backend/cdb/cdbpartition.c | 2 ++ src/backend/commands/tablecmds.c | 2 +- src/backend/parser/parse_utilcmd.c | 16 ---------------- src/include/commands/tablecmds.h | 2 ++ src/test/regress/expected/alter_table_ao.out | 16 ++++++++-------- src/test/regress/expected/alter_table_aocs.out | 12 ++++++------ 6 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index fc9fec099304..7bac71ddcbe4 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -6773,6 +6773,8 @@ atpxPartAddList(Relation rel, if (pelem->storeAttr) ct->options = (List *) ((AlterPartitionCmd *) pelem->storeAttr)->arg1; + else if (gp_add_partition_inherits_table_setting) + ct->options = reloptions_list(RelationGetRelid(rel)); ct->tableElts = list_concat(ct->tableElts, list_copy(colencs)); diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 680516a7585e..f5d669dd80a1 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -14447,7 +14447,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid, bool is_partitio /* * deparse pg_class.reloptions into a list. */ -static List * +List * reloptions_list(Oid relid) { Datum reloptions; diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index b22f9bc20651..b95ff4bb7085 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -4883,22 +4883,6 @@ transformAlterTable_all_PartitionStmt( /* No need to hold onto the lock -- see above */ heap_close(rel, AccessShareLock); } /* end if alter */ - else if (gp_add_partition_inherits_table_setting && - atc1->subtype == AT_PartAdd && - RelationIsAppendOptimized(pCxt->rel)) - { - PartitionElem *pelem = (PartitionElem *) pc->arg1; - - if (pelem->storeAttr == NULL) - { - AlterPartitionCmd *storenode = makeNode(AlterPartitionCmd); - List *opts = list_make1(makeDefElem("appendonly", (Node *) makeString("true"))); - - storenode->arg1 = (Node *) build_ao_rel_storage_opts(opts, pCxt->rel); - storenode->location = -1; - pelem->storeAttr = (Node *) storenode; - } - } switch (atc1->subtype) { diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h index 6adee26dfde6..48b8e995c515 100644 --- a/src/include/commands/tablecmds.h +++ b/src/include/commands/tablecmds.h @@ -137,4 +137,6 @@ extern void RangeVarCallbackOwnsRelation(const RangeVar *relation, Oid relId, Oid oldRelId, void *noCatalogs); extern List * rel_get_column_encodings(Relation rel); + +extern List * reloptions_list(Oid relid); #endif /* TABLECMDS_H */ diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index 471cdb8a1350..901b38348d0e 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -829,7 +829,7 @@ Check constraints: "ao_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=zstd, orientation=row +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 Append-Only Table "public.ao_alter_add_part_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Description @@ -844,7 +844,7 @@ Check constraints: "ao_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=zstd, orientation=row +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -932,22 +932,22 @@ Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, b --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: none -Compression Level: 0 -Block Size: 32768 +Compression Type: zlib +Compression Level: 2 +Block Size: 8192 Checksum: t Check constraints: "ao_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=row +Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: none +Compression Type: None Compression Level: 0 Block Size: 32768 Checksum: t @@ -955,7 +955,7 @@ Check constraints: "ao_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=row +Options: appendonly=true, orientation=row DROP TABLE ao_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index 910678b6b377..e2b2268a9b2f 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -927,7 +927,7 @@ Check constraints: "aocs_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=rle_type, orientation=column +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -939,7 +939,7 @@ Check constraints: "aocs_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=rle_type, orientation=column +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -1008,14 +1008,14 @@ Options: appendonly=true, orientation=column, compresstype=rle_type, compresslev Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description --------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | none | 0 | 32768 | - b | integer | | plain | | none | 0 | 32768 | + a | integer | | plain | | zlib | 2 | 8192 | + b | integer | | plain | | zlib | 2 | 8192 | Checksum: t Check constraints: "aocs_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=column +Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -1027,7 +1027,7 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=column +Options: appendonly=true, orientation=column DROP TABLE aocs_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; From 2c33cf4ee977e2fd4159421f5be4cc4f79e0b4c0 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 7 Nov 2023 10:08:41 +0500 Subject: [PATCH 05/40] fix --- src/backend/access/common/reloptions_gp.c | 13 +++++ src/backend/cdb/cdbpartition.c | 19 ++++++- src/include/access/reloptions.h | 2 + src/test/regress/expected/alter_table_ao.out | 56 +++++++++++++++---- .../regress/expected/alter_table_aocs.out | 44 ++++++++++++--- src/test/regress/sql/alter_table_ao.sql | 2 + src/test/regress/sql/alter_table_aocs.sql | 2 + 7 files changed, 118 insertions(+), 20 deletions(-) diff --git a/src/backend/access/common/reloptions_gp.c b/src/backend/access/common/reloptions_gp.c index 6d07cf9ed772..cb4544b8c06a 100644 --- a/src/backend/access/common/reloptions_gp.c +++ b/src/backend/access/common/reloptions_gp.c @@ -1358,6 +1358,19 @@ reloptions_has_opt(List *opts, const char *name) return false; } +DefElem * +reloptions_get_opt(List *opts, const char *name) +{ + ListCell *lc; + foreach(lc, opts) + { + DefElem *de = lfirst(lc); + if (pg_strcasecmp(de->defname, name) == 0) + return de; + } + return NULL; +} + /* * GPDB: Convenience function to build storage reloptions for a given relation, just for AO table . */ diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index 7bac71ddcbe4..576b57db80f2 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -6773,8 +6773,23 @@ atpxPartAddList(Relation rel, if (pelem->storeAttr) ct->options = (List *) ((AlterPartitionCmd *) pelem->storeAttr)->arg1; - else if (gp_add_partition_inherits_table_setting) - ct->options = reloptions_list(RelationGetRelid(rel)); + + if (gp_add_partition_inherits_table_setting) + { + ListCell *lc; + List *opts = reloptions_list(RelationGetRelid(rel)); + + foreach(lc, ct->options) + { + DefElem *de = lfirst(lc); + DefElem *def = reloptions_get_opt(opts, de->defname); + + if (def != NULL) + *def = *de; + } + + ct->options = build_ao_rel_storage_opts(opts, rel); + } ct->tableElts = list_concat(ct->tableElts, list_copy(colencs)); diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h index 741c9a93ffa3..a1010ef47d27 100644 --- a/src/include/access/reloptions.h +++ b/src/include/access/reloptions.h @@ -21,6 +21,7 @@ #include "access/htup.h" #include "access/tupdesc.h" +#include "nodes/parsenodes.h" #include "nodes/pg_list.h" #include "utils/rel.h" @@ -318,6 +319,7 @@ extern void validate_and_refill_options(StdRdOptions *result, relopt_value *opti extern void validate_and_adjust_options(StdRdOptions *result, relopt_value *options, int num_options, relopt_kind kind, bool validate); extern bool reloptions_has_opt(List *opts, const char *name); +extern DefElem *reloptions_get_opt(List *opts, const char *name); extern List *build_ao_rel_storage_opts(List *opts, Relation rel); extern void free_options_deep(relopt_value *options, int num_options); #endif /* RELOPTIONS_H */ diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index 901b38348d0e..e1c9fc631788 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -745,6 +745,8 @@ SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype -- use statement encoding ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_30" for table "ao_alter_add_part" +ALTER TABLE ao_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_60" for table "ao_alter_add_part" -- use table setting ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_40" for table "ao_alter_add_part" @@ -766,7 +768,8 @@ Child tables: ao_alter_add_part_1_prt_10, ao_alter_add_part_1_prt_20, ao_alter_add_part_1_prt_30, ao_alter_add_part_1_prt_40, - ao_alter_add_part_1_prt_50 + ao_alter_add_part_1_prt_50, + ao_alter_add_part_1_prt_60 Distributed by: (a) Partition by: (b) Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 @@ -829,7 +832,7 @@ Check constraints: "ao_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536, checksum=true Append-Only Table "public.ao_alter_add_part_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Description @@ -844,7 +847,22 @@ Check constraints: "ao_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536, checksum=true + + Append-Only Table "public.ao_alter_add_part_1_prt_60" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: zlib +Compression Level: 2 +Block Size: 32768 +Checksum: t +Check constraints: + "ao_alter_add_part_1_prt_60_check" CHECK (b >= 50 AND b < 60) +Inherits: ao_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=row, compresslevel=2 DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -856,6 +874,8 @@ SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype= -- use statement encoding ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_30" for table "ao_alter_add_part_no_compress" +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_60" for table "ao_alter_add_part_no_compress" -- use gp_default_storage_options ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_40" for table "ao_alter_add_part_no_compress" @@ -877,7 +897,8 @@ Child tables: ao_alter_add_part_no_compress_1_prt_10, ao_alter_add_part_no_compress_1_prt_20, ao_alter_add_part_no_compress_1_prt_30, ao_alter_add_part_no_compress_1_prt_40, - ao_alter_add_part_no_compress_1_prt_50 + ao_alter_add_part_no_compress_1_prt_50, + ao_alter_add_part_no_compress_1_prt_60 Distributed by: (a) Partition by: (b) Options: appendonly=true, orientation=row @@ -932,22 +953,22 @@ Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, b --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: zlib -Compression Level: 2 -Block Size: 8192 +Compression Type: none +Compression Level: 0 +Block Size: 32768 Checksum: t Check constraints: "ao_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 +Options: appendonly=true, orientation=row, blocksize=32768, compresslevel=0, checksum=true, compresstype=none Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: None +Compression Type: none Compression Level: 0 Block Size: 32768 Checksum: t @@ -955,7 +976,22 @@ Check constraints: "ao_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row +Options: appendonly=true, orientation=row, blocksize=32768, compresslevel=0, checksum=true, compresstype=none + + Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_60" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | +Compression Type: zlib +Compression Level: 2 +Block Size: 8192 +Checksum: t +Check constraints: + "ao_alter_add_part_no_compress_1_prt_60_check" CHECK (b >= 50 AND b < 60) +Inherits: ao_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 DROP TABLE ao_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index e2b2268a9b2f..897c5317eb39 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -860,6 +860,7 @@ CREATE TABLE aocs_alter_add_part(a int, b int) WITH (appendonly=true, orientatio SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); +ALTER TABLE aocs_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; @@ -876,7 +877,8 @@ Child tables: aocs_alter_add_part_1_prt_10, aocs_alter_add_part_1_prt_20, aocs_alter_add_part_1_prt_30, aocs_alter_add_part_1_prt_40, - aocs_alter_add_part_1_prt_50 + aocs_alter_add_part_1_prt_50, + aocs_alter_add_part_1_prt_60 Distributed by: (a) Partition by: (b) Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 @@ -927,7 +929,7 @@ Check constraints: "aocs_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536, checksum=true Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -939,7 +941,19 @@ Check constraints: "aocs_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536, checksum=true + + Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_60" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | zlib | 2 | 32768 | + b | integer | | plain | | zlib | 2 | 32768 | +Checksum: t +Check constraints: + "aocs_alter_add_part_1_prt_60_check" CHECK (b >= 50 AND b < 60) +Inherits: aocs_alter_add_part +Distributed by: (a) +Options: appendonly=true, orientation=column, compresslevel=2 DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -948,6 +962,7 @@ CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use gp_default_storage_options ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; @@ -964,7 +979,8 @@ Child tables: aocs_alter_add_part_no_compress_1_prt_10, aocs_alter_add_part_no_compress_1_prt_20, aocs_alter_add_part_no_compress_1_prt_30, aocs_alter_add_part_no_compress_1_prt_40, - aocs_alter_add_part_no_compress_1_prt_50 + aocs_alter_add_part_no_compress_1_prt_50, + aocs_alter_add_part_no_compress_1_prt_60 Distributed by: (a) Partition by: (b) Options: appendonly=true, orientation=column @@ -1008,14 +1024,14 @@ Options: appendonly=true, orientation=column, compresstype=rle_type, compresslev Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description --------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | zlib | 2 | 8192 | - b | integer | | plain | | zlib | 2 | 8192 | + a | integer | | plain | | none | 0 | 32768 | + b | integer | | plain | | none | 0 | 32768 | Checksum: t Check constraints: "aocs_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 +Options: appendonly=true, orientation=column, blocksize=32768, compresslevel=0, checksum=true, compresstype=none Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -1027,7 +1043,19 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column +Options: appendonly=true, orientation=column, blocksize=32768, compresslevel=0, checksum=true, compresstype=none + + Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_60" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | zlib | 2 | 8192 | + b | integer | | plain | | zlib | 2 | 8192 | +Checksum: t +Check constraints: + "aocs_alter_add_part_no_compress_1_prt_60_check" CHECK (b >= 50 AND b < 60) +Inherits: aocs_alter_add_part_no_compress +Distributed by: (a) +Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 DROP TABLE aocs_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/sql/alter_table_ao.sql b/src/test/regress/sql/alter_table_ao.sql index ceca8ece7db1..64e3dbf48666 100644 --- a/src/test/regress/sql/alter_table_ao.sql +++ b/src/test/regress/sql/alter_table_ao.sql @@ -457,6 +457,7 @@ CREATE TABLE ao_alter_add_part(a int, b int) WITH (appendonly=true, orientation= SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); +ALTER TABLE ao_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); -- use table setting ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; @@ -471,6 +472,7 @@ CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); -- use gp_default_storage_options ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; diff --git a/src/test/regress/sql/alter_table_aocs.sql b/src/test/regress/sql/alter_table_aocs.sql index c773135137ae..055a18efda5d 100644 --- a/src/test/regress/sql/alter_table_aocs.sql +++ b/src/test/regress/sql/alter_table_aocs.sql @@ -498,6 +498,7 @@ CREATE TABLE aocs_alter_add_part(a int, b int) WITH (appendonly=true, orientatio SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); +ALTER TABLE aocs_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; @@ -512,6 +513,7 @@ CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use gp_default_storage_options ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; From f907ab8950a4077d1532174c19fa0295389cb736 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 8 Nov 2023 13:35:51 +0500 Subject: [PATCH 06/40] fix doc --- gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml b/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml index 82aa15cc397a..0cbed07af5aa 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml @@ -786,7 +786,7 @@ where action is one of: If the partitioned table was originally defined using a subpartition template, then the template will be used to generate the subpartitions - automatically. + automatically.

    When you add a partition to an append-optimized, row-oriented or column-oriented table, Greenplum Database sets each parameter (appendonly, orientation, @@ -813,7 +813,7 @@ where action is one of: the server configuration parameter gp_default_storage_option. -

    +

    EXCHANGE [DEFAULT] PARTITION From 65a7686ea6aeebd542966ddf151c8e82ffd81206 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 8 Nov 2023 13:51:07 +0500 Subject: [PATCH 07/40] fix doc --- gpdb-doc/dita/ref_guide/config_params/guc_category-list.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpdb-doc/dita/ref_guide/config_params/guc_category-list.xml b/gpdb-doc/dita/ref_guide/config_params/guc_category-list.xml index 4290f9222693..5411aa7b5c97 100644 --- a/gpdb-doc/dita/ref_guide/config_params/guc_category-list.xml +++ b/gpdb-doc/dita/ref_guide/config_params/guc_category-list.xml @@ -1358,7 +1358,7 @@ >max_appendonly_tables

    gp_add_column_inherits_table_setting -

    gp_add_partition_inherits_table_setting

    Date: Wed, 8 Nov 2023 21:14:37 +0500 Subject: [PATCH 08/40] partial revert and fix test --- src/backend/access/common/reloptions_gp.c | 13 --------- src/backend/cdb/cdbpartition.c | 17 ----------- src/backend/commands/tablecmds.c | 2 +- src/backend/parser/parse_utilcmd.c | 12 ++++++++ src/include/access/reloptions.h | 2 -- src/include/commands/tablecmds.h | 2 -- src/test/regress/expected/alter_table_ao.out | 28 +++++++++---------- .../regress/expected/alter_table_aocs.out | 24 ++++++++-------- 8 files changed, 39 insertions(+), 61 deletions(-) diff --git a/src/backend/access/common/reloptions_gp.c b/src/backend/access/common/reloptions_gp.c index cb4544b8c06a..6d07cf9ed772 100644 --- a/src/backend/access/common/reloptions_gp.c +++ b/src/backend/access/common/reloptions_gp.c @@ -1358,19 +1358,6 @@ reloptions_has_opt(List *opts, const char *name) return false; } -DefElem * -reloptions_get_opt(List *opts, const char *name) -{ - ListCell *lc; - foreach(lc, opts) - { - DefElem *de = lfirst(lc); - if (pg_strcasecmp(de->defname, name) == 0) - return de; - } - return NULL; -} - /* * GPDB: Convenience function to build storage reloptions for a given relation, just for AO table . */ diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index 104ddbceed5d..732d21bef675 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -6771,23 +6771,6 @@ atpxPartAddList(Relation rel, if (pelem->storeAttr) ct->options = (List *) ((AlterPartitionCmd *) pelem->storeAttr)->arg1; - if (gp_add_partition_inherits_table_setting) - { - ListCell *lc; - List *opts = reloptions_list(RelationGetRelid(rel)); - - foreach(lc, ct->options) - { - DefElem *de = lfirst(lc); - DefElem *def = reloptions_get_opt(opts, de->defname); - - if (def != NULL) - *def = *de; - } - - ct->options = build_ao_rel_storage_opts(opts, rel); - } - ct->tableElts = list_concat(ct->tableElts, list_copy(colencs)); ct->oncommit = ONCOMMIT_NOOP; diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8b304dad77b1..a7150aa0fa5f 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -14393,7 +14393,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid, bool is_partitio /* * deparse pg_class.reloptions into a list. */ -List * +static List * reloptions_list(Oid relid) { Datum reloptions; diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index add3abd34bab..0b6678713fc9 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -4896,6 +4896,18 @@ transformAlterTable_all_PartitionStmt( /* No need to hold onto the lock -- see above */ heap_close(rel, AccessShareLock); } /* end if alter */ + else if (gp_add_partition_inherits_table_setting && + atc1->subtype == AT_PartAdd && + RelationIsAppendOptimized(pCxt->rel)) + { + PartitionElem *pelem = (PartitionElem *) pc->arg1; + AlterPartitionCmd *storenode = makeNode(AlterPartitionCmd); + List *opts = pelem->storeAttr ? ((AlterPartitionCmd *)pelem->storeAttr)->arg1 : list_make1(makeDefElem("appendonly", (Node *) makeString("true"))); + + storenode->arg1 = (Node *) build_ao_rel_storage_opts(opts, pCxt->rel); + storenode->location = -1; + pelem->storeAttr = (Node *) storenode; + } switch (atc1->subtype) { diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h index a1010ef47d27..741c9a93ffa3 100644 --- a/src/include/access/reloptions.h +++ b/src/include/access/reloptions.h @@ -21,7 +21,6 @@ #include "access/htup.h" #include "access/tupdesc.h" -#include "nodes/parsenodes.h" #include "nodes/pg_list.h" #include "utils/rel.h" @@ -319,7 +318,6 @@ extern void validate_and_refill_options(StdRdOptions *result, relopt_value *opti extern void validate_and_adjust_options(StdRdOptions *result, relopt_value *options, int num_options, relopt_kind kind, bool validate); extern bool reloptions_has_opt(List *opts, const char *name); -extern DefElem *reloptions_get_opt(List *opts, const char *name); extern List *build_ao_rel_storage_opts(List *opts, Relation rel); extern void free_options_deep(relopt_value *options, int num_options); #endif /* RELOPTIONS_H */ diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h index 48b8e995c515..6adee26dfde6 100644 --- a/src/include/commands/tablecmds.h +++ b/src/include/commands/tablecmds.h @@ -137,6 +137,4 @@ extern void RangeVarCallbackOwnsRelation(const RangeVar *relation, Oid relId, Oid oldRelId, void *noCatalogs); extern List * rel_get_column_encodings(Relation rel); - -extern List * reloptions_list(Oid relid); #endif /* TABLECMDS_H */ diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index e1c9fc631788..f9b0487ea7a3 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -817,7 +817,7 @@ Check constraints: "ao_alter_add_part_1_prt_30_check" CHECK (b >= 20 AND b < 30) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384 +Options: appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384, checksum=true Append-Only Table "public.ao_alter_add_part_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Description @@ -832,7 +832,7 @@ Check constraints: "ao_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536, checksum=true +Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=zstd, orientation=row Append-Only Table "public.ao_alter_add_part_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Description @@ -847,22 +847,22 @@ Check constraints: "ao_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536, checksum=true +Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=zstd, orientation=row Append-Only Table "public.ao_alter_add_part_1_prt_60" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: zlib -Compression Level: 2 -Block Size: 32768 +Compression Type: zstd +Compression Level: 4 +Block Size: 65536 Checksum: t Check constraints: "ao_alter_add_part_1_prt_60_check" CHECK (b >= 50 AND b < 60) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresslevel=2 +Options: appendonly=true, orientation=row, blocksize=65536, compresslevel=4, checksum=true, compresstype=zstd DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -946,7 +946,7 @@ Check constraints: "ao_alter_add_part_no_compress_1_prt_30_check" CHECK (b >= 20 AND b < 30) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384 +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384, checksum=true Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Description @@ -961,7 +961,7 @@ Check constraints: "ao_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=32768, compresslevel=0, checksum=true, compresstype=none +Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=row Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Description @@ -976,22 +976,22 @@ Check constraints: "ao_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=32768, compresslevel=0, checksum=true, compresstype=none +Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=row Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_60" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: zlib -Compression Level: 2 -Block Size: 8192 +Compression Type: none +Compression Level: 0 +Block Size: 32768 Checksum: t Check constraints: "ao_alter_add_part_no_compress_1_prt_60_check" CHECK (b >= 50 AND b < 60) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 +Options: appendonly=true, orientation=row, blocksize=32768, compresslevel=0, checksum=true, compresstype=none DROP TABLE ao_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index 70de68f50494..5ef31dee2364 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -914,7 +914,7 @@ Check constraints: "aocs_alter_add_part_1_prt_30_check" CHECK (b >= 20 AND b < 30) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384 +Options: appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384, checksum=true Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -926,7 +926,7 @@ Check constraints: "aocs_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536, checksum=true +Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=rle_type, orientation=column Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -938,19 +938,19 @@ Check constraints: "aocs_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536, checksum=true +Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=rle_type, orientation=column Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_60" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description --------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | zlib | 2 | 32768 | - b | integer | | plain | | zlib | 2 | 32768 | + a | integer | | plain | | rle_type | 4 | 65536 | + b | integer | | plain | | rle_type | 4 | 65536 | Checksum: t Check constraints: "aocs_alter_add_part_1_prt_60_check" CHECK (b >= 50 AND b < 60) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresslevel=2 +Options: appendonly=true, orientation=column, blocksize=65536, compresslevel=4, checksum=true, compresstype=rle_type DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -1016,7 +1016,7 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_30_check" CHECK (b >= 20 AND b < 30) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384 +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384, checksum=true Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -1028,7 +1028,7 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=32768, compresslevel=0, checksum=true, compresstype=none +Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=column Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -1040,19 +1040,19 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=32768, compresslevel=0, checksum=true, compresstype=none +Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=column Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_60" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description --------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | zlib | 2 | 8192 | - b | integer | | plain | | zlib | 2 | 8192 | + a | integer | | plain | | none | 0 | 32768 | + b | integer | | plain | | none | 0 | 32768 | Checksum: t Check constraints: "aocs_alter_add_part_no_compress_1_prt_60_check" CHECK (b >= 50 AND b < 60) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 +Options: appendonly=true, orientation=column, blocksize=32768, compresslevel=0, checksum=true, compresstype=none DROP TABLE aocs_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; From 83756418002a6d1e8ade46454cc3ebb6021b013e Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 8 Nov 2023 21:20:39 +0500 Subject: [PATCH 09/40] optimize --- src/backend/parser/parse_utilcmd.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 0b6678713fc9..36177568a7bc 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -4901,11 +4901,21 @@ transformAlterTable_all_PartitionStmt( RelationIsAppendOptimized(pCxt->rel)) { PartitionElem *pelem = (PartitionElem *) pc->arg1; - AlterPartitionCmd *storenode = makeNode(AlterPartitionCmd); - List *opts = pelem->storeAttr ? ((AlterPartitionCmd *)pelem->storeAttr)->arg1 : list_make1(makeDefElem("appendonly", (Node *) makeString("true"))); + AlterPartitionCmd *storenode = pelem->storeAttr; + List *opts; + + if (storenode != NULL) + { + opts = storenode->arg1; + } + else + { + storenode = makeNode(AlterPartitionCmd); + storenode->location = -1; + opts = list_make1(makeDefElem("appendonly", (Node *) makeString("true"))); + } storenode->arg1 = (Node *) build_ao_rel_storage_opts(opts, pCxt->rel); - storenode->location = -1; pelem->storeAttr = (Node *) storenode; } From 92019553b3f4f71f4c4b8a3f08725ddda16e478a Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 8 Nov 2023 21:21:34 +0500 Subject: [PATCH 10/40] space --- src/backend/parser/parse_utilcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 36177568a7bc..5f66e6ac4bfe 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -4904,7 +4904,7 @@ transformAlterTable_all_PartitionStmt( AlterPartitionCmd *storenode = pelem->storeAttr; List *opts; - if (storenode != NULL) + if (storenode != NULL) { opts = storenode->arg1; } From 3a41a931ea5245fc644c49f6566903dd45378e91 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 9 Nov 2023 08:23:41 +0500 Subject: [PATCH 11/40] split --- src/test/regress/expected/alter_table_ao.out | 46 +++++++++++-------- .../regress/expected/alter_table_aocs.out | 24 +++++----- src/test/regress/sql/alter_table_ao.sql | 12 ++--- src/test/regress/sql/alter_table_aocs.sql | 12 ++--- 4 files changed, 50 insertions(+), 44 deletions(-) diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index f9b0487ea7a3..fe2b783d4454 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -737,10 +737,8 @@ SELECT * FROM gp_toolkit.__gp_aoseg('ao_insert_empty_row'::regclass); -- test case: alter AO table add partition, the preference of the storage setting is: the encoding clause > table setting > gp_default_storage_options SET gp_add_partition_inherits_table_setting = on; CREATE TABLE ao_alter_add_part(a int, b int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, - PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_10" for table "ao_alter_add_part" -NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_20" for table "ao_alter_add_part" SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); @@ -748,6 +746,11 @@ NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_30" for tab ALTER TABLE ao_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_60" for table "ao_alter_add_part" -- use table setting +ALTER TABLE ao_alter_add_part SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); +NOTICE: exchanged partition "10" of relation "ao_alter_add_part" with relation "pg_temp_21823" +NOTICE: dropped partition "10" for relation "ao_alter_add_part" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_10" for table "ao_alter_add_part" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_20" for table "ao_alter_add_part" ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_40" for table "ao_alter_add_part" RESET gp_default_storage_options; @@ -784,7 +787,7 @@ Compression Level: 4 Block Size: 65536 Checksum: t Check constraints: - "ao_alter_add_part_1_prt_10_check" CHECK (b >= 1 AND b < 10) + "ao_alter_add_part_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: ao_alter_add_part Distributed by: (a) Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 @@ -799,7 +802,7 @@ Compression Level: 4 Block Size: 65536 Checksum: t Check constraints: - "ao_alter_add_part_1_prt_20_check" CHECK (b >= 11 AND b < 20) + "ao_alter_add_part_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: ao_alter_add_part Distributed by: (a) Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 @@ -866,21 +869,24 @@ Options: appendonly=true, orientation=row, blocksize=65536, compresslevel=4, che DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, - PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10" for table "ao_alter_add_part_no_compress" -NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_20" for table "ao_alter_add_part_no_compress" SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_30" for table "ao_alter_add_part_no_compress" ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_60" for table "ao_alter_add_part_no_compress" --- use gp_default_storage_options +-- use table setting +ALTER TABLE ao_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); +NOTICE: exchanged partition "10" of relation "ao_alter_add_part_no_compress" with relation "pg_temp_25089" +NOTICE: dropped partition "10" for relation "ao_alter_add_part_no_compress" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10" for table "ao_alter_add_part_no_compress" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_20" for table "ao_alter_add_part_no_compress" ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_40" for table "ao_alter_add_part_no_compress" RESET gp_default_storage_options; --- use default value +-- use table setting ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50" for table "ao_alter_add_part_no_compress" \d+ ao_alter_add_part_no_compress* @@ -908,30 +914,30 @@ Options: appendonly=true, orientation=row --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: None -Compression Level: 0 -Block Size: 32768 +Compression Type: zlib +Compression Level: 2 +Block Size: 8192 Checksum: t Check constraints: - "ao_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 1 AND b < 10) + "ao_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row +Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_20" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: None -Compression Level: 0 -Block Size: 32768 +Compression Type: zlib +Compression Level: 2 +Block Size: 8192 Checksum: t Check constraints: - "ao_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 11 AND b < 20) + "ao_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row +Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_30" Column | Type | Modifiers | Storage | Stats target | Description diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index 5ef31dee2364..49922120b3b0 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -852,13 +852,13 @@ RESET gp_add_column_inherits_table_setting; -- test case: alter AOCS table add partition, the preference of the storage setting is: the encoding clause > table setting > gp_default_storage_options SET gp_add_partition_inherits_table_setting = on; CREATE TABLE aocs_alter_add_part(a int, b int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, - PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); ALTER TABLE aocs_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting +ALTER TABLE aocs_alter_add_part SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; -- use table setting @@ -887,7 +887,7 @@ Options: appendonly=true, orientation=column, compresstype=rle_type, compresslev b | integer | | plain | | rle_type | 4 | 65536 | Checksum: t Check constraints: - "aocs_alter_add_part_1_prt_10_check" CHECK (b >= 1 AND b < 10) + "aocs_alter_add_part_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: aocs_alter_add_part Distributed by: (a) Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 @@ -899,7 +899,7 @@ Options: appendonly=true, orientation=column, compresstype=rle_type, compresslev b | integer | | plain | | rle_type | 4 | 65536 | Checksum: t Check constraints: - "aocs_alter_add_part_1_prt_20_check" CHECK (b >= 11 AND b < 20) + "aocs_alter_add_part_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: aocs_alter_add_part Distributed by: (a) Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 @@ -954,16 +954,16 @@ Options: appendonly=true, orientation=column, blocksize=65536, compresslevel=4, DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, - PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); --- use gp_default_storage_options +-- use table setting +ALTER TABLE aocs_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; --- use default value +-- use table setting ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; \d+ aocs_alter_add_part_no_compress* Append-Only Columnar Table "public.aocs_alter_add_part_no_compress" @@ -989,10 +989,10 @@ Options: appendonly=true, orientation=column b | integer | | plain | | none | 0 | 32768 | Checksum: t Check constraints: - "aocs_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 1 AND b < 10) + "aocs_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column +Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_20" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -1001,10 +1001,10 @@ Options: appendonly=true, orientation=column b | integer | | plain | | none | 0 | 32768 | Checksum: t Check constraints: - "aocs_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 11 AND b < 20) + "aocs_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column +Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_30" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description diff --git a/src/test/regress/sql/alter_table_ao.sql b/src/test/regress/sql/alter_table_ao.sql index 64e3dbf48666..e11c527d585d 100644 --- a/src/test/regress/sql/alter_table_ao.sql +++ b/src/test/regress/sql/alter_table_ao.sql @@ -452,13 +452,13 @@ SELECT * FROM gp_toolkit.__gp_aoseg('ao_insert_empty_row'::regclass); SET gp_add_partition_inherits_table_setting = on; CREATE TABLE ao_alter_add_part(a int, b int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, - PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); ALTER TABLE ao_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); -- use table setting +ALTER TABLE ao_alter_add_part SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; -- use table setting @@ -467,16 +467,16 @@ ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) E DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, - PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); --- use gp_default_storage_options +-- use table setting +ALTER TABLE ao_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; --- use default value +-- use table setting ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; \d+ ao_alter_add_part_no_compress* DROP TABLE ao_alter_add_part_no_compress; diff --git a/src/test/regress/sql/alter_table_aocs.sql b/src/test/regress/sql/alter_table_aocs.sql index 7bd374182596..085764bf6a54 100644 --- a/src/test/regress/sql/alter_table_aocs.sql +++ b/src/test/regress/sql/alter_table_aocs.sql @@ -490,13 +490,13 @@ RESET gp_add_column_inherits_table_setting; SET gp_add_partition_inherits_table_setting = on; CREATE TABLE aocs_alter_add_part(a int, b int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, - PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); ALTER TABLE aocs_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting +ALTER TABLE aocs_alter_add_part SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; -- use table setting @@ -505,16 +505,16 @@ ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (1) INCLUSIVE END (10) EXCLUSIVE, - PARTITION "20" START (11) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); --- use gp_default_storage_options +-- use table setting +ALTER TABLE aocs_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; --- use default value +-- use table setting ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; \d+ aocs_alter_add_part_no_compress* DROP TABLE aocs_alter_add_part_no_compress; From e157d5307624528da72f70b17073d7ed68ddc19c Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 9 Nov 2023 08:54:52 +0500 Subject: [PATCH 12/40] move logic and fix --- src/backend/access/common/reloptions_gp.c | 3 +++ src/backend/cdb/cdbpartition.c | 3 +++ src/backend/parser/parse_utilcmd.c | 22 ------------------- src/test/regress/expected/alter_table_ao.out | 20 ++++++++--------- .../regress/expected/alter_table_aocs.out | 8 +++---- 5 files changed, 20 insertions(+), 36 deletions(-) diff --git a/src/backend/access/common/reloptions_gp.c b/src/backend/access/common/reloptions_gp.c index 6d07cf9ed772..a0b1d5f11028 100644 --- a/src/backend/access/common/reloptions_gp.c +++ b/src/backend/access/common/reloptions_gp.c @@ -1364,6 +1364,9 @@ reloptions_has_opt(List *opts, const char *name) List * build_ao_rel_storage_opts(List *opts, Relation rel) { + if (!reloptions_has_opt(opts, "appendonly")) + opts = lappend(opts, makeDefElem("appendonly", (Node *) makeString("true"))); + if (!reloptions_has_opt(opts, "blocksize")) opts = lappend(opts, makeDefElem("blocksize", (Node *) makeInteger(rel->rd_appendonly->blocksize))); diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index 732d21bef675..94112a99abb0 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -6771,6 +6771,9 @@ atpxPartAddList(Relation rel, if (pelem->storeAttr) ct->options = (List *) ((AlterPartitionCmd *) pelem->storeAttr)->arg1; + if (gp_add_partition_inherits_table_setting && RelationIsAppendOptimized(rel)) + ct->options = build_ao_rel_storage_opts(ct->options, rel); + ct->tableElts = list_concat(ct->tableElts, list_copy(colencs)); ct->oncommit = ONCOMMIT_NOOP; diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 5f66e6ac4bfe..add3abd34bab 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -4896,28 +4896,6 @@ transformAlterTable_all_PartitionStmt( /* No need to hold onto the lock -- see above */ heap_close(rel, AccessShareLock); } /* end if alter */ - else if (gp_add_partition_inherits_table_setting && - atc1->subtype == AT_PartAdd && - RelationIsAppendOptimized(pCxt->rel)) - { - PartitionElem *pelem = (PartitionElem *) pc->arg1; - AlterPartitionCmd *storenode = pelem->storeAttr; - List *opts; - - if (storenode != NULL) - { - opts = storenode->arg1; - } - else - { - storenode = makeNode(AlterPartitionCmd); - storenode->location = -1; - opts = list_make1(makeDefElem("appendonly", (Node *) makeString("true"))); - } - - storenode->arg1 = (Node *) build_ao_rel_storage_opts(opts, pCxt->rel); - pelem->storeAttr = (Node *) storenode; - } switch (atc1->subtype) { diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index fe2b783d4454..2277950c591c 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -790,7 +790,7 @@ Check constraints: "ao_alter_add_part_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536, checksum=true Append-Only Table "public.ao_alter_add_part_1_prt_20" Column | Type | Modifiers | Storage | Stats target | Description @@ -805,7 +805,7 @@ Check constraints: "ao_alter_add_part_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536, checksum=true Append-Only Table "public.ao_alter_add_part_1_prt_30" Column | Type | Modifiers | Storage | Stats target | Description @@ -914,30 +914,30 @@ Options: appendonly=true, orientation=row --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: zlib -Compression Level: 2 -Block Size: 8192 +Compression Type: none +Compression Level: 0 +Block Size: 32768 Checksum: t Check constraints: "ao_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 +Options: appendonly=true, orientation=row, blocksize=32768, compresslevel=0, checksum=true, compresstype=none Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_20" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: zlib -Compression Level: 2 -Block Size: 8192 +Compression Type: none +Compression Level: 0 +Block Size: 32768 Checksum: t Check constraints: "ao_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 +Options: appendonly=true, orientation=row, blocksize=32768, compresslevel=0, checksum=true, compresstype=none Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_30" Column | Type | Modifiers | Storage | Stats target | Description diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index 49922120b3b0..723fa2993e47 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -890,7 +890,7 @@ Check constraints: "aocs_alter_add_part_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536, checksum=true Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_20" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -902,7 +902,7 @@ Check constraints: "aocs_alter_add_part_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536, checksum=true Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_30" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -992,7 +992,7 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 +Options: appendonly=true, orientation=column, blocksize=32768, compresslevel=0, checksum=true, compresstype=none Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_20" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -1004,7 +1004,7 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 +Options: appendonly=true, orientation=column, blocksize=32768, compresslevel=0, checksum=true, compresstype=none Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_30" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description From e6792bff697d353dcc49d79e5d1b8f591f4119d9 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 9 Nov 2023 17:26:31 +0500 Subject: [PATCH 13/40] add checksum to doc --- gpdb-doc/dita/ref_guide/config_params/guc-list.xml | 5 +++-- gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml | 2 +- gpdb-doc/markdown/ref_guide/config_params/guc-list.html.md | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gpdb-doc/dita/ref_guide/config_params/guc-list.xml b/gpdb-doc/dita/ref_guide/config_params/guc-list.xml index 8d1ce1e4bc95..1eb5c855aa8a 100644 --- a/gpdb-doc/dita/ref_guide/config_params/guc-list.xml +++ b/gpdb-doc/dita/ref_guide/config_params/guc-list.xml @@ -2263,13 +2263,14 @@

    When adding a partition to an append-optimized, row-oriented or column-oriented table with the ALTER TABLE command, this parameter controls whether the table's parameters (appendonly, orientation, - compresstype, compresslevel, and + compresstype, compresslevel, checksum and blocksize) can be inherited from the table values. The default is off, the table's settings are not considered when adding a partition to the table. If the value is on, the table's settings are considered.

    When you create an append-optimized row-oriented or column-oriented table, you can set the table's - parameters appendonly, orientation, compresstype, compresslevel, and + parameters appendonly, orientation, compresstype, + compresslevel, checksum and blocksize for the table in the WITH clause. When you add a partition, Greenplum Database sets each parameter based on one of the following settings, in order of preference.

      diff --git a/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml b/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml index 0cbed07af5aa..36d8f9b9d074 100644 --- a/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml +++ b/gpdb-doc/dita/ref_guide/sql_commands/ALTER_TABLE.xml @@ -791,7 +791,7 @@ where action is one of: append-optimized, row-oriented or column-oriented table, Greenplum Database sets each parameter (appendonly, orientation, compresstype, - compresslevel, and + compresslevel, checksum and blocksize) based on the following setting, in order of preference.
        diff --git a/gpdb-doc/markdown/ref_guide/config_params/guc-list.html.md b/gpdb-doc/markdown/ref_guide/config_params/guc-list.html.md index 8769df882091..0ef162688ee4 100644 --- a/gpdb-doc/markdown/ref_guide/config_params/guc-list.html.md +++ b/gpdb-doc/markdown/ref_guide/config_params/guc-list.html.md @@ -439,9 +439,9 @@ For information about the data storage compression parameters, see [CREATE TABLE ## gp\_add\_partition\_inherits\_table\_setting -When adding a partition to an append-optimized, row-oriented or column-oriented table with the [ALTER TABLE](../sql_commands/ALTER_TABLE.html) command, this parameter controls whether the table's parameters \(`appendonly`, `orientation`, `compresstype`, `compresslevel`, and `blocksize`\) can be inherited from the table. The default is `off`, the table's settings are not considered when adding a partition to the table. If the value is `on`, the table's settings are considered. +When adding a partition to an append-optimized, row-oriented or column-oriented table with the [ALTER TABLE](../sql_commands/ALTER_TABLE.html) command, this parameter controls whether the table's parameters \(`appendonly`, `orientation`, `compresstype`, `compresslevel`, `checksum` and `blocksize`\) can be inherited from the table. The default is `off`, the table's settings are not considered when adding a partition to the table. If the value is `on`, the table's settings are considered. -When you create an append-optimized row-oriented or column-oriented table, you can set the table's parameters `appendonly`, `orientation`, `compresstype`, `compresslevel`, and `blocksize` for the table in the `WITH` clause. When you add a partition, Greenplum Database sets each parameter based on one of the following settings, in order of preference. +When you create an append-optimized row-oriented or column-oriented table, you can set the table's parameters `appendonly`, `orientation`, `compresstype`, `compresslevel`, `checksum` and `blocksize` for the table in the `WITH` clause. When you add a partition, Greenplum Database sets each parameter based on one of the following settings, in order of preference. 1. The setting specified in the `ALTER TABLE` command `WITH` clause. 2. If this server configuration parameter is set to `on`, the table's setting specified in the `WITH` clause when the table was created. Otherwise, the table's setting is ignored. From 029382471ce89c2adfefb1c4c857958ec6f5a12f Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Thu, 3 Oct 2024 11:35:34 +0500 Subject: [PATCH 14/40] abi --- .abi-check/6.27.1_arenadata57/postgres.symbols.ignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .abi-check/6.27.1_arenadata57/postgres.symbols.ignore diff --git a/.abi-check/6.27.1_arenadata57/postgres.symbols.ignore b/.abi-check/6.27.1_arenadata57/postgres.symbols.ignore new file mode 100644 index 000000000000..aa4c33e2be25 --- /dev/null +++ b/.abi-check/6.27.1_arenadata57/postgres.symbols.ignore @@ -0,0 +1 @@ +ConfigureNamesBool_gp From d17b6ac4bbd7b6f4fc9bd47534d24701f59eac4a Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 8 Oct 2024 18:27:56 +0500 Subject: [PATCH 15/40] direct copy opts --- src/backend/access/common/reloptions_gp.c | 64 +++++++++++++------ src/backend/cdb/cdbpartition.c | 2 +- src/test/regress/expected/alter_table_ao.out | 52 +++++++-------- .../regress/expected/alter_table_aocs.out | 46 +++++++------ 4 files changed, 95 insertions(+), 69 deletions(-) diff --git a/src/backend/access/common/reloptions_gp.c b/src/backend/access/common/reloptions_gp.c index d66c732215e8..708888eab833 100644 --- a/src/backend/access/common/reloptions_gp.c +++ b/src/backend/access/common/reloptions_gp.c @@ -29,6 +29,7 @@ #include "utils/formatting.h" #include "utils/guc.h" #include "utils/memutils.h" +#include "utils/syscache.h" #include "miscadmin.h" #include "nodes/makefuncs.h" #include "storage/gp_compress.h" @@ -1365,30 +1366,57 @@ reloptions_has_opt(List *opts, const char *name) List * build_ao_rel_storage_opts(List *opts, Relation rel) { - if (!reloptions_has_opt(opts, "appendonly")) - opts = lappend(opts, makeDefElem("appendonly", (Node *) makeString("true"))); + Oid relid = RelationGetRelid(rel); + HeapTuple tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); - if (!reloptions_has_opt(opts, "blocksize")) - opts = lappend(opts, makeDefElem("blocksize", (Node *) makeInteger(rel->rd_appendonly->blocksize))); + if (!HeapTupleIsValid(tuple)) + elog(ERROR, "cache lookup failed for relation %u", relid); - if (!reloptions_has_opt(opts, "compresslevel")) - opts = lappend(opts, makeDefElem("compresslevel", (Node *) makeInteger(rel->rd_appendonly->compresslevel))); + bool isnull; + Datum reloptions = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions, &isnull); - if (!reloptions_has_opt(opts, "checksum")) - opts = lappend(opts, makeDefElem("checksum", (Node *) makeInteger(rel->rd_appendonly->checksum))); - - if (!reloptions_has_opt(opts, "compresstype")) + if (PointerIsValid(DatumGetPointer(reloptions))) { - char *compresstype = rel->rd_appendonly->compresstype.data; - compresstype = (compresstype && compresstype[0]) ? pnstrdup(compresstype, strlen(compresstype)) : "none"; - opts = lappend(opts, makeDefElem("compresstype", (Node *) makeString(compresstype))); - } + ArrayType *array = DatumGetArrayTypeP(reloptions); + Datum *oldoptions; + List *newopts = NIL; + int noldoptions; + int i; - if (!reloptions_has_opt(opts, "orientation")) - { - char *orientation = rel->rd_appendonly->columnstore ? "column" : "row"; - opts = lappend(opts, makeDefElem("orientation", (Node *) makeString(orientation))); + deconstruct_array(array, TEXTOID, -1, false, 'i', + &oldoptions, NULL, &noldoptions); + + for (i = 0; i < noldoptions; i++) + { + ListCell *cell; + text *oldoption = DatumGetTextP(oldoptions[i]); + char *text_str = VARDATA(oldoption); + int text_len = VARSIZE(oldoption) - VARHDRSZ; + + foreach(cell, opts) + { + DefElem *def = (DefElem *) lfirst(cell); + int kw_len = strlen(def->defname); + + if (text_len > kw_len && text_str[kw_len] == '=' && + pg_strncasecmp(text_str, def->defname, kw_len) == 0) + break; + } + + if (!cell) { + char *equal = strchr(text_str, '='); + + if (equal) { + text_str[equal - text_str] = '\0'; + newopts = lappend(newopts, makeDefElem(text_str, (Node *) makeString(equal + 1))); + } + } + } + + opts = list_concat(opts, newopts); } + ReleaseSysCache(tuple); + return opts; } diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index 6e6ccc8b2be5..80c2a64a6866 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -6784,7 +6784,7 @@ atpxPartAddList(Relation rel, if (pelem->storeAttr) ct->options = (List *) ((AlterPartitionCmd *) pelem->storeAttr)->arg1; - if (gp_add_partition_inherits_table_setting && RelationIsAppendOptimized(rel)) + if (gp_add_partition_inherits_table_setting) ct->options = build_ao_rel_storage_opts(ct->options, rel); ct->tableElts = list_concat(ct->tableElts, list_copy(colencs)); diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index 2277950c591c..36717a8ab5d9 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -790,7 +790,7 @@ Check constraints: "ao_alter_add_part_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536, checksum=true +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 Append-Only Table "public.ao_alter_add_part_1_prt_20" Column | Type | Modifiers | Storage | Stats target | Description @@ -805,7 +805,7 @@ Check constraints: "ao_alter_add_part_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536, checksum=true +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 Append-Only Table "public.ao_alter_add_part_1_prt_30" Column | Type | Modifiers | Storage | Stats target | Description @@ -820,7 +820,7 @@ Check constraints: "ao_alter_add_part_1_prt_30_check" CHECK (b >= 20 AND b < 30) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384, checksum=true +Options: appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384 Append-Only Table "public.ao_alter_add_part_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Description @@ -835,7 +835,7 @@ Check constraints: "ao_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=zstd, orientation=row +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 Append-Only Table "public.ao_alter_add_part_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Description @@ -850,7 +850,7 @@ Check constraints: "ao_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=zstd, orientation=row +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 Append-Only Table "public.ao_alter_add_part_1_prt_60" Column | Type | Modifiers | Storage | Stats target | Description @@ -865,7 +865,7 @@ Check constraints: "ao_alter_add_part_1_prt_60_check" CHECK (b >= 50 AND b < 60) Inherits: ao_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=65536, compresslevel=4, checksum=true, compresstype=zstd +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -879,7 +879,7 @@ ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIV NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_60" for table "ao_alter_add_part_no_compress" -- use table setting ALTER TABLE ao_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); -NOTICE: exchanged partition "10" of relation "ao_alter_add_part_no_compress" with relation "pg_temp_25089" +NOTICE: exchanged partition "10" of relation "ao_alter_add_part_no_compress" with relation "pg_temp_25798" NOTICE: dropped partition "10" for relation "ao_alter_add_part_no_compress" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10" for table "ao_alter_add_part_no_compress" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_20" for table "ao_alter_add_part_no_compress" @@ -914,30 +914,30 @@ Options: appendonly=true, orientation=row --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: none -Compression Level: 0 -Block Size: 32768 +Compression Type: zlib +Compression Level: 2 +Block Size: 8192 Checksum: t Check constraints: "ao_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=32768, compresslevel=0, checksum=true, compresstype=none +Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_20" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: none -Compression Level: 0 -Block Size: 32768 +Compression Type: zlib +Compression Level: 2 +Block Size: 8192 Checksum: t Check constraints: "ao_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=32768, compresslevel=0, checksum=true, compresstype=none +Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_30" Column | Type | Modifiers | Storage | Stats target | Description @@ -952,29 +952,29 @@ Check constraints: "ao_alter_add_part_no_compress_1_prt_30_check" CHECK (b >= 20 AND b < 30) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384, checksum=true +Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384 Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: none -Compression Level: 0 -Block Size: 32768 +Compression Type: zlib +Compression Level: 2 +Block Size: 8192 Checksum: t Check constraints: "ao_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=row +Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: none +Compression Type: None Compression Level: 0 Block Size: 32768 Checksum: t @@ -982,22 +982,22 @@ Check constraints: "ao_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=row +Options: appendonly=true, orientation=row Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_60" Column | Type | Modifiers | Storage | Stats target | Description --------+---------+-----------+---------+--------------+------------- a | integer | | plain | | b | integer | | plain | | -Compression Type: none -Compression Level: 0 -Block Size: 32768 +Compression Type: zlib +Compression Level: 2 +Block Size: 8192 Checksum: t Check constraints: "ao_alter_add_part_no_compress_1_prt_60_check" CHECK (b >= 50 AND b < 60) Inherits: ao_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=32768, compresslevel=0, checksum=true, compresstype=none +Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 DROP TABLE ao_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index 723fa2993e47..60b5a54c54ad 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -890,7 +890,7 @@ Check constraints: "aocs_alter_add_part_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536, checksum=true +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_20" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -902,7 +902,7 @@ Check constraints: "aocs_alter_add_part_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536, checksum=true +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_30" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -914,31 +914,29 @@ Check constraints: "aocs_alter_add_part_1_prt_30_check" CHECK (b >= 20 AND b < 30) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384, checksum=true +Options: appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384 Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description --------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | rle_type | 4 | 65536 | - b | integer | | plain | | rle_type | 4 | 65536 | + a | integer | | plain | | zlib | 2 | 32768 | + b | integer | | plain | | zlib | 2 | 32768 | Checksum: t Check constraints: "aocs_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=rle_type, orientation=column +Options: appendonly=true, orientation=column, compresslevel=2 - Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_50" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | rle_type | 4 | 65536 | - b | integer | | plain | | rle_type | 4 | 65536 | -Checksum: t + Table "public.aocs_alter_add_part_1_prt_50" + Column | Type | Modifiers | Storage | Stats target | Description +--------+---------+-----------+---------+--------------+------------- + a | integer | | plain | | + b | integer | | plain | | Check constraints: "aocs_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, blocksize=65536, compresslevel=4, checksum=true, compresstype=rle_type, orientation=column Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_60" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -950,7 +948,7 @@ Check constraints: "aocs_alter_add_part_1_prt_60_check" CHECK (b >= 50 AND b < 60) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=65536, compresslevel=4, checksum=true, compresstype=rle_type +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -992,7 +990,7 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 0 AND b < 10) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=32768, compresslevel=0, checksum=true, compresstype=none +Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_20" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -1004,7 +1002,7 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 10 AND b < 20) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=32768, compresslevel=0, checksum=true, compresstype=none +Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_30" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -1016,19 +1014,19 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_30_check" CHECK (b >= 20 AND b < 30) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384, checksum=true +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384 Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description --------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | none | 0 | 32768 | - b | integer | | plain | | none | 0 | 32768 | + a | integer | | plain | | zlib | 2 | 8192 | + b | integer | | plain | | zlib | 2 | 8192 | Checksum: t Check constraints: "aocs_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=column +Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_50" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -1040,19 +1038,19 @@ Check constraints: "aocs_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, blocksize=32768, compresslevel=0, checksum=true, compresstype=none, orientation=column +Options: appendonly=true, orientation=column Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_60" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description --------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | none | 0 | 32768 | - b | integer | | plain | | none | 0 | 32768 | + a | integer | | plain | | zlib | 2 | 8192 | + b | integer | | plain | | zlib | 2 | 8192 | Checksum: t Check constraints: "aocs_alter_add_part_no_compress_1_prt_60_check" CHECK (b >= 50 AND b < 60) Inherits: aocs_alter_add_part_no_compress Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=32768, compresslevel=0, checksum=true, compresstype=none +Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 DROP TABLE aocs_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; From ce6b5ee13c39a1e0cdf41381d85693085293f3c9 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 8 Oct 2024 19:19:53 +0500 Subject: [PATCH 16/40] optimize --- src/backend/access/common/reloptions_gp.c | 59 +++++-------------- src/backend/commands/tablecmds.c | 2 +- src/include/commands/tablecmds.h | 2 + src/test/regress/expected/alter_table_ao.out | 2 + .../regress/expected/alter_table_aocs.out | 20 ++++--- src/test/regress/sql/alter_table_ao.sql | 2 + src/test/regress/sql/alter_table_aocs.sql | 2 + 7 files changed, 35 insertions(+), 54 deletions(-) diff --git a/src/backend/access/common/reloptions_gp.c b/src/backend/access/common/reloptions_gp.c index 708888eab833..beefe95ed25a 100644 --- a/src/backend/access/common/reloptions_gp.c +++ b/src/backend/access/common/reloptions_gp.c @@ -24,12 +24,12 @@ #include "access/reloptions.h" #include "cdb/cdbappendonlyam.h" #include "cdb/cdbvars.h" +#include "commands/tablecmds.h" #include "utils/array.h" #include "utils/builtins.h" #include "utils/formatting.h" #include "utils/guc.h" #include "utils/memutils.h" -#include "utils/syscache.h" #include "miscadmin.h" #include "nodes/makefuncs.h" #include "storage/gp_compress.h" @@ -1366,57 +1366,26 @@ reloptions_has_opt(List *opts, const char *name) List * build_ao_rel_storage_opts(List *opts, Relation rel) { - Oid relid = RelationGetRelid(rel); - HeapTuple tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); + ListCell *cell; + List *relopts = reloptions_list(RelationGetRelid(rel)); + List *retopts = NIL; - if (!HeapTupleIsValid(tuple)) - elog(ERROR, "cache lookup failed for relation %u", relid); - - bool isnull; - Datum reloptions = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions, &isnull); - - if (PointerIsValid(DatumGetPointer(reloptions))) + foreach(cell, relopts) { - ArrayType *array = DatumGetArrayTypeP(reloptions); - Datum *oldoptions; - List *newopts = NIL; - int noldoptions; - int i; - - deconstruct_array(array, TEXTOID, -1, false, 'i', - &oldoptions, NULL, &noldoptions); + DefElem *def = lfirst(cell); + ListCell *cl; - for (i = 0; i < noldoptions; i++) + foreach(cl, opts) { - ListCell *cell; - text *oldoption = DatumGetTextP(oldoptions[i]); - char *text_str = VARDATA(oldoption); - int text_len = VARSIZE(oldoption) - VARHDRSZ; - - foreach(cell, opts) - { - DefElem *def = (DefElem *) lfirst(cell); - int kw_len = strlen(def->defname); - - if (text_len > kw_len && text_str[kw_len] == '=' && - pg_strncasecmp(text_str, def->defname, kw_len) == 0) - break; - } - - if (!cell) { - char *equal = strchr(text_str, '='); + DefElem *de = lfirst(cl); - if (equal) { - text_str[equal - text_str] = '\0'; - newopts = lappend(newopts, makeDefElem(text_str, (Node *) makeString(equal + 1))); - } - } + if (pg_strcasecmp(de->defname, def->defname) == 0) + break; } - opts = list_concat(opts, newopts); + if (!cl) + retopts = lappend(retopts, def); } - ReleaseSysCache(tuple); - - return opts; + return list_concat(opts, retopts); } diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 76ed72ab4c28..603e1d3e3105 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -14396,7 +14396,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid, bool is_partitio /* * deparse pg_class.reloptions into a list. */ -static List * +List * reloptions_list(Oid relid) { Datum reloptions; diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h index 6adee26dfde6..48b8e995c515 100644 --- a/src/include/commands/tablecmds.h +++ b/src/include/commands/tablecmds.h @@ -137,4 +137,6 @@ extern void RangeVarCallbackOwnsRelation(const RangeVar *relation, Oid relId, Oid oldRelId, void *noCatalogs); extern List * rel_get_column_encodings(Relation rel); + +extern List * reloptions_list(Oid relid); #endif /* TABLECMDS_H */ diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index 36717a8ab5d9..1a2e6f889ab5 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -757,6 +757,7 @@ RESET gp_default_storage_options; -- use table setting ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50" for table "ao_alter_add_part" +RESET gp_default_storage_options; \d+ ao_alter_add_part* Append-Only Table "public.ao_alter_add_part" Column | Type | Modifiers | Storage | Stats target | Description @@ -889,6 +890,7 @@ RESET gp_default_storage_options; -- use table setting ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50" for table "ao_alter_add_part_no_compress" +RESET gp_default_storage_options; \d+ ao_alter_add_part_no_compress* Append-Only Table "public.ao_alter_add_part_no_compress" Column | Type | Modifiers | Storage | Stats target | Description diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index 60b5a54c54ad..e2dd89bea6ed 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -863,6 +863,7 @@ ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) RESET gp_default_storage_options; -- use table setting ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +RESET gp_default_storage_options; \d+ aocs_alter_add_part* Append-Only Columnar Table "public.aocs_alter_add_part" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -919,24 +920,26 @@ Options: appendonly=true, orientation=column, compresstype=zlib, compresslevel=3 Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_40" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description --------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | zlib | 2 | 32768 | - b | integer | | plain | | zlib | 2 | 32768 | + a | integer | | plain | | rle_type | 4 | 65536 | + b | integer | | plain | | rle_type | 4 | 65536 | Checksum: t Check constraints: "aocs_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) Inherits: aocs_alter_add_part Distributed by: (a) -Options: appendonly=true, orientation=column, compresslevel=2 +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 - Table "public.aocs_alter_add_part_1_prt_50" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | + Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_50" + Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description +--------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- + a | integer | | plain | | rle_type | 4 | 65536 | + b | integer | | plain | | rle_type | 4 | 65536 | +Checksum: t Check constraints: "aocs_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) Inherits: aocs_alter_add_part Distributed by: (a) +Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_60" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description @@ -963,6 +966,7 @@ ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUS RESET gp_default_storage_options; -- use table setting ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +RESET gp_default_storage_options; \d+ aocs_alter_add_part_no_compress* Append-Only Columnar Table "public.aocs_alter_add_part_no_compress" Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description diff --git a/src/test/regress/sql/alter_table_ao.sql b/src/test/regress/sql/alter_table_ao.sql index e11c527d585d..957f5aac2d08 100644 --- a/src/test/regress/sql/alter_table_ao.sql +++ b/src/test/regress/sql/alter_table_ao.sql @@ -463,6 +463,7 @@ ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) E RESET gp_default_storage_options; -- use table setting ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +RESET gp_default_storage_options; \d+ ao_alter_add_part* DROP TABLE ao_alter_add_part; @@ -478,6 +479,7 @@ ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIV RESET gp_default_storage_options; -- use table setting ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +RESET gp_default_storage_options; \d+ ao_alter_add_part_no_compress* DROP TABLE ao_alter_add_part_no_compress; diff --git a/src/test/regress/sql/alter_table_aocs.sql b/src/test/regress/sql/alter_table_aocs.sql index 085764bf6a54..bfdf6e040ea1 100644 --- a/src/test/regress/sql/alter_table_aocs.sql +++ b/src/test/regress/sql/alter_table_aocs.sql @@ -501,6 +501,7 @@ ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) RESET gp_default_storage_options; -- use table setting ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +RESET gp_default_storage_options; \d+ aocs_alter_add_part* DROP TABLE aocs_alter_add_part; @@ -516,6 +517,7 @@ ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUS RESET gp_default_storage_options; -- use table setting ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; +RESET gp_default_storage_options; \d+ aocs_alter_add_part_no_compress* DROP TABLE aocs_alter_add_part_no_compress; From 907cdf92950ec50f50c5882ff159fd4fb0406554 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 8 Oct 2024 19:21:19 +0500 Subject: [PATCH 17/40] optimize --- src/backend/access/common/reloptions_gp.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/backend/access/common/reloptions_gp.c b/src/backend/access/common/reloptions_gp.c index beefe95ed25a..c9f34c2e9093 100644 --- a/src/backend/access/common/reloptions_gp.c +++ b/src/backend/access/common/reloptions_gp.c @@ -1373,17 +1373,8 @@ build_ao_rel_storage_opts(List *opts, Relation rel) foreach(cell, relopts) { DefElem *def = lfirst(cell); - ListCell *cl; - foreach(cl, opts) - { - DefElem *de = lfirst(cl); - - if (pg_strcasecmp(de->defname, def->defname) == 0) - break; - } - - if (!cl) + if (!reloptions_has_opt(opts, def->defname)) retopts = lappend(retopts, def); } From 06e02e5e2447b4ba6a22b8111df60face7f8d3ec Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 8 Oct 2024 19:53:32 +0500 Subject: [PATCH 18/40] simplify --- src/backend/access/common/reloptions_gp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/reloptions_gp.c b/src/backend/access/common/reloptions_gp.c index c9f34c2e9093..790800aac34b 100644 --- a/src/backend/access/common/reloptions_gp.c +++ b/src/backend/access/common/reloptions_gp.c @@ -1368,7 +1368,7 @@ build_ao_rel_storage_opts(List *opts, Relation rel) { ListCell *cell; List *relopts = reloptions_list(RelationGetRelid(rel)); - List *retopts = NIL; + List *retopts = opts; foreach(cell, relopts) { @@ -1378,5 +1378,5 @@ build_ao_rel_storage_opts(List *opts, Relation rel) retopts = lappend(retopts, def); } - return list_concat(opts, retopts); + return retopts; } From 9db9a457655ff788668910f8b7f0024e5a76dc36 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 8 Oct 2024 19:56:15 +0500 Subject: [PATCH 19/40] optimize --- src/backend/access/common/reloptions_gp.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/backend/access/common/reloptions_gp.c b/src/backend/access/common/reloptions_gp.c index 790800aac34b..a807146d0e39 100644 --- a/src/backend/access/common/reloptions_gp.c +++ b/src/backend/access/common/reloptions_gp.c @@ -1366,17 +1366,16 @@ reloptions_has_opt(List *opts, const char *name) List * build_ao_rel_storage_opts(List *opts, Relation rel) { - ListCell *cell; - List *relopts = reloptions_list(RelationGetRelid(rel)); - List *retopts = opts; + ListCell *lc; + List *res = opts; - foreach(cell, relopts) + foreach(lc, reloptions_list(RelationGetRelid(rel))) { - DefElem *def = lfirst(cell); + DefElem *de = lfirst(lc); - if (!reloptions_has_opt(opts, def->defname)) - retopts = lappend(retopts, def); + if (!reloptions_has_opt(opts, de->defname)) + res = lappend(res, de); } - return retopts; + return res; } From b8967818a651f9a15018e2733cc8f4d2d700be29 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 9 Oct 2024 08:26:03 +0500 Subject: [PATCH 20/40] fix --- src/test/regress/expected/expand_table_ao.out | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/regress/expected/expand_table_ao.out b/src/test/regress/expected/expand_table_ao.out index fe96007a0280..ebb69c436afc 100644 --- a/src/test/regress/expected/expand_table_ao.out +++ b/src/test/regress/expected/expand_table_ao.out @@ -860,7 +860,7 @@ from gp_distribution_policy where localoid = 't_9526'::regclass::oid; select blocksize,compresslevel,checksum,compresstype,columnstore from pg_appendonly where relid='t_9526'::regclass::oid; blocksize | compresslevel | checksum | compresstype | columnstore -----------+---------------+----------+--------------+------------- - 32768 | 0 | t | none | f + 32768 | 0 | t | | f (1 row) -- set back @@ -899,7 +899,7 @@ select relname, relstorage from pg_class where relname = 't_9527'; select blocksize,compresslevel,checksum,compresstype,columnstore from pg_appendonly where relid='t_9527'::regclass::oid; blocksize | compresslevel | checksum | compresstype | columnstore -----------+---------------+----------+--------------+------------- - 32768 | 0 | t | none | f + 32768 | 0 | t | | f (1 row) -- set back @@ -932,7 +932,7 @@ select relname, relstorage from pg_class where relname = 't_9528'; select blocksize,compresslevel,checksum,compresstype,columnstore from pg_appendonly where relid='t_9528'::regclass::oid; blocksize | compresslevel | checksum | compresstype | columnstore -----------+---------------+----------+--------------+------------- - 32768 | 0 | t | none | f + 32768 | 0 | t | | f (1 row) -- set back From 42ac8d5fed8521ad6a32737d4d50b3af907f14d0 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 9 Oct 2024 08:59:41 +0500 Subject: [PATCH 21/40] move and fix --- src/backend/access/common/reloptions_gp.c | 26 +++++++++++++------ src/backend/cdb/cdbpartition.c | 15 ++++++++++- src/test/regress/expected/expand_table_ao.out | 6 ++--- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/backend/access/common/reloptions_gp.c b/src/backend/access/common/reloptions_gp.c index a807146d0e39..ee835ec73ecc 100644 --- a/src/backend/access/common/reloptions_gp.c +++ b/src/backend/access/common/reloptions_gp.c @@ -24,7 +24,6 @@ #include "access/reloptions.h" #include "cdb/cdbappendonlyam.h" #include "cdb/cdbvars.h" -#include "commands/tablecmds.h" #include "utils/array.h" #include "utils/builtins.h" #include "utils/formatting.h" @@ -1366,16 +1365,27 @@ reloptions_has_opt(List *opts, const char *name) List * build_ao_rel_storage_opts(List *opts, Relation rel) { - ListCell *lc; - List *res = opts; + if (!reloptions_has_opt(opts, "blocksize")) + opts = lappend(opts, makeDefElem("blocksize", (Node *) makeInteger(rel->rd_appendonly->blocksize))); + + if (!reloptions_has_opt(opts, "compresslevel")) + opts = lappend(opts, makeDefElem("compresslevel", (Node *) makeInteger(rel->rd_appendonly->compresslevel))); + + if (!reloptions_has_opt(opts, "checksum")) + opts = lappend(opts, makeDefElem("checksum", (Node *) makeInteger(rel->rd_appendonly->checksum))); - foreach(lc, reloptions_list(RelationGetRelid(rel))) + if (!reloptions_has_opt(opts, "compresstype")) { - DefElem *de = lfirst(lc); + char *compresstype = rel->rd_appendonly->compresstype.data; + compresstype = (compresstype && compresstype[0]) ? pnstrdup(compresstype, strlen(compresstype)) : "none"; + opts = lappend(opts, makeDefElem("compresstype", (Node *) makeString(compresstype))); + } - if (!reloptions_has_opt(opts, de->defname)) - res = lappend(res, de); + if (!reloptions_has_opt(opts, "orientation")) + { + char *orientation = rel->rd_appendonly->columnstore ? "column" : "row"; + opts = lappend(opts, makeDefElem("orientation", (Node *) makeString(orientation))); } - return res; + return opts; } diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index 80c2a64a6866..b2ba0c987c1e 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -6785,7 +6785,20 @@ atpxPartAddList(Relation rel, ct->options = (List *) ((AlterPartitionCmd *) pelem->storeAttr)->arg1; if (gp_add_partition_inherits_table_setting) - ct->options = build_ao_rel_storage_opts(ct->options, rel); + { + ListCell *lc; + List *res = ct->options; + + foreach(lc, reloptions_list(RelationGetRelid(rel))) + { + DefElem *de = lfirst(lc); + + if (!reloptions_has_opt(ct->options, de->defname)) + res = lappend(res, de); + } + + ct->options = res; + } ct->tableElts = list_concat(ct->tableElts, list_copy(colencs)); diff --git a/src/test/regress/expected/expand_table_ao.out b/src/test/regress/expected/expand_table_ao.out index ebb69c436afc..fe96007a0280 100644 --- a/src/test/regress/expected/expand_table_ao.out +++ b/src/test/regress/expected/expand_table_ao.out @@ -860,7 +860,7 @@ from gp_distribution_policy where localoid = 't_9526'::regclass::oid; select blocksize,compresslevel,checksum,compresstype,columnstore from pg_appendonly where relid='t_9526'::regclass::oid; blocksize | compresslevel | checksum | compresstype | columnstore -----------+---------------+----------+--------------+------------- - 32768 | 0 | t | | f + 32768 | 0 | t | none | f (1 row) -- set back @@ -899,7 +899,7 @@ select relname, relstorage from pg_class where relname = 't_9527'; select blocksize,compresslevel,checksum,compresstype,columnstore from pg_appendonly where relid='t_9527'::regclass::oid; blocksize | compresslevel | checksum | compresstype | columnstore -----------+---------------+----------+--------------+------------- - 32768 | 0 | t | | f + 32768 | 0 | t | none | f (1 row) -- set back @@ -932,7 +932,7 @@ select relname, relstorage from pg_class where relname = 't_9528'; select blocksize,compresslevel,checksum,compresstype,columnstore from pg_appendonly where relid='t_9528'::regclass::oid; blocksize | compresslevel | checksum | compresstype | columnstore -----------+---------------+----------+--------------+------------- - 32768 | 0 | t | | f + 32768 | 0 | t | none | f (1 row) -- set back From 5f1e1013843e4bb7f92b0293101649388fbcb140 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 14 Oct 2024 13:24:24 +0500 Subject: [PATCH 22/40] optimize --- src/backend/cdb/cdbpartition.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index b2ba0c987c1e..a49d3c1c23ef 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -6787,17 +6787,14 @@ atpxPartAddList(Relation rel, if (gp_add_partition_inherits_table_setting) { ListCell *lc; - List *res = ct->options; foreach(lc, reloptions_list(RelationGetRelid(rel))) { DefElem *de = lfirst(lc); if (!reloptions_has_opt(ct->options, de->defname)) - res = lappend(res, de); + ct->options = lappend(ct->options, de); } - - ct->options = res; } ct->tableElts = list_concat(ct->tableElts, list_copy(colencs)); From 0848fcbf7c1a0eb3fe10b1ae2086c228798704e1 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 14 Oct 2024 17:08:18 +0500 Subject: [PATCH 23/40] ao only --- src/backend/cdb/cdbpartition.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index a49d3c1c23ef..7caa27290124 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -6784,7 +6784,7 @@ atpxPartAddList(Relation rel, if (pelem->storeAttr) ct->options = (List *) ((AlterPartitionCmd *) pelem->storeAttr)->arg1; - if (gp_add_partition_inherits_table_setting) + if (gp_add_partition_inherits_table_setting && RelationIsAppendOptimized(rel)) { ListCell *lc; From b570dcf5e92962346e268ef79d9bd8eecd5dbd0f Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 14 Oct 2024 17:11:28 +0500 Subject: [PATCH 24/40] fix abi --- .../postgres.symbols.ignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .abi-check/{6.27.1_arenadata57 => 6.27.1_arenadata58}/postgres.symbols.ignore (100%) diff --git a/.abi-check/6.27.1_arenadata57/postgres.symbols.ignore b/.abi-check/6.27.1_arenadata58/postgres.symbols.ignore similarity index 100% rename from .abi-check/6.27.1_arenadata57/postgres.symbols.ignore rename to .abi-check/6.27.1_arenadata58/postgres.symbols.ignore From 8ec74bc4f9741f0cf5a9f4ec7a7d96b673487492 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 15 Oct 2024 12:39:57 +0500 Subject: [PATCH 25/40] upper --- src/backend/utils/misc/guc_gp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/utils/misc/guc_gp.c b/src/backend/utils/misc/guc_gp.c index 68a1c6f4c1e3..ccc1cc8e51b1 100644 --- a/src/backend/utils/misc/guc_gp.c +++ b/src/backend/utils/misc/guc_gp.c @@ -3412,7 +3412,7 @@ struct config_bool ConfigureNamesBool_gp[] = { {"gp_add_partition_inherits_table_setting", PGC_USERSET, CUSTOM_OPTIONS, - gettext_noop("Alter table add partition inherits storage setting from the table."), + gettext_noop("ALTER TABLE ADD PARTITION inherits storage setting from the AO table."), NULL, GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE }, From d368a56ecfa3a3a9b6ad4e2df18a31a038b43356 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 15 Oct 2024 15:49:03 +0500 Subject: [PATCH 26/40] remove comments --- src/test/regress/expected/alter_table_ao.out | 2 -- src/test/regress/expected/alter_table_aocs.out | 2 -- src/test/regress/sql/alter_table_ao.sql | 2 -- src/test/regress/sql/alter_table_aocs.sql | 2 -- 4 files changed, 8 deletions(-) diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index 1a2e6f889ab5..a45fa0733733 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -754,7 +754,6 @@ NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_20" for tab ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_40" for table "ao_alter_add_part" RESET gp_default_storage_options; --- use table setting ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50" for table "ao_alter_add_part" RESET gp_default_storage_options; @@ -887,7 +886,6 @@ NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_40" for table "ao_alter_add_part_no_compress" RESET gp_default_storage_options; --- use table setting ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50" for table "ao_alter_add_part_no_compress" RESET gp_default_storage_options; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index e2dd89bea6ed..eea19f8dc829 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -861,7 +861,6 @@ ALTER TABLE aocs_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) ALTER TABLE aocs_alter_add_part SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; --- use table setting ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; \d+ aocs_alter_add_part* @@ -964,7 +963,6 @@ ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUS ALTER TABLE aocs_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; --- use table setting ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; \d+ aocs_alter_add_part_no_compress* diff --git a/src/test/regress/sql/alter_table_ao.sql b/src/test/regress/sql/alter_table_ao.sql index 957f5aac2d08..56be5061263f 100644 --- a/src/test/regress/sql/alter_table_ao.sql +++ b/src/test/regress/sql/alter_table_ao.sql @@ -461,7 +461,6 @@ ALTER TABLE ao_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) E ALTER TABLE ao_alter_add_part SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; --- use table setting ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; \d+ ao_alter_add_part* @@ -477,7 +476,6 @@ ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIV ALTER TABLE ao_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; --- use table setting ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; \d+ ao_alter_add_part_no_compress* diff --git a/src/test/regress/sql/alter_table_aocs.sql b/src/test/regress/sql/alter_table_aocs.sql index bfdf6e040ea1..4e06f2cb47ca 100644 --- a/src/test/regress/sql/alter_table_aocs.sql +++ b/src/test/regress/sql/alter_table_aocs.sql @@ -499,7 +499,6 @@ ALTER TABLE aocs_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) ALTER TABLE aocs_alter_add_part SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; --- use table setting ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; \d+ aocs_alter_add_part* @@ -515,7 +514,6 @@ ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUS ALTER TABLE aocs_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; --- use table setting ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; \d+ aocs_alter_add_part_no_compress* From cb7121df0de812666cd17b8f5dbd0e397bb73abf Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 15 Oct 2024 15:57:37 +0500 Subject: [PATCH 27/40] simplify tests --- src/test/regress/expected/alter_table_ao.out | 240 ++---------------- .../regress/expected/alter_table_aocs.out | 198 ++------------- src/test/regress/sql/alter_table_ao.sql | 4 +- src/test/regress/sql/alter_table_aocs.sql | 4 +- 4 files changed, 48 insertions(+), 398 deletions(-) diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index a45fa0733733..3a16adc4d4c8 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -757,115 +757,17 @@ RESET gp_default_storage_options; ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50" for table "ao_alter_add_part" RESET gp_default_storage_options; -\d+ ao_alter_add_part* - Append-Only Table "public.ao_alter_add_part" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zstd -Compression Level: 4 -Block Size: 65536 -Checksum: t -Child tables: ao_alter_add_part_1_prt_10, - ao_alter_add_part_1_prt_20, - ao_alter_add_part_1_prt_30, - ao_alter_add_part_1_prt_40, - ao_alter_add_part_1_prt_50, - ao_alter_add_part_1_prt_60 -Distributed by: (a) -Partition by: (b) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 - - Append-Only Table "public.ao_alter_add_part_1_prt_10" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zstd -Compression Level: 4 -Block Size: 65536 -Checksum: t -Check constraints: - "ao_alter_add_part_1_prt_10_check" CHECK (b >= 0 AND b < 10) -Inherits: ao_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 - - Append-Only Table "public.ao_alter_add_part_1_prt_20" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zstd -Compression Level: 4 -Block Size: 65536 -Checksum: t -Check constraints: - "ao_alter_add_part_1_prt_20_check" CHECK (b >= 10 AND b < 20) -Inherits: ao_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 - - Append-Only Table "public.ao_alter_add_part_1_prt_30" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zlib -Compression Level: 3 -Block Size: 16384 -Checksum: t -Check constraints: - "ao_alter_add_part_1_prt_30_check" CHECK (b >= 20 AND b < 30) -Inherits: ao_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384 - - Append-Only Table "public.ao_alter_add_part_1_prt_40" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zstd -Compression Level: 4 -Block Size: 65536 -Checksum: t -Check constraints: - "ao_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) -Inherits: ao_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 - - Append-Only Table "public.ao_alter_add_part_1_prt_50" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zstd -Compression Level: 4 -Block Size: 65536 -Checksum: t -Check constraints: - "ao_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) -Inherits: ao_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 - - Append-Only Table "public.ao_alter_add_part_1_prt_60" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zstd -Compression Level: 4 -Block Size: 65536 -Checksum: t -Check constraints: - "ao_alter_add_part_1_prt_60_check" CHECK (b >= 50 AND b < 60) -Inherits: ao_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536 +SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part%' ORDER BY 1; + relname | reloptions +----------------------------+------------------------------------------------------------------------------------- + ao_alter_add_part | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} + ao_alter_add_part_1_prt_10 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} + ao_alter_add_part_1_prt_20 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} + ao_alter_add_part_1_prt_30 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=3,blocksize=16384} + ao_alter_add_part_1_prt_40 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} + ao_alter_add_part_1_prt_50 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} + ao_alter_add_part_1_prt_60 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} +(7 rows) DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -889,115 +791,17 @@ RESET gp_default_storage_options; ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50" for table "ao_alter_add_part_no_compress" RESET gp_default_storage_options; -\d+ ao_alter_add_part_no_compress* - Append-Only Table "public.ao_alter_add_part_no_compress" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: None -Compression Level: 0 -Block Size: 32768 -Checksum: t -Child tables: ao_alter_add_part_no_compress_1_prt_10, - ao_alter_add_part_no_compress_1_prt_20, - ao_alter_add_part_no_compress_1_prt_30, - ao_alter_add_part_no_compress_1_prt_40, - ao_alter_add_part_no_compress_1_prt_50, - ao_alter_add_part_no_compress_1_prt_60 -Distributed by: (a) -Partition by: (b) -Options: appendonly=true, orientation=row - - Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_10" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zlib -Compression Level: 2 -Block Size: 8192 -Checksum: t -Check constraints: - "ao_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 0 AND b < 10) -Inherits: ao_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 - - Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_20" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zlib -Compression Level: 2 -Block Size: 8192 -Checksum: t -Check constraints: - "ao_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 10 AND b < 20) -Inherits: ao_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 - - Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_30" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zstd -Compression Level: 3 -Block Size: 16384 -Checksum: t -Check constraints: - "ao_alter_add_part_no_compress_1_prt_30_check" CHECK (b >= 20 AND b < 30) -Inherits: ao_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384 - - Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_40" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zlib -Compression Level: 2 -Block Size: 8192 -Checksum: t -Check constraints: - "ao_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) -Inherits: ao_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 - - Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_50" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: None -Compression Level: 0 -Block Size: 32768 -Checksum: t -Check constraints: - "ao_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) -Inherits: ao_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=row - - Append-Only Table "public.ao_alter_add_part_no_compress_1_prt_60" - Column | Type | Modifiers | Storage | Stats target | Description ---------+---------+-----------+---------+--------------+------------- - a | integer | | plain | | - b | integer | | plain | | -Compression Type: zlib -Compression Level: 2 -Block Size: 8192 -Checksum: t -Check constraints: - "ao_alter_add_part_no_compress_1_prt_60_check" CHECK (b >= 50 AND b < 60) -Inherits: ao_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=row, blocksize=8192, compresslevel=2 +SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part_no_compress%' ORDER BY 1; + relname | reloptions +----------------------------------------+------------------------------------------------------------------------------------- + ao_alter_add_part_no_compress | {appendonly=true,orientation=row} + ao_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} + ao_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} + ao_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=3,blocksize=16384} + ao_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} + ao_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=row} + ao_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} +(7 rows) DROP TABLE ao_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index eea19f8dc829..078f0c39ad7e 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -863,94 +863,17 @@ ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) RESET gp_default_storage_options; ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; -\d+ aocs_alter_add_part* - Append-Only Columnar Table "public.aocs_alter_add_part" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | rle_type | 4 | 65536 | - b | integer | | plain | | rle_type | 4 | 65536 | -Checksum: t -Child tables: aocs_alter_add_part_1_prt_10, - aocs_alter_add_part_1_prt_20, - aocs_alter_add_part_1_prt_30, - aocs_alter_add_part_1_prt_40, - aocs_alter_add_part_1_prt_50, - aocs_alter_add_part_1_prt_60 -Distributed by: (a) -Partition by: (b) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 - - Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_10" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | rle_type | 4 | 65536 | - b | integer | | plain | | rle_type | 4 | 65536 | -Checksum: t -Check constraints: - "aocs_alter_add_part_1_prt_10_check" CHECK (b >= 0 AND b < 10) -Inherits: aocs_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 - - Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_20" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | rle_type | 4 | 65536 | - b | integer | | plain | | rle_type | 4 | 65536 | -Checksum: t -Check constraints: - "aocs_alter_add_part_1_prt_20_check" CHECK (b >= 10 AND b < 20) -Inherits: aocs_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 - - Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_30" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | zlib | 3 | 16384 | - b | integer | | plain | | zlib | 3 | 16384 | -Checksum: t -Check constraints: - "aocs_alter_add_part_1_prt_30_check" CHECK (b >= 20 AND b < 30) -Inherits: aocs_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384 - - Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_40" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | rle_type | 4 | 65536 | - b | integer | | plain | | rle_type | 4 | 65536 | -Checksum: t -Check constraints: - "aocs_alter_add_part_1_prt_40_check" CHECK (b >= 30 AND b < 40) -Inherits: aocs_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 - - Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_50" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | rle_type | 4 | 65536 | - b | integer | | plain | | rle_type | 4 | 65536 | -Checksum: t -Check constraints: - "aocs_alter_add_part_1_prt_50_check" CHECK (b >= 40 AND b < 50) -Inherits: aocs_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 - - Append-Only Columnar Table "public.aocs_alter_add_part_1_prt_60" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | rle_type | 4 | 65536 | - b | integer | | plain | | rle_type | 4 | 65536 | -Checksum: t -Check constraints: - "aocs_alter_add_part_1_prt_60_check" CHECK (b >= 50 AND b < 60) -Inherits: aocs_alter_add_part -Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536 +SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part%' ORDER BY 1; + relname | reloptions +------------------------------+-------------------------------------------------------------------------------------------- + aocs_alter_add_part | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} + aocs_alter_add_part_1_prt_10 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} + aocs_alter_add_part_1_prt_20 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} + aocs_alter_add_part_1_prt_30 | {appendonly=true,orientation=column,compresstype=zlib,compresslevel=3,blocksize=16384} + aocs_alter_add_part_1_prt_40 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} + aocs_alter_add_part_1_prt_50 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} + aocs_alter_add_part_1_prt_60 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} +(7 rows) DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -965,94 +888,17 @@ ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUS RESET gp_default_storage_options; ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; -\d+ aocs_alter_add_part_no_compress* - Append-Only Columnar Table "public.aocs_alter_add_part_no_compress" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | none | 0 | 32768 | - b | integer | | plain | | none | 0 | 32768 | -Checksum: t -Child tables: aocs_alter_add_part_no_compress_1_prt_10, - aocs_alter_add_part_no_compress_1_prt_20, - aocs_alter_add_part_no_compress_1_prt_30, - aocs_alter_add_part_no_compress_1_prt_40, - aocs_alter_add_part_no_compress_1_prt_50, - aocs_alter_add_part_no_compress_1_prt_60 -Distributed by: (a) -Partition by: (b) -Options: appendonly=true, orientation=column - - Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_10" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | none | 0 | 32768 | - b | integer | | plain | | none | 0 | 32768 | -Checksum: t -Check constraints: - "aocs_alter_add_part_no_compress_1_prt_10_check" CHECK (b >= 0 AND b < 10) -Inherits: aocs_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 - - Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_20" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | none | 0 | 32768 | - b | integer | | plain | | none | 0 | 32768 | -Checksum: t -Check constraints: - "aocs_alter_add_part_no_compress_1_prt_20_check" CHECK (b >= 10 AND b < 20) -Inherits: aocs_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 - - Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_30" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | rle_type | 3 | 16384 | - b | integer | | plain | | rle_type | 3 | 16384 | -Checksum: t -Check constraints: - "aocs_alter_add_part_no_compress_1_prt_30_check" CHECK (b >= 20 AND b < 30) -Inherits: aocs_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384 - - Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_40" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | zlib | 2 | 8192 | - b | integer | | plain | | zlib | 2 | 8192 | -Checksum: t -Check constraints: - "aocs_alter_add_part_no_compress_1_prt_40_check" CHECK (b >= 30 AND b < 40) -Inherits: aocs_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 - - Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_50" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | none | 0 | 32768 | - b | integer | | plain | | none | 0 | 32768 | -Checksum: t -Check constraints: - "aocs_alter_add_part_no_compress_1_prt_50_check" CHECK (b >= 40 AND b < 50) -Inherits: aocs_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=column - - Append-Only Columnar Table "public.aocs_alter_add_part_no_compress_1_prt_60" - Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description ---------+---------+-----------+---------+--------------+------------------+-------------------+------------+------------- - a | integer | | plain | | zlib | 2 | 8192 | - b | integer | | plain | | zlib | 2 | 8192 | -Checksum: t -Check constraints: - "aocs_alter_add_part_no_compress_1_prt_60_check" CHECK (b >= 50 AND b < 60) -Inherits: aocs_alter_add_part_no_compress -Distributed by: (a) -Options: appendonly=true, orientation=column, blocksize=8192, compresslevel=2 +SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part_no_compress%' ORDER BY 1; + relname | reloptions +------------------------------------------+-------------------------------------------------------------------------------------------- + aocs_alter_add_part_no_compress | {appendonly=true,orientation=column} + aocs_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} + aocs_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} + aocs_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=3,blocksize=16384} + aocs_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} + aocs_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=column} + aocs_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} +(7 rows) DROP TABLE aocs_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/sql/alter_table_ao.sql b/src/test/regress/sql/alter_table_ao.sql index 56be5061263f..13b2cd1bbaf4 100644 --- a/src/test/regress/sql/alter_table_ao.sql +++ b/src/test/regress/sql/alter_table_ao.sql @@ -463,7 +463,7 @@ ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) E RESET gp_default_storage_options; ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; -\d+ ao_alter_add_part* +SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part%' ORDER BY 1; DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -478,7 +478,7 @@ ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIV RESET gp_default_storage_options; ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; -\d+ ao_alter_add_part_no_compress* +SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part_no_compress%' ORDER BY 1; DROP TABLE ao_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/sql/alter_table_aocs.sql b/src/test/regress/sql/alter_table_aocs.sql index 4e06f2cb47ca..2ee6a2a2e0aa 100644 --- a/src/test/regress/sql/alter_table_aocs.sql +++ b/src/test/regress/sql/alter_table_aocs.sql @@ -501,7 +501,7 @@ ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) RESET gp_default_storage_options; ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; -\d+ aocs_alter_add_part* +SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part%' ORDER BY 1; DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) @@ -516,7 +516,7 @@ ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUS RESET gp_default_storage_options; ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; RESET gp_default_storage_options; -\d+ aocs_alter_add_part_no_compress* +SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part_no_compress%' ORDER BY 1; DROP TABLE aocs_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; From 3125da5f9f19a3333b8db958590f5f782513dc80 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 15 Oct 2024 16:30:37 +0500 Subject: [PATCH 28/40] subpartition template --- src/test/regress/expected/alter_table_ao.out | 82 +++++++++++-------- .../regress/expected/alter_table_aocs.out | 64 ++++++++------- src/test/regress/sql/alter_table_ao.sql | 16 ++-- src/test/regress/sql/alter_table_aocs.sql | 16 ++-- 4 files changed, 98 insertions(+), 80 deletions(-) diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index 3a16adc4d4c8..cd3ddf72943f 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -736,72 +736,82 @@ SELECT * FROM gp_toolkit.__gp_aoseg('ao_insert_empty_row'::regclass); -- test case: alter AO table add partition, the preference of the storage setting is: the encoding clause > table setting > gp_default_storage_options SET gp_add_partition_inherits_table_setting = on; -CREATE TABLE ao_alter_add_part(a int, b int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); +CREATE TABLE ao_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) + PARTITION BY RANGE (b) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=5, blocksize=32768)) + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_10" for table "ao_alter_add_part" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_10_2_prt_11" for table "ao_alter_add_part_1_prt_10" SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_30" for table "ao_alter_add_part" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_30_2_prt_11" for table "ao_alter_add_part_1_prt_30" ALTER TABLE ao_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_60" for table "ao_alter_add_part" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_60_2_prt_11" for table "ao_alter_add_part_1_prt_60" -- use table setting -ALTER TABLE ao_alter_add_part SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); -NOTICE: exchanged partition "10" of relation "ao_alter_add_part" with relation "pg_temp_21823" -NOTICE: dropped partition "10" for relation "ao_alter_add_part" -NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_10" for table "ao_alter_add_part" -NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_20" for table "ao_alter_add_part" ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_40" for table "ao_alter_add_part" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_40_2_prt_11" for table "ao_alter_add_part_1_prt_40" RESET gp_default_storage_options; ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50" for table "ao_alter_add_part" -RESET gp_default_storage_options; +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50_2_prt_11" for table "ao_alter_add_part_1_prt_50" SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part%' ORDER BY 1; - relname | reloptions -----------------------------+------------------------------------------------------------------------------------- - ao_alter_add_part | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} - ao_alter_add_part_1_prt_10 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} - ao_alter_add_part_1_prt_20 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} - ao_alter_add_part_1_prt_30 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=3,blocksize=16384} - ao_alter_add_part_1_prt_40 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} - ao_alter_add_part_1_prt_50 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} - ao_alter_add_part_1_prt_60 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} -(7 rows) + relname | reloptions +-------------------------------------+------------------------------------------------------------------------------------- + ao_alter_add_part | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} + ao_alter_add_part_1_prt_10 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} + ao_alter_add_part_1_prt_10_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} + ao_alter_add_part_1_prt_30 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=3,blocksize=16384} + ao_alter_add_part_1_prt_30_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} + ao_alter_add_part_1_prt_40 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} + ao_alter_add_part_1_prt_40_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} + ao_alter_add_part_1_prt_50 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} + ao_alter_add_part_1_prt_50_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} + ao_alter_add_part_1_prt_60 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} + ao_alter_add_part_1_prt_60_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} +(11 rows) DROP TABLE ao_alter_add_part; -CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); +CREATE TABLE ao_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) + PARTITION BY RANGE (b) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=5, blocksize=32768)) + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10" for table "ao_alter_add_part_no_compress" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_10" SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_30" for table "ao_alter_add_part_no_compress" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_30_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_30" ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_60" for table "ao_alter_add_part_no_compress" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_60_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_60" -- use table setting -ALTER TABLE ao_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); -NOTICE: exchanged partition "10" of relation "ao_alter_add_part_no_compress" with relation "pg_temp_25798" -NOTICE: dropped partition "10" for relation "ao_alter_add_part_no_compress" -NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10" for table "ao_alter_add_part_no_compress" -NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_20" for table "ao_alter_add_part_no_compress" ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_40" for table "ao_alter_add_part_no_compress" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_40_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_40" RESET gp_default_storage_options; ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50" for table "ao_alter_add_part_no_compress" -RESET gp_default_storage_options; +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_50" SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part_no_compress%' ORDER BY 1; - relname | reloptions -----------------------------------------+------------------------------------------------------------------------------------- - ao_alter_add_part_no_compress | {appendonly=true,orientation=row} - ao_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} - ao_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} - ao_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=3,blocksize=16384} - ao_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} - ao_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=row} - ao_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} -(7 rows) + relname | reloptions +-------------------------------------------------+------------------------------------------------------------------------------------- + ao_alter_add_part_no_compress | {appendonly=true,orientation=row} + ao_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=row} + ao_alter_add_part_no_compress_1_prt_10_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} + ao_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=3,blocksize=16384} + ao_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} + ao_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} + ao_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} + ao_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=row} + ao_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} + ao_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} + ao_alter_add_part_no_compress_1_prt_60_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} +(11 rows) DROP TABLE ao_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index 078f0c39ad7e..759e4e18ebbf 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -851,54 +851,62 @@ DROP TABLE aocs_alter_add_col_reorganize; RESET gp_add_column_inherits_table_setting; -- test case: alter AOCS table add partition, the preference of the storage setting is: the encoding clause > table setting > gp_default_storage_options SET gp_add_partition_inherits_table_setting = on; -CREATE TABLE aocs_alter_add_part(a int, b int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); +CREATE TABLE aocs_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) + PARTITION BY RANGE (b) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); ALTER TABLE aocs_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting -ALTER TABLE aocs_alter_add_part SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; -RESET gp_default_storage_options; SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part%' ORDER BY 1; - relname | reloptions -------------------------------+-------------------------------------------------------------------------------------------- - aocs_alter_add_part | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} - aocs_alter_add_part_1_prt_10 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} - aocs_alter_add_part_1_prt_20 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} - aocs_alter_add_part_1_prt_30 | {appendonly=true,orientation=column,compresstype=zlib,compresslevel=3,blocksize=16384} - aocs_alter_add_part_1_prt_40 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} - aocs_alter_add_part_1_prt_50 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} - aocs_alter_add_part_1_prt_60 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} -(7 rows) + relname | reloptions +---------------------------------------+-------------------------------------------------------------------------------------------- + aocs_alter_add_part | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} + aocs_alter_add_part_1_prt_10 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} + aocs_alter_add_part_1_prt_10_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_1_prt_30 | {appendonly=true,orientation=column,compresstype=zlib,compresslevel=3,blocksize=16384} + aocs_alter_add_part_1_prt_30_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_1_prt_40 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} + aocs_alter_add_part_1_prt_40_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_1_prt_50 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} + aocs_alter_add_part_1_prt_50_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_1_prt_60 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} + aocs_alter_add_part_1_prt_60_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} +(11 rows) DROP TABLE aocs_alter_add_part; -CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); +CREATE TABLE aocs_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) + PARTITION BY RANGE (b) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting -ALTER TABLE aocs_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; -RESET gp_default_storage_options; SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part_no_compress%' ORDER BY 1; - relname | reloptions -------------------------------------------+-------------------------------------------------------------------------------------------- - aocs_alter_add_part_no_compress | {appendonly=true,orientation=column} - aocs_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} - aocs_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} - aocs_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=3,blocksize=16384} - aocs_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} - aocs_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=column} - aocs_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} -(7 rows) + relname | reloptions +---------------------------------------------------+-------------------------------------------------------------------------------------------- + aocs_alter_add_part_no_compress | {appendonly=true,orientation=column} + aocs_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=column} + aocs_alter_add_part_no_compress_1_prt_10_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=3,blocksize=16384} + aocs_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} + aocs_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=column} + aocs_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} + aocs_alter_add_part_no_compress_1_prt_60_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} +(11 rows) DROP TABLE aocs_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/sql/alter_table_ao.sql b/src/test/regress/sql/alter_table_ao.sql index 13b2cd1bbaf4..af243f2ea1c6 100644 --- a/src/test/regress/sql/alter_table_ao.sql +++ b/src/test/regress/sql/alter_table_ao.sql @@ -451,33 +451,33 @@ SELECT * FROM gp_toolkit.__gp_aoseg('ao_insert_empty_row'::regclass); -- test case: alter AO table add partition, the preference of the storage setting is: the encoding clause > table setting > gp_default_storage_options SET gp_add_partition_inherits_table_setting = on; -CREATE TABLE ao_alter_add_part(a int, b int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); +CREATE TABLE ao_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) + PARTITION BY RANGE (b) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=5, blocksize=32768)) + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); ALTER TABLE ao_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); -- use table setting -ALTER TABLE ao_alter_add_part SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; -RESET gp_default_storage_options; SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part%' ORDER BY 1; DROP TABLE ao_alter_add_part; -CREATE TABLE ao_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); +CREATE TABLE ao_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) + PARTITION BY RANGE (b) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=5, blocksize=32768)) + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); -- use table setting -ALTER TABLE ao_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; -RESET gp_default_storage_options; SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part_no_compress%' ORDER BY 1; DROP TABLE ao_alter_add_part_no_compress; diff --git a/src/test/regress/sql/alter_table_aocs.sql b/src/test/regress/sql/alter_table_aocs.sql index 2ee6a2a2e0aa..9189be6d59e3 100644 --- a/src/test/regress/sql/alter_table_aocs.sql +++ b/src/test/regress/sql/alter_table_aocs.sql @@ -489,33 +489,33 @@ RESET gp_add_column_inherits_table_setting; -- test case: alter AOCS table add partition, the preference of the storage setting is: the encoding clause > table setting > gp_default_storage_options SET gp_add_partition_inherits_table_setting = on; -CREATE TABLE aocs_alter_add_part(a int, b int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); +CREATE TABLE aocs_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) + PARTITION BY RANGE (b) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); ALTER TABLE aocs_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting -ALTER TABLE aocs_alter_add_part SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; -RESET gp_default_storage_options; SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part%' ORDER BY 1; DROP TABLE aocs_alter_add_part; -CREATE TABLE aocs_alter_add_part_no_compress(a int, b int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); +CREATE TABLE aocs_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) + PARTITION BY RANGE (b) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) + (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting -ALTER TABLE aocs_alter_add_part_no_compress SPLIT PARTITION "10" AT (10) INTO (PARTITION "10", PARTITION "20"); ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; -RESET gp_default_storage_options; SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part_no_compress%' ORDER BY 1; DROP TABLE aocs_alter_add_part_no_compress; From e40f6045c6db7a155f0d2f96a12c3f74c62e256c Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 16 Oct 2024 11:51:24 +0500 Subject: [PATCH 29/40] save and restore --- src/backend/cdb/cdbpartition.c | 14 ++++++++++++++ src/test/regress/expected/alter_table_ao.out | 4 ++-- src/test/regress/expected/alter_table_aocs.out | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index 7caa27290124..9b0cb097a7de 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -7143,6 +7143,14 @@ atpxPartAddList(Relation rel, ((CreateStmt *) q)->ownerid = ownerid; } + char *gp_default_storage_options_save = NULL; + + if (gp_add_partition_inherits_table_setting && RelationIsAppendOptimized(rel)) + { + gp_default_storage_options_save = pstrdup(GetConfigOption("gp_default_storage_options", false, false)); + SetConfigOption("gp_default_storage_options", "", PGC_USERSET, PGC_S_SESSION); + } + /* * normal case - add partitions using CREATE statements that get * dispatched to the segments @@ -7216,6 +7224,12 @@ atpxPartAddList(Relation rel, } /* end else setting subpartition templates * only */ + if (gp_default_storage_options_save != NULL) + { + SetConfigOption("gp_default_storage_options", gp_default_storage_options_save, PGC_USERSET, PGC_S_SESSION); + pfree(gp_default_storage_options_save); + } + ii++; } /* end for each cell */ } diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index cd3ddf72943f..1a13c06919f4 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -805,11 +805,11 @@ SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part_n ao_alter_add_part_no_compress_1_prt_10_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} ao_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=3,blocksize=16384} ao_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} - ao_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} + ao_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} ao_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} - ao_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=row,blocksize=8192,compresslevel=2} + ao_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_60_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} (11 rows) diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index 759e4e18ebbf..6b9eef158bf0 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -900,11 +900,11 @@ SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part aocs_alter_add_part_no_compress_1_prt_10_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} aocs_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=3,blocksize=16384} aocs_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} + aocs_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} aocs_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=column,blocksize=8192,compresslevel=2} + aocs_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_60_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} (11 rows) From b688923315cadbd4ada3e63c153f59e612aee00c Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 16 Oct 2024 11:55:00 +0500 Subject: [PATCH 30/40] try-catch --- src/backend/cdb/cdbpartition.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index 9b0cb097a7de..ec2df71f07cd 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -7151,6 +7151,9 @@ atpxPartAddList(Relation rel, SetConfigOption("gp_default_storage_options", "", PGC_USERSET, PGC_S_SESSION); } + PG_TRY(); + { + /* * normal case - add partitions using CREATE statements that get * dispatched to the segments @@ -7223,6 +7226,18 @@ atpxPartAddList(Relation rel, } } /* end else setting subpartition templates * only */ + } + PG_CATCH(); + { + if (gp_default_storage_options_save != NULL) + { + SetConfigOption("gp_default_storage_options", gp_default_storage_options_save, PGC_USERSET, PGC_S_SESSION); + pfree(gp_default_storage_options_save); + } + + PG_RE_THROW(); + } + PG_END_TRY(); if (gp_default_storage_options_save != NULL) { From b1da2e16536831ae2de048f7428ff4a252940ea7 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Wed, 16 Oct 2024 12:03:34 +0500 Subject: [PATCH 31/40] optimize --- src/backend/cdb/cdbpartition.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index ec2df71f07cd..d2f687ba369d 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -7143,12 +7143,12 @@ atpxPartAddList(Relation rel, ((CreateStmt *) q)->ownerid = ownerid; } - char *gp_default_storage_options_save = NULL; + StdRdOptions ao_opts; if (gp_add_partition_inherits_table_setting && RelationIsAppendOptimized(rel)) { - gp_default_storage_options_save = pstrdup(GetConfigOption("gp_default_storage_options", false, false)); - SetConfigOption("gp_default_storage_options", "", PGC_USERSET, PGC_S_SESSION); + ao_opts = *currentAOStorageOptions(); + resetDefaultAOStorageOpts(); } PG_TRY(); @@ -7229,21 +7229,15 @@ atpxPartAddList(Relation rel, } PG_CATCH(); { - if (gp_default_storage_options_save != NULL) - { - SetConfigOption("gp_default_storage_options", gp_default_storage_options_save, PGC_USERSET, PGC_S_SESSION); - pfree(gp_default_storage_options_save); - } + if (gp_add_partition_inherits_table_setting && RelationIsAppendOptimized(rel)) + setDefaultAOStorageOpts(&ao_opts); PG_RE_THROW(); } PG_END_TRY(); - if (gp_default_storage_options_save != NULL) - { - SetConfigOption("gp_default_storage_options", gp_default_storage_options_save, PGC_USERSET, PGC_S_SESSION); - pfree(gp_default_storage_options_save); - } + if (gp_add_partition_inherits_table_setting && RelationIsAppendOptimized(rel)) + setDefaultAOStorageOpts(&ao_opts); ii++; } /* end for each cell */ From 0dcba65b7aa7293b2bee3ccc8772c5731db99831 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 21 Oct 2024 12:23:56 +0500 Subject: [PATCH 32/40] move condition --- src/backend/cdb/cdbpartition.c | 23 ----------------------- src/backend/commands/tablecmds.c | 2 ++ 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index d2f687ba369d..7caa27290124 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -7143,17 +7143,6 @@ atpxPartAddList(Relation rel, ((CreateStmt *) q)->ownerid = ownerid; } - StdRdOptions ao_opts; - - if (gp_add_partition_inherits_table_setting && RelationIsAppendOptimized(rel)) - { - ao_opts = *currentAOStorageOptions(); - resetDefaultAOStorageOpts(); - } - - PG_TRY(); - { - /* * normal case - add partitions using CREATE statements that get * dispatched to the segments @@ -7226,18 +7215,6 @@ atpxPartAddList(Relation rel, } } /* end else setting subpartition templates * only */ - } - PG_CATCH(); - { - if (gp_add_partition_inherits_table_setting && RelationIsAppendOptimized(rel)) - setDefaultAOStorageOpts(&ao_opts); - - PG_RE_THROW(); - } - PG_END_TRY(); - - if (gp_add_partition_inherits_table_setting && RelationIsAppendOptimized(rel)) - setDefaultAOStorageOpts(&ao_opts); ii++; } /* end for each cell */ diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 810b0798b3e3..85805b4487f6 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -897,6 +897,8 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, char relstorage, boo errhint("Use OIDS=FALSE."))); } + if (gp_add_partition_inherits_table_setting && stmt->is_add_part) + useChangedOpts = false; bool valid_opts = (relstorage == RELSTORAGE_EXTERNAL || !useChangedOpts); /* From 6c807a3bbfabb2b6084bbabe97628f20368eb639 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Mon, 21 Oct 2024 12:43:17 +0500 Subject: [PATCH 33/40] AO --- src/backend/commands/tablecmds.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 85805b4487f6..0cbb1a76591e 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -898,7 +898,16 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, char relstorage, boo } if (gp_add_partition_inherits_table_setting && stmt->is_add_part) - useChangedOpts = false; + { + ListCell *lc; + foreach(lc, stmt->options) + { + DefElem *de = lfirst(lc); + if (pg_strcasecmp(de->defname, "appendonly") == 0 && pg_strcasecmp(defGetString(de), "none") != 0) + useChangedOpts = false; + } + } + bool valid_opts = (relstorage == RELSTORAGE_EXTERNAL || !useChangedOpts); /* From 31f19d75d5749f023a3463a03bc57d68120f600b Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 29 Oct 2024 09:18:01 +0500 Subject: [PATCH 34/40] optimize --- src/backend/commands/tablecmds.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 0cbb1a76591e..337be69f2261 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -903,8 +903,12 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, char relstorage, boo foreach(lc, stmt->options) { DefElem *de = lfirst(lc); - if (pg_strcasecmp(de->defname, "appendonly") == 0 && pg_strcasecmp(defGetString(de), "none") != 0) - useChangedOpts = false; + if (pg_strcasecmp(de->defname, "appendonly") == 0) + { + if (pg_strcasecmp(defGetString(de), "none") != 0) + useChangedOpts = false; + break; + } } } From 981b39481a68151a97ed377fc13a054877cf1d54 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 29 Oct 2024 09:22:30 +0500 Subject: [PATCH 35/40] order --- src/test/regress/expected/alter_table_ao.out | 32 +++++++++---------- .../regress/expected/alter_table_aocs.out | 24 +++++++------- src/test/regress/sql/alter_table_ao.sql | 12 +++---- src/test/regress/sql/alter_table_aocs.sql | 12 +++---- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index 1a13c06919f4..0ee459121a44 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -739,17 +739,17 @@ SET gp_add_partition_inherits_table_setting = on; CREATE TABLE ao_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=5, blocksize=32768)) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_10" for table "ao_alter_add_part" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_10_2_prt_11" for table "ao_alter_add_part_1_prt_10" SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype=zlib, compresslevel=2'; -- use statement encoding -ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); +ALTER TABLE ao_alter_add_part ADD PARTITION "20" START (10) INCLUSIVE END (20) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_20" for table "ao_alter_add_part" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_20_2_prt_11" for table "ao_alter_add_part_1_prt_20" +ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_30" for table "ao_alter_add_part" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_30_2_prt_11" for table "ao_alter_add_part_1_prt_30" -ALTER TABLE ao_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); -NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_60" for table "ao_alter_add_part" -NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_60_2_prt_11" for table "ao_alter_add_part_1_prt_60" -- use table setting ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_40" for table "ao_alter_add_part" @@ -764,31 +764,31 @@ SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part%' ao_alter_add_part | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_10 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_10_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} - ao_alter_add_part_1_prt_30 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=3,blocksize=16384} + ao_alter_add_part_1_prt_20 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=3,blocksize=16384} + ao_alter_add_part_1_prt_20_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} + ao_alter_add_part_1_prt_30 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_30_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} ao_alter_add_part_1_prt_40 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_40_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} ao_alter_add_part_1_prt_50 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_50_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} - ao_alter_add_part_1_prt_60 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} - ao_alter_add_part_1_prt_60_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} (11 rows) DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=5, blocksize=32768)) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10" for table "ao_alter_add_part_no_compress" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_10" SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding -ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "20" START (10) INCLUSIVE END (20) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_20" for table "ao_alter_add_part_no_compress" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_20_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_20" +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_30" for table "ao_alter_add_part_no_compress" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_30_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_30" -ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); -NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_60" for table "ao_alter_add_part_no_compress" -NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_60_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_60" -- use table setting ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_40" for table "ao_alter_add_part_no_compress" @@ -803,14 +803,14 @@ SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part_n ao_alter_add_part_no_compress | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_10_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} - ao_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=3,blocksize=16384} + ao_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=3,blocksize=16384} + ao_alter_add_part_no_compress_1_prt_20_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} + ao_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} ao_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} ao_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} - ao_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=row} - ao_alter_add_part_no_compress_1_prt_60_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} (11 rows) DROP TABLE ao_alter_add_part_no_compress; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index 6b9eef158bf0..e73559b59a61 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -854,11 +854,11 @@ SET gp_add_partition_inherits_table_setting = on; CREATE TABLE aocs_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; -- use statement encoding -ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); -ALTER TABLE aocs_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); +ALTER TABLE aocs_alter_add_part ADD PARTITION "20" START (10) INCLUSIVE END (20) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); +ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; @@ -869,25 +869,25 @@ SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part aocs_alter_add_part | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_10 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_10_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_1_prt_30 | {appendonly=true,orientation=column,compresstype=zlib,compresslevel=3,blocksize=16384} + aocs_alter_add_part_1_prt_20 | {appendonly=true,orientation=column,compresstype=zlib,compresslevel=3,blocksize=16384} + aocs_alter_add_part_1_prt_20_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_1_prt_30 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_30_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} aocs_alter_add_part_1_prt_40 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_40_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} aocs_alter_add_part_1_prt_50 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_50_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_1_prt_60 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} - aocs_alter_add_part_1_prt_60_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} (11 rows) DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding -ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); -ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "20" START (10) INCLUSIVE END (20) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; @@ -898,14 +898,14 @@ SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part aocs_alter_add_part_no_compress | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_10_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=3,blocksize=16384} + aocs_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=3,blocksize=16384} + aocs_alter_add_part_no_compress_1_prt_20_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} aocs_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} aocs_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_no_compress_1_prt_60 | {appendonly=true,orientation=column} - aocs_alter_add_part_no_compress_1_prt_60_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} (11 rows) DROP TABLE aocs_alter_add_part_no_compress; diff --git a/src/test/regress/sql/alter_table_ao.sql b/src/test/regress/sql/alter_table_ao.sql index af243f2ea1c6..f1f2893fd96a 100644 --- a/src/test/regress/sql/alter_table_ao.sql +++ b/src/test/regress/sql/alter_table_ao.sql @@ -454,11 +454,11 @@ SET gp_add_partition_inherits_table_setting = on; CREATE TABLE ao_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=5, blocksize=32768)) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype=zlib, compresslevel=2'; -- use statement encoding -ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); -ALTER TABLE ao_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); +ALTER TABLE ao_alter_add_part ADD PARTITION "20" START (10) INCLUSIVE END (20) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); +ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row); -- use table setting ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; @@ -469,11 +469,11 @@ DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=5, blocksize=32768)) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding -ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); -ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=row); +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "20" START (10) INCLUSIVE END (20) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); +ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row); -- use table setting ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; diff --git a/src/test/regress/sql/alter_table_aocs.sql b/src/test/regress/sql/alter_table_aocs.sql index 9189be6d59e3..0aa0c9876ac0 100644 --- a/src/test/regress/sql/alter_table_aocs.sql +++ b/src/test/regress/sql/alter_table_aocs.sql @@ -492,11 +492,11 @@ SET gp_add_partition_inherits_table_setting = on; CREATE TABLE aocs_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; -- use statement encoding -ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); -ALTER TABLE aocs_alter_add_part ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); +ALTER TABLE aocs_alter_add_part ADD PARTITION "20" START (10) INCLUSIVE END (20) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=zlib, compresslevel=3, blocksize=16384); +ALTER TABLE aocs_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; @@ -507,11 +507,11 @@ DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) - (PARTITION "10" START (0) INCLUSIVE END (20) EXCLUSIVE); + (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding -ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); -ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "60" START (50) INCLUSIVE END (60) EXCLUSIVE WITH (appendonly=true, orientation=column); +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "20" START (10) INCLUSIVE END (20) EXCLUSIVE WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=3, blocksize=16384); +ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=column); -- use table setting ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; RESET gp_default_storage_options; From 31f71474dda168b9b98153be641cf2829bbe1897 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 29 Oct 2024 09:31:31 +0500 Subject: [PATCH 36/40] another subpartition --- src/test/regress/expected/alter_table_ao.out | 34 ++++++++++++++++--- .../regress/expected/alter_table_aocs.out | 24 ++++++++++--- src/test/regress/sql/alter_table_ao.sql | 10 ++++-- src/test/regress/sql/alter_table_aocs.sql | 10 ++++-- 4 files changed, 66 insertions(+), 12 deletions(-) diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index 0ee459121a44..df1664babb2f 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -738,80 +738,106 @@ SELECT * FROM gp_toolkit.__gp_aoseg('ao_insert_empty_row'::regclass); SET gp_add_partition_inherits_table_setting = on; CREATE TABLE ao_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=5, blocksize=32768)) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE ( + SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=5, blocksize=32768), + SUBPARTITION "22" VALUES (4, 5, 6) WITH (appendonly=true, orientation=row) + ) (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_10" for table "ao_alter_add_part" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_10_2_prt_11" for table "ao_alter_add_part_1_prt_10" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_10_2_prt_22" for table "ao_alter_add_part_1_prt_10" SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype=zlib, compresslevel=2'; -- use statement encoding ALTER TABLE ao_alter_add_part ADD PARTITION "20" START (10) INCLUSIVE END (20) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=3, blocksize=16384); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_20" for table "ao_alter_add_part" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_20_2_prt_11" for table "ao_alter_add_part_1_prt_20" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_20_2_prt_22" for table "ao_alter_add_part_1_prt_20" ALTER TABLE ao_alter_add_part ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_30" for table "ao_alter_add_part" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_30_2_prt_11" for table "ao_alter_add_part_1_prt_30" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_30_2_prt_22" for table "ao_alter_add_part_1_prt_30" -- use table setting ALTER TABLE ao_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_40" for table "ao_alter_add_part" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_40_2_prt_11" for table "ao_alter_add_part_1_prt_40" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_40_2_prt_22" for table "ao_alter_add_part_1_prt_40" RESET gp_default_storage_options; ALTER TABLE ao_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50" for table "ao_alter_add_part" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50_2_prt_11" for table "ao_alter_add_part_1_prt_50" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50_2_prt_22" for table "ao_alter_add_part_1_prt_50" SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part%' ORDER BY 1; relname | reloptions -------------------------------------+------------------------------------------------------------------------------------- ao_alter_add_part | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_10 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_10_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} + ao_alter_add_part_1_prt_10_2_prt_22 | {appendonly=true,orientation=row} ao_alter_add_part_1_prt_20 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=3,blocksize=16384} ao_alter_add_part_1_prt_20_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} + ao_alter_add_part_1_prt_20_2_prt_22 | {appendonly=true,orientation=row} ao_alter_add_part_1_prt_30 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_30_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} + ao_alter_add_part_1_prt_30_2_prt_22 | {appendonly=true,orientation=row} ao_alter_add_part_1_prt_40 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_40_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} + ao_alter_add_part_1_prt_40_2_prt_22 | {appendonly=true,orientation=row} ao_alter_add_part_1_prt_50 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_50_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} -(11 rows) + ao_alter_add_part_1_prt_50_2_prt_22 | {appendonly=true,orientation=row} +(16 rows) DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=5, blocksize=32768)) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE ( + SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=5, blocksize=32768), + SUBPARTITION "22" VALUES (4, 5, 6) WITH (appendonly=true, orientation=row) + ) (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10" for table "ao_alter_add_part_no_compress" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_10" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_10_2_prt_22" for table "ao_alter_add_part_no_compress_1_prt_10" SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "20" START (10) INCLUSIVE END (20) EXCLUSIVE WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=3, blocksize=16384); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_20" for table "ao_alter_add_part_no_compress" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_20_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_20" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_20_2_prt_22" for table "ao_alter_add_part_no_compress_1_prt_20" ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "30" START (20) INCLUSIVE END (30) EXCLUSIVE WITH (appendonly=true, orientation=row); NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_30" for table "ao_alter_add_part_no_compress" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_30_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_30" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_30_2_prt_22" for table "ao_alter_add_part_no_compress_1_prt_30" -- use table setting ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUSIVE END (40) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_40" for table "ao_alter_add_part_no_compress" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_40_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_40" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_40_2_prt_22" for table "ao_alter_add_part_no_compress_1_prt_40" RESET gp_default_storage_options; ALTER TABLE ao_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50" for table "ao_alter_add_part_no_compress" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_50" +NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50_2_prt_22" for table "ao_alter_add_part_no_compress_1_prt_50" SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part_no_compress%' ORDER BY 1; relname | reloptions -------------------------------------------------+------------------------------------------------------------------------------------- ao_alter_add_part_no_compress | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_10_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} + ao_alter_add_part_no_compress_1_prt_10_2_prt_22 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=3,blocksize=16384} ao_alter_add_part_no_compress_1_prt_20_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} + ao_alter_add_part_no_compress_1_prt_20_2_prt_22 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} + ao_alter_add_part_no_compress_1_prt_30_2_prt_22 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} + ao_alter_add_part_no_compress_1_prt_40_2_prt_22 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} -(11 rows) + ao_alter_add_part_no_compress_1_prt_50_2_prt_22 | {appendonly=true,orientation=row} +(16 rows) DROP TABLE ao_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index e73559b59a61..8a0e337fdc08 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -853,7 +853,10 @@ RESET gp_add_column_inherits_table_setting; SET gp_add_partition_inherits_table_setting = on; CREATE TABLE aocs_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE ( + SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768), + SUBPARTITION "22" VALUES (4, 5, 6) WITH (appendonly=true, orientation=column) + ) (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; -- use statement encoding @@ -869,20 +872,28 @@ SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part aocs_alter_add_part | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_10 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_10_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_1_prt_10_2_prt_22 | {appendonly=true,orientation=column} aocs_alter_add_part_1_prt_20 | {appendonly=true,orientation=column,compresstype=zlib,compresslevel=3,blocksize=16384} aocs_alter_add_part_1_prt_20_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_1_prt_20_2_prt_22 | {appendonly=true,orientation=column} aocs_alter_add_part_1_prt_30 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_30_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_1_prt_30_2_prt_22 | {appendonly=true,orientation=column} aocs_alter_add_part_1_prt_40 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_40_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_1_prt_40_2_prt_22 | {appendonly=true,orientation=column} aocs_alter_add_part_1_prt_50 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_50_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} -(11 rows) + aocs_alter_add_part_1_prt_50_2_prt_22 | {appendonly=true,orientation=column} +(16 rows) DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE ( + SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768), + SUBPARTITION "22" VALUES (4, 5, 6) WITH (appendonly=true, orientation=column) + ) (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding @@ -898,15 +909,20 @@ SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part aocs_alter_add_part_no_compress | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_10_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_no_compress_1_prt_10_2_prt_22 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=3,blocksize=16384} aocs_alter_add_part_no_compress_1_prt_20_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_no_compress_1_prt_20_2_prt_22 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_no_compress_1_prt_30_2_prt_22 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} + aocs_alter_add_part_no_compress_1_prt_40_2_prt_22 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} -(11 rows) + aocs_alter_add_part_no_compress_1_prt_50_2_prt_22 | {appendonly=true,orientation=column} +(16 rows) DROP TABLE aocs_alter_add_part_no_compress; RESET gp_add_partition_inherits_table_setting; diff --git a/src/test/regress/sql/alter_table_ao.sql b/src/test/regress/sql/alter_table_ao.sql index f1f2893fd96a..b6ccb5a1c87b 100644 --- a/src/test/regress/sql/alter_table_ao.sql +++ b/src/test/regress/sql/alter_table_ao.sql @@ -453,7 +453,10 @@ SET gp_add_partition_inherits_table_setting = on; CREATE TABLE ao_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=5, blocksize=32768)) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE ( + SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zstd, compresslevel=5, blocksize=32768), + SUBPARTITION "22" VALUES (4, 5, 6) WITH (appendonly=true, orientation=row) + ) (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=row, compresstype=zlib, compresslevel=2'; -- use statement encoding @@ -468,7 +471,10 @@ DROP TABLE ao_alter_add_part; CREATE TABLE ao_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=row) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=5, blocksize=32768)) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE ( + SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=row, compresstype=zlib, compresslevel=5, blocksize=32768), + SUBPARTITION "22" VALUES (4, 5, 6) WITH (appendonly=true, orientation=row) + ) (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=row, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding diff --git a/src/test/regress/sql/alter_table_aocs.sql b/src/test/regress/sql/alter_table_aocs.sql index 0aa0c9876ac0..26bfa30fc2ab 100644 --- a/src/test/regress/sql/alter_table_aocs.sql +++ b/src/test/regress/sql/alter_table_aocs.sql @@ -491,7 +491,10 @@ SET gp_add_partition_inherits_table_setting = on; CREATE TABLE aocs_alter_add_part(a int, b int, c int) WITH (appendonly=true, orientation=column, compresstype=rle_type, compresslevel=4, blocksize=65536) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE ( + SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768), + SUBPARTITION "22" VALUES (4, 5, 6) WITH (appendonly=true, orientation=column) + ) (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options = 'appendonly=true, orientation=column, compresstype=zlib, compresslevel=2'; -- use statement encoding @@ -506,7 +509,10 @@ DROP TABLE aocs_alter_add_part; CREATE TABLE aocs_alter_add_part_no_compress(a int, b int, c int) WITH (appendonly=true, orientation=column) DISTRIBUTED BY (a) PARTITION BY RANGE (b) - SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE (SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768)) + SUBPARTITION BY LIST (c) SUBPARTITION TEMPLATE ( + SUBPARTITION "11" VALUES (1, 2, 3) WITH (appendonly=true, orientation=column, compresstype=zstd, compresslevel=5, blocksize=32768), + SUBPARTITION "22" VALUES (4, 5, 6) WITH (appendonly=true, orientation=column) + ) (PARTITION "10" START (0) INCLUSIVE END (10) EXCLUSIVE); SET gp_default_storage_options ='appendonly=true, orientation=column, compresstype=zlib, compresslevel=2, blocksize=8192'; -- use statement encoding From 54dbfbe5ac1935885e6abbebdb4e03e58203eff6 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 29 Oct 2024 10:47:12 +0500 Subject: [PATCH 37/40] inherit table options --- src/backend/access/common/reloptions.c | 4 +- src/backend/access/common/reloptions_gp.c | 45 ++++++++++++++- src/backend/cdb/cdbpartition.c | 9 ++- src/backend/commands/tablecmds.c | 15 ----- src/include/access/reloptions.h | 1 + src/include/utils/guc.h | 1 + src/include/utils/rel.h | 1 + src/test/regress/expected/alter_table_ao.out | 56 +++++++++---------- .../regress/expected/alter_table_aocs.out | 56 +++++++++---------- 9 files changed, 113 insertions(+), 75 deletions(-) diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index 6daf3314956a..f4c496019e9b 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -1225,7 +1225,9 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind) {"user_catalog_table", RELOPT_TYPE_BOOL, offsetof(StdRdOptions, user_catalog_table)}, {SOPT_ANALYZEHLL, RELOPT_TYPE_BOOL, - offsetof(StdRdOptions, analyze_hll_non_part_table)} + offsetof(StdRdOptions, analyze_hll_non_part_table)}, + {SOPT_INHERIT, RELOPT_TYPE_BOOL, + offsetof(StdRdOptions, inherit_table_options)} }; options = parseRelOptions(reloptions, validate, kind, &numoptions); diff --git a/src/backend/access/common/reloptions_gp.c b/src/backend/access/common/reloptions_gp.c index ee835ec73ecc..55335163fd88 100644 --- a/src/backend/access/common/reloptions_gp.c +++ b/src/backend/access/common/reloptions_gp.c @@ -71,6 +71,14 @@ static relopt_bool boolRelOpts_gp[] = }, ANALYZE_DEFAULT_HLL }, + { + { + SOPT_INHERIT, + "Inherit table options", + RELOPT_KIND_HEAP + }, + INHERIT_DEFAULT + }, /* list terminator */ {{NULL}} }; @@ -613,7 +621,8 @@ transformAOStdRdOptions(StdRdOptions *opts, Datum withOpts) foundComplevel = false, foundChecksum = false, foundOrientation = false, - foundAnalyzeHLL = false; + foundAnalyzeHLL = false, + foundInherit = false; /* * withOpts must be parsed to see if an option was spcified in WITH() @@ -744,6 +753,17 @@ transformAOStdRdOptions(StdRdOptions *opts, Datum withOpts) astate = accumArrayResult(astate, d, false, TEXTOID, CurrentMemoryContext); } + soptLen = strlen(SOPT_INHERIT); + if (withLen > soptLen && + pg_strncasecmp(strval, SOPT_INHERIT, soptLen) == 0) + { + foundInherit = true; + d = CStringGetTextDatum(psprintf("%s=%s", + SOPT_INHERIT, + (opts->inherit_table_options ? "true" : "false"))); + astate = accumArrayResult(astate, d, false, TEXTOID, + CurrentMemoryContext); + } } } @@ -821,6 +841,14 @@ transformAOStdRdOptions(StdRdOptions *opts, Datum withOpts) astate = accumArrayResult(astate, d, false, TEXTOID, CurrentMemoryContext); } + if ((opts->inherit_table_options != INHERIT_DEFAULT) && !foundInherit) + { + d = CStringGetTextDatum(psprintf("%s=%s", + SOPT_INHERIT, + (opts->inherit_table_options ? "true" : "false"))); + astate = accumArrayResult(astate, d, false, TEXTOID, + CurrentMemoryContext); + } return astate ? makeArrayResult(astate, CurrentMemoryContext) : PointerGetDatum(NULL); @@ -840,6 +868,7 @@ validate_and_adjust_options(StdRdOptions *result, relopt_value *checksum_opt; relopt_value *orientation_opt; relopt_value *analyze_hll_non_part_table_opt; + relopt_value *inherit_table_options_opt; /* fillfactor */ fillfactor_opt = get_option_set(options, num_options, SOPT_FILLFACTOR); @@ -1106,6 +1135,16 @@ validate_and_adjust_options(StdRdOptions *result, errmsg("usage of parameter \"analyze_hll_non_part_table\" in a non relation object is not supported"))); result->analyze_hll_non_part_table = analyze_hll_non_part_table_opt->values.bool_val; } + /* inherit_table_options */ + inherit_table_options_opt = get_option_set(options, num_options, SOPT_INHERIT); + if (inherit_table_options_opt != NULL) + { + if (!KIND_IS_RELATION(kind)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("usage of parameter \"inherit\" in a non relation object is not supported"))); + result->inherit_table_options = inherit_table_options_opt->values.bool_val; + } if (result->appendonly && result->compresstype[0]) if (result->compresslevel == AO_DEFAULT_COMPRESSLEVEL) @@ -1116,7 +1155,7 @@ void validate_and_refill_options(StdRdOptions *result, relopt_value *options, int numrelopts, relopt_kind kind, bool validate) { - if (validate && + if (validate && !get_option_set(options, numrelopts, SOPT_INHERIT) && ao_storage_opts_changed && KIND_IS_RELATION(kind)) { @@ -1142,6 +1181,8 @@ validate_and_refill_options(StdRdOptions *result, relopt_value *options, result->columnstore = ao_storage_opts.columnstore; if (!(get_option_set(options, numrelopts, SOPT_ANALYZEHLL))) result->analyze_hll_non_part_table = ao_storage_opts.analyze_hll_non_part_table; + // if (!(get_option_set(options, numrelopts, SOPT_INHERIT))) + // result->inherit_table_options = ao_storage_opts.inherit_table_options; } validate_and_adjust_options(result, options, numrelopts, kind, validate); diff --git a/src/backend/cdb/cdbpartition.c b/src/backend/cdb/cdbpartition.c index 7caa27290124..2abbbc5952f5 100644 --- a/src/backend/cdb/cdbpartition.c +++ b/src/backend/cdb/cdbpartition.c @@ -7140,7 +7140,14 @@ atpxPartAddList(Relation rel, else if (IsA(q, CreateStmt)) { /* propagate owner */ - ((CreateStmt *) q)->ownerid = ownerid; + CreateStmt *ct = (CreateStmt *)q; + ct->ownerid = ownerid; + + if (gp_add_partition_inherits_table_setting && RelationIsAppendOptimized(rel)) + { + if (!reloptions_has_opt(ct->options, "inherit")) + ct->options = lappend(ct->options, makeDefElem("inherit", (Node *) makeString("true"))); + } } /* diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 337be69f2261..810b0798b3e3 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -897,21 +897,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, char relstorage, boo errhint("Use OIDS=FALSE."))); } - if (gp_add_partition_inherits_table_setting && stmt->is_add_part) - { - ListCell *lc; - foreach(lc, stmt->options) - { - DefElem *de = lfirst(lc); - if (pg_strcasecmp(de->defname, "appendonly") == 0) - { - if (pg_strcasecmp(defGetString(de), "none") != 0) - useChangedOpts = false; - break; - } - } - } - bool valid_opts = (relstorage == RELSTORAGE_EXTERNAL || !useChangedOpts); /* diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h index 741c9a93ffa3..b37cd7dbd417 100644 --- a/src/include/access/reloptions.h +++ b/src/include/access/reloptions.h @@ -42,6 +42,7 @@ #define AO_DEFAULT_CHECKSUM true #define AO_DEFAULT_COLUMNSTORE false #define ANALYZE_DEFAULT_HLL false +#define INHERIT_DEFAULT false /* types supported by reloptions */ typedef enum relopt_type diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index 60e9fa430d2d..3db7d737ee02 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -624,6 +624,7 @@ extern IndexCheckType gp_indexcheck_vacuum; /* Max number of chars needed to hold value of a storage option. */ #define MAX_SOPT_VALUE_LEN 15 #define SOPT_ANALYZEHLL "analyze_hll_non_part_table" +#define SOPT_INHERIT "inherit" /* * Functions exported by guc.c diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 24d39757f4cc..b3cf38ea9575 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -229,6 +229,7 @@ typedef struct StdRdOptions AutoVacOpts autovacuum; /* autovacuum-related options */ bool analyze_hll_non_part_table; /* force hll statistics collection on relation */ + bool inherit_table_options; /* inherit table options */ bool appendonly; /* is this an appendonly relation? */ int blocksize; /* max varblock size (AO rels only) */ int compresslevel; /* compression level (AO rels only) */ diff --git a/src/test/regress/expected/alter_table_ao.out b/src/test/regress/expected/alter_table_ao.out index df1664babb2f..37db0d5e60d4 100644 --- a/src/test/regress/expected/alter_table_ao.out +++ b/src/test/regress/expected/alter_table_ao.out @@ -767,24 +767,24 @@ NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50" for tab NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50_2_prt_11" for table "ao_alter_add_part_1_prt_50" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_1_prt_50_2_prt_22" for table "ao_alter_add_part_1_prt_50" SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part%' ORDER BY 1; - relname | reloptions --------------------------------------+------------------------------------------------------------------------------------- + relname | reloptions +-------------------------------------+-------------------------------------------------------------------------------------------------- ao_alter_add_part | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_10 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} ao_alter_add_part_1_prt_10_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} ao_alter_add_part_1_prt_10_2_prt_22 | {appendonly=true,orientation=row} - ao_alter_add_part_1_prt_20 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=3,blocksize=16384} - ao_alter_add_part_1_prt_20_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} - ao_alter_add_part_1_prt_20_2_prt_22 | {appendonly=true,orientation=row} - ao_alter_add_part_1_prt_30 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} - ao_alter_add_part_1_prt_30_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} - ao_alter_add_part_1_prt_30_2_prt_22 | {appendonly=true,orientation=row} - ao_alter_add_part_1_prt_40 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} - ao_alter_add_part_1_prt_40_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} - ao_alter_add_part_1_prt_40_2_prt_22 | {appendonly=true,orientation=row} - ao_alter_add_part_1_prt_50 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536} - ao_alter_add_part_1_prt_50_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768} - ao_alter_add_part_1_prt_50_2_prt_22 | {appendonly=true,orientation=row} + ao_alter_add_part_1_prt_20 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=3,blocksize=16384,inherit=true} + ao_alter_add_part_1_prt_20_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + ao_alter_add_part_1_prt_20_2_prt_22 | {appendonly=true,orientation=row,inherit=true} + ao_alter_add_part_1_prt_30 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536,inherit=true} + ao_alter_add_part_1_prt_30_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + ao_alter_add_part_1_prt_30_2_prt_22 | {appendonly=true,orientation=row,inherit=true} + ao_alter_add_part_1_prt_40 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536,inherit=true} + ao_alter_add_part_1_prt_40_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + ao_alter_add_part_1_prt_40_2_prt_22 | {appendonly=true,orientation=row,inherit=true} + ao_alter_add_part_1_prt_50 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=4,blocksize=65536,inherit=true} + ao_alter_add_part_1_prt_50_2_prt_11 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + ao_alter_add_part_1_prt_50_2_prt_22 | {appendonly=true,orientation=row,inherit=true} (16 rows) DROP TABLE ao_alter_add_part; @@ -819,24 +819,24 @@ NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50_2_prt_11" for table "ao_alter_add_part_no_compress_1_prt_50" NOTICE: CREATE TABLE will create partition "ao_alter_add_part_no_compress_1_prt_50_2_prt_22" for table "ao_alter_add_part_no_compress_1_prt_50" SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'ao_alter_add_part_no_compress%' ORDER BY 1; - relname | reloptions --------------------------------------------------+------------------------------------------------------------------------------------- + relname | reloptions +-------------------------------------------------+-------------------------------------------------------------------------------------------------- ao_alter_add_part_no_compress | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=row} ao_alter_add_part_no_compress_1_prt_10_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} ao_alter_add_part_no_compress_1_prt_10_2_prt_22 | {appendonly=true,orientation=row} - ao_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=3,blocksize=16384} - ao_alter_add_part_no_compress_1_prt_20_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} - ao_alter_add_part_no_compress_1_prt_20_2_prt_22 | {appendonly=true,orientation=row} - ao_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=row} - ao_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} - ao_alter_add_part_no_compress_1_prt_30_2_prt_22 | {appendonly=true,orientation=row} - ao_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=row} - ao_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} - ao_alter_add_part_no_compress_1_prt_40_2_prt_22 | {appendonly=true,orientation=row} - ao_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=row} - ao_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768} - ao_alter_add_part_no_compress_1_prt_50_2_prt_22 | {appendonly=true,orientation=row} + ao_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=row,compresstype=zstd,compresslevel=3,blocksize=16384,inherit=true} + ao_alter_add_part_no_compress_1_prt_20_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768,inherit=true} + ao_alter_add_part_no_compress_1_prt_20_2_prt_22 | {appendonly=true,orientation=row,inherit=true} + ao_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=row,inherit=true} + ao_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768,inherit=true} + ao_alter_add_part_no_compress_1_prt_30_2_prt_22 | {appendonly=true,orientation=row,inherit=true} + ao_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=row,inherit=true} + ao_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768,inherit=true} + ao_alter_add_part_no_compress_1_prt_40_2_prt_22 | {appendonly=true,orientation=row,inherit=true} + ao_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=row,inherit=true} + ao_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=row,compresstype=zlib,compresslevel=5,blocksize=32768,inherit=true} + ao_alter_add_part_no_compress_1_prt_50_2_prt_22 | {appendonly=true,orientation=row,inherit=true} (16 rows) DROP TABLE ao_alter_add_part_no_compress; diff --git a/src/test/regress/expected/alter_table_aocs.out b/src/test/regress/expected/alter_table_aocs.out index 8a0e337fdc08..4ce10235f945 100644 --- a/src/test/regress/expected/alter_table_aocs.out +++ b/src/test/regress/expected/alter_table_aocs.out @@ -867,24 +867,24 @@ ALTER TABLE aocs_alter_add_part ADD PARTITION "40" START (30) INCLUSIVE END (40) RESET gp_default_storage_options; ALTER TABLE aocs_alter_add_part ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part%' ORDER BY 1; - relname | reloptions ----------------------------------------+-------------------------------------------------------------------------------------------- + relname | reloptions +---------------------------------------+--------------------------------------------------------------------------------------------------------- aocs_alter_add_part | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_10 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} aocs_alter_add_part_1_prt_10_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} aocs_alter_add_part_1_prt_10_2_prt_22 | {appendonly=true,orientation=column} - aocs_alter_add_part_1_prt_20 | {appendonly=true,orientation=column,compresstype=zlib,compresslevel=3,blocksize=16384} - aocs_alter_add_part_1_prt_20_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_1_prt_20_2_prt_22 | {appendonly=true,orientation=column} - aocs_alter_add_part_1_prt_30 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} - aocs_alter_add_part_1_prt_30_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_1_prt_30_2_prt_22 | {appendonly=true,orientation=column} - aocs_alter_add_part_1_prt_40 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} - aocs_alter_add_part_1_prt_40_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_1_prt_40_2_prt_22 | {appendonly=true,orientation=column} - aocs_alter_add_part_1_prt_50 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536} - aocs_alter_add_part_1_prt_50_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_1_prt_50_2_prt_22 | {appendonly=true,orientation=column} + aocs_alter_add_part_1_prt_20 | {appendonly=true,orientation=column,compresstype=zlib,compresslevel=3,blocksize=16384,inherit=true} + aocs_alter_add_part_1_prt_20_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + aocs_alter_add_part_1_prt_20_2_prt_22 | {appendonly=true,orientation=column,inherit=true} + aocs_alter_add_part_1_prt_30 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536,inherit=true} + aocs_alter_add_part_1_prt_30_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + aocs_alter_add_part_1_prt_30_2_prt_22 | {appendonly=true,orientation=column,inherit=true} + aocs_alter_add_part_1_prt_40 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536,inherit=true} + aocs_alter_add_part_1_prt_40_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + aocs_alter_add_part_1_prt_40_2_prt_22 | {appendonly=true,orientation=column,inherit=true} + aocs_alter_add_part_1_prt_50 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=4,blocksize=65536,inherit=true} + aocs_alter_add_part_1_prt_50_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + aocs_alter_add_part_1_prt_50_2_prt_22 | {appendonly=true,orientation=column,inherit=true} (16 rows) DROP TABLE aocs_alter_add_part; @@ -904,24 +904,24 @@ ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "40" START (30) INCLUS RESET gp_default_storage_options; ALTER TABLE aocs_alter_add_part_no_compress ADD PARTITION "50" START (40) INCLUSIVE END (50) EXCLUSIVE; SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'aocs_alter_add_part_no_compress%' ORDER BY 1; - relname | reloptions ----------------------------------------------------+-------------------------------------------------------------------------------------------- + relname | reloptions +---------------------------------------------------+--------------------------------------------------------------------------------------------------------- aocs_alter_add_part_no_compress | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_10 | {appendonly=true,orientation=column} aocs_alter_add_part_no_compress_1_prt_10_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} aocs_alter_add_part_no_compress_1_prt_10_2_prt_22 | {appendonly=true,orientation=column} - aocs_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=3,blocksize=16384} - aocs_alter_add_part_no_compress_1_prt_20_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_no_compress_1_prt_20_2_prt_22 | {appendonly=true,orientation=column} - aocs_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=column} - aocs_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_no_compress_1_prt_30_2_prt_22 | {appendonly=true,orientation=column} - aocs_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=column} - aocs_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_no_compress_1_prt_40_2_prt_22 | {appendonly=true,orientation=column} - aocs_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=column} - aocs_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768} - aocs_alter_add_part_no_compress_1_prt_50_2_prt_22 | {appendonly=true,orientation=column} + aocs_alter_add_part_no_compress_1_prt_20 | {appendonly=true,orientation=column,compresstype=rle_type,compresslevel=3,blocksize=16384,inherit=true} + aocs_alter_add_part_no_compress_1_prt_20_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + aocs_alter_add_part_no_compress_1_prt_20_2_prt_22 | {appendonly=true,orientation=column,inherit=true} + aocs_alter_add_part_no_compress_1_prt_30 | {appendonly=true,orientation=column,inherit=true} + aocs_alter_add_part_no_compress_1_prt_30_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + aocs_alter_add_part_no_compress_1_prt_30_2_prt_22 | {appendonly=true,orientation=column,inherit=true} + aocs_alter_add_part_no_compress_1_prt_40 | {appendonly=true,orientation=column,inherit=true} + aocs_alter_add_part_no_compress_1_prt_40_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + aocs_alter_add_part_no_compress_1_prt_40_2_prt_22 | {appendonly=true,orientation=column,inherit=true} + aocs_alter_add_part_no_compress_1_prt_50 | {appendonly=true,orientation=column,inherit=true} + aocs_alter_add_part_no_compress_1_prt_50_2_prt_11 | {appendonly=true,orientation=column,compresstype=zstd,compresslevel=5,blocksize=32768,inherit=true} + aocs_alter_add_part_no_compress_1_prt_50_2_prt_22 | {appendonly=true,orientation=column,inherit=true} (16 rows) DROP TABLE aocs_alter_add_part_no_compress; From 89b508fee3d71a0a260fa5c5bcc20633315a8428 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 29 Oct 2024 11:41:46 +0500 Subject: [PATCH 38/40] fix abi --- .abi-check/6.27.1_arenadata58/postgres.symbols.ignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.abi-check/6.27.1_arenadata58/postgres.symbols.ignore b/.abi-check/6.27.1_arenadata58/postgres.symbols.ignore index aa4c33e2be25..a8ca7ba160cf 100644 --- a/.abi-check/6.27.1_arenadata58/postgres.symbols.ignore +++ b/.abi-check/6.27.1_arenadata58/postgres.symbols.ignore @@ -1 +1,2 @@ ConfigureNamesBool_gp +StdRdOptions From ebe920914a55cccb036056a851d9e9c6859c3b59 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 29 Oct 2024 12:44:21 +0500 Subject: [PATCH 39/40] fix abi --- src/include/utils/rel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index b3cf38ea9575..5175f7df8a79 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -229,7 +229,6 @@ typedef struct StdRdOptions AutoVacOpts autovacuum; /* autovacuum-related options */ bool analyze_hll_non_part_table; /* force hll statistics collection on relation */ - bool inherit_table_options; /* inherit table options */ bool appendonly; /* is this an appendonly relation? */ int blocksize; /* max varblock size (AO rels only) */ int compresslevel; /* compression level (AO rels only) */ @@ -241,6 +240,7 @@ typedef struct StdRdOptions int check_option_offset; /* for views */ bool user_catalog_table; /* use as an additional catalog * relation */ + bool inherit_table_options; /* inherit table options */ } StdRdOptions; #define HEAP_MIN_FILLFACTOR 10 From 460fc9bb384ff750643080989da4d2823dc8ed58 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 29 Oct 2024 13:30:34 +0500 Subject: [PATCH 40/40] rm --- src/backend/access/common/reloptions_gp.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/backend/access/common/reloptions_gp.c b/src/backend/access/common/reloptions_gp.c index 55335163fd88..0acd15662622 100644 --- a/src/backend/access/common/reloptions_gp.c +++ b/src/backend/access/common/reloptions_gp.c @@ -1181,8 +1181,6 @@ validate_and_refill_options(StdRdOptions *result, relopt_value *options, result->columnstore = ao_storage_opts.columnstore; if (!(get_option_set(options, numrelopts, SOPT_ANALYZEHLL))) result->analyze_hll_non_part_table = ao_storage_opts.analyze_hll_non_part_table; - // if (!(get_option_set(options, numrelopts, SOPT_INHERIT))) - // result->inherit_table_options = ao_storage_opts.inherit_table_options; } validate_and_adjust_options(result, options, numrelopts, kind, validate);