public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Andreas Karlsson <[email protected]>
Cc: Marcos Pegoraro <[email protected]>
Cc: Pavel Stehule <[email protected]>
Cc: jian he <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: not fully correct error message
Date: Sat, 03 Jan 2026 14:16:20 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <CAFj8pRCveWPR06bbad9GnMb0Kcr6jnXPttv9XOaOB+oFCD1Tsg@mail.gmail.com>
<CACJufxEOQ+2=L3aLBzW6A4vu75gN7vKw07+QgU_398Avqb5KTg@mail.gmail.com>
<CAFj8pRBoybDsAZdQJ3nz=E1uCSu3Buoa+VXM8wnwy6ixKqzYxA@mail.gmail.com>
<CAB-JLwZGsWHcK3tnD-uUZf=QTRC0NJQ7qxdQrDYk2b_uFPTaww@mail.gmail.com>
<[email protected]>
<[email protected]>
<[email protected]>
Andreas Karlsson <[email protected]> writes:
> On 1/3/26 7:03 PM, Tom Lane wrote:
>> Yeah, I like just adding "or procedure" and calling it good.
>> I do not think we need a regression test, either ...
> Yeah, let's keep it simple.
>> Poking around, I also found this:
>> src/backend/commands/wait.c: errdetail("WAIT FOR cannot be executed from a function or a procedure or within a transaction with an isolation level higher than READ COMMITTED."));
>> which is also not great grammar. What do you think of "WAIT FOR
>> cannot be executed from a function or procedure, nor within a
>> transaction with an isolation level higher than READ COMMITTED." ?
> Much better!
Putting that all together, and fixing affected regression tests
(yes, this code was covered already), I get the attached.
regards, tom lane
Attachments:
[text/x-diff] v2-improve-vacuum-error-message.patch (3.3K, ../[email protected]/2-v2-improve-vacuum-error-message.patch)
download | inline diff:
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 842faa44232..c857e23552f 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -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 &&
diff --git a/src/backend/commands/wait.c b/src/backend/commands/wait.c
index d43dfd642d6..e4509fffe06 100644
--- a/src/backend/commands/wait.c
+++ b/src/backend/commands/wait.c
@@ -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
diff --git a/src/test/recovery/t/049_wait_for_lsn.pl b/src/test/recovery/t/049_wait_for_lsn.pl
index e0ddb06a2f0..5f415b9af51 100644
--- a/src/test/recovery/t/049_wait_for_lsn.pl
+++ b/src/test/recovery/t/049_wait_for_lsn.pl
@@ -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
diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out
index 327d1e7731f..b3eccd8afe3 100644
--- a/src/test/regress/expected/subscription.out
+++ b/src/test/regress/expected/subscription.out
@@ -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);
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: not fully correct error message
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox