!1530 1. 禁止pglz与compresslevel参数同时使用;2. 页内词典压缩当且仅当compression为yes,而不是compression为空或者为no。3. pg_rewind修改部分日志打印等级

Merge pull request !1530 from 吴岳川/master
This commit is contained in:
opengauss-bot
2022-03-07 11:01:55 +00:00
committed by Gitee
8 changed files with 22 additions and 13 deletions

View File

@ -586,7 +586,7 @@ static void CompressedFileCopy(const file_entry_t* entry, bool rebuild)
if (PQputCopyData(conn, linebuf, strlen(linebuf)) != 1) {
pg_fatal("could not send COPY data: %s", PQerrorMessage(conn));
}
pg_log(PG_PROGRESS, "CompressedFileCopy:%s", linebuf);
pg_log(PG_DEBUG, "CompressedFileCopy: %s", linebuf);
}
static void CompressedFileRemove(const file_entry_t* entry)
@ -598,7 +598,7 @@ static void CompressedFileRemove(const file_entry_t* entry)
remove_target_file(dst, false);
FormatPathToPcd(path, dst, MAXPGPATH);
remove_target_file(dst, false);
pg_log(PG_PROGRESS, "CompressedFileRemove: %s\n", path);
pg_log(PG_DEBUG, "CompressedFileRemove: %s\n", path);
}
/*

View File

@ -1288,7 +1288,7 @@ void CompressedFileTruncate(const char *path, const RewindCompressInfo *rewindCo
truncate_target_file(pcdPath, max_used_chunkno * chunkSize);
}
pc_munmap(map);
pg_log(PG_PROGRESS, "CompressedFileTruncate: %s\n", path);
pg_log(PG_DEBUG, "CompressedFileTruncate: %s\n", path);
}
void OpenCompressedPcaFile(const char* fileName, int32 chunkSize, int32 algorithm, bool rebuild)

View File

@ -1054,11 +1054,11 @@ Oid DefineIndex(Oid relationId, IndexStmt* stmt, Oid indexRelationId, bool is_al
}
}
TableCreateSupport indexCreateSupport{false,false,false,false,false,false};
TableCreateSupport indexCreateSupport{COMPRESS_TYPE_NONE, false, false, false, false, false};
ListCell* cell = NULL;
foreach (cell, stmt->options) {
DefElem* defElem = (DefElem*)lfirst(cell);
SetOneOfCompressOption(defElem->defname, &indexCreateSupport);
SetOneOfCompressOption(defElem, &indexCreateSupport);
}
CheckCompressOption(&indexCreateSupport);

View File

@ -1103,7 +1103,7 @@ static List* AddDefaultOptionsIfNeed(List* options, const char relkind, CreateSt
bool isUstore = false;
bool assignedStorageType = false;
TableCreateSupport tableCreateSupport{false,false,false,false,false,false};
TableCreateSupport tableCreateSupport{COMPRESS_TYPE_NONE, false, false, false, false, false};
(void)isOrientationSet(options, NULL, false);
foreach (cell, options) {
DefElem* def = (DefElem*)lfirst(cell);
@ -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 {
SetOneOfCompressOption(def->defname, &tableCreateSupport);
SetOneOfCompressOption(def, &tableCreateSupport);
}
if (pg_strcasecmp(def->defname, "orientation") == 0 && pg_strcasecmp(defGetString(def), ORIENTATION_ORC) == 0) {

View File

@ -2935,10 +2935,11 @@ bool is_cstore_option(char relkind, Datum reloptions)
return result;
}
void SetOneOfCompressOption(const char* defname, TableCreateSupport* tableCreateSupport)
void SetOneOfCompressOption(DefElem* defElem, TableCreateSupport* tableCreateSupport)
{
auto defname = defElem->defname;
if (pg_strcasecmp(defname, "compresstype") == 0) {
tableCreateSupport->compressType = true;
tableCreateSupport->compressType = defGetInt64(defElem);
} else if (pg_strcasecmp(defname, "compress_chunk_size") == 0) {
tableCreateSupport->compressChunkSize = true;
} else if (pg_strcasecmp(defname, "compress_prealloc_chunks") == 0) {
@ -2963,4 +2964,8 @@ void CheckCompressOption(TableCreateSupport *tableCreateSupport)
ereport(ERROR, (errcode(ERRCODE_INVALID_OPTION),
errmsg("compress_diff_convert should be used with compress_byte_convert.")));
}
if (tableCreateSupport->compressType != COMPRESS_TYPE_ZSTD && tableCreateSupport->compressLevel) {
ereport(ERROR, (errcode(ERRCODE_INVALID_OPTION),
errmsg("compress_level should be used with ZSTD algorithm.")));
}
}

View File

@ -132,7 +132,7 @@ typedef struct {
} relopt_parse_elt;
struct TableCreateSupport {
bool compressType;
int compressType;
bool compressLevel;
bool compressChunkSize;
bool compressPreAllocChunks;
@ -301,7 +301,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, int8 rowCompress = REL_CMPRS_PAGE_PLAIN);
void RowTblCheckHashBucketOption(List* options, StdRdOptions* std_opt);
void SetOneOfCompressOption(const char *defname, TableCreateSupport *tableCreateSupport);
void ForbidUserToSetCompressedOptions(List *options);
void SetOneOfCompressOption(DefElem* defElem, TableCreateSupport *tableCreateSupport);
void CheckCompressOption(TableCreateSupport *tableCreateSupport);
void ForbidUserToSetCompressedOptions(List *options);
#endif /* RELOPTIONS_H */

View File

@ -77,3 +77,6 @@ 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.
create table unspported_feature.t_rowcompress_pglz_compresslevel(id int) with (compresstype=1,compress_level=2); -- failed
ERROR: compress_level should be used with ZSTD algorithm.
create table unspported_feature.t_rowcompress_pglz_compresslevel(id int) with (compresstype=2,compress_level=2); -- success

View File

@ -48,5 +48,5 @@ create table unspported_feature.t_rowcompress_0007(cid int, name varchar2) with
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
create table unspported_feature.t_rowcompress_pglz_compresslevel(id int) with (compresstype=1,compress_level=2); -- failed
create table unspported_feature.t_rowcompress_pglz_compresslevel(id int) with (compresstype=2,compress_level=2); -- success