Re: not fully correct error message

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: not fully correct error message
Date: 2026-01-03 06:34:52
Message-ID: CAFj8pRBoybDsAZdQJ3nz=E1uCSu3Buoa+VXM8wnwy6ixKqzYxA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

čt 1. 1. 2026 v 11:05 odesílatel jian he <jian(dot)universality(at)gmail(dot)com>
napsal:

> On Thu, Jan 1, 2026 at 3:10 PM Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
> >
> > Hi
> >
> > I tested one use case, and maybe I found little bit possible error
> message
> >
> > create procedure test()
> > as $$
> > begin
> > vacuum;
> > end;
> > $$ language plpgsql;
> >
> > (2026-01-01 08:04:05) postgres=# call test();
> > ERROR: 25001: VACUUM cannot be executed from a function
> > CONTEXT: SQL statement "vacuum"
> > PL/pgSQL function test() line 3 at SQL statement
> > LOCATION: PreventInTransactionBlock, xact.c:3695
> > (2026-01-01 08:09:18) postgres=#
> >
> > should be "VACUUM cannot be executed from a function or a procedure"
> instead ?
> >
>
> hi.
> "VACUUM cannot be executed from a function or a procedure"
> looks good to me.
>
> similarly, in ExecWaitStmt we have:
> 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."));
>
> PreventInTransactionBlock is used in so many places, but this error
> message:
> ``
> (errmsg("%s cannot be executed from a function", stmtType)));
> ``
> only appears once in the regress tests.
> maybe we can add some dummy tests for it.
>

here is a patch (with small regress test)

Regards

Pavel

Attachment Content-Type Size
0001-VACUUM-cannot-be-executed-inside-a-function-or-a-pro.patch text/x-patch 2.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2026-01-03 09:32:28 Re: Make copyObject work in C++
Previous Message Tristan Partin 2026-01-03 04:49:52 Re: Decouple C++ support in Meson's PGXS from LLVM enablement