diff --git a/src/common/backend/utils/init/globals.cpp b/src/common/backend/utils/init/globals.cpp index 558c4b4ca..51f9b4519 100644 --- a/src/common/backend/utils/init/globals.cpp +++ b/src/common/backend/utils/init/globals.cpp @@ -92,6 +92,7 @@ const uint32 CLIENT_ENCRYPTION_PROC_VERSION_NUM = 92383; const uint32 DECODE_ABORT_VERSION_NUM = 92386; const uint32 COPY_TRANSFORM_VERSION_NUM = 92394; const uint32 COMMENT_PCT_TYPE_VERSION_NUM = 92396; +const uint32 RELMAP_4K_VERSION_NUM = 92403; const uint32 TDE_VERSION_NUM = 92407; const uint32 SWCB_VERSION_NUM = 92427; const uint32 COMMENT_ROWTYPE_TABLEOF_VERSION_NUM = 92513; diff --git a/src/gausskernel/optimizer/commands/cluster.cpp b/src/gausskernel/optimizer/commands/cluster.cpp index 7d66f8509..e5e5ce4dd 100755 --- a/src/gausskernel/optimizer/commands/cluster.cpp +++ b/src/gausskernel/optimizer/commands/cluster.cpp @@ -421,6 +421,15 @@ void cluster_rel(Oid tableOid, Oid partitionOid, Oid indexOid, bool recheck, boo return; } + /* Forbid cluster on shared relation during upgrade, to protect global/pg_filenode.map not changed */ + if (u_sess->attr.attr_common.upgrade_mode != 0 && + tableOid < FirstBootstrapObjectId && OldHeap->rd_rel->relisshared && + t_thrd.proc->workingVersionNum < RELMAP_4K_VERSION_NUM) { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot cluster shared relation during upgrade"))); + } + /* * Since we may open a new transaction for each relation, we have to check * that the relation still is what we think it is. diff --git a/src/gausskernel/optimizer/commands/tablecmds.cpp b/src/gausskernel/optimizer/commands/tablecmds.cpp index e303a4d1b..0e88cbbe9 100644 --- a/src/gausskernel/optimizer/commands/tablecmds.cpp +++ b/src/gausskernel/optimizer/commands/tablecmds.cpp @@ -4514,6 +4514,15 @@ void truncate_check_rel(Relation rel) (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied: \"%s\" is a system catalog", RelationGetRelationName(rel)))); + /* Forbid truncate on shared relation during upgrade, to protect global/pg_filenode.map not changed */ + if (u_sess->attr.attr_common.upgrade_mode != 0 && + rel->rd_id < FirstBootstrapObjectId && rel->rd_rel->relisshared && + t_thrd.proc->workingVersionNum < RELMAP_4K_VERSION_NUM) { + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot truncate shared relation during upgrade"))); + } + /* * Don't allow truncate on temp tables of other backends ... their local * buffer manager is not going to cope. diff --git a/src/gausskernel/optimizer/commands/vacuum.cpp b/src/gausskernel/optimizer/commands/vacuum.cpp index 6c78fbdda..8b5e12ab1 100644 --- a/src/gausskernel/optimizer/commands/vacuum.cpp +++ b/src/gausskernel/optimizer/commands/vacuum.cpp @@ -2109,6 +2109,19 @@ static bool vacuum_rel(Oid relid, VacuumStmt* vacstmt, bool do_toast) return false; } + /* Forbid vacuum full on shared relation during upgrade, to protect global/pg_filenode.map not changed */ + if (u_sess->attr.attr_common.upgrade_mode != 0 && rel != NULL && + relid < FirstBootstrapObjectId && rel->rd_rel->relisshared && + t_thrd.proc->workingVersionNum < RELMAP_4K_VERSION_NUM) { + ereport(NOTICE, + (errcode(ERRCODE_E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED), + errmsg("skipping \"%s\" --- VACUUM FULL on shared relation is not allowed during upgrade", + RelationGetRelationName(rel)))); + relation_close(rel, AccessShareLock); + proc_snapshot_and_transaction(); + return false; + } + if (rel != NULL) relation_close(rel, AccessShareLock); } diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index f2f96ee14..f89d3d8b9 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -86,6 +86,7 @@ extern const uint32 WAIT_N_TUPLE_LOCK_VERSION_NUM; extern const uint32 DISASTER_READ_VERSION_NUM; extern const uint32 SUPPORT_DATA_REPAIR; extern const uint32 SCAN_BATCH_MODE_VERSION_NUM; +extern const uint32 RELMAP_4K_VERSION_NUM; extern const uint32 PUBLICATION_VERSION_NUM; extern const uint32 ANALYZER_HOOK_VERSION_NUM; extern const uint32 SUPPORT_HASH_XLOG_VERSION_NUM;