pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Only allow returning string types or bytea from json_serialize
6+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2022-07-11 0a6be1f0ec 834fce52f9  Improve error message with JSON_SERIALIZE()
* pgsql: Only allow returning string types or bytea from json_serialize
@ 2022-07-07 21:46  Andrew Dunstan <andrew@dunslane.net>
  0 siblings, 1 reply; 6+ messages in thread

From: Andrew Dunstan @ 2022-07-07 21:46 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Only allow returning string types or bytea from json_serialize

These are documented to be the allowed types for the RETURNING clause,
but the restriction was not being enforced, which caused a segfault if
another type was specified. Add some testing for this.

Per report from a.kozhemyakin

Backpatch to release 15.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3c633f32b9c712cc0b4c8d946f0eeae04a3ff51a

Modified Files
--------------
src/backend/parser/parse_expr.c       | 17 +++++++++++++++++
src/test/regress/expected/sqljson.out | 10 ++++++++++
src/test/regress/sql/sqljson.sql      |  5 +++++
3 files changed, 32 insertions(+)



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

* pgsql: Only allow returning string types or bytea from json_serialize
@ 2022-07-07 21:46  Andrew Dunstan <andrew@dunslane.net>
  0 siblings, 0 replies; 6+ messages in thread

From: Andrew Dunstan @ 2022-07-07 21:46 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Only allow returning string types or bytea from json_serialize

These are documented to be the allowed types for the RETURNING clause,
but the restriction was not being enforced, which caused a segfault if
another type was specified. Add some testing for this.

Per report from a.kozhemyakin

Backpatch to release 15.

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2b2bcc22e571c27a9ea8861e29e0c40874dae714

Modified Files
--------------
src/backend/parser/parse_expr.c       | 17 +++++++++++++++++
src/test/regress/expected/sqljson.out | 10 ++++++++++
src/test/regress/sql/sqljson.sql      |  5 +++++
3 files changed, 32 insertions(+)



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

* Re: pgsql: Only allow returning string types or bytea from json_serialize
@ 2022-07-08 06:41  Kyotaro Horiguchi <horikyota.ntt@gmail.com>
  parent: Andrew Dunstan <andrew@dunslane.net>
  0 siblings, 1 reply; 6+ messages in thread

From: Kyotaro Horiguchi @ 2022-07-08 06:41 UTC (permalink / raw)
  To: andrew@dunslane.net; +Cc: pgsql-committers@lists.postgresql.org

At Thu, 07 Jul 2022 21:46:12 +0000, Andrew Dunstan <andrew@dunslane.net> wrote in 
> Only allow returning string types or bytea from json_serialize

I noticed that this introcues the following error message.

+  errmsg("cannot use RETURNING type %s in JSON_SERIALIZE"
+								format_type_be(returning->typid)),

However, the same file has the following error message.

>			 errmsg("cannot use RETURNING type %s in %s",
>					format_type_be(returning->typid), fname),

So, couldn't we share the format string to reduce translatable
messages?

And, the other messages are

cannot use RETURNING type %s in JSON_SCALAR(), and
cannot use RETURNING type %s in JSON()

So, I think this should not be

cannot use RETURNING type %s in JSON_SERIALIZE

, but should be

cannot use RETURNING type %s in JSON_SERIALIZE()

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center

Attachments:

  0001-Fix-an-error-message.patch (text/x-patch, 0B) download

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

* Re: pgsql: Only allow returning string types or bytea from json_serialize
@ 2022-07-08 10:20  Michael Paquier <michael@paquier.xyz>
  parent: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Michael Paquier @ 2022-07-08 10:20 UTC (permalink / raw)
  To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>; +Cc: andrew@dunslane.net; pgsql-committers@lists.postgresql.org

On Fri, Jul 08, 2022 at 03:41:35PM +0900, Kyotaro Horiguchi wrote:
> I noticed that this introcues the following error message.
> 
> +  errmsg("cannot use RETURNING type %s in JSON_SERIALIZE"
> +								format_type_be(returning->typid)),
> 
> However, the same file has the following error message.
> 
> >			 errmsg("cannot use RETURNING type %s in %s",
> >					format_type_be(returning->typid), fname),
> 
> So, couldn't we share the format string to reduce translatable
> messages?

Yeah, I think that you are right, so let's fix this.  If Andrew does
not show up, I'll take care of it.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

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

* Re: pgsql: Only allow returning string types or bytea from json_serialize
@ 2022-07-11 03:49  Michael Paquier <michael@paquier.xyz>
  parent: Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 6+ messages in thread

From: Michael Paquier @ 2022-07-11 03:49 UTC (permalink / raw)
  To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>; +Cc: andrew@dunslane.net; pgsql-committers@lists.postgresql.org

On Fri, Jul 08, 2022 at 07:20:14PM +0900, Michael Paquier wrote:
> Yeah, I think that you are right, so let's fix this.  If Andrew does
> not show up, I'll take care of it.

Okay, this one is done, then.  Thanks for the patch, Horiguchi-san.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

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

* Re: pgsql: Only allow returning string types or bytea from json_serialize
@ 2022-07-11 06:18  Kyotaro Horiguchi <horikyota.ntt@gmail.com>
  parent: Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 6+ messages in thread

From: Kyotaro Horiguchi @ 2022-07-11 06:18 UTC (permalink / raw)
  To: michael@paquier.xyz; +Cc: andrew@dunslane.net; pgsql-committers@lists.postgresql.org

At Mon, 11 Jul 2022 12:49:11 +0900, Michael Paquier <michael@paquier.xyz> wrote in 
> On Fri, Jul 08, 2022 at 07:20:14PM +0900, Michael Paquier wrote:
> > Yeah, I think that you are right, so let's fix this.  If Andrew does
> > not show up, I'll take care of it.
> 
> Okay, this one is done, then.  Thanks for the patch, Horiguchi-san.

Thanks!
(I came to notice that I sent the mail only to -commiters..)

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center





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


end of thread, other threads:[~2022-07-11 06:18 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 21:46 pgsql: Only allow returning string types or bytea from json_serialize Andrew Dunstan <andrew@dunslane.net>
2022-07-08 06:41 ` Kyotaro Horiguchi <horikyota.ntt@gmail.com>
2022-07-08 10:20   ` Michael Paquier <michael@paquier.xyz>
2022-07-11 03:49     ` Michael Paquier <michael@paquier.xyz>
2022-07-11 06:18       ` Kyotaro Horiguchi <horikyota.ntt@gmail.com>
2022-07-07 21:46 pgsql: Only allow returning string types or bytea from json_serialize 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