@@ -54,6 +54,7 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> (
54
54
[ , ELEMENT = <replaceable class="parameter">element</replaceable> ]
55
55
[ , DELIMITER = <replaceable class="parameter">delimiter</replaceable> ]
56
56
[ , COLLATABLE = <replaceable class="parameter">collatable</replaceable> ]
57
+ [ , SUBSCRIPTION = <replaceable class="parameter">subscription_function</replaceable> ]
57
58
)
58
59
59
60
CREATE TYPE <replaceable class="parameter">name</replaceable>
@@ -194,7 +195,8 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
194
195
<replaceable class="parameter">send_function</replaceable>,
195
196
<replaceable class="parameter">type_modifier_input_function</replaceable>,
196
197
<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>
198
200
are optional. Generally these functions have to be coded in C
199
201
or another low-level language.
200
202
</para>
@@ -451,6 +453,22 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
451
453
make use of the collation information; this does not happen
452
454
automatically merely by marking the type collatable.
453
455
</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>
454
472
</refsect2>
455
473
456
474
<refsect2>
@@ -766,6 +784,16 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
766
784
</para>
767
785
</listitem>
768
786
</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>
769
797
</variablelist>
770
798
</refsect1>
771
799
0 commit comments