diff --git a/src/gausskernel/optimizer/commands/tablecmds.cpp b/src/gausskernel/optimizer/commands/tablecmds.cpp index 68a24e387..ad876fcee 100644 --- a/src/gausskernel/optimizer/commands/tablecmds.cpp +++ b/src/gausskernel/optimizer/commands/tablecmds.cpp @@ -9827,6 +9827,8 @@ static void ATExecAddColumn(List** wqueue, AlteredTableInfo* tab, Relation rel, } #endif + bool isDelta = RELATION_IS_DELTA(rel); + /* construct new attribute's pg_attribute entry */ attribute.attrelid = myrelid; (void)namestrcpy(&(attribute.attname), colDef->colname); @@ -9845,14 +9847,18 @@ static void ATExecAddColumn(List** wqueue, AlteredTableInfo* tab, Relation rel, attribute.attisdropped = false; attribute.attislocal = colDef->is_local; attribute.attkvtype = colDef->kvtype; - VerifyAttrCompressMode(colDef->cmprs_mode, attribute.attlen, colDef->colname); - attribute.attcmprmode = colDef->cmprs_mode; + if (!isDelta) { + VerifyAttrCompressMode(colDef->cmprs_mode, attribute.attlen, colDef->colname); + attribute.attcmprmode = colDef->cmprs_mode; + } else { + attribute.attcmprmode = ATT_CMPR_NOCOMPRESS; + } attribute.attinhcount = colDef->inhcount; attribute.attcollation = collOid; /* attribute.attacl is handled by InsertPgAttributeTuple */ ReleaseSysCache(typeTuple); - if (RelationIsRowFormat(rel) && ATT_CMPR_NOCOMPRESS < colDef->cmprs_mode + if (!isDelta && RelationIsRowFormat(rel) && ATT_CMPR_NOCOMPRESS < colDef->cmprs_mode && colDef->cmprs_mode <= ATT_CMPR_NUMSTR) { ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), diff --git a/src/test/regress/input/cstore_cmpr_delta.source b/src/test/regress/input/cstore_cmpr_delta.source index bef4299bc..9710b27da 100644 --- a/src/test/regress/input/cstore_cmpr_delta.source +++ b/src/test/regress/input/cstore_cmpr_delta.source @@ -19,4 +19,8 @@ CREATE TABLE cstore_cmpr_delta_macaddr ( distkey INT4, a1 macaddr -) with ( orientation = column, compression = low ) ; \ No newline at end of file +) with ( orientation = column, compression = low ) ; +create table t_1093961(id int) with (orientation = column); +alter table t_1093961 add column score varchar prefix; +select attcmprmode from pg_attribute where attname = 'score' and attrelid in (select relfilenode from pg_class where relname = 't_1093961'); +select attcmprmode from pg_attribute where attname = 'score' and attrelid in (select relfilenode from pg_class where relname in (select concat('pg_delta_', relfilenode) from (select relfilenode from pg_class where relname = 't_1093961'))); \ No newline at end of file diff --git a/src/test/regress/output/cstore_cmpr_delta.source b/src/test/regress/output/cstore_cmpr_delta.source index 34e9187c5..3f06893a4 100644 --- a/src/test/regress/output/cstore_cmpr_delta.source +++ b/src/test/regress/output/cstore_cmpr_delta.source @@ -41,3 +41,17 @@ CREATE TABLE cstore_cmpr_delta_macaddr a1 macaddr ) with ( orientation = column, compression = low ) ; ERROR: type "macaddr" is not supported in column store +create table t_1093961(id int) with (orientation = column); +alter table t_1093961 add column score varchar prefix; +select attcmprmode from pg_attribute where attname = 'score' and attrelid in (select relfilenode from pg_class where relname = 't_1093961'); + attcmprmode +------------- + 3 +(1 row) + +select attcmprmode from pg_attribute where attname = 'score' and attrelid in (select relfilenode from pg_class where relname in (select concat('pg_delta_', relfilenode) from (select relfilenode from pg_class where relname = 't_1093961'))); + attcmprmode +------------- + 0 +(1 row) +