Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 87a19eb

Browse files
committed
doc: explain use of json_populate_record{set}()
The set-returning nature of these functions make their use unclear. The modified paragraph was added in PG 9.4. Reported-by: yshaladi@denodo.com Discussion: https://postgr.es/m/152571684246.9460.18059951267371255159@wrigleys.postgresql.org Backpatch-through: 9.4
1 parent fb6accd commit 87a19eb

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

doc/src/sgml/func.sgml

+21-7
Original file line numberDiff line numberDiff line change
@@ -11997,13 +11997,27 @@ table2-mapping
1199711997

1199811998
<note>
1199911999
<para>
12000-
In <function>json_populate_record</function>, <function>json_populate_recordset</function>,
12001-
<function>json_to_record</function> and <function>json_to_recordset</function>,
12002-
type coercion from the JSON is <quote>best effort</quote> and may not result
12003-
in desired values for some types. JSON keys are matched to
12004-
identical column names in the target row type. JSON fields that do not
12005-
appear in the target row type will be omitted from the output, and
12006-
target columns that do not match any JSON field will simply be NULL.
12000+
While the examples for the functions
12001+
<function>json_populate_record</function>,
12002+
<function>json_populate_recordset</function>,
12003+
<function>json_to_record</function> and
12004+
<function>json_to_recordset</function> use constants, the typical use
12005+
would be to reference a table in the <literal>FROM</literal> clause
12006+
and use one of its <type>json</type> or <type>jsonb</type> columns
12007+
as an argument to the function. Extracted key values can then be
12008+
referenced in other parts of the query, like <literal>WHERE</literal>
12009+
clauses and target lists. Extracting multiple values in this
12010+
way can improve performance over extracting them separately with
12011+
per-key operators.
12012+
</para>
12013+
12014+
<para>
12015+
JSON keys are matched to identical column names in the target
12016+
row type. JSON type coercion for these functions is <quote>best
12017+
effort</quote> and may not result in desired values for some types.
12018+
JSON fields that do not appear in the target row type will be
12019+
omitted from the output, and target columns that do not match any
12020+
JSON field will simply be NULL.
1200712021
</para>
1200812022
</note>
1200912023

0 commit comments

Comments
 (0)