range type, as described in <xref linkend="rangetypes"/>.
</para>
<para>
The range type's <replaceable class="parameter">subtype</replaceable> can
be any type with an associated b-tree operator class (to determine the
ordering of values for the range type). Normally the subtype's default
b-tree operator class is used to determine ordering; to use a non-default
operator class, specify its name with <replaceable
class="parameter">subtype_opclass</replaceable>. If the subtype is
collatable, and you want to use a non-default collation in the range's
ordering, specify the desired collation with the <replaceable
class="parameter">collation</replaceable> option.
</para>
<para>
The optional <replaceable class="parameter">canonical</replaceable>
function must take one argument of the range type being defined, and
return a value of the same type. This is used to convert range values
to a canonical form, when applicable. See <xref
linkend="rangetypes-defining"/> for more information. Creating a
<replaceable class="parameter">canonical</replaceable> function
is a bit tricky, since it must be defined before the range type can be
declared. To do this, you must first create a shell type, which is a
placeholder type that has no properties except a name and an
owner. This is done by issuing the command <literal>CREATE TYPE
<replaceable>name</replaceable></literal>, with no additional parameters. Then
the function can be declared using the shell type as argument and result,
and finally the range type can be declared using the same name. This
automatically replaces the shell type entry with a valid range type.
</para>
<para>
The optional <replaceable class="parameter">subtype_diff</replaceable>
function must take two values of the
<replaceable class="parameter">subtype</replaceable> type as argument,
and return a <type>double precision</type> value representing the
difference between the two given values. While this is optional,
providing it allows much greater efficiency of GiST indexes on columns of
the range type. See <xref linkend="rangetypes-defining"/> for more
information.
</para>
<para>
The optional <replaceable class="parameter">multirange_type_name</replaceable>
parameter specifies the name of the corresponding multirange type. If not
specified, this name is chosen automatically as follows.
If the range type name contains the substring <literal>range</literal>, then
the multirange type name is formed by replacement of the <literal>range</literal>
substring with <literal>multirange</literal> in the range
type name. Otherwise, the multirange type name is formed by appending a
<literal>_multirange</literal> suffix to the range type name.
</para>
</refsect2>
<refsect2>
<title>Base Types</title>
<para>
The fourth form of <command>CREATE TYPE</command> creates a new base type
(scalar type). To create a new base type, you must be a superuser.
(This restriction is made because an erroneous type definition could
confuse or even crash the server.)
</para>
<para>
The parameters can appear in any order, not only that
illustrated above, and most are optional. You must register
two or more functions (using <command>CREATE FUNCTION</command>) before
defining the type. The support functions
<replaceable class="parameter">input_function</replaceable> and
<replaceable class="parameter">output_function</replaceable>
are required, while the functions
<replaceable class="parameter">receive_function</replaceable>,
<replaceable class="parameter">send_function</replaceable>,
<replaceable class="parameter">type_modifier_input_function</replaceable>,
<replaceable class="parameter">type_modifier_output_function</replaceable>,
<replaceable class="parameter">analyze_function</replaceable>, and
<replaceable