Home Explore Blog CI



postgresql

10th chunk of `doc/src/sgml/ref/create_type.sgml`
36c9b00b8b7426cf17d6544e79086ce8cc5c739d00f7c9640000000100000fa4
 <literal>point[1]</literal>.
    Note that
    this facility only works for fixed-length types whose internal form
    is exactly a sequence of identical fixed-length fields.
    For historical reasons (i.e., this is clearly wrong but it's far too
    late to change it), subscripting of fixed-length array types starts from
    zero, rather than from one as for variable-length arrays.
   </para>

   <para>
    Specifying the <option>SUBSCRIPT</option> option allows a data type to
    be subscripted, even though the system does not otherwise regard it as
    an array type.  The behavior just described for fixed-length arrays is
    actually implemented by the <option>SUBSCRIPT</option> handler
    function <function>raw_array_subscript_handler</function>, which is
    used automatically if you specify <option>ELEMENT</option> for a
    fixed-length type without also writing <option>SUBSCRIPT</option>.
   </para>

   <para>
    When specifying a custom <option>SUBSCRIPT</option> function, it is
    not necessary to specify <option>ELEMENT</option> unless
    the <option>SUBSCRIPT</option> handler function needs to
    consult <structfield>typelem</structfield> to find out what to return.
    Be aware that specifying <option>ELEMENT</option> causes the system to
    assume that the new type contains, or is somehow physically dependent on,
    the element type; thus for example changing properties of the element
    type won't be allowed if there are any columns of the dependent type.
   </para>
  </refsect2>
 </refsect1>

 <refsect1>
  <title>Parameters</title>

  <variablelist>
   <varlistentry>
    <term><replaceable class="parameter">name</replaceable></term>
    <listitem>
     <para>
      The name (optionally schema-qualified) of a type to be created.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">attribute_name</replaceable></term>
    <listitem>
     <para>
      The name of an attribute (column) for the composite type.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">data_type</replaceable></term>
    <listitem>
     <para>
      The name of an existing data type to become a column of the
      composite type.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">collation</replaceable></term>
    <listitem>
     <para>
      The name of an existing collation to be associated with a column of
      a composite type, or with a range type.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">label</replaceable></term>
    <listitem>
     <para>
      A string literal representing the textual label associated with
      one value of an enum type.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">subtype</replaceable></term>
    <listitem>
     <para>
      The name of the element type that the range type will represent ranges
      of.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">subtype_operator_class</replaceable></term>
    <listitem>
     <para>
      The name of a b-tree operator class for the subtype.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">canonical_function</replaceable></term>
    <listitem>
     <para>
      The name of the canonicalization function for the range type.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">subtype_diff_function</replaceable></term>
    <listitem>
     <para>
      The name of a difference function for the subtype.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">multirange_type_name</replaceable></term>
    <listitem>
     <para>
      The name of the corresponding

Title: CREATE TYPE - SUBSCRIPT Option and Parameters
Summary
This section discusses the SUBSCRIPT option in CREATE TYPE, explaining its role in allowing subscripting of data types even when they aren't arrays. It also details the circumstances under which ELEMENT is needed when specifying a custom SUBSCRIPT function. The section then transitions to defining the parameters used with the CREATE TYPE command, including name, attribute_name, data_type, collation, label, subtype, subtype_operator_class, canonical_function, subtype_diff_function and multirange_type_name.