mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Support arrays of composite types, including the rowtypes of regular tables
and views (but not system catalogs, nor sequences or toast tables). Get rid of the hardwired convention that a type's array type is named exactly "_type", instead using a new column pg_type.typarray to provide the linkage. (It still will be named "_type", though, except in odd corner cases such as maximum-length type names.) Along the way, make tracking of owner and schema dependencies for types more uniform: a type directly created by the user has these dependencies, while a table rowtype or auto-generated array type does not have them, but depends on its parent object instead. David Fetter, Andrew Dunstan, Tom Lane
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.69 2007/04/02 03:49:37 tgl Exp $
|
||||
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.70 2007/05/11 17:57:11 tgl Exp $
|
||||
PostgreSQL documentation
|
||||
-->
|
||||
|
||||
@ -312,15 +312,17 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
|
||||
<title>Array Types</title>
|
||||
|
||||
<para>
|
||||
Whenever a user-defined base or enum data type is created,
|
||||
Whenever a user-defined type is created,
|
||||
<productname>PostgreSQL</productname> automatically creates an
|
||||
associated array type, whose name consists of the base type's
|
||||
name prepended with an underscore. The parser understands this
|
||||
naming convention, and translates requests for columns of type
|
||||
<literal>foo[]</> into requests for type <literal>_foo</>.
|
||||
The implicitly-created array type is variable length and uses the
|
||||
name prepended with an underscore, and truncated if necessary to keep
|
||||
it less than <symbol>NAMEDATALEN</symbol> bytes long. (If the name
|
||||
so generated collides with an existing type name, the process is
|
||||
repeated until a non-colliding name is found.)
|
||||
This implicitly-created array type is variable length and uses the
|
||||
built-in input and output functions <literal>array_in</> and
|
||||
<literal>array_out</>.
|
||||
<literal>array_out</>. The array type tracks any changes in its
|
||||
element type's owner or schema, and is dropped if the element type is.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@ -330,10 +332,9 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
|
||||
making a fixed-length type that happens to be internally an array of a number of
|
||||
identical things, and you want to allow these things to be accessed
|
||||
directly by subscripting, in addition to whatever operations you plan
|
||||
to provide for the type as a whole. For example, type <type>name</>
|
||||
allows its constituent <type>char</> elements to be accessed this way.
|
||||
A 2-D <type>point</> type could allow its two component numbers to be
|
||||
accessed like <literal>point[0]</> and <literal>point[1]</>.
|
||||
to provide for the type as a whole. For example, type <type>point</>
|
||||
is represented as just two floating-point numbers, which it allows to be
|
||||
accessed as <literal>point[0]</> and <literal>point[1]</>.
|
||||
Note that
|
||||
this facility only works for fixed-length types whose internal form
|
||||
is exactly a sequence of identical fixed-length fields. A subscriptable
|
||||
@ -529,12 +530,15 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
|
||||
<title>Notes</title>
|
||||
|
||||
<para>
|
||||
User-defined type names should not begin with the underscore character
|
||||
(<literal>_</literal>) and should only be 62 characters
|
||||
long (or in general <symbol>NAMEDATALEN</symbol> - 2, rather than
|
||||
the <symbol>NAMEDATALEN</symbol> - 1 characters allowed for other
|
||||
names). Type names beginning with underscore are reserved for
|
||||
internally-created array type names.
|
||||
It is best to avoid using type names that begin with the underscore
|
||||
character (<literal>_</literal>). <productname>PostgreSQL</productname>
|
||||
forms the name of an array type by prepending one or more underscores
|
||||
to the element type's name, and these names may collide with user-defined
|
||||
type names that begin with underscore. While the system will modify
|
||||
generated array type names to avoid collisions, this does not help if the
|
||||
conflicting array type already exists when you try to create your type.
|
||||
Also, various old client software may assume that names beginning with
|
||||
underscores always represent arrays.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
Reference in New Issue
Block a user