From: Liudmila Mantrova <l.mantrova@postgrespro.ru>
To: pgsql-docs@lists.postgresql.org
Subject: improve examples for JSON functions
Date: Thu, 28 Mar 2019 17:01:19 +0300
Message-ID: <1d5ae053-86ad-139e-f7a5-16dfad8dd3ba@postgrespro.ru> (raw)
Hi,
Please consider a small documentation patch that adds custom type
definition to a couple of JSON function examples, so that they match the
provided results. Previously, having "myrowtype" without a definition
here could cause confusion as this type does not exist by default, and
actually differs between these examples.
--
Liudmila Mantrova
Technical writer at Postgres Professional:http://www.postgrespro.com
The Russian Postgres Company
Attachments:json-func-examples.patch (text/x-patch, 2.1K) downloaddiff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgmlindex 1a01473..c5ab59e 100644--- a/doc/src/sgml/func.sgml+++ b/doc/src/sgml/func.sgml@@ -12614,7 +12614,10 @@ table2-mapping
whose columns match the record type defined by <replaceable>base</replaceable>
(see note below).
</entry>
- <entry><literal>select * from json_populate_record(null::myrowtype, '{"a": 1, "b": ["2", "a b"], "c": {"d": 4, "e": "a b c"}}')</literal></entry>+ <entry>+ <para><literal>create type myrowtype as (a int, b json, c json);</literal></para>+ <para><literal>select * from json_populate_record(null::myrowtype, '{"a": 1, "b": ["2", "a b"], "c": {"d": 4, "e": "a b c"}}')</literal></para>+ </entry>
<entry>
<programlisting>
a | b | c
@@ -12634,7 +12637,10 @@ table2-mapping
columns match the record type defined by <replaceable>base</replaceable> (see
note below).
</entry>
- <entry><literal>select * from json_populate_recordset(null::myrowtype, '[{"a":1,"b":2},{"a":3,"b":4}]')</literal></entry>+ <entry>+ <para><literal>create type myrowtype as (a int, b int);</literal></para>+ <para><literal>select * from json_populate_recordset(null::myrowtype, '[{"a":1,"b":2},{"a":3,"b":4}]') as (a int, b int)</literal></para>+ </entry>
<entry>
<programlisting>
a | b
@@ -12708,7 +12714,10 @@ table2-mapping
explicitly define the structure of the record with an <literal>AS</literal>
clause.
</entry>
- <entry><literal>select * from json_to_record('{"a":1,"b":[1,2,3],"c":[1,2,3],"e":"bar","r": {"a": 123, "b": "a b c"}}') as x(a int, b text, c int[], d text, r myrowtype) </literal></entry>+ <entry>+ <para><literal>create type myrowtype as (a int, b text);</literal></para>+ <para><literal>select * from json_to_record('{"a":1,"b":[1,2,3],"c":[1,2,3],"e":"bar","r": {"a": 123, "b": "a b c"}}') as x(a int, b text, c int[], d text, r myrowtype)</literal></para>+ </entry>
<entry>
<programlisting>
a | b | c | d | r
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-docs@postgresql.org
Cc: l.mantrova@postgrespro.ru, pgsql-docs@lists.postgresql.org
Subject: Re: improve examples for JSON functions
In-Reply-To: <1d5ae053-86ad-139e-f7a5-16dfad8dd3ba@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