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

Commitd7c8af3

Browse files
committed
Add sgml documentation for:
* jsonb* catalog* create type
1 parent0c346f1 commitd7c8af3

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

‎doc/src/sgml/catalogs.sgml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7055,6 +7055,13 @@
70557055
</para></entry>
70567056
</row>
70577057

7058+
<row>
7059+
<entry><structfield>typsubscription</structfield></entry>
7060+
<entry><type>regproc</type></entry>
7061+
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
7062+
<entry>Custom subscription function with type-specific logic, or 0 if this type doesn't support subscription.</entry>
7063+
</row>
7064+
70587065
<row>
70597066
<entry><structfield>typdefaultbin</structfield></entry>
70607067
<entry><type>pg_node_tree</type></entry>

‎doc/src/sgml/json.sgml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,4 +569,29 @@ SELECT jdoc-&gt;'guid', jdoc-&gt;'name' FROM api WHERE jdoc @&gt; '{"tags": ["qu
569569
compared using the default database collation.
570570
</para>
571571
</sect2>
572+
573+
<sect2 id="json-subscription">
574+
<title>JSON subscription</title>
575+
<para>
576+
JSONB data type support array-style subscription expressions to extract or update particular element. An example of subscription syntax:
577+
<programlisting>
578+
-- Extract value by key
579+
SELECT ('{"a": 1}'::jsonb)['a'];
580+
581+
-- Extract nested value by key path
582+
SELECT ('{"a": {"b": {"c": 1}}}'::jsonb)['a']['b']['c'];
583+
584+
-- Extract element by index
585+
SELECT ('[1, "2", null]'::jsonb)['1'];
586+
587+
-- Update value by key
588+
UPDATE table_name set jsonb_field['key'] = 1;
589+
590+
-- Select records using where clause with subscription
591+
SELECT * from table_name where jsonb_field['key'] = '"value"';
592+
</programlisting>
593+
</para>
594+
</sect2>
595+
596+
572597
</sect1>

‎doc/src/sgml/ref/create_type.sgml‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> (
5454
[ , ELEMENT = <replaceable class="parameter">element</replaceable> ]
5555
[ , DELIMITER = <replaceable class="parameter">delimiter</replaceable> ]
5656
[ , COLLATABLE = <replaceable class="parameter">collatable</replaceable> ]
57+
[ , SUBSCRIPTION = <replaceable class="parameter">subscription_function</replaceable> ]
5758
)
5859

5960
CREATE TYPE <replaceable class="parameter">name</replaceable>
@@ -194,7 +195,8 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
194195
<replaceable class="parameter">send_function</replaceable>,
195196
<replaceable class="parameter">type_modifier_input_function</replaceable>,
196197
<replaceable class="parameter">type_modifier_output_function</replaceable> and
197-
<replaceable class="parameter">analyze_function</replaceable>
198+
<replaceable class="parameter">analyze_function</replaceable>,
199+
<replaceable class="parameter">subscription_function</replaceable>
198200
are optional. Generally these functions have to be coded in C
199201
or another low-level language.
200202
</para>
@@ -451,6 +453,22 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
451453
make use of the collation information; this does not happen
452454
automatically merely by marking the type collatable.
453455
</para>
456+
457+
<para>
458+
The optional
459+
<replaceable class="parameter">subscription_function</replaceable>
460+
contains type-specific logic for subscription of the data type.
461+
By default, there is no such function, which means that the data
462+
type doesn't support subscription. The subscription function must be
463+
declared to take a single argument of type <type>internal</>, and return
464+
a <type>internal</> result. There are two examples of implementation for
465+
subscription function in case of array
466+
(<replaceable class="parameter">array_subscription</replaceable>)
467+
and jsonb
468+
(<replaceable class="parameter">jsonb_subscription</replaceable>)
469+
types in <filename>src/backend/utils/adt/arrayfuncs.c</> and
470+
<filename>src/backend/utils/adt/jsonfuncs.c</> corresponding.
471+
</para>
454472
</refsect2>
455473

456474
<refsect2>
@@ -766,6 +784,16 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
766784
</para>
767785
</listitem>
768786
</varlistentry>
787+
788+
<varlistentry>
789+
<term><replaceable class="parameter">subscription_function</replaceable></term>
790+
<listitem>
791+
<para>
792+
The name of a function that contains type-specific subscription logic for
793+
the data type.
794+
</para>
795+
</listitem>
796+
</varlistentry>
769797
</variablelist>
770798
</refsect1>
771799

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp