@@ -18005,8 +18005,8 @@ SELECT JSON_VALUE(jsonb '[1,2]', 'strict $[*]' DEFAULT 1 ON ERROR);
18005
18005
[ RETURNING <replaceable class="parameter">data_type</replaceable> [ FORMAT JSON [ ENCODING UTF8 ] ]
18006
18006
[ { WITHOUT | WITH { CONDITIONAL | [UNCONDITIONAL] } } [ ARRAY ] WRAPPER ]
18007
18007
[ { KEEP | OMIT } QUOTES [ ON SCALAR STRING ] ]
18008
- [ { ERROR | NULL | EMPTY { [ ARRAY ] | OBJECT } } ON EMPTY ]
18009
- [ { ERROR | NULL | EMPTY { [ ARRAY ] | OBJECT } } ON ERROR ]
18008
+ [ { ERROR | NULL | EMPTY { [ ARRAY ] | OBJECT } | DEFAULT <replaceable class="parameter">expression</replaceable> } ON EMPTY ]
18009
+ [ { ERROR | NULL | EMPTY { [ ARRAY ] | OBJECT } | DEFAULT <replaceable class="parameter">expression</replaceable> } ON ERROR ]
18010
18010
)
18011
18011
</synopsis>
18012
18012
</refsynopsisdiv>
@@ -18120,13 +18120,16 @@ SELECT JSON_VALUE(jsonb '[1,2]', 'strict $[*]' DEFAULT 1 ON ERROR);
18120
18120
18121
18121
<varlistentry>
18122
18122
<term>
18123
- <literal>{ ERROR | NULL | EMPTY { [ ARRAY ] | OBJECT } } ON EMPTY</literal>
18123
+ <literal>{ ERROR | NULL | EMPTY { [ ARRAY ] | OBJECT } | DEFAULT <replaceable class="parameter">expression</replaceable> } ON EMPTY</literal>
18124
18124
</term>
18125
18125
<listitem>
18126
18126
<para>
18127
18127
Defines the return value if no JSON value is found. The default is <literal>NULL</literal>.
18128
18128
If you use <literal>EMPTY [ARRAY]</literal> or <literal>EMPTY OBJECT</literal>,
18129
18129
an empty JSON array [] or object {} is returned, respectively.
18130
+ If you use <literal>DEFAULT <replaceable>expression</replaceable></literal>,
18131
+ the provided <replaceable>expression</replaceable> is evaluated and cast
18132
+ to the type specified in the <command>RETURNING</command> clause.
18130
18133
</para>
18131
18134
<para>
18132
18135
You cannot use this clause together with the <literal>WRAPPER</literal> clause.
@@ -18136,13 +18139,16 @@ SELECT JSON_VALUE(jsonb '[1,2]', 'strict $[*]' DEFAULT 1 ON ERROR);
18136
18139
18137
18140
<varlistentry>
18138
18141
<term>
18139
- <literal>{ ERROR | NULL | EMPTY { [ ARRAY ] | OBJECT } } ON ERROR</literal>
18142
+ <literal>{ ERROR | NULL | EMPTY { [ ARRAY ] | OBJECT } | DEFAULT <replaceable class="parameter">expression</replaceable> } ON ERROR</literal>
18140
18143
</term>
18141
18144
<listitem>
18142
18145
<para>
18143
18146
Defines the return value if an unhandled error occurs. The default is <literal>NULL</literal>.
18144
18147
If you use <literal>EMPTY [ARRAY]</literal> or <literal>EMPTY OBJECT</literal>,
18145
18148
an empty JSON array [] or object {} are returned, respectively.
18149
+ If you use <literal>DEFAULT <replaceable>expression</replaceable></literal>,
18150
+ the provided <replaceable>expression</replaceable> is evaluated and cast
18151
+ to the type specified in the <command>RETURNING</command> clause.
18146
18152
</para>
18147
18153
</listitem>
18148
18154
</varlistentry>
0 commit comments