From 11d53786f7788f0115b4e404c4069dfa4477217d Mon Sep 17 00:00:00 2001 From: wuyuechuan Date: Mon, 6 Jun 2022 10:52:22 +0800 Subject: [PATCH] optimize the message for `create table` --- .../optimizer/commands/tablecmds.cpp | 3 ++- src/include/storage/page_compression.h | 8 +++--- .../row_compression/unsupported_feature.out | 25 +++++++++++++++---- .../row_compression/unsupported_feature.sql | 17 ++++++++++++- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/gausskernel/optimizer/commands/tablecmds.cpp b/src/gausskernel/optimizer/commands/tablecmds.cpp index 88244786d..db31fc2d1 100644 --- a/src/gausskernel/optimizer/commands/tablecmds.cpp +++ b/src/gausskernel/optimizer/commands/tablecmds.cpp @@ -1167,7 +1167,8 @@ static List* AddDefaultOptionsIfNeed(List* options, const char relkind, CreateSt stmt->relation->relpersistence == RELPERSISTENCE_TEMP || stmt->relation->relpersistence == RELPERSISTENCE_GLOBAL_TEMP; if (noSupportTable && tableCreateSupport.compressType) { - ereport(ERROR, (errcode(ERRCODE_INVALID_OPTION), errmsg("only row orientation table support compresstype."))); + ereport(ERROR, (errcode(ERRCODE_INVALID_OPTION), errmsg("compresstype can not be used in ustore table, segment table, " + "column table, view, unlogged table or temp table."))); } CheckCompressOption(&tableCreateSupport); diff --git a/src/include/storage/page_compression.h b/src/include/storage/page_compression.h index 0dfafe167..e28b73581 100644 --- a/src/include/storage/page_compression.h +++ b/src/include/storage/page_compression.h @@ -41,10 +41,10 @@ constexpr uint32 COMPRESS_ADDRESS_FLUSH_CHUNKS = 5000; #define SUPPORT_COMPRESSED(relKind, relam) \ - ((relKind) == RELKIND_RELATION || ((relKind) == RELKIND_INDEX && (relam) == BTREE_AM_OID)) -#define REL_SUPPORT_COMPRESSED(relation) \ - (((relation)->rd_rel->relkind) == RELKIND_RELATION || \ - (((relation)->rd_rel->relkind) == RELKIND_INDEX && ((relation)->rd_rel->relam) == BTREE_AM_OID)) + ((relKind) == RELKIND_RELATION || \ + (((relKind) == RELKIND_INDEX || (relKind == RELKIND_GLOBAL_INDEX)) && (relam) == BTREE_AM_OID)) + +#define REL_SUPPORT_COMPRESSED(relation) SUPPORT_COMPRESSED((relation)->rd_rel->relkind, (relation)->rd_rel->relam) typedef uint32 pc_chunk_number_t; const uint32 PAGE_COMPRESSION_VERSION = 92603; diff --git a/src/test/regress/expected/row_compression/unsupported_feature.out b/src/test/regress/expected/row_compression/unsupported_feature.out index 469000151..8d5a0cb2a 100644 --- a/src/test/regress/expected/row_compression/unsupported_feature.out +++ b/src/test/regress/expected/row_compression/unsupported_feature.out @@ -20,13 +20,13 @@ ERROR: value 128 out of bounds for option "compress_level" DETAIL: Valid values are between "-31" and "31". -- compresstype cant be used with column table CREATE TABLE unsupported_feature.compressed_table_1024(id int) WITH(ORIENTATION = 'column', compresstype=2); -ERROR: only row orientation table support compresstype. +ERROR: compresstype can not be used in ustore table, segment table, column table, view, unlogged table or temp table. -- compresstype cant be used with temp table CREATE TEMP TABLE compressed_temp_table_1024(id int) WITH(compresstype=2); -ERROR: only row orientation table support compresstype. +ERROR: compresstype can not be used in ustore table, segment table, column table, view, unlogged table or temp table. -- compresstype cant be used with unlogged table CREATE unlogged TABLE compressed_unlogged_table_1024(id int) WITH(compresstype=2); -ERROR: only row orientation table support compresstype. +ERROR: compresstype can not be used in ustore table, segment table, column table, view, unlogged table or temp table. -- use compress_prealloc_chunks\compress_chunk_size\compress_level without compresstype CREATE TABLE unsupported_feature.compressed_table_1024(id int) WITH(compress_prealloc_chunks=5); ERROR: compress_chunk_size/compress_prealloc_chunks/compress_level/compress_byte_convert/compress_diff_convert should be used with compresstype. @@ -83,12 +83,12 @@ create table unsupported_feature.t_rowcompress_pglz_compresslevel(id int) with ( CREATE TABLE unsupported_feature.index_test(id int, c1 text); -- ustore CREATE TABLE unsupported_feature.ustore_table(id int, c1 text) WITH(compresstype=2, storage_type=ustore); --failed -ERROR: only row orientation table support compresstype. +ERROR: compresstype can not be used in ustore table, segment table, column table, view, unlogged table or temp table. CREATE INDEX tbl_pc_idx1 on unsupported_feature.index_test(c1) WITH(compresstype=2, storage_type=ustore); --failed ERROR: Can not use compress option in ustore index. -- segment CREATE TABLE unsupported_feature.segment_table(id int, c1 text) WITH(compresstype=2, segment=on); --failed -ERROR: only row orientation table support compresstype. +ERROR: compresstype can not be used in ustore table, segment table, column table, view, unlogged table or temp table. CREATE INDEX on unsupported_feature.index_test(c1) WITH(compresstype=2, segment=on); --failed ERROR: Can not use compress option in segment storage. -- set compress_diff_convert @@ -98,3 +98,18 @@ create table unsupported_feature.test(id int) with (compresstype=2); -- success alter table unsupported_feature.test set(Compresstype=1); -- failed ERROR: change compresstype OPTION is not supported alter table unsupported_feature.test set(Compress_level=3); -- success +create table lm_rcp_4 (c1 int,c2 varchar2,c3 number,c4 money,c5 CHAR(20),c6 CLOB,c7 blob,c8 DATE,c9 BOOLEAN,c10 TIMESTAMP,c11 point,columns12 cidr) with(Compresstype=2,Compress_chunk_size=512) + partition by list(c1) subpartition by range(c3)( + partition ts1 values(1,2,3,4,5)(subpartition ts11 values less than(500),subpartition ts12 values less than(5000),subpartition ts13 values less than(MAXVALUE)), + partition ts2 values(6,7,8,9,10), + partition ts3 values(11,12,13,14,15)(subpartition ts31 values less than(5000),subpartition ts32 values less than(10000),subpartition ts33 values less than(MAXVALUE)), + partition ts4 values(default)); +create unique index indexg_lm_rcp_4 on lm_rcp_4(c1 NULLS first,c2,c3) global +with(FILLFACTOR=80,Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert=1); +--s3. +alter index indexg_lm_rcp_4 rename to indexg_lm_rcp_4_newname; +--s4.修改压缩类型 +alter index indexg_lm_rcp_4_newname set(Compresstype=1); +ERROR: change compresstype OPTION is not supported +--s5.修改Compress_level +alter index indexg_lm_rcp_4_newname set(Compress_level=3); diff --git a/src/test/regress/sql/row_compression/unsupported_feature.sql b/src/test/regress/sql/row_compression/unsupported_feature.sql index 3fa3aec46..81d395c3a 100644 --- a/src/test/regress/sql/row_compression/unsupported_feature.sql +++ b/src/test/regress/sql/row_compression/unsupported_feature.sql @@ -63,4 +63,19 @@ create table unsupported_feature.compress_byte_test(id int) with (compresstype=2 create table unsupported_feature.test(id int) with (compresstype=2); -- success alter table unsupported_feature.test set(Compresstype=1); -- failed -alter table unsupported_feature.test set(Compress_level=3); -- success \ No newline at end of file +alter table unsupported_feature.test set(Compress_level=3); -- success + +create table lm_rcp_4 (c1 int,c2 varchar2,c3 number,c4 money,c5 CHAR(20),c6 CLOB,c7 blob,c8 DATE,c9 BOOLEAN,c10 TIMESTAMP,c11 point,columns12 cidr) with(Compresstype=2,Compress_chunk_size=512) + partition by list(c1) subpartition by range(c3)( + partition ts1 values(1,2,3,4,5)(subpartition ts11 values less than(500),subpartition ts12 values less than(5000),subpartition ts13 values less than(MAXVALUE)), + partition ts2 values(6,7,8,9,10), + partition ts3 values(11,12,13,14,15)(subpartition ts31 values less than(5000),subpartition ts32 values less than(10000),subpartition ts33 values less than(MAXVALUE)), + partition ts4 values(default)); +create unique index indexg_lm_rcp_4 on lm_rcp_4(c1 NULLS first,c2,c3) global +with(FILLFACTOR=80,Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert=1); +--s3. +alter index indexg_lm_rcp_4 rename to indexg_lm_rcp_4_newname; +--s4.修改压缩类型 +alter index indexg_lm_rcp_4_newname set(Compresstype=1); +--s5.修改Compress_level +alter index indexg_lm_rcp_4_newname set(Compress_level=3); \ No newline at end of file