Update execClusterResize.cpp
This commit is contained in:
parent
ea34e898c5
commit
50230625f0
|
|
@ -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-2012,PostgreSQL 全球开发集团
|
||||
* 部分版权 (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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue