From c66d37c274af373900592d1f012d4a5f2016cb16 Mon Sep 17 00:00:00 2001 From: wuyuechuan Date: Fri, 18 Mar 2022 09:54:50 +0800 Subject: [PATCH] =?UTF-8?q?1=20=20ustore=20bugfix=202=20=20=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E6=AE=B5=E9=A1=B5=E5=BC=8F=E3=80=81USTORE=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9=E8=A1=A8=E4=BD=BF=E7=94=A8=203=20=20=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E5=8E=8B=E7=BC=A9=E8=A1=A8=E9=A1=B5=E9=9D=A2=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=204=20=20=E4=BF=AE=E5=A4=8Dremote=20read=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/catalog/catalog.cpp | 1 + src/common/backend/catalog/storage.cpp | 1 + src/common/backend/catalog/storage_gtt.cpp | 1 + .../cbb/grpc/remote_read_client.cpp | 5 +- .../optimizer/commands/indexcmds.cpp | 29 ++++++++--- .../optimizer/commands/tablecmds.cpp | 6 ++- .../optimizer/commands/verifyrepair.cpp | 49 ++++++++++++++----- .../process/postmaster/pagerepair.cpp | 19 ++++--- src/gausskernel/process/postmaster/pgstat.cpp | 1 + .../storage/access/redo/redo_dbcommands.cpp | 1 + .../storage/access/redo/redo_segpage.cpp | 2 + .../storage/access/redo/redo_tablespace.cpp | 1 + .../storage/access/redo/redo_xact.cpp | 1 + .../access/transam/extreme_rto/page_redo.cpp | 1 + .../storage/access/transam/xact.cpp | 1 + src/gausskernel/storage/buffer/bufmgr.cpp | 8 ++- .../storage/remote/remote_adapter.cpp | 9 ++-- .../storage/replication/basebackup.cpp | 1 + src/gausskernel/storage/replication/bcm.cpp | 1 + src/gausskernel/storage/smgr/md.cpp | 7 ++- .../storage/smgr/segment/data_file.cpp | 2 +- .../storage/smgr/segment/extent_group.cpp | 3 +- src/gausskernel/storage/smgr/segstore.cpp | 3 +- src/gausskernel/storage/smgr/smgr.cpp | 1 + .../storage/tcap/tcap_truncate.cpp | 1 + .../access/ustore/undo/knl_uundotype.h | 13 ++--- src/include/storage/smgr/relfilenode.h | 30 ++++++------ .../row_compression/unsupported_feature.out | 11 +++++ .../row_compression/unsupported_feature.sql | 10 +++- 29 files changed, 161 insertions(+), 58 deletions(-) diff --git a/src/common/backend/catalog/catalog.cpp b/src/common/backend/catalog/catalog.cpp index d5c9099c0..f1d168b13 100644 --- a/src/common/backend/catalog/catalog.cpp +++ b/src/common/backend/catalog/catalog.cpp @@ -491,6 +491,7 @@ RelFileNodeForkNum relpath_to_filenode(char* path) securec_check(rc, "\0", "\0"); filenode.rnode.node.spcNode = DEFAULTTABLESPACE_OID; filenode.rnode.node.bucketNode = InvalidBktId; + filenode.rnode.node.opt = 0; filenode.rnode.backend = InvalidBackendId; if (0 == strncmp(token, "global", 7)) { diff --git a/src/common/backend/catalog/storage.cpp b/src/common/backend/catalog/storage.cpp index a41dc4cbc..bc238184c 100644 --- a/src/common/backend/catalog/storage.cpp +++ b/src/common/backend/catalog/storage.cpp @@ -967,6 +967,7 @@ void push_del_rel_to_hashtbl(bool isCommit) entry->rnode.dbNode = pending->relnode.dbNode; entry->rnode.relNode = pending->relnode.relNode; entry->rnode.bucketNode = pending->relnode.bucketNode; + entry->rnode.opt = pending->relnode.opt; entry->maxSegNo = -1; } BatchClearBadBlock(pending->relnode, pending->forknum, 0); diff --git a/src/common/backend/catalog/storage_gtt.cpp b/src/common/backend/catalog/storage_gtt.cpp index 6d52e52df..544116ae0 100644 --- a/src/common/backend/catalog/storage_gtt.cpp +++ b/src/common/backend/catalog/storage_gtt.cpp @@ -561,6 +561,7 @@ static void gtt_storage_removeall(int code, Datum arg) rnode.spcNode = gtt_rnode->spcnode; rnode.dbNode = u_sess->proc_cxt.MyDatabaseId; rnode.relNode = gtt_rnode->relfilenode; + rnode.opt = 0; rnode.bucketNode = InvalidBktId; srel = smgropen(rnode, BackendIdForTempRelations); diff --git a/src/gausskernel/cbb/grpc/remote_read_client.cpp b/src/gausskernel/cbb/grpc/remote_read_client.cpp index 411530f59..2b5e7666e 100755 --- a/src/gausskernel/cbb/grpc/remote_read_client.cpp +++ b/src/gausskernel/cbb/grpc/remote_read_client.cpp @@ -284,9 +284,10 @@ extern int RemoteGetPage(char* remoteAddress, RepairBlockKey *key, uint32 blocks pblk->block, timeout); } else { tnRet = snprintf_s(sqlCommands, MAX_PATH_LEN, MAX_PATH_LEN - 1, - "SELECT gs_read_block_from_remote(%u, %u, %u, %d, %d, '%lu', %u, '%lu', false, %d);", + "SELECT gs_read_block_from_remote(%u, %u, %u, %d, %d, %d, '%lu', %u, '%lu', false, %d);", key->relfilenode.spcNode, key->relfilenode.dbNode, key->relfilenode.relNode, - key->relfilenode.bucketNode, key->relfilenode.opt, key->forknum, key->blocknum, blocksize, lsn, timeout); + key->relfilenode.bucketNode, (int2)key->relfilenode.opt, key->forknum, key->blocknum, + blocksize, lsn, timeout); } securec_check_ss(tnRet, "", ""); diff --git a/src/gausskernel/optimizer/commands/indexcmds.cpp b/src/gausskernel/optimizer/commands/indexcmds.cpp index 05ae60a60..8021a8c48 100644 --- a/src/gausskernel/optimizer/commands/indexcmds.cpp +++ b/src/gausskernel/optimizer/commands/indexcmds.cpp @@ -514,6 +514,15 @@ Oid DefineIndex(Oid relationId, IndexStmt* stmt, Oid indexRelationId, bool is_al lockmode = concurrent ? ShareUpdateExclusiveLock : ShareLock; rel = heap_open(relationId, lockmode); + TableCreateSupport indexCreateSupport{COMPRESS_TYPE_NONE, false, false, false, false, false}; + ListCell *cell = NULL; + foreach (cell, stmt->options) { + DefElem *defElem = (DefElem *)lfirst(cell); + SetOneOfCompressOption(defElem, &indexCreateSupport); + } + + CheckCompressOption(&indexCreateSupport); + /* Forbidden to create gin index on ustore table. */ if (rel->rd_tam_type == TAM_USTORE) { if (strcmp(stmt->accessMethod, "btree") == 0) { @@ -1054,13 +1063,21 @@ Oid DefineIndex(Oid relationId, IndexStmt* stmt, Oid indexRelationId, bool is_al } } - TableCreateSupport indexCreateSupport{COMPRESS_TYPE_NONE, false, false, false, false, false}; - ListCell* cell = NULL; - foreach (cell, stmt->options) { - DefElem* defElem = (DefElem*)lfirst(cell); - SetOneOfCompressOption(defElem, &indexCreateSupport); + if (indexCreateSupport.compressType || HasCompressOption(&indexCreateSupport)) { + foreach (cell, stmt->options) { + DefElem *defElem = (DefElem *)lfirst(cell); + if (pg_strcasecmp(defElem->defname, "storage_type") == 0 && + pg_strcasecmp(defGetString(defElem), "ustore") == 0) { + 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)) { + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Can not use compress option in segment storage."))); + } + } } - + CheckCompressOption(&indexCreateSupport); /* * Parse AM-specific options, convert to text array form, validate. diff --git a/src/gausskernel/optimizer/commands/tablecmds.cpp b/src/gausskernel/optimizer/commands/tablecmds.cpp index 4686ea5fb..9b300481d 100644 --- a/src/gausskernel/optimizer/commands/tablecmds.cpp +++ b/src/gausskernel/optimizer/commands/tablecmds.cpp @@ -1102,7 +1102,7 @@ static List* AddDefaultOptionsIfNeed(List* options, const char relkind, CreateSt bool createWithOrientationRow = false; /* To mark whether table have been create with(orientation = row) */ bool isUstore = false; bool assignedStorageType = false; - + bool segment = false; TableCreateSupport tableCreateSupport{COMPRESS_TYPE_NONE, false, false, false, false, false}; (void)isOrientationSet(options, NULL, false); foreach (cell, options) { @@ -1133,6 +1133,8 @@ static List* AddDefaultOptionsIfNeed(List* options, const char relkind, CreateSt ereport(ERROR, (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 = true; } else { SetOneOfCompressOption(def, &tableCreateSupport); } @@ -1160,7 +1162,7 @@ static List* AddDefaultOptionsIfNeed(List* options, const char relkind, CreateSt res = lappend(options, def); } - bool noSupportTable = isCStore || isTsStore || relkind != RELKIND_RELATION || + bool noSupportTable = segment || isUstore || isCStore || isTsStore || relkind != RELKIND_RELATION || stmt->relation->relpersistence == RELPERSISTENCE_UNLOGGED || stmt->relation->relpersistence == RELPERSISTENCE_TEMP || stmt->relation->relpersistence == RELPERSISTENCE_GLOBAL_TEMP; diff --git a/src/gausskernel/optimizer/commands/verifyrepair.cpp b/src/gausskernel/optimizer/commands/verifyrepair.cpp index 3f5eccee0..8f41aca2b 100644 --- a/src/gausskernel/optimizer/commands/verifyrepair.cpp +++ b/src/gausskernel/optimizer/commands/verifyrepair.cpp @@ -71,6 +71,23 @@ void initRepairBadBlockStat() } } +static void UnsupportedPageRepair(const char *path) +{ + char pcaPath[MAXPGPATH]; + int rc = 0; + rc = snprintf_s(pcaPath, MAXPGPATH, MAXPGPATH - 1, "%s/%s_pca", t_thrd.proc_cxt.DataDir, path); + securec_check_ss(rc, "\0", "\0"); + + char pcdPath[MAXPGPATH]; + rc = snprintf_s(pcdPath, MAXPGPATH, MAXPGPATH - 1, "%s/%s_pcd", t_thrd.proc_cxt.DataDir, path); + struct stat pcaStat; + struct stat pcdStat; + bool pcaState = stat(pcaPath, &pcaStat) == 0; + bool pcdState = stat(pcdPath, &pcdStat) == 0; + if (pcaState || pcdState) { + ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errmsg("Compressed Table is not allowed here.")))); + } +} /* BatchClearBadBlock * clear global_repair_bad_block_stat hashtable entry when the relation drop or truncate. @@ -167,6 +184,7 @@ void UpdateRepairTime(const RelFileNode &rnode, ForkNumber forknum, BlockNumber key.relfilenode.dbNode = rnode.dbNode; key.relfilenode.relNode = rnode.relNode; key.relfilenode.bucketNode = rnode.bucketNode; + key.relfilenode.opt = 0; key.forknum = forknum; key.blocknum = blocknum; @@ -208,6 +226,7 @@ void addGlobalRepairBadBlockStat(const RelFileNodeBackend &rnode, ForkNumber for key.relfilenode.dbNode = rnode.node.dbNode; key.relfilenode.relNode = rnode.node.relNode; key.relfilenode.bucketNode = rnode.node.bucketNode; + key.relfilenode.opt = 0; key.forknum = forknum; key.blocknum = blocknum; @@ -360,6 +379,7 @@ bool tryRepairPage(int blocknum, bool is_segment, RelFileNode *relnode, int time logicalRelNode.spcNode = relnode->spcNode; logicalRelNode.dbNode = relnode->dbNode; logicalRelNode.bucketNode = SegmentBktId; + logicalRelNode.opt = 0; logicalBlocknum = loc.blocknum; } @@ -576,6 +596,8 @@ Datum gs_repair_page(PG_FUNCTION_ARGS) bool is_segment = PG_GETARG_BOOL(2); int32 timeout = PG_GETARG_INT32(3); + UnsupportedPageRepair(path); + bool result = repairPage(path, blockNum, is_segment, timeout); PG_RETURN_BOOL(result); } @@ -602,6 +624,8 @@ Datum gs_repair_file(PG_FUNCTION_ARGS) char* path = text_to_cstring(PG_GETARG_TEXT_P(1)); int32 timeout = PG_GETARG_INT32(2); + UnsupportedPageRepair(path); + if (!CheckRelDataFilePath(path)) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errmsg("The input path(%s) is an incorrect relation file path input. \n", path)))); @@ -780,6 +804,8 @@ Datum gs_verify_and_tryrepair_page(PG_FUNCTION_ARGS) int j = 1; XLogPhyBlock pblk = {0, 0, 0}; + UnsupportedPageRepair(path); + /* build tupdesc for result tuples */ tupdesc = CreateTemplateTupleDesc(REPAIR_BLOCK_STAT_NATTS, false); TupleDescInitEntry(tupdesc, (AttrNumber)j++, "node_name", TEXTOID, -1, 0); @@ -854,14 +880,13 @@ Datum gs_read_segment_block_from_remote(PG_FUNCTION_ARGS) uint32 dbNode = PG_GETARG_UINT32(1); uint32 relNode = PG_GETARG_UINT32(2); int16 bucketNode = PG_GETARG_INT16(3); - uint16 opt = PG_GETARG_INT16(4); - int32 forkNum = PG_GETARG_INT32(5); - uint64 blockNum = (uint64)PG_GETARG_TRANSACTIONID(6); - uint32 blockSize = PG_GETARG_UINT32(7); - uint64 lsn = (uint64)PG_GETARG_TRANSACTIONID(8); - uint32 seg_relNode = PG_GETARG_UINT32(9); - uint32 seg_block = PG_GETARG_UINT32(10); - int32 timeout = PG_GETARG_INT32(11); + int32 forkNum = PG_GETARG_INT32(4); + uint64 blockNum = (uint64)PG_GETARG_TRANSACTIONID(5); + uint32 blockSize = PG_GETARG_UINT32(6); + uint64 lsn = (uint64)PG_GETARG_TRANSACTIONID(7); + uint32 seg_relNode = PG_GETARG_UINT32(8); + uint32 seg_block = PG_GETARG_UINT32(9); + int32 timeout = PG_GETARG_INT32(10); XLogPhyBlock pblk = { .relNode = seg_relNode, @@ -874,7 +899,7 @@ Datum gs_read_segment_block_from_remote(PG_FUNCTION_ARGS) key.relfilenode.dbNode = dbNode; key.relfilenode.relNode = relNode; key.relfilenode.bucketNode = bucketNode; - key.relfilenode.opt = opt; + key.relfilenode.opt = 0; key.forknum = forkNum; key.blocknum = blockNum; @@ -1114,7 +1139,8 @@ List* getSegmentBadFiles(List* spcList, List* badFileItems) .spcNode = lfirst_oid(currentCell), .dbNode = u_sess->proc_cxt.MyDatabaseId, .relNode = 1, - .bucketNode = SegmentBktId + .bucketNode = SegmentBktId, + .opt = 0 }; char* segmentDir = relSegmentDir(relFileNode, MAIN_FORKNUM); List* segmentFiles = getSegmentMainFilesPath(segmentDir, '/', 5); @@ -1576,7 +1602,8 @@ bool gsRepairCsnOrCLog(char* path, int timeout) .spcNode = (uint32)transType, .dbNode = 0, .relNode = logName, - .bucketNode = InvalidBktId + .bucketNode = InvalidBktId, + .opt = 0 }; RemoteReadFileKey repairFileKey = { diff --git a/src/gausskernel/process/postmaster/pagerepair.cpp b/src/gausskernel/process/postmaster/pagerepair.cpp index 9c68bcf12..68ebc65e7 100644 --- a/src/gausskernel/process/postmaster/pagerepair.cpp +++ b/src/gausskernel/process/postmaster/pagerepair.cpp @@ -71,13 +71,13 @@ static void SeqRemoteReadFile(); static void checkOtherFile(RepairFileKey key, uint32 max_segno, uint64 size); static void PushBadFileToRemoteHashTbl(RepairFileKey key); -#define COMPARE_REPAIR_PAGE_KEY(key1, key2) \ - ((key1).relfilenode.relNode == (key2).relfilenode.relNode && \ - (key1).relfilenode.dbNode == (key2).relfilenode.dbNode && \ - (key1).relfilenode.spcNode == (key2).relfilenode.spcNode && \ - (key1).relfilenode.bucketNode == (key2).relfilenode.bucketNode && \ - (key1).forknum == (key2).forknum && \ - (key1).blocknum == (key2).blocknum) +#define COMPARE_REPAIR_PAGE_KEY(key1, key2) \ + ((key1).relfilenode.relNode == (key2).relfilenode.relNode && \ + (key1).relfilenode.dbNode == (key2).relfilenode.dbNode && \ + (key1).relfilenode.spcNode == (key2).relfilenode.spcNode && \ + (key1).relfilenode.bucketNode == (key2).relfilenode.bucketNode && \ + (key1).relfilenode.opt == (key2).relfilenode.opt && (key1).forknum == (key2).forknum && \ + (key1).blocknum == (key2).blocknum) #define NOT_SUPPORT_PAGE_REPAIR \ (g_instance.attr.attr_common.cluster_run_mode == RUN_MODE_STANDBY || \ @@ -935,6 +935,7 @@ static void PushBadFileToRemoteHashTbl(RepairFileKey key) entry->key.relfilenode.dbNode = key.relfilenode.dbNode; entry->key.relfilenode.spcNode = key.relfilenode.spcNode; entry->key.relfilenode.bucketNode = key.relfilenode.bucketNode; + entry->key.relfilenode.opt = key.relfilenode.opt; entry->key.forknum = key.forknum; entry->key.segno = key.segno; entry->min_recovery_point = min_recovery_point; @@ -1438,6 +1439,7 @@ bool CheckAllSegmentFileRepair(RepairFileKey key, uint32 max_segno) temp_key.relfilenode.dbNode = key.relfilenode.dbNode; temp_key.relfilenode.spcNode = key.relfilenode.spcNode; temp_key.relfilenode.bucketNode = key.relfilenode.bucketNode; + temp_key.relfilenode.bucketNode = key.relfilenode.opt; temp_key.forknum = key.forknum; temp_key.segno = i; @@ -1460,6 +1462,7 @@ bool CheckAllSegmentFileRepair(RepairFileKey key, uint32 max_segno) rename_key.relfilenode.dbNode = key.relfilenode.dbNode; rename_key.relfilenode.spcNode = key.relfilenode.spcNode; rename_key.relfilenode.bucketNode = key.relfilenode.bucketNode; + rename_key.relfilenode.opt = key.relfilenode.opt; rename_key.forknum = key.forknum; rename_key.segno = i; @@ -1484,6 +1487,7 @@ bool CheckAllSegmentFileRepair(RepairFileKey key, uint32 max_segno) change_key.relfilenode.dbNode = key.relfilenode.dbNode; change_key.relfilenode.spcNode = key.relfilenode.spcNode; change_key.relfilenode.bucketNode = key.relfilenode.bucketNode; + change_key.relfilenode.opt = key.relfilenode.opt; change_key.forknum = key.forknum; change_key.segno = i; @@ -1600,6 +1604,7 @@ static void checkOtherFile(RepairFileKey key, uint32 max_segno, uint64 size) temp_key.relfilenode.dbNode = key.relfilenode.dbNode; temp_key.relfilenode.spcNode = key.relfilenode.spcNode; temp_key.relfilenode.bucketNode = key.relfilenode.bucketNode; + temp_key.relfilenode.opt = key.relfilenode.opt; temp_key.forknum = key.forknum; temp_key.segno = i; diff --git a/src/gausskernel/process/postmaster/pgstat.cpp b/src/gausskernel/process/postmaster/pgstat.cpp index 2fd975b7b..79d69bdb9 100644 --- a/src/gausskernel/process/postmaster/pgstat.cpp +++ b/src/gausskernel/process/postmaster/pgstat.cpp @@ -9649,6 +9649,7 @@ void addBadBlockStat(const RelFileNode* relfilenode, ForkNumber forknum) hash_key.relfilenode.dbNode = relfilenode->dbNode; hash_key.relfilenode.relNode = relfilenode->relNode; hash_key.relfilenode.bucketNode = relfilenode->bucketNode; + hash_key.relfilenode.opt = relfilenode->opt; hash_key.forknum = forknum; bool found = false; diff --git a/src/gausskernel/storage/access/redo/redo_dbcommands.cpp b/src/gausskernel/storage/access/redo/redo_dbcommands.cpp index 1183fd97a..bc8314f42 100644 --- a/src/gausskernel/storage/access/redo/redo_dbcommands.cpp +++ b/src/gausskernel/storage/access/redo/redo_dbcommands.cpp @@ -65,6 +65,7 @@ XLogRecParseState *DatabaseXlogCommonParseToBlock(XLogReaderState *record, uint3 } rnode.bucketNode = InvalidBktId; + rnode.opt = 0; (*blocknum)++; XLogParseBufferAllocListFunc(record, &recordstatehead, NULL); diff --git a/src/gausskernel/storage/access/redo/redo_segpage.cpp b/src/gausskernel/storage/access/redo/redo_segpage.cpp index b898fcb3a..26ae98c49 100644 --- a/src/gausskernel/storage/access/redo/redo_segpage.cpp +++ b/src/gausskernel/storage/access/redo/redo_segpage.cpp @@ -67,6 +67,7 @@ static XLogRecParseState *segpage_redo_parse_space_drop(XLogReaderState *record, rnode.spcNode = *(Oid *)data; rnode.dbNode = *(Oid *)(data + sizeof(Oid)); rnode.relNode = InvalidOid; + rnode.opt = 0; rnode.bucketNode = InvalidBktId; (*blocknum)++; @@ -425,6 +426,7 @@ void SegPageRedoSpaceShrink(XLogBlockHead *blockhead) rnode.dbNode = blockhead->dbNode; rnode.relNode = blockhead->relNode; rnode.bucketNode = blockhead->bucketNode; + rnode.opt = 0; char *path = relpathperm(rnode, blockhead->forknum); ereport(LOG, (errmsg("call space shrink files, filename: %s, xlog lsn: %lX", path, blockhead->end_ptr))); pfree(path); diff --git a/src/gausskernel/storage/access/redo/redo_tablespace.cpp b/src/gausskernel/storage/access/redo/redo_tablespace.cpp index c907f47e3..4dfff0ed7 100644 --- a/src/gausskernel/storage/access/redo/redo_tablespace.cpp +++ b/src/gausskernel/storage/access/redo/redo_tablespace.cpp @@ -98,6 +98,7 @@ XLogRecParseState *tblspc_xlog_common_parse_to_block(XLogReaderState *record, ui relnode.dbNode = InvalidOid; relnode.relNode = InvalidOid; relnode.bucketNode = InvalidBktId; + relnode.opt = 0; (*blocknum)++; XLogParseBufferAllocListFunc(record, &recordstatehead, NULL); if (recordstatehead == NULL) { diff --git a/src/gausskernel/storage/access/redo/redo_xact.cpp b/src/gausskernel/storage/access/redo/redo_xact.cpp index 4808ba9ba..827bb8ffd 100644 --- a/src/gausskernel/storage/access/redo/redo_xact.cpp +++ b/src/gausskernel/storage/access/redo/redo_xact.cpp @@ -294,6 +294,7 @@ XLogRecParseState *xact_xlog_commit_parse_to_block(XLogReaderState *record, XLog relnode.spcNode = InvalidOid; relnode.relNode = InvalidOid; relnode.bucketNode = InvalidBktId; + relnode.opt = 0; (*blocknum)++; XLogParseBufferAllocListStateFunc(record, &blockstate, &recordstatehead); diff --git a/src/gausskernel/storage/access/transam/extreme_rto/page_redo.cpp b/src/gausskernel/storage/access/transam/extreme_rto/page_redo.cpp index b72db3d56..f0f7237e2 100755 --- a/src/gausskernel/storage/access/transam/extreme_rto/page_redo.cpp +++ b/src/gausskernel/storage/access/transam/extreme_rto/page_redo.cpp @@ -2912,6 +2912,7 @@ void RecordBadBlockAndPushToRemote(XLogBlockDataParse *datadecode, PageErrorType key.relfilenode.dbNode = state->blockparse.blockhead.dbNode; key.relfilenode.relNode = state->blockparse.blockhead.relNode; key.relfilenode.bucketNode = state->blockparse.blockhead.bucketNode; + key.relfilenode.opt = state->blockparse.blockhead.opt; key.forknum = state->blockparse.blockhead.forknum; key.blocknum = state->blockparse.blockhead.blkno; diff --git a/src/gausskernel/storage/access/transam/xact.cpp b/src/gausskernel/storage/access/transam/xact.cpp index 205e035f5..e78f94dd1 100755 --- a/src/gausskernel/storage/access/transam/xact.cpp +++ b/src/gausskernel/storage/access/transam/xact.cpp @@ -7174,6 +7174,7 @@ void push_unlink_rel_to_hashtbl(ColFileNodeRel *xnodes, int nrels) entry->rnode.dbNode = colFileNode.filenode.dbNode; entry->rnode.relNode = colFileNode.filenode.relNode; entry->rnode.bucketNode = colFileNode.filenode.bucketNode; + entry->rnode.opt = colFileNode.filenode.opt; entry->maxSegNo = -1; del_rel_num++; } diff --git a/src/gausskernel/storage/buffer/bufmgr.cpp b/src/gausskernel/storage/buffer/bufmgr.cpp index 121dc1e97..2b73fb32a 100644 --- a/src/gausskernel/storage/buffer/bufmgr.cpp +++ b/src/gausskernel/storage/buffer/bufmgr.cpp @@ -1360,6 +1360,7 @@ void PageListBackWrite(uint32 *buf_list, int32 nbufs, uint32 flags = 0, SMgrRela Assert(smgrReln->smgr_rnode.node.dbNode == bufHdr->tag.rnode.dbNode); Assert(smgrReln->smgr_rnode.node.relNode == bufHdr->tag.rnode.relNode); Assert(smgrReln->smgr_rnode.node.bucketNode == bufHdr->tag.rnode.bucketNode); + Assert(smgrReln->smgr_rnode.node.opt == bufHdr->tag.rnode.opt); /* PageListBackWrite: jeh XLogFlush blocking? */ /* @@ -1985,7 +1986,8 @@ static bool ReadBuffer_common_ReadBlock(SMgrRelation smgr, char relpersistence, .spcNode = spc->spcNode, .dbNode = spc->dbNode, .relNode = pblk->relNode, - .bucketNode = SegmentBktId + .bucketNode = SegmentBktId, + .opt = 0 }; seg_physical_read(spc, fakenode, forkNum, pblk->block, (char *)bufBlock); if (PageIsVerified((Page)bufBlock, pblk->block)) { @@ -4446,7 +4448,8 @@ void FlushBuffer(void *buf, SMgrRelation reln, ReadBufferMethod flushmethod, boo .spcNode = spc->spcNode, .dbNode = spc->dbNode, .relNode = bufdesc->seg_fileno, - .bucketNode = SegmentBktId + .bucketNode = SegmentBktId, + .opt = 0 }; seg_physical_write(spc, fakenode, bufferinfo.blockinfo.forknum, bufdesc->seg_blockno, bufToWrite, false); } else { @@ -6532,6 +6535,7 @@ int ckpt_buforder_comparator(const void *pa, const void *pb) } else { /* should not be the same block ... */ return 1; } + /* do not need to compare opt */ } /* diff --git a/src/gausskernel/storage/remote/remote_adapter.cpp b/src/gausskernel/storage/remote/remote_adapter.cpp index ed20092bc..0adcf7d73 100755 --- a/src/gausskernel/storage/remote/remote_adapter.cpp +++ b/src/gausskernel/storage/remote/remote_adapter.cpp @@ -282,8 +282,8 @@ int StandbyReadPageforPrimary(RepairBlockKey key, uint32 blocksize, uint64 lsn, } } - RelFileNode relfilenode {key.relfilenode.spcNode, key.relfilenode.dbNode, key.relfilenode.relNode, - key.relfilenode.bucketNode}; + RelFileNode relfilenode{key.relfilenode.spcNode, key.relfilenode.dbNode, key.relfilenode.relNode, + key.relfilenode.bucketNode, key.relfilenode.opt}; if (NULL != pblk) { SegPageLocation loc = seg_get_physical_location(relfilenode, key.forknum, key.blocknum); @@ -383,6 +383,7 @@ Datum gs_read_file_from_remote(PG_FUNCTION_ARGS) rnode.dbNode = PG_GETARG_UINT32(parano++); rnode.relNode = PG_GETARG_UINT32(parano++); rnode.bucketNode = PG_GETARG_INT32(parano++); + rnode.opt = 0; forknum = PG_GETARG_INT32(parano++); blockstart = PG_GETARG_INT32(parano++); lsn = (uint64)PG_GETARG_TRANSACTIONID(parano++); @@ -443,6 +444,7 @@ Datum gs_read_file_size_from_remote(PG_FUNCTION_ARGS) rnode.dbNode = PG_GETARG_UINT32(parano++); rnode.relNode = PG_GETARG_UINT32(parano++); rnode.bucketNode = PG_GETARG_INT32(parano++); + rnode.opt = 0; forknum = PG_GETARG_INT32(parano++); lsn = (uint64)PG_GETARG_TRANSACTIONID(parano++); timeout = PG_GETARG_INT32(parano++); @@ -555,7 +557,8 @@ int ReadFileByReadDisk(SegSpace* spc, RemoteReadFileKey *key, char* bufBlock, Bl .spcNode = key->relfilenode.spcNode, .dbNode = key->relfilenode.dbNode, .relNode = key->relfilenode.relNode, - .bucketNode = SegmentBktId + .bucketNode = SegmentBktId, + .opt = 0 }; SEG_RETRY: seg_physical_read(spc, fakenode, key->forknum, blocknum, (char *)bufBlock); diff --git a/src/gausskernel/storage/replication/basebackup.cpp b/src/gausskernel/storage/replication/basebackup.cpp index 3d69fe40b..781e1ccf3 100755 --- a/src/gausskernel/storage/replication/basebackup.cpp +++ b/src/gausskernel/storage/replication/basebackup.cpp @@ -1686,6 +1686,7 @@ UndoFileType CheckUndoPath(const char* fname, int* segNo) rnode.dbNode = InvalidOid; rnode.relNode = InvalidOid; rnode.bucketNode = InvalidBktId; + rnode.opt = 0; /* undo file and undo transaction slot file Checking */ if (sscanf_s(fname, "undo/permanent/%05X.%07zX", &rnode.relNode, segNo) == MATCH_TWO) { return UNDO_RECORD; diff --git a/src/gausskernel/storage/replication/bcm.cpp b/src/gausskernel/storage/replication/bcm.cpp index dec964ef9..bd82f48e2 100644 --- a/src/gausskernel/storage/replication/bcm.cpp +++ b/src/gausskernel/storage/replication/bcm.cpp @@ -144,6 +144,7 @@ void createBCMFile(Relation rel, int col) hd->node.relNode = rel->rd_node.relNode; hd->node.spcNode = rel->rd_node.spcNode; hd->node.bucketNode = rel->rd_node.bucketNode; + hd->node.opt = 0; hd->blockSize = col > 0 ? CUAlignUtils::GetCuAlignSizeColumnId(col) : BLCKSZ; /* defaut size for ROW_STORE */ if (col > 0) diff --git a/src/gausskernel/storage/smgr/md.cpp b/src/gausskernel/storage/smgr/md.cpp index 117aeef27..1a4ca5498 100644 --- a/src/gausskernel/storage/smgr/md.cpp +++ b/src/gausskernel/storage/smgr/md.cpp @@ -1815,7 +1815,12 @@ SMGR_READ_STATUS mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber block static THR_LOCAL Oid lstSpc = InvalidOid; if (IS_COMPRESSED_MAINFORK(reln, forknum)) { - return mdread_pc(reln, forknum, blocknum, buffer) ? SMGR_RD_OK : SMGR_RD_CRC_ERROR; + bool success = mdread_pc(reln, forknum, blocknum, buffer); + if (success && PageIsVerified((Page)buffer, blocknum)) { + return SMGR_RD_OK; + } else { + return SMGR_RD_CRC_ERROR; + } } (void)INSTR_TIME_SET_CURRENT(startTime); diff --git a/src/gausskernel/storage/smgr/segment/data_file.cpp b/src/gausskernel/storage/smgr/segment/data_file.cpp index 4201cb2d3..d3268e23d 100644 --- a/src/gausskernel/storage/smgr/segment/data_file.cpp +++ b/src/gausskernel/storage/smgr/segment/data_file.cpp @@ -764,7 +764,7 @@ int seg_unlink_filetag(const FileTag *ftag, char *path) void segForgetDatabaseFsyncRequests(Oid dbid) { FileTag tag; - RelFileNode rnode = {.spcNode = 0, .dbNode = dbid, .relNode = 0, .bucketNode = InvalidBktId}; + RelFileNode rnode = {.spcNode = 0, .dbNode = dbid, .relNode = 0, .bucketNode = InvalidBktId, .opt = 0}; tag.rnode = rnode; tag.handler = SYNC_HANDLER_SEGMENT; diff --git a/src/gausskernel/storage/smgr/segment/extent_group.cpp b/src/gausskernel/storage/smgr/segment/extent_group.cpp index 9cd35131b..d674ff8ff 100644 --- a/src/gausskernel/storage/smgr/segment/extent_group.cpp +++ b/src/gausskernel/storage/smgr/segment/extent_group.cpp @@ -174,7 +174,8 @@ void eg_ctrl_init(SegSpace *spc, SegExtentGroup *seg, int extent_size, ForkNumbe seg->rnode = {.spcNode = spc->spcNode, .dbNode = spc->dbNode, .relNode = EXTENT_SIZE_TO_TYPE(extent_size), - .bucketNode = SegmentBktId}; + .bucketNode = SegmentBktId, + .opt = 0}; seg->forknum = forknum; seg->map_head_entry = DF_MAP_HEAD_PAGE; diff --git a/src/gausskernel/storage/smgr/segstore.cpp b/src/gausskernel/storage/smgr/segstore.cpp index efd4120fb..f2ddbfc34 100755 --- a/src/gausskernel/storage/smgr/segstore.cpp +++ b/src/gausskernel/storage/smgr/segstore.cpp @@ -187,7 +187,8 @@ RelFileNode EXTENT_GROUP_RNODE(SegSpace *spc, ExtentSize extentSize) return {.spcNode = spc->spcNode, .dbNode = spc->dbNode, .relNode = EXTENT_SIZE_TO_TYPE(extentSize), - .bucketNode = SegmentBktId}; + .bucketNode = SegmentBktId, + .opt = 0}; } void seg_head_update_xlog(Buffer head_buffer, SegmentHead *seg_head, int level0_slot, diff --git a/src/gausskernel/storage/smgr/smgr.cpp b/src/gausskernel/storage/smgr/smgr.cpp index 210045dae..b76bbfe3b 100644 --- a/src/gausskernel/storage/smgr/smgr.cpp +++ b/src/gausskernel/storage/smgr/smgr.cpp @@ -962,6 +962,7 @@ static void push_unlink_rel_one_fork_to_hashtbl(RelFileNode node, ForkNumber for entry->forkrnode.rnode.dbNode = key.rnode.dbNode; entry->forkrnode.rnode.relNode = key.rnode.relNode; entry->forkrnode.rnode.bucketNode = key.rnode.bucketNode; + entry->forkrnode.rnode.opt = key.rnode.opt; entry->forkrnode.forkNum = key.forkNum; entry->maxSegNo = -1; del_rel_num++; diff --git a/src/gausskernel/storage/tcap/tcap_truncate.cpp b/src/gausskernel/storage/tcap/tcap_truncate.cpp index 9fb89f4f5..0303a2640 100644 --- a/src/gausskernel/storage/tcap/tcap_truncate.cpp +++ b/src/gausskernel/storage/tcap/tcap_truncate.cpp @@ -396,6 +396,7 @@ void TrDoPurgeObjectTruncate(TrObjDesc *desc) rnode.dbNode = (rnode.spcNode == GLOBALTABLESPACE_OID) ? InvalidOid : u_sess->proc_cxt.MyDatabaseId; rnode.relNode = rbForm->rcyrelfilenode; + rnode.opt = 0; rnode.bucketNode = InvalidBktId; /* diff --git a/src/include/access/ustore/undo/knl_uundotype.h b/src/include/access/ustore/undo/knl_uundotype.h index e5e2fd469..22140747d 100644 --- a/src/include/access/ustore/undo/knl_uundotype.h +++ b/src/include/access/ustore/undo/knl_uundotype.h @@ -173,12 +173,13 @@ typedef enum { /* Populate a RelFileNode from an UndoRecPtr. */ -#define UNDO_PTR_ASSIGN_REL_FILE_NODE(rfn, urp, dbId) \ - do { \ - (rfn).spcNode = DEFAULTTABLESPACE_OID; \ - (rfn).dbNode = dbId; \ - (rfn).relNode = UNDO_PTR_GET_REL_NODE(urp); \ - (rfn).bucketNode = InvalidBktId; \ +#define UNDO_PTR_ASSIGN_REL_FILE_NODE(rfn, urp, dbId) \ + do { \ + (rfn).spcNode = DEFAULTTABLESPACE_OID; \ + (rfn).dbNode = dbId; \ + (rfn).relNode = UNDO_PTR_GET_REL_NODE(urp); \ + (rfn).bucketNode = InvalidBktId; \ + (rfn).opt = 0; \ } while (false); #define DECLARE_NODE_COUNT() \ diff --git a/src/include/storage/smgr/relfilenode.h b/src/include/storage/smgr/relfilenode.h index b984c7b7f..d283d100b 100644 --- a/src/include/storage/smgr/relfilenode.h +++ b/src/include/storage/smgr/relfilenode.h @@ -135,12 +135,13 @@ typedef struct RelFileNodeOld } while(0) #define RelFileNodeCopy(relFileNode, relFileNodeRel, bucketid) \ - do { \ - (relFileNode).spcNode = (relFileNodeRel).spcNode; \ - (relFileNode).dbNode = (relFileNodeRel).dbNode; \ - (relFileNode).relNode = (relFileNodeRel).relNode; \ - (relFileNode).bucketNode = (bucketid); \ - } while(0) + do { \ + (relFileNode).spcNode = (relFileNodeRel).spcNode; \ + (relFileNode).dbNode = (relFileNodeRel).dbNode; \ + (relFileNode).relNode = (relFileNodeRel).relNode; \ + (relFileNode).bucketNode = (bucketid); \ + (relFileNode).opt = 0; \ + } while (0) #define RelFileNodeV2Copy(relFileNodeV2, relFileNode) \ do { \ @@ -291,14 +292,15 @@ static inline StorageType forknum_get_storage_type(const ForkNumber& forknum) return (StorageType)(((uint)forknum & 0xC000) >> 14); } -#define ColFileNodeCopy(colFileNode, colFileNodeRel) \ - do { \ - (colFileNode)->filenode.spcNode = (colFileNodeRel)->filenode.spcNode; \ - (colFileNode)->filenode.dbNode = (colFileNodeRel)->filenode.dbNode; \ - (colFileNode)->filenode.relNode = (colFileNodeRel)->filenode.relNode; \ +#define ColFileNodeCopy(colFileNode, colFileNodeRel) \ + do { \ + (colFileNode)->filenode.spcNode = (colFileNodeRel)->filenode.spcNode; \ + (colFileNode)->filenode.dbNode = (colFileNodeRel)->filenode.dbNode; \ + (colFileNode)->filenode.relNode = (colFileNodeRel)->filenode.relNode; \ + (colFileNode)->filenode.opt = 0; \ (colFileNode)->filenode.bucketNode = forknum_get_bucketid((colFileNodeRel)->forknum); \ - (colFileNode)->forknum = forknum_get_forknum((colFileNodeRel)->forknum); \ - (colFileNode)->ownerid= (colFileNodeRel)->ownerid; \ - } while(0) + (colFileNode)->forknum = forknum_get_forknum((colFileNodeRel)->forknum); \ + (colFileNode)->ownerid = (colFileNodeRel)->ownerid; \ + } while (0) #endif /* RELFILENODE_H */ diff --git a/src/test/regress/expected/row_compression/unsupported_feature.out b/src/test/regress/expected/row_compression/unsupported_feature.out index 70f7f30d8..ef14589b2 100644 --- a/src/test/regress/expected/row_compression/unsupported_feature.out +++ b/src/test/regress/expected/row_compression/unsupported_feature.out @@ -80,3 +80,14 @@ 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 +CREATE TABLE unspported_feature.index_test(id int, c1 text); +-- ustore +CREATE TABLE unspported_feature.ustore_table(id int, c1 text) WITH(compresstype=2, storage_type=ustore); --failed +ERROR: only row orientation table support compresstype. +CREATE INDEX tbl_pc_idx1 on unspported_feature.index_test(c1) WITH(compresstype=2, storage_type=ustore); --failed +ERROR: Can not use compress option in ustore index. +-- segment +CREATE TABLE unspported_feature.segment_table(id int, c1 text) WITH(compresstype=2, segment=on); --failed +ERROR: only row orientation table support compresstype. +CREATE INDEX on unspported_feature.index_test(c1) WITH(compresstype=2, segment=on); --faled +ERROR: Can not use compress option in segment storage. diff --git a/src/test/regress/sql/row_compression/unsupported_feature.sql b/src/test/regress/sql/row_compression/unsupported_feature.sql index dc1b6d6b9..fff526481 100644 --- a/src/test/regress/sql/row_compression/unsupported_feature.sql +++ b/src/test/regress/sql/row_compression/unsupported_feature.sql @@ -49,4 +49,12 @@ alter table unspported_feature.t_rowcompress_0007 set (compress_diff_convert=tru 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 \ No newline at end of file +create table unspported_feature.t_rowcompress_pglz_compresslevel(id int) with (compresstype=2,compress_level=2); -- success + +CREATE TABLE unspported_feature.index_test(id int, c1 text); +-- ustore +CREATE TABLE unspported_feature.ustore_table(id int, c1 text) WITH(compresstype=2, storage_type=ustore); --failed +CREATE INDEX tbl_pc_idx1 on unspported_feature.index_test(c1) WITH(compresstype=2, storage_type=ustore); --failed +-- segment +CREATE TABLE unspported_feature.segment_table(id int, c1 text) WITH(compresstype=2, segment=on); --failed +CREATE INDEX on unspported_feature.index_test(c1) WITH(compresstype=2, segment=on); --faled \ No newline at end of file