diff --git a/src/gausskernel/optimizer/commands/indexcmds.cpp b/src/gausskernel/optimizer/commands/indexcmds.cpp index 6e735dccb..2d4a34842 100644 --- a/src/gausskernel/optimizer/commands/indexcmds.cpp +++ b/src/gausskernel/optimizer/commands/indexcmds.cpp @@ -1071,7 +1071,7 @@ Oid DefineIndex(Oid relationId, IndexStmt* stmt, Oid indexRelationId, bool is_al ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Can not use compress option in ustore index."))); } - if (pg_strcasecmp(defElem->defname, "segment") == 0 && defGetBoolean(defElem)) { + if (pg_strcasecmp(defElem->defname, "segment") == 0 && ReadBoolFromDefElem(defElem)) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Can not use compress option in segment storage."))); } diff --git a/src/gausskernel/optimizer/commands/tablecmds.cpp b/src/gausskernel/optimizer/commands/tablecmds.cpp index 1c02e0993..67d3eda78 100644 --- a/src/gausskernel/optimizer/commands/tablecmds.cpp +++ b/src/gausskernel/optimizer/commands/tablecmds.cpp @@ -1134,7 +1134,7 @@ static List* AddDefaultOptionsIfNeed(List* options, const char relkind, CreateSt (errcode(ERRCODE_INVALID_OPTION), errmsg("It is not allowed to assign version option for non-dfs table."))); } else if (pg_strcasecmp(def->defname, "segment") == 0){ - segment = defGetBoolean(def); + segment = ReadBoolFromDefElem(def); } else { SetOneOfCompressOption(def, &tableCreateSupport); } diff --git a/src/gausskernel/storage/access/common/reloptions.cpp b/src/gausskernel/storage/access/common/reloptions.cpp index a77abfe15..21b4eaa19 100644 --- a/src/gausskernel/storage/access/common/reloptions.cpp +++ b/src/gausskernel/storage/access/common/reloptions.cpp @@ -2935,6 +2935,16 @@ bool is_cstore_option(char relkind, Datum reloptions) return result; } +bool ReadBoolFromDefElem(DefElem* defElem) +{ + bool result = false; + char *boolStr = defGetString(defElem); + if (!parse_bool_with_len(boolStr, strlen(boolStr), &result)) { + ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires a Boolean value", defElem->defname))); + } + return result; +} + void SetOneOfCompressOption(DefElem* defElem, TableCreateSupport* tableCreateSupport) { auto defname = defElem->defname; @@ -2948,9 +2958,9 @@ void SetOneOfCompressOption(DefElem* defElem, TableCreateSupport* tableCreateSup } else if (pg_strcasecmp(defname, "compress_level") == 0) { tableCreateSupport->compressLevel = true; } else if (pg_strcasecmp(defname, "compress_byte_convert") == 0) { - tableCreateSupport->compressByteConvert = defGetBoolean(defElem); + tableCreateSupport->compressByteConvert = ReadBoolFromDefElem(defElem); } else if (pg_strcasecmp(defname, "compress_diff_convert") == 0) { - tableCreateSupport->compressDiffConvert = defGetBoolean(defElem); + tableCreateSupport->compressDiffConvert = ReadBoolFromDefElem(defElem); } } diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h index fb4c6a06d..4af6491da 100644 --- a/src/include/access/reloptions.h +++ b/src/include/access/reloptions.h @@ -303,6 +303,7 @@ void RowTblCheckCompressionOption(List *options, int8 rowCompress = REL_CMPRS_PA void RowTblCheckHashBucketOption(List* options, StdRdOptions* std_opt); void ForbidUserToSetCompressedOptions(List *options); void SetOneOfCompressOption(DefElem* defElem, TableCreateSupport *tableCreateSupport); +bool ReadBoolFromDefElem(DefElem* defElem); void CheckCompressOption(TableCreateSupport *tableCreateSupport); void ForbidUserToSetCompressedOptions(List *options); #endif /* RELOPTIONS_H */ diff --git a/src/test/regress/expected/row_compression/normal_test.out b/src/test/regress/expected/row_compression/normal_test.out index 1364f2ad4..a2707142b 100644 --- a/src/test/regress/expected/row_compression/normal_test.out +++ b/src/test/regress/expected/row_compression/normal_test.out @@ -200,6 +200,49 @@ Has OIDs: no Options: orientation=row, compresstype=2 create table normal_test.segment_off(id int) with (compresstype=2,segment=off); --success +--compress_diff_convert布尔值: +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert=t); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert='t'); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert='f'); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert=yes); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert='no'); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert='1'); +drop table if exists normal_test.tb1; +--compress_byte_convert布尔值: +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=t,compress_diff_convert=true); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert='t',compress_diff_convert=true); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=f,compress_diff_convert=false); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=yes,compress_diff_convert=TRUE); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=NO,compress_diff_convert=OFF); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert='1',compress_diff_convert=1); +drop table if exists normal_test.tb1; +--segment参数: +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = on); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = off); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = 1); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = 0); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = t); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = 't'); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = yes); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = no); +drop table if exists normal_test.t_bool_value; drop schema normal_test cascade; NOTICE: drop cascades to 8 other objects DETAIL: drop cascades to table normal_test.tbl_pc diff --git a/src/test/regress/sql/row_compression/normal_test.sql b/src/test/regress/sql/row_compression/normal_test.sql index cb1149ae4..8c7747fc5 100644 --- a/src/test/regress/sql/row_compression/normal_test.sql +++ b/src/test/regress/sql/row_compression/normal_test.sql @@ -76,4 +76,52 @@ create table normal_test.including_all_new2(like normal_test.including_all inclu \d+ normal_test.including_all_new \d+ normal_test.including_all_new2 create table normal_test.segment_off(id int) with (compresstype=2,segment=off); --success + + +--compress_diff_convert布尔值: +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert=t); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert='t'); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert='f'); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert=yes); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert='no'); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=1,compress_diff_convert='1'); +drop table if exists normal_test.tb1; + +--compress_byte_convert布尔值: +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=t,compress_diff_convert=true); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert='t',compress_diff_convert=true); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=f,compress_diff_convert=false); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=yes,compress_diff_convert=TRUE); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert=NO,compress_diff_convert=OFF); +drop table if exists normal_test.tb1; +create table normal_test.tb1 (c_int int, c_bool boolean) with (Compresstype=2,Compress_chunk_size=512,compress_byte_convert='1',compress_diff_convert=1); +drop table if exists normal_test.tb1; + +--segment参数: +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = on); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = off); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = 1); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = 0); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = t); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = 't'); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = yes); +drop table if exists normal_test.t_bool_value; +create table normal_test.t_bool_value (c_int int, c_bool boolean) with (segment = no); +drop table if exists normal_test.t_bool_value; + drop schema normal_test cascade; \ No newline at end of file