Commit 3d5ddc0b authored by Tom Lane's avatar Tom Lane

Clean up wrong, misleading, or obsolete documentation about array types,

particularly in the CREATE TYPE reference page.  Fix some other errors
in the CREATE TYPE page, too.
parent f008976b
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/array.sgml,v 1.12 2001/09/09 17:21:44 petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/array.sgml,v 1.13 2001/11/03 21:42:47 tgl Exp $ -->
<chapter id="arrays">
<title>Arrays</title>
......@@ -23,15 +23,15 @@ CREATE TABLE sal_emp (
<structname>sal_emp</structname> with a <type>text</type> string
(<structfield>name</structfield>), a one-dimensional array of type
<type>integer</type> (<structfield>pay_by_quarter</structfield>),
which shall represent the employee's salary by quarter, and a
which represents the employee's salary by quarter, and a
two-dimensional array of <type>text</type>
(<structfield>schedule</structfield>), which represents the
employee's weekly schedule.
</para>
<para>
Now we do some <command>INSERT</command>s; note that when appending
to an array, we enclose the values within braces and separate them
Now we do some <command>INSERT</command>s. Observe that to write an array
value, we enclose the element values within braces and separate them
by commas. If you know C, this is not unlike the syntax for
initializing structures.
......@@ -200,8 +200,7 @@ SELECT * FROM sal_emp WHERE pay_by_quarter[1] = 10000 OR
However, this quickly becomes tedious for large arrays, and is not
helpful if the size of the array is unknown. Although it is not part
of the primary <productname>PostgreSQL</productname> distribution,
in the contributions directory, there is an extension to
<productname>PostgreSQL</productname> that defines new functions and
there is an extension available that defines new functions and
operators for iterating over array values. Using this, the above
query could be:
......
<!--
Documentation of the system catalogs, directed toward PostgreSQL developers
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.26 2001/10/15 22:47:47 tgl Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.27 2001/11/03 21:42:47 tgl Exp $
-->
<chapter id="catalogs">
......@@ -420,7 +420,9 @@
<entry><type>int4</type></entry>
<entry></entry>
<entry>
Number of dimensions, if the column is an array; otherwise 0.
Number of dimensions, if the column is an array type; otherwise 0.
(Presently, the number of dimensions of an array is not enforced,
so any nonzero value effectively means <quote>it's an array</>.)
</entry>
</row>
......@@ -1064,7 +1066,7 @@
<entry><type>int2vector</type></entry>
<entry>pg_attribute.attnum</entry>
<entry>
This is an vector (array) of up to
This is a vector (array) of up to
<symbol>INDEX_MAX_KEYS</symbol> values that indicate which
table columns this index pertains to. For example a value of
<literal>1 3</literal> would mean that the first and the third
......@@ -2336,7 +2338,9 @@
<entry>typdelim</entry>
<entry><type>char</type></entry>
<entry></entry>
<entry>Character that separates two values of this type when parsing array input</entry>
<entry>Character that separates two values of this type when parsing
array input. Note that the delimiter is associated with the array
element datatype, not the array datatype.</entry>
</row>
<row>
......@@ -2360,14 +2364,17 @@
If <structfield>typelem</structfield> is not 0 then it
identifies another row in <structname>pg_type</structname>.
The current type can then be subscripted like an array yielding
values of type <structfield>typelem</structfield>. A non-zero
<structfield>typelem</structfield> does not guarantee this type
to be a <quote>real</quote> array type; some ordinary
fixed-length types can also be subscripted (e.g.,
<type>oidvector</type>). Variable-length types can
<emphasis>not</emphasis> be turned into pseudo-arrays like
that. Hence, the way to determine whether a type is a
<quote>true</quote> array type is typelem != 0 and typlen < 0.
values of type <structfield>typelem</structfield>. A
<quote>true</quote> array type is variable length
(<structfield>typlen</structfield> = -1),
but some fixed-length (<structfield>typlen</structfield> &gt; 0) types
also have nonzero <structfield>typelem</structfield>, for example
<type>name</type> and <type>oidvector</type>.
If a fixed-length type has a <structfield>typelem</structfield> then
its internal representation must be N values of the
<structfield>typelem</structfield> datatype with no other data.
Variable-length array types have a header defined by the array
subroutines.
</entry>
</row>
......
This diff is collapsed.
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_type.sgml,v 1.11 2001/09/13 19:05:29 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_type.sgml,v 1.12 2001/11/03 21:42:47 tgl Exp $
Postgres documentation
-->
......@@ -105,7 +105,9 @@ ERROR: RemoveType: type '<replaceable class="parameter">typename</replaceable>'
<para>
It is the user's responsibility to remove any operators,
functions, aggregates, access methods, subtypes, and tables that
use a deleted type.
use a deleted type. However, the associated array datatype
(which was automatically created by <command>CREATE TYPE</command>)
will be removed automatically.
</para>
</listitem>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment