]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Improve a couple of error messages.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 3 Jan 2026 22:18:39 +0000 (17:18 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 3 Jan 2026 22:18:39 +0000 (17:18 -0500)
Change "function" to "function or procedure" in
PreventInTransactionBlock, and improve grammar of ExecWaitStmt's
complaint about having an active snapshot.

Author: Pavel Stehule <pavel.stehule@gmail.com>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Marcos Pegoraro <marcos@f10.com.br>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAFj8pRCveWPR06bbad9GnMb0Kcr6jnXPttv9XOaOB+oFCD1Tsg@mail.gmail.com

src/backend/access/transam/xact.c
src/backend/commands/wait.c
src/test/recovery/t/049_wait_for_lsn.pl
src/test/regress/expected/subscription.out

index 842faa44232cb69f56bca6071b801a9e6b5ccd36..c857e23552f595d2d86b653018110a7113b76f2f 100644 (file)
@@ -3695,7 +3695,8 @@ PreventInTransactionBlock(bool isTopLevel, const char *stmtType)
                ereport(ERROR,
                                (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
                /* translator: %s represents an SQL statement name */
-                                errmsg("%s cannot be executed from a function", stmtType)));
+                                errmsg("%s cannot be executed from a function or procedure",
+                                               stmtType)));
 
        /* If we got past IsTransactionBlock test, should be in default state */
        if (CurrentTransactionState->blockState != TBLOCK_DEFAULT &&
index d43dfd642d63da7c628645d61952d15849c5bc31..e4509fffe069575b3be84e361694310afb0fb7ba 100644 (file)
@@ -131,8 +131,8 @@ ExecWaitStmt(ParseState *pstate, WaitStmt *stmt, DestReceiver *dest)
        if (HaveRegisteredOrActiveSnapshot())
                ereport(ERROR,
                                errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
-                               errmsg("WAIT FOR must be only called without an active or registered snapshot"),
-                               errdetail("WAIT FOR cannot be executed from a function or a procedure or within a transaction with an isolation level higher than READ COMMITTED."));
+                               errmsg("WAIT FOR must be called without an active or registered snapshot"),
+                               errdetail("WAIT FOR cannot be executed from a function or procedure, nor within a transaction with an isolation level higher than READ COMMITTED."));
 
        /*
         * As the result we should hold no snapshot, and correspondingly our xmin
index e0ddb06a2f04813d10be623160a93ac42ddf5f41..5f415b9af51af96c1b39b4927ba249ed6b4297d4 100644 (file)
@@ -102,7 +102,7 @@ $node_standby->psql(
        "BEGIN ISOLATION LEVEL REPEATABLE READ; SELECT 1; WAIT FOR LSN '${lsn3}';",
        stderr => \$stderr);
 ok( $stderr =~
-         /WAIT FOR must be only called without an active or registered snapshot/,
+         /WAIT FOR must be called without an active or registered snapshot/,
        "get an error when running in a transaction with an isolation level higher than REPEATABLE READ"
 );
 
@@ -122,7 +122,7 @@ $node_standby->psql(
        "SELECT pg_wal_replay_wait_wrap('${lsn3}');",
        stderr => \$stderr);
 ok( $stderr =~
-         /WAIT FOR must be only called without an active or registered snapshot/,
+         /WAIT FOR must be called without an active or registered snapshot/,
        "get an error when running within another function");
 
 # 5. Check parameter validation error cases on standby before promotion
index 327d1e7731f971ac8592bb53e80ac8329b7a6b43..b3eccd8afe3dd2b78b55cc912de1abc164d75f7a 100644 (file)
@@ -357,7 +357,7 @@ END;
 CREATE FUNCTION func() RETURNS VOID AS
 $$ ALTER SUBSCRIPTION regress_testsub SET PUBLICATION mypub WITH (refresh = true) $$ LANGUAGE SQL;
 SELECT func();
-ERROR:  ALTER SUBSCRIPTION with refresh cannot be executed from a function
+ERROR:  ALTER SUBSCRIPTION with refresh cannot be executed from a function or procedure
 CONTEXT:  SQL function "func" statement 1
 ALTER SUBSCRIPTION regress_testsub DISABLE;
 ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE);