Update execClusterResize.cpp

This commit is contained in:
ljh0804 2023-08-10 20:52:45 +08:00
parent ea34e898c5
commit 50230625f0
1 changed files with 170 additions and 170 deletions

View File

@ -3,9 +3,9 @@
* execClusterResize.cpp
* MPPDB ClusterResizing relevant routines
*
* Portions Copyright (c) 2020 Huawei Technologies Co.,Ltd.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* c 2020
* c 1996-2012PostgreSQL
* c 1994
*
* IDENTIFICATION
* src/gausskernel/runtime/executor/execClusterResize.cpp
@ -44,10 +44,10 @@
/*
* ---------------------------------------------------------------------------------
* *Local functions/variables declaration fields*
* /*
* ---------------------------------------------------------------------------------
*/
/* delete delta table definition */
/*删除增量表定义 */
#define Natts_pg_delete_delta 3
#define Anum_pg_delete_delta_xcnodeid_and_dntableoid 1
@ -120,12 +120,12 @@ static inline bool redis_ctid_retrive_function(const char* funcname, Oid rettype
/*
* - Brief: Record the given tuple's tupleid into pg_delete_delta table
* - Parameter:
* @rel: target relation of UPDATE/DELETE operation
* @tupleid: tupleid that needs record
* - Return:
* no return value
*pg_delete_delta表中
* -
* @rel/
* @tupleid
*-
*
*/
void RecordDeletedTuple(Oid relid, int2 bucketid, const ItemPointer tupleid, const Relation deldelta_rel)
{
@ -134,10 +134,10 @@ void RecordDeletedTuple(Oid relid, int2 bucketid, const ItemPointer tupleid, con
HeapTuple tup = NULL;
Assert(deldelta_rel);
/* In redistribution, table delete_delta has 3 or 2 column. */
/*在重新分发中,表 delete_delta 有 3 列或 2 列。 */
Assert(RelationGetDescr(deldelta_rel)->natts <= 3);
/* Iterate through attributes initializing nulls and values */
/*循环访问初始化空值和值的属性 */
for (int i = 0; i < Natts_pg_delete_delta; i++) {
nulls[i] = false;
values[i] = (Datum)0;
@ -149,7 +149,7 @@ void RecordDeletedTuple(Oid relid, int2 bucketid, const ItemPointer tupleid, con
if (BUCKET_NODE_IS_VALID(bucketid)) {
values[Anum_pg_delete_delta_tablebucketid_and_ctid - 1] |= ((uint64)bucketid << 48);
}
/* Record delta */
/* 记录增量 */
tup = heap_form_tuple(RelationGetDescr(deldelta_rel), values, nulls);
(void)simple_heap_insert(deldelta_rel, tup);
@ -157,18 +157,18 @@ void RecordDeletedTuple(Oid relid, int2 bucketid, const ItemPointer tupleid, con
}
/*
* - Brief: Determine if the relation is under cluster resizing operation
* - Parameter:
* @rel: relation that needs to check
* - Return:
* @TRUE: relation is under cluster resizing
* @FALSE: relation is not under cluster resizing
* -
* -
* @rel
* -
* @TRUE
* @FALSE:
*/
bool RelationInClusterResizing(const Relation rel)
{
Assert(rel != NULL);
/* Check relation's append_mode status */
/*检查关系的append_mode状态 */
if (!IsInitdb && RelationInRedistribute(rel))
return true;
@ -176,18 +176,18 @@ bool RelationInClusterResizing(const Relation rel)
}
/*
* - Brief: Determine if the relation is under cluster resizing read only operation
* - Parameter:
* @rel: relation that needs to check
* - Return:
* @TRUE: relation is under cluster resizing read only
* @FALSE: relation is not under cluster resizing read only
* - :
* - :
* @rel:
* - :
* @TRUE:
* @FALSE:
*/
bool RelationInClusterResizingReadOnly(const Relation rel)
{
Assert(rel != NULL);
/* Check relation's append_mode status */
/*检查关系的append_mode状态 */
if (!IsInitdb && RelationInRedistributeReadOnly(rel))
return true;
@ -195,18 +195,18 @@ bool RelationInClusterResizingReadOnly(const Relation rel)
}
/*
* - Brief: Determine if the relation is under cluster resizing read only operation
* - Parameter:
* @rel: relation that needs to check
* - Return:
* @TRUE: relation is under cluster resizing endcatchup(write error)
* @FALSE: relation is not under cluster resizing endcatchup(write error)
* - :
* - :
* @rel:
* - :
* @TRUE: endcatchup()
* @FALSE: endcatchup()
*/
bool RelationInClusterResizingEndCatchup(const Relation rel)
{
Assert(rel != NULL);
/* Check relation's append_mode status */
/* 检查关系的append_mode状态*/
if (!IsInitdb && RelationInRedistributeEndCatchup(rel))
return true;
@ -214,9 +214,9 @@ bool RelationInClusterResizingEndCatchup(const Relation rel)
}
/*
* @Description: check whether relation is in redistribution though range variable.
* @in range_var: range variable which stored relation info.
* @return: true for in redistribution.
* @:
* @range_var:
* @:true
*/
bool CheckRangeVarInRedistribution(const RangeVar* range_var)
{
@ -228,7 +228,7 @@ bool CheckRangeVarInRedistribution(const RangeVar* range_var)
if (OidIsValid(relid)) {
relation = relation_open(relid, NoLock);
/* If the relation is index, we should check the related table is resizing or not. */
/* 如果关系是索引,我们应该检查相关表是否在调整大小。*/
if (RelationIsIndex(relation)) {
Oid heapOid = IndexGetRelation(relid, false);
Relation heapRelation = relation_open(heapOid, AccessShareLock);
@ -245,12 +245,12 @@ bool CheckRangeVarInRedistribution(const RangeVar* range_var)
}
/*
* - Brief: Determine if the table name is delete_delta table.
* - Parameter:
* @relname: name of target table
* - Return:
* @TRUE: the table is delete_delta table
* @FALSE: the table is not delete_delta table
* - :delete_delta table
* - :
* @relname:
* - :
* @TRUE: delete_delta表
* @FALSE: delete_delta表
*/
bool RelationIsDeleteDeltaTable(char* delete_delta_name)
{
@ -292,10 +292,10 @@ bool RelationIsDeleteDeltaTable(char* delete_delta_name)
}
/*
* - Brief: Determine if the Progress is under cluster resizing status
* - Return:
* @TRUE: Progress is under cluster resizing
* @FALSE: Progress is not under cluster resizing
* - :
* - :
* @TRUE:
* @FALSE:
*/
bool ClusterResizingInProgress()
{
@ -329,27 +329,27 @@ bool ClusterResizingInProgress()
}
/*
* - Brief: get the name of delete_delta table
* - Parameter:
* @relname: name of target table
* @delta_delta_name: output value for delete_delta table name
* @isMultiCatchup: multi catchup delta or not
* - Return:
* no return value
* -:delete_delta表的名称
* - :
* @relname:
* @delta_delta_name: delete_delta表名的输出值
* @isMultiCatchup: delta
* - :
*
*/
static inline void RelationGetDeleteDeltaTableName(Relation rel, char* delete_delta_name, bool isMultiCatchup)
{
int rc = 0;
/* Check if output parameter it not palloc()-ed from caller side */
/* 检查输出参数是否没有从调用方palloc()-ed */
if (delete_delta_name == NULL || rel == NULL) {
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("Invalid parameter in function '%s'", __FUNCTION__)));
}
/*
* Look up Relation's reloptions to get table's cnoid to
* form the name of delete_delta table
* Relation的关联以获得表的id
* delete_delta表的名称
*/
if (!IsInitdb) {
if (RelationInClusterResizing(rel) && !RelationInClusterResizingReadOnly(rel)) {
@ -381,12 +381,12 @@ static inline void RelationGetDeleteDeltaTableName(Relation rel, char* delete_de
}
/*
* - Brief: get and open delete_delta rel
* - Parameter:
* @rel: target relation of UPDATE/DELETE/TRUNCATE operation
* @lockmode: lock mode
* @isMultiCatchup: multi catchup delta or not
* - Return:
* - :delete_delta rel
* - :
* @rel: UPDATE/DELETE/TRUNCATE操作的目标关系
* @lockmode:
* @isMultiCatchup: delta
* - :
* delete_delta rel
*/
Relation GetAndOpenDeleteDeltaRel(const Relation rel, LOCKMODE lockmode, bool isMultiCatchup)
@ -403,22 +403,22 @@ Relation GetAndOpenDeleteDeltaRel(const Relation rel, LOCKMODE lockmode, bool is
RelationGetDeleteDeltaTableName(rel, (char*)delete_delta_tablename, isMultiCatchup);
data_redis_namespace = get_namespace_oid("data_redis", false);
/* We are going to fetch the delete delta relation under data_redis schema. */
/* 我们将在data_redis模式下获取delete delta关系。 */
deldelta_relid = get_relname_relid(delete_delta_tablename, data_redis_namespace);
if (!OidIsValid(deldelta_relid)) {
/*
* If multi catchup delta table is not there, just return NULL. We should not
* report error, because it is a valid case. Multi catchup delta table is
* dropped in each catchup iteration.
* NULL We should not
* delta表是( Multi catchup delta table is)
*
*/
if (isMultiCatchup) {
return NULL;
}
/*
* To support Update or Delete during extension, we need to add 2 more columns.
* more columns. Limited by MaxHeapAttributeNumber, if the table already contains too many columns,
* we don't allow update or delete anymore, but insert statement can still proceed.
* 2
* maxheapattributennumber的限制
*
*/
if (((rel->rd_att->natts > (MaxHeapAttributeNumber - (Natts_pg_delete_delta - 1))) &&
!RELATION_IS_PARTITIONED(rel)) ||
@ -429,7 +429,7 @@ Relation GetAndOpenDeleteDeltaRel(const Relation rel, LOCKMODE lockmode, bool is
RelationGetRelationName(rel)),
errdetail("Can not support online extension, if the table contains too many columns")));
}
/* ERROR case, should never come here */
/* 错误情况下,不应该出现在这里 */
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_TABLE),
errmsg("delete delta table %s is not found when do cluster resizing table \"%s\"",
@ -446,11 +446,11 @@ Relation GetAndOpenDeleteDeltaRel(const Relation rel, LOCKMODE lockmode, bool is
}
/*
* - Brief: Check the stmtment during online expansion, block unsupported ddl in cluster resizing.
* - Parameter:
* @rel: parsetree of DDL
* - Return:
* no return value
* - :线ddl
* - :
* @rel: DDL的解析树
* -:
*
*/
void BlockUnsupportedDDL(const Node* parsetree)
{
@ -466,11 +466,11 @@ void BlockUnsupportedDDL(const Node* parsetree)
LOCKMODE lockmode_openrel = AccessShareLock;
/*
* Check for shared-cache-inval messages before trying to access the
* relation. This is needed to cover the case where the name
* identifies a rel that has been dropped and recreated since the
* start of our transaction: if we don't flush the old syscache entry,
* then we'll latch onto that entry and suffer an error later.
*
* relation.
* rel
* :syscache条目
*
*/
AcceptInvalidationMessages();
@ -501,13 +501,13 @@ void BlockUnsupportedDDL(const Node* parsetree)
return;
} break;
/* Block CURSOR for while table in cluster resizing */
/* 在集群调整大小时阻塞游标 */
case T_PlannedStmt: {
PlannedStmt* stmt = (PlannedStmt*)parsetree;
relidlist = stmt->relationOids;
} break;
/* Block RENAME while table in cluster resizing */
/* 当表在集群中调整大小时块RENAME */
case T_RenameStmt: {
RenameStmt* stmt = (RenameStmt*)parsetree;
@ -540,11 +540,11 @@ void BlockUnsupportedDDL(const Node* parsetree)
stmt->relation->relname)));
} break;
/* Block ALTER set schema while table in cluster resizing */
/* 当表在集群中调整大小时Block ALTER设置模式 */
case T_AlterObjectSchemaStmt: {
AlterObjectSchemaStmt* stmt = (AlterObjectSchemaStmt*)parsetree;
/* disable alter table set schema when transfer */
/* 在传输时禁用alter table set schema */
if (stmt->relation != NULL) {
Oid relOid = RangeVarGetRelid(stmt->relation, AccessShareLock, true);
if (OidIsValid(relOid)) {
@ -567,7 +567,7 @@ void BlockUnsupportedDDL(const Node* parsetree)
stmt->relation->relname)));
} break;
/* Block CREATE index while table in cluster resizing(for row table only) */
/* 当表在集群中调整大小时,阻塞创建索引(仅适用于行表) */
case T_IndexStmt: {
IndexStmt* stmt = (IndexStmt*)parsetree;
if (stmt->relation) {
@ -590,13 +590,13 @@ void BlockUnsupportedDDL(const Node* parsetree)
}
} break;
/* Block REINDEX while table in cluster resizing(for row table only) */
/* 当表在集群中调整大小时块REINDEX(仅适用于行表) */
case T_ReindexStmt: {
ReindexStmt* stmt = (ReindexStmt*)parsetree;
if (stmt->relation) {
relid = RangeVarGetRelid(stmt->relation, AccessShareLock, true);
if (OidIsValid(relid)) {
/* release index lock before lock table to avoid deadlock */
/* 在锁表之前释放索引锁以避免死锁 */
UnlockRelationOid(relid, AccessShareLock);
Relation relation = relation_open(relid, NoLock);
@ -622,7 +622,7 @@ void BlockUnsupportedDDL(const Node* parsetree)
}
} break;
/* Block ALTER-Table while table in cluster resizing */
/* 当表在集群中调整大小时阻塞ALTER-Table */
case T_AlterTableStmt: {
AlterTableStmt* stmt = (AlterTableStmt*)parsetree;
AlterTableCmd* cmd = NULL;
@ -631,13 +631,13 @@ void BlockUnsupportedDDL(const Node* parsetree)
switch (cmd->subtype) {
case AT_TruncatePartition: {
/*
* We do not allow truncate partition when the target is in read only
* mode during online expansion time.
*
*线
*/
if (stmt->relation) {
relid = RangeVarGetRelid(stmt->relation, lockmode_getrelid, true);
if (OidIsValid(relid)) {
/* disable alter table truncate partition during transfer */
/* 禁止在传输过程中截断分区 */
if (CheckRangeVarInRedistribution(stmt->relation)) {
Oid nsOid = GetNamespaceIdbyRelId(relid);
TRANSFER_DISABLE_DDL(nsOid);
@ -704,12 +704,12 @@ void BlockUnsupportedDDL(const Node* parsetree)
}
}
/* If rel option contain append_mode, then not check. */
/* 如果rel选项包含append_mode则不检查。 */
if (opt != NULL) {
break;
}
}
/* fall through */
/* 失败 */
default: {
if (stmt->relation && !u_sess->attr.attr_sql.enable_cluster_resize &&
CheckRangeVarInRedistribution(stmt->relation))
@ -725,7 +725,7 @@ void BlockUnsupportedDDL(const Node* parsetree)
return;
} break;
/* Block CREATE-RULE statements while target table in cluster resizing */
/* 当集群中的目标表调整大小时阻塞CREATE-RULE语句 */
case T_RuleStmt: {
RuleStmt* stmt = (RuleStmt*)parsetree;
if (stmt->relation) {
@ -734,7 +734,7 @@ void BlockUnsupportedDDL(const Node* parsetree)
}
} break;
/* Block CREATE SEQUENCE set schema while owner table in cluster resizing */
/* 当所有者表在集群中调整大小时Block CREATE SEQUENCE设置模式 */
case T_CreateSeqStmt: {
CreateSeqStmt* stmt = (CreateSeqStmt*)parsetree;
List* owned_by = NULL;
@ -761,7 +761,7 @@ void BlockUnsupportedDDL(const Node* parsetree)
}
} break;
/* Block ALTER SEQUENCE while owner table in cluster resizing */
/* 当集群中的所有者表调整大小时阻塞ALTER SEQUENCE */
case T_AlterSeqStmt: {
AlterSeqStmt* stmt = (AlterSeqStmt*)parsetree;
List* owned_by = NIL;
@ -788,7 +788,7 @@ void BlockUnsupportedDDL(const Node* parsetree)
}
} break;
/* Block CLUSTER while table in cluster resizing */
/* 当表在集群中调整大小时阻塞集群 */
case T_ClusterStmt: {
ClusterStmt* stmt = (ClusterStmt*)parsetree;
if (stmt->relation && CheckRangeVarInRedistribution(stmt->relation))
@ -799,7 +799,7 @@ void BlockUnsupportedDDL(const Node* parsetree)
stmt->relation->relname)));
} break;
/* Block VACUUM FULL while table in cluster resizing */
/* 当表在集群中调整大小时,块真空已满 */
case T_VacuumStmt: {
VacuumStmt* stmt = (VacuumStmt*)parsetree;
if ((stmt->options & VACOPT_VACUUM) || (stmt->options & VACOPT_MERGE)) {
@ -822,7 +822,7 @@ void BlockUnsupportedDDL(const Node* parsetree)
}
} break;
/* Block truncate DDL when the target table is read only in cluster resizing */
/* 在集群调整大小时当目标表为只读时块截断DDL */
case T_TruncateStmt: {
ListCell* cell = NULL;
TruncateStmt* stmt = (TruncateStmt*)parsetree;
@ -857,7 +857,7 @@ void BlockUnsupportedDDL(const Node* parsetree)
DropStmt* stmt = (DropStmt*)parsetree;
switch (stmt->removeType) {
case OBJECT_TABLE: {
/* disable drop table when transfer */
/* 在传输时禁用drop表 */
ListCell* cell = NULL;
foreach (cell, stmt->objects) {
RangeVar* rel = makeRangeVarFromNameList((List*)lfirst(cell));
@ -871,7 +871,7 @@ void BlockUnsupportedDDL(const Node* parsetree)
break;
}
case OBJECT_SCHEMA: {
/* disable drop schema when transfer */
/* 传输时禁用删除模式 */
ListCell* cell = NULL;
foreach (cell, stmt->objects) {
List* objname = (List*)lfirst(cell);
@ -887,7 +887,7 @@ void BlockUnsupportedDDL(const Node* parsetree)
} break;
case T_CreateStmt: {
/* disable create table when transfer */
/* 禁止传输时创建表 */
CreateStmt* stmt = (CreateStmt*)parsetree;
if (stmt->relation != NULL) {
Oid nsOid = RangeVarGetCreationNamespace(stmt->relation);
@ -916,14 +916,14 @@ void BlockUnsupportedDDL(const Node* parsetree)
}
/*
* - Brief: For online expanions, the shippable function is evaluated here, the module
* will be invoked in optimizer when do FQS evaluation, we have to define function
* as STABLE
* - Parameter:
* @funcid: oid of user defined function which is createed/dropped in scope of gs_redis
* - Return:
* @true: shippable
* @false: unshippable
* - :线
* FQS评估时
* as STABLE
* - :
* @funcid: gs_redis范围内创建/Oid
* - :
* @true:
* @false:
*/
bool redis_func_shippable(Oid funcid)
{
@ -937,11 +937,11 @@ bool redis_func_shippable(Oid funcid)
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("function with OID %u does not exist", funcid)));
}
/* Fetch function signatures */
/* 获取函数签名 */
rettype = get_func_signature(funcid, &argstype, &nargs);
if (redis_tupleid_retrive_function(func_name, rettype, argstype, nargs)) {
/* tupleid retrive functions is shippable to datanodes */
/* Tupleid检索函数可以发布到数据节点 */
result = true;
} else if (redis_offset_retrive_function(func_name, rettype, argstype, nargs)) {
result = true;
@ -961,11 +961,11 @@ bool redis_func_shippable(Oid funcid)
}
/*
* - Brief: determine if given funcid reflects a dn-stable function
* - Parameter:
* @funcid: function oid that to evaluate
* - Return:
* @result: true:dnstable false: not-dnstable function
* - :
* - :
* @funcid: oid
* - :
* @result: true: false:
*/
bool redis_func_dnstable(Oid funcid)
{
@ -981,11 +981,11 @@ bool redis_func_dnstable(Oid funcid)
errmsg("function with OID %u does not exist when checking function dnstable", funcid)));
}
/* Fetch function signatures */
/* 获取函数签名 */
rettype = get_func_signature(funcid, &argstype, &nargs);
if (redis_tupleid_retrive_function(func_name, rettype, argstype, nargs)) {
/* tupleid retrive functions is dnstable */
/* 管状反射函数是不稳定的 */
result = true;
}
@ -993,23 +993,23 @@ bool redis_func_dnstable(Oid funcid)
}
/*
* - Brief: evaluate ctid functions into a const value to avoid per-scanning
* tuple invokation in seqscan.
* - Parameter:
* @rel: the rel being redistributing
* @original_quals: the original quals possible contains ctid_funcs
* @isRangeScanInRedis: if is a redis range scan
* - Return:
* @new_quals: quals which func call be replaced by a const
* - :ctid函数求值为const值以避免每次扫描
* seqscan中调用元组
* - :
* @rel:
* @original_quals: quals可能包含ctid_funcs
* @isRangeScanInRedis: redis范围扫描
* - :
* @new_quals: Quals将被const替换
*/
List* eval_ctid_funcs(Relation rel, List* original_quals, RangeScanInRedis *rangeScanInRedis)
{
StringInfo qual_str = makeStringInfo();
/*
* we have to make a copy of the original quals, since the eval_dnstable_func_mutator
* will modify the it. the original qual will be needed again and again in later
* to be re-eval in partition table scans.
* eval_dnstable_func_mutator的存在quals进行复制
*
*
*/
List* new_quals = (List*)copyObject((const void*)(original_quals));
@ -1033,16 +1033,16 @@ static int32 get_expr_const_val(Node *val){
}
/*
* - Brief: working house for eval_dnstable_func() to evaluate dn stable function into a const
* value to avoid per-scanning tuple invocation in seqscan
* - Parameter:
* @rel: the rel being redistributing
* @node: expression node
* @qual_str: predicate pattern
* @isRangeScanInRedis: output to indicate if the predicate pattern is range scan in redis
* @isRoot: we want to compare the predicate pattern only once at root level
* - Return:
* @result: expression tree with dn stable function const-evaluated
* - :eval_dnstable_func()const
* seqscan中调用每次扫描的元组
* - :
* @rel:
* @node:
* @qual_str:
* @isRangeScanInRedis: redis中的范围扫描
* @isRoot:
* - :
* @result: dn稳定函数const评估
*/
static Node* eval_dnstable_func_mutator(
Relation rel, Node* node, StringInfo qual_str, RangeScanInRedis *rangeScanInRedis, bool isRoot)
@ -1057,7 +1057,7 @@ static Node* eval_dnstable_func_mutator(
case T_FuncExpr: {
FuncExpr* expr = (FuncExpr*)node;
/* flatten dn stable function into const value */
/* 将一个稳定函数扁平化为const值 */
if (redis_func_dnstable(expr->funcid)) {
Node* new_const = NULL;
char* funcname = get_func_name(expr->funcid);
@ -1093,8 +1093,8 @@ static Node* eval_dnstable_func_mutator(
Node* new_expr = eval_dnstable_func_mutator(rel, expr, qual_str, rangeScanInRedis, false);
/*
* If a FuncExpr node is evalated into a T_Const value, we are hitting
* the point so replace it in qual list.
* FuncExpr节点求值为T_Const值
*
*/
if (expr && IsA(expr, FuncExpr) && new_expr && IsA(new_expr, Const)) {
l = list_delete_ptr(l, expr);
@ -1103,8 +1103,8 @@ static Node* eval_dnstable_func_mutator(
}
/*
* If the predicate at root is something like "where ctid between pg_get_redis_rel_start_ctid('xx')
* and pg_get_redis_rel_end_ctid('xx')" on DN, we will pushdown the predicate at scan node.
* where ctid between pg_get_redis_rel_start_ctid('xx')
* pg_get_redis_rel_end_ctid('xx')"在DN上我们将在扫描节点下推谓词。
*/
if (isRoot && pg_strcasecmp(qual_str->data, RANGE_SCAN_IN_REDIS) == 0) {
rangeScanInRedis->isRangeScanInRedis = true;
@ -1129,7 +1129,7 @@ static Node* eval_dnstable_func_mutator(
}
case T_Var: {
Var* var = (Var*)node;
/* we only expect tid column in the predicate */
/* 我们只期望谓词中有tid列 */
if (var->vartype == TIDOID) {
appendStringInfoString(qual_str, "tid");
appendStringInfoString(qual_str, "+");
@ -1147,10 +1147,10 @@ static Node* eval_dnstable_func_mutator(
}
/*
* - Brief: get and open new_table rel
* - Parameter:
* @rel: target relation of TRUNCATE operation
* - Return:
* - :new_table rel
* - :
* @rel: TRUNCATE操作的目标关系
* - :
* new_table rel
*/
Relation GetAndOpenNewTableRel(const Relation rel, LOCKMODE lockmode)
@ -1168,7 +1168,7 @@ Relation GetAndOpenNewTableRel(const Relation rel, LOCKMODE lockmode)
data_redis_namespace = get_namespace_oid("data_redis", false);
newtable_relid = get_relname_relid(new_tablename, data_redis_namespace);
if (!OidIsValid(newtable_relid)) {
/* ERROR case, should never come here */
/* 错误情况下,不应该出现在这里 */
ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
errmsg("new table %s is not found when do cluster resizing table \"%s\"",
@ -1185,18 +1185,18 @@ Relation GetAndOpenNewTableRel(const Relation rel, LOCKMODE lockmode)
}
/*
* - Brief: get the name of new table
* - Parameter:
* @relname: name of target table
* @newtable_name: output value for new table name
* - Return:
* no return value
* - :
* - :
* @relname:
* @newtable_name:
* - :
*
*/
void RelationGetNewTableName(Relation rel, char* newtable_name)
{
int rc = 0;
/* Check if output parameter it not palloc()-ed from caller side */
/* 检查输出参数是否没有从调用方palloc()-ed */
if (newtable_name == NULL || rel == NULL) {
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@ -1204,8 +1204,8 @@ void RelationGetNewTableName(Relation rel, char* newtable_name)
}
/*
* Look up relaion's reloptions to get table's cnoid to
* form the name of new table
*
*
*/
if (!IsInitdb) {
Oid rel_cn_oid = RelationGetRelCnOid(rel);
@ -1216,19 +1216,19 @@ void RelationGetNewTableName(Relation rel, char* newtable_name)
rc = snprintf_s(
newtable_name, NAMEDATALEN, NAMEDATALEN - 1, "data_redis_tmp_%s", RelationGetRelationName(rel));
}
/* check the return value of security function */
/* 检查安全函数的返回值 */
securec_check_ss(rc, "\0", "\0");
}
return;
}
/*
* - Brief: Determine if the relation is under cluster resizing write error mode
* - Parameter:
* @rel: relation that needs to check
* - Return:
* @TRUE: relation is under cluster resizing write error mode
* @FALSE: relation is not under cluster resizing write error mode
* - :
* - :
* @rel:
* - :
* @TRUE:
* @FALSE:
*/
bool RelationInClusterResizingWriteErrorMode(const Relation rel)
{