pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nikita Glukhov <n.gluhov@postgrespro.ru>
To: Pavel Stehule <pavel.stehule@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Jonathan S. Katz <jkatz@postgresql.org>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: John Naylor <john.naylor@enterprisedb.com>
Cc: Amit Langote <amitlangote09@gmail.com>
Subject: Re: SQL/JSON features for v15
Date: Tue, 23 Aug 2022 21:16:24 +0300
Message-ID: <e8183ff7-2fd0-c2e2-caed-ea77e19e2dba@postgrespro.ru> (raw)
In-Reply-To: <CAFj8pRDyv7vsSmN8RcpugOCctM-UudV58z14pyvJz2ZtwXPCpg@mail.gmail.com>
References: <20220815223853.itrlpqgpqheg6r6a@awork3.anarazel.de>
	<225d341b-f310-eed0-ceff-b8ec61669d9f@postgrespro.ru>
	<20220816021425.5sa6gx67zmpou3bc@awork3.anarazel.de>
	<8d0ffc54-469a-ffab-68a3-8b547e24a08d@postgresql.org>
	<7d83684b-7932-9f29-400b-0beedfafcdd4@postgrespro.ru>
	<69022273-e7e3-6d1a-10f8-d1b4740e4b97@postgresql.org>
	<92cab50c-152b-84fc-fd49-12b936113a3d@postgresql.org>
	<CA+TgmoaAZq6rRdVA65PBXBKs=jUHhf42Jf78kBLOaX3c6J7MfQ@mail.gmail.com>
	<20220823155511.ffyntlyjl6wrgljv@awork3.anarazel.de>
	<CAFj8pRBqhLvTvf8_zHoM6Jc656atEWRUPnp6i_T5hjExeB83Ag@mail.gmail.com>
	<20220823172718.o4p25k2bcrmsnj3a@awork3.anarazel.de>
	<CAFj8pRDyv7vsSmN8RcpugOCctM-UudV58z14pyvJz2ZtwXPCpg@mail.gmail.com>


On 23.08.2022 20:38, Pavel Stehule wrote:
> út 23. 8. 2022 v 19:27 odesílatel Andres Freund <andres@anarazel.de> 
> napsal:
>
>     Hi,
>
>     On 2022-08-23 18:06:22 +0200, Pavel Stehule wrote:
>     > The errors that should be handled are related to json structure
>     errors. I
>     > don't think so we have to handle all errors and all conversions.
>     >
>     > The JSON knows only three types - and these conversions can be
>     written
>     > specially for this case - or we can write json io routines to be
>     able to
>     > signal error
>     > without an exception.
>
>     I think that's not true unfortunately. You can specify return
>     types, and
>     composite types can be populated. Which essentially requires arbitrary
>     coercions.
>
>
> Please, can you send an example? Maybe we try to fix a feature that is 
> not required by standard.

- Returning arbitrary types in JSON_VALUE using I/O coercion
from JSON string (more precisely, text::arbitrary_type cast):

SELECT JSON_QUERY(jsonb '"1, 2"', '$' RETURNING point);
  json_query
------------
  (1,2)
(1 row)


- Returning composite and array types in JSON_QUERY, which is implemented
reusing the code of our json[b]_populate_record[set]():

SELECT JSON_QUERY(jsonb '[1, "2", null]', '$' RETURNING int[]);
  json_query
------------
  {1,2,NULL}
(1 row)

-- 
Nikita Glukhov
Postgres Professional:http://www.postgrespro.com
The Russian Postgres Company

view thread (95+ messages)  latest in thread

Message-ID: <e8183ff7-2fd0-c2e2-caed-ea77e19e2dba@postgrespro.ru>
Permalink:  ../e8183ff7-2fd0-c2e2-caed-ea77e19e2dba@postgrespro.ru/
Also on:    postgresql.org/message-id/e8183ff7-2fd0-c2e2-caed-ea77e19e2dba@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: n.gluhov@postgrespro.ru, pavel.stehule@gmail.com, andres@anarazel.de, robertmhaas@gmail.com, jkatz@postgresql.org, pgsql-hackers@lists.postgresql.org, andrew@dunslane.net, tgl@sss.pgh.pa.us, michael@paquier.xyz, john.naylor@enterprisedb.com, amitlangote09@gmail.com
  Subject: Re: SQL/JSON features for v15
  In-Reply-To: <e8183ff7-2fd0-c2e2-caed-ea77e19e2dba@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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