You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doc: improve examples for json_populate_record() and related functions.
Make these examples self-contained by providing declarations of the
user-defined row types they rely on. There wasn't room to do this
in the old doc format, but now there is, and I think it makes the
examples a good bit less confusing.
Copy file name to clipboardExpand all lines: doc/src/sgml/func.sgml
+14-3
Original file line number
Diff line number
Diff line change
@@ -15414,7 +15414,12 @@ table2-mapping
15414
15414
calls.
15415
15415
</para>
15416
15416
<para>
15417
-
<literal>select * from json_populate_record(null::myrowtype, '{"a": 1, "b": ["2", "a b"], "c": {"d": 4, "e": "a b c"}}')</literal>
15417
+
<literal>create type subrowtype as (d int, e text);</literal>
15418
+
<literal>create type myrowtype as (a int, b text[], c subrowtype);</literal>
15419
+
</para>
15420
+
<para>
15421
+
<literal>select * from json_populate_record(null::myrowtype,
15422
+
'{"a": 1, "b": ["2", "a b"], "c": {"d": 4, "e": "a b c"}, "x": "foo"}')</literal>
15418
15423
<returnvalue></returnvalue>
15419
15424
<programlisting>
15420
15425
a | b | c
@@ -15446,7 +15451,10 @@ table2-mapping
15446
15451
for <function>json[b]_populate_record</function>.
15447
15452
</para>
15448
15453
<para>
15449
-
<literal>select * from json_populate_recordset(null::myrowtype, '[{"a":1,"b":2},{"a":3,"b":4}]')</literal>
15454
+
<literal>create type twoints as (a int, b int);</literal>
15455
+
</para>
15456
+
<para>
15457
+
<literal>select * from json_populate_recordset(null::twoints, '[{"a":1,"b":2},{"a":3,"b":4}]')</literal>
15450
15458
<returnvalue></returnvalue>
15451
15459
<programlisting>
15452
15460
a | b
@@ -15483,7 +15491,10 @@ table2-mapping
15483
15491
input record value, unmatched columns are always filled with nulls.
15484
15492
</para>
15485
15493
<para>
15486
-
<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>
15494
+
<literal>create type myrowtype as (a int, b text);</literal>
15495
+
</para>
15496
+
<para>
15497
+
<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>
0 commit comments