Skip to content

Commit 2ad34f3

Browse files
committed
fix: remove utility.c atomicity override, fix test separator
Remove the Oracle-mode atomicity override in utility.c for CALL/DO statements. Instead, add / separator after CREATE FUNCTION in the test to properly separate it from the following DO block. Restore expected "invalid transaction termination" error for START TRANSACTION; DO ... COMMIT case, which is correct behavior.
1 parent 20c3898 commit 2ad34f3

File tree

3 files changed

+7
-39
lines changed

3 files changed

+7
-39
lines changed

src/backend/tcop/utility.c

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
#include "utils/acl.h"
6868
#include "utils/guc.h"
6969
#include "utils/lsyscache.h"
70-
#include "utils/ora_compatible.h"
7170

7271
/* Hook for plugins to get control in ProcessUtility() */
7372
ProcessUtility_hook_type ProcessUtility_hook = NULL;
@@ -714,25 +713,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
714713
break;
715714

716715
case T_DoStmt:
717-
/*
718-
* In Oracle compatibility mode, anonymous blocks are non-atomic
719-
* by default when executed at the top level or in a non-atomic
720-
* context, allowing COMMIT/ROLLBACK within the block and in
721-
* any procedures called from it. However, if we're already in
722-
* an atomic context (e.g., called from a function), we must
723-
* respect that.
724-
*/
725-
{
726-
bool doAtomicContext = isAtomicContext;
727-
728-
if (compatible_db == ORA_PARSER &&
729-
(context == PROCESS_UTILITY_TOPLEVEL ||
730-
context == PROCESS_UTILITY_QUERY_NONATOMIC))
731-
doAtomicContext = false;
732-
733-
ExecuteDoStmt(pstate, (DoStmt *) parsetree,
734-
doAtomicContext, params, dest);
735-
}
716+
ExecuteDoStmt(pstate, (DoStmt *) parsetree, isAtomicContext, params, dest);
736717
break;
737718

738719
case T_CreateTableSpaceStmt:
@@ -876,24 +857,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
876857
break;
877858

878859
case T_CallStmt:
879-
/*
880-
* In Oracle compatibility mode, CALL statements are non-atomic
881-
* by default when executed at the top level or in a non-atomic
882-
* context, allowing COMMIT/ROLLBACK within the called procedure
883-
* and any nested calls. However, if we're already in an atomic
884-
* context (e.g., called from a function), we must respect that.
885-
*/
886-
{
887-
bool callAtomicContext = isAtomicContext;
888-
889-
if (compatible_db == ORA_PARSER &&
890-
(context == PROCESS_UTILITY_TOPLEVEL ||
891-
context == PROCESS_UTILITY_QUERY_NONATOMIC))
892-
callAtomicContext = false;
893-
894-
ExecuteCallStmt(castNode(CallStmt, parsetree), params,
895-
callAtomicContext, dest);
896-
}
860+
ExecuteCallStmt(castNode(CallStmt, parsetree), params, isAtomicContext, dest);
897861
break;
898862

899863
case T_ClusterStmt:

src/pl/plisql/src/expected/plisql_transaction.out

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ CONTEXT: PL/iSQL function transaction_test1(pg_catalog.int4,text) line 6 at COM
5555
COMMIT;
5656
START TRANSACTION;
5757
DO LANGUAGE plisql $$ BEGIN COMMIT; END $$;
58+
ERROR: invalid transaction termination
59+
CONTEXT: PL/iSQL function inline_code_block line 1 at COMMIT
5860
COMMIT;
5961
TRUNCATE test1;
6062
-- not allowed in a function
@@ -470,6 +472,7 @@ INSERT INTO test4 SELECT repeat('xyzzy', 2000);
470472
-- that will return a still-toasted value
471473
CREATE FUNCTION data_source(i int) RETURNS TEXT LANGUAGE sql
472474
AS 'select f1 from test4' IMMUTABLE;
475+
/
473476
DO $$
474477
declare x text;
475478
begin
@@ -479,8 +482,8 @@ begin
479482
end loop;
480483
raise notice 'length(x) = %', length(x);
481484
end $$;
482-
/
483485
NOTICE: length(x) = 10000
486+
/
484487
-- operations on composite types vs. internal transactions
485488
DO LANGUAGE plisql $$
486489
declare

src/pl/plisql/src/sql/plisql_transaction.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ INSERT INTO test4 SELECT repeat('xyzzy', 2000);
393393
-- that will return a still-toasted value
394394
CREATE FUNCTION data_source(i int) RETURNS TEXT LANGUAGE sql
395395
AS 'select f1 from test4' IMMUTABLE;
396+
/
396397

397398
DO $$
398399
declare x text;

0 commit comments

Comments
 (0)