agora inbox for pgsql-docs@postgresql.org  
help / color / mirror / Atom feed
9.4.1. format
4+ messages / 4 participants
[nested] [flat]

* 9.4.1. format
@ 2026-09-19 05:52 PG Doc comments form <noreply@postgresql.org>
  2026-09-19 13:55 ` Re: 9.4.1. format David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: PG Doc comments form @ 2026-09-19 05:52 UTC (permalink / raw)
  To: pgsql-docs@lists.postgresql.org; +Cc: y.saburov@gmail.com

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/18/functions-string.html
Description:

>> Here are some examples of the basic format conversions:

```html
SELECT format('INSERT INTO %I VALUES(%L)', 'locations', 'C:\Program Files');
Result: INSERT INTO locations VALUES('C:\Program Files')
```

```sql
db=# SELECT format('INSERT INTO %I VALUES(%L)', 'locations', 'C:\Program
Files');

                       format
----------------------------------------------------
 INSERT INTO locations VALUES(E'C:\\Program Files')
```






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

* Re: 9.4.1. format
  2026-09-19 05:52 9.4.1. format PG Doc comments form <noreply@postgresql.org>
@ 2026-09-19 13:55 ` David G. Johnston <david.g.johnston@gmail.com>
  2026-09-20 19:24   ` Re: 9.4.1. format shihao zhong <zhong950419@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: David G. Johnston @ 2026-09-19 13:55 UTC (permalink / raw)
  To: y.saburov@gmail.com <y.saburov@gmail.com>; pgsql-docs@lists.postgresql.org <pgsql-docs@lists.postgresql.org>

On Saturday, September 19, 2026, PG Doc comments form <
noreply@postgresql.org> wrote:

> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/18/functions-string.html
> Description:
>
> >> Here are some examples of the basic format conversions:
>
> ```html
> SELECT format('INSERT INTO %I VALUES(%L)', 'locations', 'C:\Program
> Files');
> Result: INSERT INTO locations VALUES('C:\Program Files')
> ```
>
> ```sql
> db=# SELECT format('INSERT INTO %I VALUES(%L)', 'locations', 'C:\Program
> Files');
>
>                        format
> ----------------------------------------------------
>  INSERT INTO locations VALUES(E'C:\\Program Files')
> ```
>

Indeed, the example doesn’t reflect the actual output since the presence of
a backslash prompts format to produce syntax for an escape string.

I don’t see a point for explaining when it may choose to write an escape
string but the examples should match reality.  I’d back-patch this to
supported versions on that basis.

David J.

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

* Re: 9.4.1. format
  2026-09-19 05:52 9.4.1. format PG Doc comments form <noreply@postgresql.org>
  2026-09-19 13:55 ` Re: 9.4.1. format David G. Johnston <david.g.johnston@gmail.com>
@ 2026-09-20 19:24   ` shihao zhong <zhong950419@gmail.com>
  2026-09-21 08:47     ` Re: 9.4.1. format Daniel Gustafsson <daniel@yesql.se>
  0 siblings, 1 reply; 4+ messages in thread

From: shihao zhong @ 2026-09-20 19:24 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: y.saburov@gmail.com <y.saburov@gmail.com>; pgsql-docs@lists.postgresql.org <pgsql-docs@lists.postgresql.org>

> I don’t see a point for explaining when it may choose to write an escape
> string but the examples should match reality.
> I’d back-patch this to supported versions on that basis.

Agree with you, patch attached.
0001 is for master
0002 is for backport

Thanks,
Shihao

Attachments:

  [application/octet-stream] v1-0001-doc-fix-format-example-output-for-a-value-with-a-.patch (1.5K, ../../CAGRkXqQ=21Gy8VT-WvUHxG0f9JFQTo_RtrbZ_X6qcNy0pd3eLw@mail.gmail.com/3-v1-0001-doc-fix-format-example-output-for-a-value-with-a-.patch)
  download | inline diff:
From e81bf4882ad4ced655d10a4d65b222aba066d4db Mon Sep 17 00:00:00 2001
From: Shihao <zhong950419@gmail.com>
Date: Sun, 20 Sep 2026 14:48:21 -0400
Subject: [PATCH v1] doc: fix format() example output for a value with a
 backslash

The example says that format('INSERT INTO %I VALUES(%L)', 'locations',
'C:\Program Files') returns INSERT INTO locations VALUES('C:\Program Files').
A backslash makes quote_literal emit an escape string constant, so the real
output is INSERT INTO locations VALUES(E'C:\\Program Files').

Reported-by: Yury Saburov <y.saburov@gmail.com>
Discussion: https://postgr.es/m/178979714249.1241.1230833804069549466%40wrigleys.postgresql.org
Backpatch-through: 14
---
 doc/src/sgml/func/func-string.sgml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/src/sgml/func/func-string.sgml b/doc/src/sgml/func/func-string.sgml
index fb7408ee014..941ebd3cd68 100644
--- a/doc/src/sgml/func/func-string.sgml
+++ b/doc/src/sgml/func/func-string.sgml
@@ -1773,7 +1773,7 @@ SELECT format('INSERT INTO %I VALUES(%L)', 'Foo bar', E'O\'Reilly');
 <lineannotation>Result: </lineannotation><computeroutput>INSERT INTO "Foo bar" VALUES('O''Reilly')</computeroutput>
 
 SELECT format('INSERT INTO %I VALUES(%L)', 'locations', 'C:\Program Files');
-<lineannotation>Result: </lineannotation><computeroutput>INSERT INTO locations VALUES('C:\Program Files')</computeroutput>
+<lineannotation>Result: </lineannotation><computeroutput>INSERT INTO locations VALUES(E'C:\\Program Files')</computeroutput>
 </screen>
     </para>
 
-- 
2.37.1 (Apple Git-137.1)



  [application/octet-stream] v1-0002-doc-fix-format-example-output-REL_14-to-REL_18.patch (1.5K, ../../CAGRkXqQ=21Gy8VT-WvUHxG0f9JFQTo_RtrbZ_X6qcNy0pd3eLw@mail.gmail.com/4-v1-0002-doc-fix-format-example-output-REL_14-to-REL_18.patch)
  download | inline diff:
From e29db615b0f1056b9de9aa748e6881381959026f Mon Sep 17 00:00:00 2001
From: Shihao <zhong950419@gmail.com>
Date: Sun, 20 Sep 2026 15:20:20 -0400
Subject: [PATCH v1] doc: fix format() example output for a value with a
 backslash

The example says that format('INSERT INTO %I VALUES(%L)', 'locations',
'C:\Program Files') returns INSERT INTO locations VALUES('C:\Program Files').
A backslash makes quote_literal emit an escape string constant, so the real
output is INSERT INTO locations VALUES(E'C:\\Program Files').

Reported-by: Yury Saburov <y.saburov@gmail.com>
Discussion: https://postgr.es/m/178979714249.1241.1230833804069549466%40wrigleys.postgresql.org
Backpatch-through: 14
---
 doc/src/sgml/func.sgml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index d065b8be1e1..9a15fe73a4d 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -4198,7 +4198,7 @@ SELECT format('INSERT INTO %I VALUES(%L)', 'Foo bar', E'O\'Reilly');
 <lineannotation>Result: </lineannotation><computeroutput>INSERT INTO "Foo bar" VALUES('O''Reilly')</computeroutput>
 
 SELECT format('INSERT INTO %I VALUES(%L)', 'locations', 'C:\Program Files');
-<lineannotation>Result: </lineannotation><computeroutput>INSERT INTO locations VALUES('C:\Program Files')</computeroutput>
+<lineannotation>Result: </lineannotation><computeroutput>INSERT INTO locations VALUES(E'C:\\Program Files')</computeroutput>
 </screen>
     </para>
 
-- 
2.37.1 (Apple Git-137.1)



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

* Re: 9.4.1. format
  2026-09-19 05:52 9.4.1. format PG Doc comments form <noreply@postgresql.org>
  2026-09-19 13:55 ` Re: 9.4.1. format David G. Johnston <david.g.johnston@gmail.com>
  2026-09-20 19:24   ` Re: 9.4.1. format shihao zhong <zhong950419@gmail.com>
@ 2026-09-21 08:47     ` Daniel Gustafsson <daniel@yesql.se>
  0 siblings, 0 replies; 4+ messages in thread

From: Daniel Gustafsson @ 2026-09-21 08:47 UTC (permalink / raw)
  To: shihao zhong <zhong950419@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; y.saburov@gmail.com <y.saburov@gmail.com>; pgsql-docs@lists.postgresql.org <pgsql-docs@lists.postgresql.org>

> On 20 Sep 2026, at 21:24, shihao zhong <zhong950419@gmail.com> wrote:

> > .. the examples should match reality. 
> > I’d back-patch this to supported versions on that basis.
> 
> Agree with you, patch attached.

Agreed, I will apply once the current beta4 freeze is lifted.

--
Daniel Gustafsson







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


end of thread, other threads:[~2026-09-21 08:47 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-09-19 05:52 9.4.1. format PG Doc comments form <noreply@postgresql.org>
2026-09-19 13:55 ` David G. Johnston <david.g.johnston@gmail.com>
2026-09-20 19:24   ` shihao zhong <zhong950419@gmail.com>
2026-09-21 08:47     ` Daniel Gustafsson <daniel@yesql.se>

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