forked from huawei/openGauss-server
!1503 压缩参数修改增加限制:compress_byte_convert需要与compress_diff_convert一起使用;compress_level需要使用zstd压缩算法时才能设置和修改
Merge pull request !1503 from 吴岳川/master
This commit is contained in:
commit
a939423194
|
|
@ -934,11 +934,7 @@ Oid DefineIndex(Oid relationId, IndexStmt* stmt, Oid indexRelationId, bool is_al
|
|||
SetOneOfCompressOption(defElem->defname, &indexCreateSupport);
|
||||
}
|
||||
|
||||
if (!indexCreateSupport.compressType && HasCompressOption(&indexCreateSupport)) {
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_OPTION),
|
||||
errmsg("compress_chunk_size/compress_prealloc_chunks/compress_level/compress_byte_convert/"
|
||||
"compress_diff_convert should be used with compresstype.")));
|
||||
}
|
||||
CheckCompressOption(&indexCreateSupport);
|
||||
/*
|
||||
* Parse AM-specific options, convert to text array form, validate.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1148,11 +1148,7 @@ static List* AddDefaultOptionsIfNeed(List* options, const char relkind, CreateSt
|
|||
if (noSupportTable && tableCreateSupport.compressType) {
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_OPTION), errmsg("only row orientation table support compresstype.")));
|
||||
}
|
||||
if (!tableCreateSupport.compressType && HasCompressOption(&tableCreateSupport)) {
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_OPTION),
|
||||
errmsg("compress_chunk_size/compress_prealloc_chunks/compress_level/compress_byte_convert/"
|
||||
"compress_diff_convert should be used with compresstype.")));
|
||||
}
|
||||
CheckCompressOption(&tableCreateSupport);
|
||||
|
||||
if (isUstore && !isCStore && !hasCompression) {
|
||||
DefElem* def = makeDefElem("compression", (Node *)makeString(COMPRESSION_NO));
|
||||
|
|
@ -14464,27 +14460,44 @@ static void ATExecSetRelOptionsToast(Oid toastid, List* defList, AlterTableType
|
|||
/*
|
||||
* Do not modify compression parameters.
|
||||
*/
|
||||
void static CheckSupportModifyCompression(Relation rel, bytea* relOoption)
|
||||
void static CheckSupportModifyCompression(Relation rel, bytea* relOoption, List* defList)
|
||||
{
|
||||
if (!relOoption || !REL_SUPPORT_COMPRESSED(rel)) {
|
||||
if (!relOoption) {
|
||||
return;
|
||||
}
|
||||
if (!REL_SUPPORT_COMPRESSED(rel) || rel->rd_node.opt == 0) {
|
||||
ForbidUserToSetCompressedOptions(defList);
|
||||
return;
|
||||
}
|
||||
PageCompressOpts* newCompressOpt = &(((StdRdOptions*)relOoption)->compress);
|
||||
RelFileCompressOption current;
|
||||
TransCompressOptions(rel->rd_node, ¤t);
|
||||
if (newCompressOpt) {
|
||||
int1 algorithm = newCompressOpt->compressType;
|
||||
if (algorithm != current.compressAlgorithm) {
|
||||
if (newCompressOpt->compressType != (int)current.compressAlgorithm) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("change compresstype OPTION is not supported")));
|
||||
}
|
||||
if (current.compressAlgorithm != COMPRESS_TYPE_NONE &&
|
||||
if ((int)current.compressAlgorithm != COMPRESS_TYPE_NONE &&
|
||||
newCompressOpt->compressChunkSize != CHUNK_SIZE_LIST[current.compressChunkSize]) {
|
||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("change compress_chunk_size OPTION is not supported")));
|
||||
}
|
||||
if (!newCompressOpt->compressByteConvert && newCompressOpt->compressDiffConvert) {
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_OPTION),
|
||||
errmsg("compress_diff_convert should be used with compress_byte_convert.")));
|
||||
}
|
||||
if (current.compressAlgorithm == COMPRESS_TYPE_PGLZ) {
|
||||
ListCell *opt = NULL;
|
||||
foreach (opt, defList) {
|
||||
DefElem *def = (DefElem *)lfirst(opt);
|
||||
if (pg_strcasecmp(def->defname, "compress_level") == 0) {
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_OPTION),
|
||||
errmsg("compress_level should be used with ZSTD algorithm.")));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (current.compressAlgorithm != COMPRESS_TYPE_NONE) {
|
||||
if ((int)current.compressAlgorithm != COMPRESS_TYPE_NONE) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("change compresstype OPTION is not supported")));
|
||||
}
|
||||
|
|
@ -14697,7 +14710,7 @@ static void ATExecSetRelOptions(Relation rel, List* defList, AlterTableType oper
|
|||
break;
|
||||
}
|
||||
|
||||
CheckSupportModifyCompression(rel, relOpt);
|
||||
CheckSupportModifyCompression(rel, relOpt, defList);
|
||||
|
||||
/*
|
||||
* All we need do here is update the pg_class row; the new options will be
|
||||
|
|
|
|||
|
|
@ -2604,6 +2604,25 @@ void ForbidUserToSetDefinedOptions(List *options)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @Description: compressed parameter cannot be changed by ALTER TABLE statement if table is uncompressed table.
|
||||
* this function do the checking work.
|
||||
* @Param[IN] options: input user options
|
||||
* @See also:
|
||||
*/
|
||||
void ForbidUserToSetCompressedOptions(List *options)
|
||||
{
|
||||
static const char *unSupportOptions[] = {"compresstype", "compress_chunk_size", "compress_prealloc_chunks",
|
||||
"compress_level", "compress_byte_convert", "compress_diff_convert"};
|
||||
int firstInvalidOpt = -1;
|
||||
if (FindInvalidOption(options, unSupportOptions, lengthof(unSupportOptions), &firstInvalidOpt)) {
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
(errmsg("Un-support feature"), errdetail("Option \"%s\" doesn't allow ALTER on uncompressed table",
|
||||
unSupportOptions[firstInvalidOpt]))));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @Description: forbid to change inner option
|
||||
* inner options only can be used by system itself.
|
||||
|
|
@ -2914,3 +2933,16 @@ void SetOneOfCompressOption(const char* defname, TableCreateSupport* tableCreate
|
|||
tableCreateSupport->compressDiffConvert = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CheckCompressOption(TableCreateSupport *tableCreateSupport)
|
||||
{
|
||||
if (!tableCreateSupport->compressType && HasCompressOption(tableCreateSupport)) {
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_OPTION),
|
||||
errmsg("compress_chunk_size/compress_prealloc_chunks/compress_level/compress_byte_convert/"
|
||||
"compress_diff_convert should be used with compresstype.")));
|
||||
}
|
||||
if (!tableCreateSupport->compressByteConvert && tableCreateSupport->compressDiffConvert) {
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_OPTION),
|
||||
errmsg("compress_diff_convert should be used with compress_byte_convert.")));
|
||||
}
|
||||
}
|
||||
|
|
@ -300,6 +300,8 @@ extern void forbid_to_set_options_for_timeseries_tbl(List* options);
|
|||
extern List* RemoveRelOption(List* options, const char* optName, bool* removed);
|
||||
void RowTblCheckCompressionOption(List *options);
|
||||
void RowTblCheckHashBucketOption(List* options, StdRdOptions* std_opt);
|
||||
void ForbidUserToSetCompressedOptions(List *options);
|
||||
void SetOneOfCompressOption(const char *defname, TableCreateSupport *tableCreateSupport);
|
||||
void CheckCompressOption(TableCreateSupport *tableCreateSupport);
|
||||
#endif /* RELOPTIONS_H */
|
||||
|
||||
|
|
|
|||
|
|
@ -68,3 +68,12 @@ ERROR: change compresstype OPTION is not supported
|
|||
ALTER TABLE unspported_feature.alter_table_option SET(compress_chunk_size=2048); -- fail
|
||||
ERROR: change compress_chunk_size OPTION is not supported
|
||||
ALTER TABLE unspported_feature.alter_table_option SET(compress_level=2, compress_prealloc_chunks=0);
|
||||
-- alter compress_byte_convert\compress_diff_convert
|
||||
create table unspported_feature.rolcompress_table_001(a int) with (compresstype=2, compress_diff_convert=true); -- fail
|
||||
ERROR: compress_diff_convert should be used with compress_byte_convert.
|
||||
create table unspported_feature.t_rowcompress_0007(cid int, name varchar2) with (compresstype=1);
|
||||
alter table unspported_feature.t_rowcompress_0007 set (compress_diff_convert=true); --fail
|
||||
ERROR: compress_diff_convert should be used with compress_byte_convert.
|
||||
alter table unspported_feature.t_rowcompress_0007 set (compress_byte_convert=true, compress_diff_convert=true); --success
|
||||
alter table unspported_feature.t_rowcompress_0007 set (compress_level=31); --failed
|
||||
ERROR: compress_level should be used with ZSTD algorithm.
|
||||
|
|
|
|||
|
|
@ -41,3 +41,12 @@ create TABLE unspported_feature.alter_table_option(id int) WITH(compresstype=2);
|
|||
ALTER TABLE unspported_feature.alter_table_option SET(compresstype=0); -- fail
|
||||
ALTER TABLE unspported_feature.alter_table_option SET(compress_chunk_size=2048); -- fail
|
||||
ALTER TABLE unspported_feature.alter_table_option SET(compress_level=2, compress_prealloc_chunks=0);
|
||||
-- alter compress_byte_convert\compress_diff_convert
|
||||
create table unspported_feature.rolcompress_table_001(a int) with (compresstype=2, compress_diff_convert=true); -- fail
|
||||
|
||||
create table unspported_feature.t_rowcompress_0007(cid int, name varchar2) with (compresstype=1);
|
||||
alter table unspported_feature.t_rowcompress_0007 set (compress_diff_convert=true); --fail
|
||||
alter table unspported_feature.t_rowcompress_0007 set (compress_byte_convert=true, compress_diff_convert=true); --success
|
||||
alter table unspported_feature.t_rowcompress_0007 set (compress_level=31); --failed
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue