【标题】: 修复IAEZOR所示的大数据量下执行游标表达报错的问题

【实现内容】: 修复IAEZOR所示的大数据量下执行游标表达报错的问题。
【根因分析】: 对于sql select a, cursor (xx) from table1, table1的每一行都要创建一个protal,prota需要推带session的hash表中存放,大数据量的时候直接撑破内存。
【实现方案】: 对于select a, cursor (xx) from table1此种场景,其实游标是没有意义的,因此没必要创建protal,可以直接返回。
【关联需求或issue】: https://e.gitee.com/opengaussorg/dashboard?issue=IAEZOR
This commit is contained in:
wangfeihuo
2024-07-25 22:28:27 +08:00
parent dbd6d13ce3
commit ffd64175d3
11 changed files with 173 additions and 128 deletions

View File

@ -364,6 +364,7 @@ Node* transformExpr(ParseState* pstate, Node* expr, ParseExprKind exprKind)
sv_expr_kind = pstate->p_expr_kind;
pstate->p_expr_kind = exprKind;
pstate->p_expr_transform_level = 0;
result = transformExprRecurse(pstate, expr);
pstate->p_expr_kind = sv_expr_kind;
@ -380,6 +381,7 @@ Node *transformExprRecurse(ParseState *pstate, Node *expr)
}
/* Guard against stack overflow due to overly complex expressions */
check_stack_depth();
pstate->p_expr_transform_level++;
switch (nodeTag(expr)) {
case T_ColumnRef:
@ -1903,7 +1905,7 @@ static Node* transformFuncCall(ParseState* pstate, FuncCall* fn)
if (i != seq) {
dopControl.CloseSmp();
}
lfirst(args) = transformCursorExpression(pstate, (CursorExpression*)arg);
lfirst(args) = transformExprRecurse(pstate, arg);
dopControl.ResetSmp();
}
i++;
@ -3942,6 +3944,13 @@ static Node* transformCursorExpression(ParseState* pstate, CursorExpression* cur
newm->raw_query_str = queryString;
newm->param = (List*)copyObject(parse_state_parent->cursor_expression_para_var);
if (pstate->p_pre_columnref_hook == NULL && pstate->p_post_columnref_hook == NULL &&
pstate->p_expr_kind == EXPR_KIND_SELECT_TARGET && pstate->p_expr_transform_level == 1) {
newm->is_simple_select_target = true;
} else {
newm->is_simple_select_target = false;
}
list_free_ext(stmt_list);
list_free_ext(raw_parsetree_list);