pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #18829: RAISE NOTICE appends 's' to string in PostgreSQL 17.2
4+ messages / 4 participants
[nested] [flat]

* BUG #18829: RAISE NOTICE appends 's' to string in PostgreSQL 17.2
@ 2025-03-02 14:18  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 2 replies; 4+ messages in thread

From: PG Bug reporting form @ 2025-03-02 14:18 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: armandnortjee@gmail.com

The following bug has been logged on the website:

Bug reference:      18829
Logged by:          Armand
Email address:      armandnortjee@gmail.com
PostgreSQL version: 17.2
Operating system:   Windows 10
Description:        

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.
This issue does not occur when running the same code in earlier PostgreSQL
versions (e.g., PostgreSQL 16).

DO $$
DECLARE
    my_var TEXT := 'garth';
BEGIN
    RAISE NOTICE '%s is slim', my_var;
END
$$;

Expected Result:
The output should be:
NOTICE:  garth is slim

Actual Result:
The output incorrectly shows:
NOTICE:  garths is slim



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

* Re: BUG #18829: RAISE NOTICE appends 's' to string in PostgreSQL 17.2
@ 2025-03-02 16:09  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 1 reply; 4+ messages in thread

From: Tom Lane @ 2025-03-02 16:09 UTC (permalink / raw)
  To: armandnortjee@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.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.

			regards, tom lane





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

* Re: BUG #18829: RAISE NOTICE appends 's' to string in PostgreSQL 17.2
@ 2025-03-02 16:10  Andrew Dunstan <andrew@dunslane.net>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 0 replies; 4+ messages in thread

From: Andrew Dunstan @ 2025-03-02 16:10 UTC (permalink / raw)
  To: armandnortjee@gmail.com; pgsql-bugs@lists.postgresql.org


On 2025-03-02 Su 9:18 AM, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference:      18829
> Logged by:          Armand
> Email address:armandnortjee@gmail.com
> PostgreSQL version: 17.2
> Operating system:   Windows 10
> Description:
>
> 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.
> This issue does not occur when running the same code in earlier PostgreSQL
> versions (e.g., PostgreSQL 16).
>
> DO $$
> DECLARE
>      my_var TEXT := 'garth';
> BEGIN
>      RAISE NOTICE '%s is slim', my_var;
> END
> $$;
>
> Expected Result:
> The output should be:
> NOTICE:  garth is slim
>
> Actual Result:
> The output incorrectly shows:
> NOTICE:  garths is slim
>

This is not a bug, it's working as documented.

The 's' is there because you told it to be there. The docs say: "Inside 
the format string, |%| is replaced by the string representation of the 
next optional argument's value."

This is not a printf style format string, as you appear to think it is.


cheers


andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com

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

* Re: BUG #18829: RAISE NOTICE appends 's' to string in PostgreSQL 17.2
@ 2025-03-02 18:59  Robert Treat <rob@xzilla.net>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Robert Treat @ 2025-03-02 18:59 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: armandnortjee@gmail.com; pgsql-bugs@lists.postgresql.org

On Sun, Mar 2, 2025 at 11:09 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> PG Bug reporting form <noreply@postgresql.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





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


end of thread, other threads:[~2025-03-02 18:59 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-03-02 14:18 BUG #18829: RAISE NOTICE appends 's' to string in PostgreSQL 17.2 PG Bug reporting form <noreply@postgresql.org>
2025-03-02 16:09 ` Tom Lane <tgl@sss.pgh.pa.us>
2025-03-02 18:59   ` Robert Treat <rob@xzilla.net>
2025-03-02 16:10 ` Andrew Dunstan <andrew@dunslane.net>

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