enter
This commit is contained in:
parent
24604252dd
commit
b01ae798e4
|
|
@ -885,7 +885,7 @@ static bool check_trigger_deferable(Relation rel)
|
|||
|
||||
List *indexList = (List *)RelationGetIndexList(rel);
|
||||
|
||||
/* no constaint then retrun true directly. */
|
||||
/* 如果没有索引,则直接返回 true */
|
||||
if (indexList == NIL) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -893,6 +893,7 @@ static bool check_trigger_deferable(Relation rel)
|
|||
foreach (item, indexList) {
|
||||
Oid indexoid = lfirst_oid(item);
|
||||
|
||||
/* 在系统缓存中查找索引元组 */
|
||||
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
|
||||
if (!HeapTupleIsValid(indexTuple)) {
|
||||
ereport(ERROR,
|
||||
|
|
@ -901,18 +902,22 @@ static bool check_trigger_deferable(Relation rel)
|
|||
}
|
||||
|
||||
indexStruct = (Form_pg_index)GETSTRUCT(indexTuple);
|
||||
|
||||
/* 检查索引是否有效,无效索引会被跳过 */
|
||||
if (!IndexIsValid(indexStruct)) {
|
||||
deferablesCheck = true;
|
||||
ReleaseSysCache(indexTuple);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 如果索引不是立即触发的,则将 deferablesCheck 设置为 true,并释放系统缓存 */
|
||||
if (!indexStruct->indimmediate) {
|
||||
deferablesCheck = true;
|
||||
ReleaseSysCache(indexTuple);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* if indexTuple is invalid or normal(not deferable), then cannot pushable. */
|
||||
/* 如果索引是立即触发的,将 deferablesCheck 设置为 true,并释放系统缓存 */
|
||||
deferablesCheck = true;
|
||||
ReleaseSysCache(indexTuple);
|
||||
}
|
||||
|
|
@ -920,19 +925,21 @@ static bool check_trigger_deferable(Relation rel)
|
|||
return deferablesCheck;
|
||||
}
|
||||
|
||||
static bool table_contain_unsupport_feature(Oid relid, Query* query)
|
||||
|
||||
static bool table_contain_unsupport_feature(Oid relid, Query* query)//该函数用于检查指定的表是否包含不支持流式操作的特性
|
||||
{
|
||||
Relation rel;
|
||||
errno_t sprintf_rc = 0;
|
||||
|
||||
// 尝试打开关系(表)
|
||||
rel = try_relation_open(relid, NoLock);
|
||||
if (rel != NULL) {
|
||||
/* If contains system relation, we will not output the not shipping reasion */
|
||||
// 如果关系属于系统命名空间,不记录不支持的原因
|
||||
if (rel->rd_rel->relnamespace == PG_CATALOG_NAMESPACE) {
|
||||
u_sess->opt_cxt.not_shipping_info->need_log = false;
|
||||
}
|
||||
|
||||
/* globel temp table could not ship */
|
||||
// 全局临时表不支持流操作
|
||||
if (rel->rd_rel->relpersistence == RELPERSISTENCE_GLOBAL_TEMP) {
|
||||
sprintf_rc = sprintf_s(u_sess->opt_cxt.not_shipping_info->not_shipping_reason,
|
||||
NOTPLANSHIPPING_LENGTH,
|
||||
|
|
@ -942,7 +949,7 @@ static bool table_contain_unsupport_feature(Oid relid, Query* query)
|
|||
return true;
|
||||
}
|
||||
|
||||
/* Currently dml with trigger can not get stream plan. */
|
||||
// 当前带有触发器的 DML 操作不支持流操作
|
||||
if (rel->rd_rel->relhastriggers && NULL != rel->trigdesc &&
|
||||
((query->commandType == CMD_INSERT && pgxc_has_trigger_for_event(TRIGGER_TYPE_INSERT, rel->trigdesc)) ||
|
||||
(query->commandType == CMD_UPDATE && check_trigger_deferable(rel) &&
|
||||
|
|
@ -963,19 +970,24 @@ static bool table_contain_unsupport_feature(Oid relid, Query* query)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool contain_unsupport_function(Oid funcId)
|
||||
{
|
||||
// 如果函数的 Oid 大于等于 FirstNormalObjectId,表示它是用户定义的函数,不支持流式操作
|
||||
if (funcId >= FirstNormalObjectId)
|
||||
return true;
|
||||
|
||||
// 遍历不支持的函数列表,如果给定的 funcId 匹配其中一个,则表示不支持流式操作
|
||||
for (uint i = 0; i < lengthof(unsupport_func); i++) {
|
||||
if (funcId == unsupport_func[i])
|
||||
return true;
|
||||
}
|
||||
|
||||
// 如果没有匹配的不支持函数,返回 false,表示支持流式操作
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool contain_unsupport_expression(Node* expr, void* context)
|
||||
{
|
||||
if (expr == NULL) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue