public inbox for [email protected]  
help / color / mirror / Atom feed
Re: not fully correct error message
4+ messages / 3 participants
[nested] [flat]

* Re: not fully correct error message
@ 2026-01-03 19:16  Tom Lane <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2026-01-03 19:16 UTC (permalink / raw)
  To: Andreas Karlsson <[email protected]>; +Cc: Marcos Pegoraro <[email protected]>; Pavel Stehule <[email protected]>; jian he <[email protected]>; PostgreSQL Hackers <[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);


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: not fully correct error message
@ 2026-01-03 21:12  Andreas Karlsson <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Andreas Karlsson @ 2026-01-03 21:12 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Marcos Pegoraro <[email protected]>; Pavel Stehule <[email protected]>; jian he <[email protected]>; PostgreSQL Hackers <[email protected]>

On 1/3/26 8:16 PM, Tom Lane wrote:
> Putting that all together, and fixing affected regression tests
> (yes, this code was covered already), I get the attached.

That looks good to me.

Andreas







^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: not fully correct error message
@ 2026-01-03 22:19  Tom Lane <[email protected]>
  parent: Andreas Karlsson <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2026-01-03 22:19 UTC (permalink / raw)
  To: Andreas Karlsson <[email protected]>; +Cc: Marcos Pegoraro <[email protected]>; Pavel Stehule <[email protected]>; jian he <[email protected]>; PostgreSQL Hackers <[email protected]>

Andreas Karlsson <[email protected]> writes:
> On 1/3/26 8:16 PM, Tom Lane wrote:
>> Putting that all together, and fixing affected regression tests
>> (yes, this code was covered already), I get the attached.

> That looks good to me.

Pushed.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: DOCS - clarify CREATE SUBSCRIPTION only synchronizes sequences when copy_data=true
@ 2026-07-09 23:29  Peter Smith <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Peter Smith @ 2026-07-09 23:29 UTC (permalink / raw)
  To: vignesh C <[email protected]>; +Cc: PostgreSQL Hackers <[email protected]>

This docs patch was combined with a similar one and has now been pushed [1].

I have closed the CF entry.

======
[1] https://www.postgresql.org/message-id/[email protected]

Kind Regards
Peter Smith.
Fujitsu Australia






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2026-07-09 23:29 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-01-03 19:16 Re: not fully correct error message Tom Lane <[email protected]>
2026-01-03 21:12 ` Andreas Karlsson <[email protected]>
2026-01-03 22:19   ` Tom Lane <[email protected]>
2026-07-09 23:29 Re: DOCS - clarify CREATE SUBSCRIPTION only synchronizes sequences when copy_data=true Peter Smith <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox