1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Add a "LIKE = typename" clause to CREATE TYPE for base types. This allows

the basic representational details (typlen, typalign, typbyval, typstorage)
to be copied from an existing type rather than listed explicitly in the
CREATE TYPE command.  The immediate reason for this is to provide a simple
solution for add-on modules that want to define types represented as int8,
float4, or float8: as of 8.4 the appropriate PASSEDBYVALUE setting is
platform-specific and so it's hard for a SQL script to know what to do.

This patch fixes the contrib/isn breakage reported by Rushabh Lathia.
This commit is contained in:
Tom Lane
2008-11-30 19:01:29 +00:00
parent 0ddede58e6
commit 3f936aacc0
3 changed files with 208 additions and 111 deletions

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.78 2008/11/14 10:22:46 petere Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.79 2008/11/30 19:01:29 tgl Exp $
PostgreSQL documentation
-->
@ -39,6 +39,7 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> (
[ , PASSEDBYVALUE ]
[ , ALIGNMENT = <replaceable class="parameter">alignment</replaceable> ]
[ , STORAGE = <replaceable class="parameter">storage</replaceable> ]
[ , LIKE = <replaceable class="parameter">like_type</replaceable> ]
[ , CATEGORY = <replaceable class="parameter">category</replaceable> ]
[ , PREFERRED = <replaceable class="parameter">preferred</replaceable> ]
[ , DEFAULT = <replaceable class="parameter">default</replaceable> ]
@ -290,6 +291,21 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
<literal>external</literal> items.)
</para>
<para>
The <replaceable class="parameter">like_type</replaceable> parameter
provides an alternative method for specifying the basic representation
properties of a data type: copy them from some existing type. The values of
<replaceable class="parameter">internallength</replaceable>,
<replaceable class="parameter">passedbyvalue</replaceable>,
<replaceable class="parameter">alignment</replaceable>, and
<replaceable class="parameter">storage</replaceable> are copied from the
named type. (It is possible, though usually undesirable, to override
some of these values by specifying them along with the <literal>LIKE</>
clause.) Specifying representation this way is especially useful when
the low-level implementation of the new type <quote>piggybacks</> on an
existing type in some fashion.
</para>
<para>
The <replaceable class="parameter">category</replaceable> and
<replaceable class="parameter">preferred</replaceable> parameters can be
@ -524,6 +540,22 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">like_type</replaceable></term>
<listitem>
<para>
The name of an existing data type that the new type will have the
same representation as. The values of
<replaceable class="parameter">internallength</replaceable>,
<replaceable class="parameter">passedbyvalue</replaceable>,
<replaceable class="parameter">alignment</replaceable>, and
<replaceable class="parameter">storage</replaceable>
are copied from that type, unless overridden by explicit
specification elsewhere in this <command>CREATE TYPE</> command.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">category</replaceable></term>
<listitem>