summaryrefslogtreecommitdiff
path: root/doc/src/sgml
diff options
context:
space:
mode:
authorTom Lane2008-11-30 19:01:29 +0000
committerTom Lane2008-11-30 19:01:29 +0000
commit3f936aacc057e4b391ab953fea2ffb689a12a8bc (patch)
tree481da44f2f1755e0405174a25d0145f1c80ac6d9 /doc/src/sgml
parent0ddede58e6e7a39438b83469ec74928900767a86 (diff)
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.
Diffstat (limited to 'doc/src/sgml')
-rw-r--r--doc/src/sgml/ref/create_type.sgml34
1 files changed, 33 insertions, 1 deletions
diff --git a/doc/src/sgml/ref/create_type.sgml b/doc/src/sgml/ref/create_type.sgml
index 222d41d28bb..78b11b8a80e 100644
--- a/doc/src/sgml/ref/create_type.sgml
+++ b/doc/src/sgml/ref/create_type.sgml
@@ -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> ]
@@ -291,6 +292,21 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
</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
used to help control which implicit cast will be applied in ambiguous
@@ -525,6 +541,22 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
</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>
<para>