forked from huawei/openGauss-server
fix forbid execute function commit/rollback
Offering: openGaussDev More detail:fix forbid execute function commit/rollback Match-id-1d200d7662fb20f0df4063a2399d31fadc5548d8
This commit is contained in:
parent
dedd14af5e
commit
b3ba5e5db9
|
|
@ -5445,7 +5445,7 @@ static int exec_stmt_execsql(PLpgSQL_execstate* estate, PLpgSQL_stmt_execsql* st
|
|||
bool has_alloc = false;
|
||||
|
||||
TransactionId oldTransactionId = SPI_get_top_transaction_id();
|
||||
|
||||
|
||||
/*
|
||||
* On the first call for this statement generate the plan, and detect
|
||||
* whether the statement is INSERT/UPDATE/DELETE/MERGE
|
||||
|
|
@ -5477,7 +5477,19 @@ static int exec_stmt_execsql(PLpgSQL_execstate* estate, PLpgSQL_stmt_execsql* st
|
|||
if (ENABLE_CN_GPC && g_instance.plan_cache->CheckRecreateSPICachePlan(expr->plan)) {
|
||||
g_instance.plan_cache->RecreateSPICachePlan(expr->plan);
|
||||
}
|
||||
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
ListCell* l = NULL;
|
||||
bool isforbid = true;
|
||||
bool savedisAllowCommitRollback = false;
|
||||
bool needResetErrMsg = false;
|
||||
foreach (l, SPI_plan_get_plan_sources(expr->plan)) {
|
||||
CachedPlanSource* plansource = (CachedPlanSource*)lfirst(l);
|
||||
isforbid = CheckElementParsetreeTag(plansource->raw_parse_tree);
|
||||
if (isforbid) {
|
||||
needResetErrMsg = stp_disable_xact_and_set_err_msg(&savedisAllowCommitRollback, STP_XACT_COMPL_SQL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Set up ParamListInfo (hook function and possibly data values)
|
||||
*/
|
||||
|
|
@ -5539,7 +5551,11 @@ static int exec_stmt_execsql(PLpgSQL_execstate* estate, PLpgSQL_stmt_execsql* st
|
|||
// This is used for nested STP. If the transaction Id changed,
|
||||
// then need to create new econtext for the TopTransaction.
|
||||
stp_check_transaction_and_create_econtext(estate,oldTransactionId);
|
||||
|
||||
#ifndef ENABLE_MULTIPLE_NODES
|
||||
if (isforbid) {
|
||||
stp_reset_xact_state_and_err_msg(savedisAllowCommitRollback, needResetErrMsg);
|
||||
}
|
||||
#endif
|
||||
plpgsql_estate = NULL;
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -785,7 +785,7 @@ exception
|
|||
end;
|
||||
/
|
||||
select p2();
|
||||
ERROR: transaction statement in store procedure used as sql to get value is not supported
|
||||
ERROR: can not use commit rollback in Complex SQL
|
||||
CONTEXT: PL/pgSQL function p1() line 12 at FOR with integer loop variable
|
||||
referenced column: p1
|
||||
referenced column: c1
|
||||
|
|
@ -830,14 +830,14 @@ end;
|
|||
/
|
||||
select p2();
|
||||
number of failures: 8
|
||||
error: 1 array index: 2 messagecode: 1282 errormessage: transaction statement in store procedure used as sql to get value is not supported
|
||||
error: 2 array index: 3 messagecode: 1282 errormessage: transaction statement in store procedure used as sql to get value is not supported
|
||||
error: 3 array index: 4 messagecode: 1282 errormessage: transaction statement in store procedure used as sql to get value is not supported
|
||||
error: 4 array index: 5 messagecode: 1282 errormessage: transaction statement in store procedure used as sql to get value is not supported
|
||||
error: 5 array index: 6 messagecode: 1282 errormessage: transaction statement in store procedure used as sql to get value is not supported
|
||||
error: 6 array index: 7 messagecode: 1282 errormessage: transaction statement in store procedure used as sql to get value is not supported
|
||||
error: 7 array index: 8 messagecode: 1282 errormessage: transaction statement in store procedure used as sql to get value is not supported
|
||||
error: 8 array index: 9 messagecode: 1282 errormessage: transaction statement in store procedure used as sql to get value is not supported
|
||||
error: 1 array index: 2 messagecode: 1282 errormessage: can not use commit rollback in Complex SQL
|
||||
error: 2 array index: 3 messagecode: 1282 errormessage: can not use commit rollback in Complex SQL
|
||||
error: 3 array index: 4 messagecode: 1282 errormessage: can not use commit rollback in Complex SQL
|
||||
error: 4 array index: 5 messagecode: 1282 errormessage: can not use commit rollback in Complex SQL
|
||||
error: 5 array index: 6 messagecode: 1282 errormessage: can not use commit rollback in Complex SQL
|
||||
error: 6 array index: 7 messagecode: 1282 errormessage: can not use commit rollback in Complex SQL
|
||||
error: 7 array index: 8 messagecode: 1282 errormessage: can not use commit rollback in Complex SQL
|
||||
error: 8 array index: 9 messagecode: 1282 errormessage: can not use commit rollback in Complex SQL
|
||||
successfully inserted: 2rows
|
||||
p2
|
||||
----
|
||||
|
|
|
|||
Loading…
Reference in New Issue