diff options
| author | Andrew Dunstan <andrew@dunslane.net> | 2017-04-06 22:11:21 -0400 |
|---|---|---|
| committer | Andrew Dunstan <andrew@dunslane.net> | 2017-04-06 22:22:13 -0400 |
| commit | cf35346e813e5a1373f308d397bb0a8f3f21d530 (patch) | |
| tree | 8eb3d30d8218ae21aef5c146d4e6a04a6d52004a /doc/src | |
| parent | 510074f9f0131a04322d6a3d2a51c87e6db243f9 (diff) | |
Make json_populate_record and friends operate recursively
With this change array fields are populated from json(b) arrays, and
composite fields are populated from json(b) objects.
Along the way, some significant code refactoring is done to remove
redundancy in the way to populate_record[_set] and to_record[_set]
functions operate, and some significant efficiency gains are made by
caching tuple descriptors.
Nikita Glukhov, edited some by me.
Reviewed by Aleksander Alekseev and Tom Lane.
Diffstat (limited to 'doc/src')
| -rw-r--r-- | doc/src/sgml/func.sgml | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index e3d852cdc71..cb0a36a170f 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -11546,12 +11546,12 @@ table2-mapping whose columns match the record type defined by <replaceable>base</> (see note below). </entry> - <entry><literal>select * from json_populate_record(null::myrowtype, '{"a":1,"b":2}')</literal></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> <programlisting> - a | b ----+--- - 1 | 2 + a | b | c +---+-----------+------------- + 1 | {2,"a b"} | (4,"a b c") </programlisting> </entry> </row> @@ -11640,12 +11640,12 @@ table2-mapping explicitly define the structure of the record with an <literal>AS</> clause. </entry> - <entry><literal>select * from json_to_record('{"a":1,"b":[1,2,3],"c":"bar"}') as x(a int, b text, d text) </literal></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> <programlisting> - a | b | d ----+---------+--- - 1 | [1,2,3] | + a | b | c | d | r +---+---------+---------+---+--------------- + 1 | [1,2,3] | {1,2,3} | | (123,"a b c") </programlisting> </entry> </row> |
