Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcf35346

Browse files
committed
Make json_populate_record and friends operate recursively
With this change array fields are populated from json(b) arrays, andcomposite fields are populated from json(b) objects.Along the way, some significant code refactoring is done to removeredundancy in the way to populate_record[_set] and to_record[_set]functions operate, and some significant efficiency gains are made bycaching tuple descriptors.Nikita Glukhov, edited some by me.Reviewed by Aleksander Alekseev and Tom Lane.
1 parent510074f commitcf35346

File tree

6 files changed

+2412
-560
lines changed

6 files changed

+2412
-560
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11546,12 +11546,12 @@ table2-mapping
1154611546
whose columns match the record type defined by <replaceable>base</>
1154711547
(see note below).
1154811548
</entry>
11549-
<entry><literal>select * from json_populate_record(null::myrowtype, '{"a":1,"b":2}')</literal></entry>
11549+
<entry><literal>select * from json_populate_record(null::myrowtype, '{"a": 1,"b": ["2", "a b"], "c": {"d": 4, "e": "a b c"}}')</literal></entry>
1155011550
<entry>
1155111551
<programlisting>
11552-
a |b
11553-
---+---
11554-
1 |2
11552+
a | b | c
11553+
---+-----------+-------------
11554+
1 |{2,"a b"} | (4,"a b c")
1155511555
</programlisting>
1155611556
</entry>
1155711557
</row>
@@ -11640,12 +11640,12 @@ table2-mapping
1164011640
explicitly define the structure of the record with an <literal>AS</>
1164111641
clause.
1164211642
</entry>
11643-
<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>
11643+
<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>
1164411644
<entry>
1164511645
<programlisting>
11646-
a | b |d
11647-
---+---------+---
11648-
1 | [1,2,3] |
11646+
a | b | c | d | r
11647+
---+---------+---------+---+---------------
11648+
1 | [1,2,3] | {1,2,3} | | (123,"a b c")
1164911649
</programlisting>
1165011650
</entry>
1165111651
</row>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp