Re: BUG #18829: RAISE NOTICE appends 's' to string in PostgreSQL 17.2

From: Robert Treat <rob(at)xzilla(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: armandnortjee(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18829: RAISE NOTICE appends 's' to string in PostgreSQL 17.2
Date: 2025-03-02 18:59:28
Message-ID: CABV9wwMwFLn01n35t0NKBM7td0uJKHEbgoerNo7YCXtakPn0Lg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sun, Mar 2, 2025 at 11:09 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> > In PostgreSQL 17.2, when using the RAISE NOTICE command with a string
> > variable, the output incorrectly appends an extra 's' to the string value.
>
> The substitution marker in plpgsql RAISE strings is just "%", not
> "%s" as it is in C, so this output is expected. That wasn't the best
> design perhaps, but it's impossible to change it now.
>
> > This issue does not occur when running the same code in earlier PostgreSQL
> > versions (e.g., PostgreSQL 16).
>
> You are quite mistaken about that. It's been like this since the
> beginning of plpgsql.
>

While Tom is certainly right about this, I have seen the following
plpgsql code style which looks like the behavior the OP is suggesting,
so they could be mis-remembering.

pagila=# DO $$
DECLARE
my_var TEXT := 'garth';
BEGIN
RAISE NOTICE USING message = format('%s is slim', my_var);
END
$$;
NOTICE: garth is slim
DO

Robert Treat
https://xzilla.net

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2025-03-02 21:00:30 BUG #18830: ExecInitMerge Segfault on MERGE
Previous Message Andrew Dunstan 2025-03-02 16:10:07 Re: BUG #18829: RAISE NOTICE appends 's' to string in PostgreSQL 17.2