Commit 027f144e authored by Peter Eisentraut's avatar Peter Eisentraut

Terminology cleanup: class -> table, instance -> row, attribute -> column,

etc.
parent 0651a579
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/admin.sgml,v 1.28 2000/11/24 17:44:21 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/admin.sgml,v 1.29 2001/01/13 23:58:55 petere Exp $
--> -->
<book id="admin"> <book id="admin">
...@@ -35,7 +35,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/admin.sgml,v 1.28 2000/11/24 17:44:21 ...@@ -35,7 +35,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/admin.sgml,v 1.28 2000/11/24 17:44:21
developed originally in the UC Berkeley Computer Science Department, developed originally in the UC Berkeley Computer Science Department,
pioneered many of the object-relational concepts pioneered many of the object-relational concepts
now becoming available in some commercial databases. now becoming available in some commercial databases.
It provides SQL92/SQL3 language support, It provides SQL92/SQL99 language support,
transaction integrity, and type extensibility. transaction integrity, and type extensibility.
<productname>PostgreSQL</productname> is an open-source descendant <productname>PostgreSQL</productname> is an open-source descendant
of this original Berkeley code. of this original Berkeley code.
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.20 2001/01/05 06:34:15 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.21 2001/01/13 23:58:55 petere Exp $
--> -->
<chapter id="advanced"> <chapter id="advanced">
...@@ -22,14 +22,14 @@ $Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.20 2001/01/05 06:34:15 tg ...@@ -22,14 +22,14 @@ $Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.20 2001/01/05 06:34:15 tg
<title>Inheritance</title> <title>Inheritance</title>
<para> <para>
Let's create two classes. The capitals class contains Let's create two tables. The capitals table contains
state capitals that are also cities. Naturally, the state capitals that are also cities. Naturally, the
capitals class should inherit from cities. capitals table should inherit from cities.
<programlisting> <programlisting>
CREATE TABLE cities ( CREATE TABLE cities (
name text, name text,
population float, population real,
altitude int -- (in ft) altitude int -- (in ft)
); );
...@@ -38,20 +38,19 @@ CREATE TABLE capitals ( ...@@ -38,20 +38,19 @@ CREATE TABLE capitals (
) INHERITS (cities); ) INHERITS (cities);
</programlisting> </programlisting>
In this case, an instance of capitals <firstterm>inherits</firstterm> all In this case, a row of capitals <firstterm>inherits</firstterm> all
attributes (name, population, and altitude) from its columns (name, population, and altitude) from its
parent, cities. The type of the attribute name is parent, cities. The type of the column name is
<type>text</type>, a native <productname>Postgres</productname> <type>text</type>, a native <productname>Postgres</productname>
type for variable length type for variable length
ASCII strings. The type of the attribute population is ASCII strings. The type of the column population is
<type>float</type>, a native <productname>Postgres</productname> <type>real</type>, a type for single precision
type for double precision
floating point numbers. State capitals have an extra floating point numbers. State capitals have an extra
attribute, state, that shows their state. column, state, that shows their state.
In <productname>Postgres</productname>, In <productname>Postgres</productname>,
a class can inherit from zero or more other classes, a table can inherit from zero or more other tables,
and a query can reference either all instances of a and a query can reference either all rows of a
class or all instances of a class plus all of its table or all rows of a tables plus all of its
descendants. descendants.
<note> <note>
...@@ -109,7 +108,7 @@ SELECT name, altitude ...@@ -109,7 +108,7 @@ SELECT name, altitude
<para> <para>
Here the <quote>ONLY</quote> before cities indicates that the query should Here the <quote>ONLY</quote> before cities indicates that the query should
be run over only the cities table, and not classes below cities in the be run over only the cities table, and not tables below cities in the
inheritance hierarchy. Many of the commands that we inheritance hierarchy. Many of the commands that we
have already discussed -- <command>SELECT</command>, have already discussed -- <command>SELECT</command>,
<command>UPDATE</command> and <command>DELETE</command> -- <command>UPDATE</command> and <command>DELETE</command> --
...@@ -122,7 +121,7 @@ SELECT name, altitude ...@@ -122,7 +121,7 @@ SELECT name, altitude
In previous versions of <productname>Postgres</productname>, the In previous versions of <productname>Postgres</productname>, the
default was not to get access to child tables. This was found to default was not to get access to child tables. This was found to
be error prone and is also in violation of SQL99. Under the old be error prone and is also in violation of SQL99. Under the old
syntax, to get the sub-classes you append "*" to the table name. syntax, to get the sub-tables you append "*" to the table name.
For example For example
<programlisting> <programlisting>
SELECT * from cities*; SELECT * from cities*;
...@@ -147,11 +146,11 @@ SET SQL_Inheritance TO OFF; ...@@ -147,11 +146,11 @@ SET SQL_Inheritance TO OFF;
<para> <para>
One of the tenets of the relational model is that the One of the tenets of the relational model is that the
attributes of a relation are atomic. columns of a table are atomic.
<productname>Postgres</productname> does not <productname>Postgres</productname> does not
have this restriction; attributes can themselves contain have this restriction; columns can themselves contain
sub-values that can be accessed from the query sub-values that can be accessed from the query
language. For example, you can create attributes that language. For example, you can create columns that
are arrays of base types. are arrays of base types.
</para> </para>
...@@ -159,26 +158,26 @@ SET SQL_Inheritance TO OFF; ...@@ -159,26 +158,26 @@ SET SQL_Inheritance TO OFF;
<title>Arrays</title> <title>Arrays</title>
<para> <para>
<productname>Postgres</productname> allows attributes of an <productname>Postgres</productname> allows columns of a
instance to be defined row to be defined
as fixed-length or variable-length multi-dimensional as fixed-length or variable-length multi-dimensional
arrays. Arrays of any base type or user-defined type arrays. Arrays of any base type or user-defined type
can be created. To illustrate their use, we first create a can be created. To illustrate their use, we first create a
class with arrays of base types. table with arrays of base types.
<programlisting> <programlisting>
CREATE TABLE SAL_EMP ( CREATE TABLE SAL_EMP (
name text, name text,
pay_by_quarter int4[], pay_by_quarter integer[],
schedule text[][] schedule text[][]
); );
</programlisting> </programlisting>
</para> </para>
<para> <para>
The above query will create a class named SAL_EMP with The above query will create a table named SAL_EMP with
a <firstterm>text</firstterm> string (name), a one-dimensional a <firstterm>text</firstterm> string (name), a one-dimensional
array of <firstterm>int4</firstterm> array of <firstterm>integer</firstterm>
(pay_by_quarter), which represents the employee's (pay_by_quarter), which represents the employee's
salary by quarter and a two-dimensional array of salary by quarter and a two-dimensional array of
<firstterm>text</firstterm> <firstterm>text</firstterm>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/array.sgml,v 1.8 2000/12/18 23:39:37 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/array.sgml,v 1.9 2001/01/13 23:58:55 petere Exp $
--> -->
<Chapter Id="arrays"> <Chapter Id="arrays">
...@@ -14,10 +14,10 @@ This must become a chapter on array behavior. Volunteers? - thomas 1998-01-12 ...@@ -14,10 +14,10 @@ This must become a chapter on array behavior. Volunteers? - thomas 1998-01-12
</Para> </Para>
<Para> <Para>
<ProductName>Postgres</ProductName> allows attributes of a class <ProductName>Postgres</ProductName> allows columns of a table
to be defined as variable-length multi-dimensional to be defined as variable-length multi-dimensional
arrays. Arrays of any built-in type or user-defined type arrays. Arrays of any built-in type or user-defined type
can be created. To illustrate their use, we create this class: can be created. To illustrate their use, we create this table:
<ProgramListing> <ProgramListing>
CREATE TABLE sal_emp ( CREATE TABLE sal_emp (
...@@ -29,7 +29,7 @@ CREATE TABLE sal_emp ( ...@@ -29,7 +29,7 @@ CREATE TABLE sal_emp (
</Para> </Para>
<Para> <Para>
The above query will create a class named <FirstTerm>sal_emp</FirstTerm> with The above query will create a table named <FirstTerm>sal_emp</FirstTerm> with
a <FirstTerm>text</FirstTerm> string (name), a one-dimensional array of <FirstTerm>int4</FirstTerm> a <FirstTerm>text</FirstTerm> string (name), a one-dimensional array of <FirstTerm>int4</FirstTerm>
(pay_by_quarter), which represents the employee's (pay_by_quarter), which represents the employee's
salary by quarter, and a two-dimensional array of <FirstTerm>text</FirstTerm> salary by quarter, and a two-dimensional array of <FirstTerm>text</FirstTerm>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.9 2001/01/13 23:58:55 petere Exp $
--> -->
<chapter id="extend"> <chapter id="extend">
...@@ -44,15 +44,15 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter ...@@ -44,15 +44,15 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter
about databases, tables, columns, etc., in what are about databases, tables, columns, etc., in what are
commonly known as system catalogs. (Some systems call commonly known as system catalogs. (Some systems call
this the data dictionary). The catalogs appear to the this the data dictionary). The catalogs appear to the
user as classes, like any other, but the <acronym>DBMS</acronym> stores user as tables like any other, but the <acronym>DBMS</acronym> stores
its internal bookkeeping in them. One key difference its internal bookkeeping in them. One key difference
between <productname>Postgres</productname> and standard relational systems is between <productname>Postgres</productname> and standard relational systems is
that <productname>Postgres</productname> stores much more information in its that <productname>Postgres</productname> stores much more information in its
catalogs -- not only information about tables and columns, catalogs -- not only information about tables and columns,
but also information about its types, functions, access but also information about its types, functions, access
methods, and so on. These classes can be modified by methods, and so on. These tables can be modified by
the user, and since <productname>Postgres</productname> bases its internal operation the user, and since <productname>Postgres</productname> bases its internal operation
on these classes, this means that <productname>Postgres</productname> can be on these tables, this means that <productname>Postgres</productname> can be
extended by users. By comparison, conventional extended by users. By comparison, conventional
database systems can only be extended by changing hardcoded database systems can only be extended by changing hardcoded
procedures within the <acronym>DBMS</acronym> or by loading modules procedures within the <acronym>DBMS</acronym> or by loading modules
...@@ -87,13 +87,13 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter ...@@ -87,13 +87,13 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter
by the user and only understands the behavior of such by the user and only understands the behavior of such
types to the extent that the user describes them. types to the extent that the user describes them.
Composite types are created whenever the user creates a Composite types are created whenever the user creates a
class. EMP is an example of a composite type. table. EMP is an example of a composite type.
</para> </para>
<para> <para>
<productname>Postgres</productname> stores these types <productname>Postgres</productname> stores these types
in only one way (within the in only one way (within the
file that stores all instances of the class) but the file that stores all rows of a table) but the
user can "look inside" at the attributes of these types user can "look inside" at the attributes of these types
from the query language and optimize their retrieval by from the query language and optimize their retrieval by
(for example) defining indices on the attributes. (for example) defining indices on the attributes.
...@@ -119,7 +119,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter ...@@ -119,7 +119,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter
reference. reference.
All system catalogs have names that begin with All system catalogs have names that begin with
<firstterm>pg_</firstterm>. <firstterm>pg_</firstterm>.
The following classes contain information that may be The following tables contain information that may be
useful to the end user. (There are many other system useful to the end user. (There are many other system
catalogs, but there should rarely be a reason to query catalogs, but there should rarely be a reason to query
them directly.) them directly.)
...@@ -141,11 +141,11 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter ...@@ -141,11 +141,11 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter
</row> </row>
<row> <row>
<entry>pg_class</entry> <entry>pg_class</entry>
<entry> classes</entry> <entry> tables</entry>
</row> </row>
<row> <row>
<entry>pg_attribute</entry> <entry>pg_attribute</entry>
<entry> class attributes</entry> <entry> table columns</entry>
</row> </row>
<row> <row>
<entry>pg_index</entry> <entry>pg_index</entry>
...@@ -195,10 +195,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter ...@@ -195,10 +195,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter
</figure> </figure>
The Reference Manual gives a more detailed explanation The Reference Manual gives a more detailed explanation
of these catalogs and their attributes. However, of these catalogs and their columns. However,
<xref linkend="EXTEND-CATALOGS"> <xref linkend="EXTEND-CATALOGS">
shows the major entities and their relationships shows the major entities and their relationships
in the system catalogs. (Attributes that do not refer in the system catalogs. (Columns that do not refer
to other entities are not shown unless they are part of to other entities are not shown unless they are part of
a primary key.) a primary key.)
This diagram is more or less incomprehensible until you This diagram is more or less incomprehensible until you
...@@ -216,13 +216,13 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter ...@@ -216,13 +216,13 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter
some of these join queries (which are often some of these join queries (which are often
three- or four-way joins) more understandable, three- or four-way joins) more understandable,
because you will be able to see that the because you will be able to see that the
attributes used in the queries form foreign keys columns used in the queries form foreign keys
in other classes. in other tables.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
Many different features (classes, attributes, Many different features (tables, columns,
functions, types, access methods, etc.) are functions, types, access methods, etc.) are
tightly integrated in this schema. A simple tightly integrated in this schema. A simple
create command may modify many of these catalogs. create command may modify many of these catalogs.
...@@ -241,15 +241,15 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter ...@@ -241,15 +241,15 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.8 2000/12/26 00:10:37 peter
</note> </note>
Nearly every catalog contains some reference to Nearly every catalog contains some reference to
instances in one or both of these classes. For rows in one or both of these tables. For
example, <productname>Postgres</productname> frequently uses type example, <productname>Postgres</productname> frequently uses type
signatures (e.g., of functions and operators) to signatures (e.g., of functions and operators) to
identify unique instances of other catalogs. identify unique rows of other catalogs.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
There are many attributes and relationships that There are many columns and relationships that
have obvious meanings, but there are many have obvious meanings, but there are many
(particularly those that have to do with access (particularly those that have to do with access
methods) that do not. The relationships between methods) that do not. The relationships between
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<para> <para>
For a <firstterm>functional index</firstterm>, an index is defined For a <firstterm>functional index</firstterm>, an index is defined
on the result of a function applied on the result of a function applied
to one or more attributes of a single class. to one or more columns of a single table.
This is a single-column index (namely, the function result) This is a single-column index (namely, the function result)
even if the function uses more than one input field. even if the function uses more than one input field.
Functional indices can be used to obtain fast access to data Functional indices can be used to obtain fast access to data
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/inherit.sgml,v 1.12 2001/01/05 06:34:15 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/inherit.sgml,v 1.13 2001/01/13 23:58:55 petere Exp $
--> -->
<chapter id="inherit"> <chapter id="inherit">
<title>Inheritance</title> <title>Inheritance</title>
<para> <para>
Let's create two classes. The capitals class contains Let's create two tables. The capitals table contains
state capitals which are also cities. Naturally, the state capitals which are also cities. Naturally, the
capitals class should inherit from cities. capitals table should inherit from cities.
<programlisting> <programlisting>
CREATE TABLE cities ( CREATE TABLE cities (
...@@ -22,7 +22,7 @@ CREATE TABLE capitals ( ...@@ -22,7 +22,7 @@ CREATE TABLE capitals (
) INHERITS (cities); ) INHERITS (cities);
</programlisting> </programlisting>
In this case, an instance of capitals <firstterm>inherits</firstterm> all In this case, a row of capitals <firstterm>inherits</firstterm> all
attributes (name, population, and altitude) from its attributes (name, population, and altitude) from its
parent, cities. The type of the attribute name is parent, cities. The type of the attribute name is
<type>text</type>, a native <productname>Postgres</productname> type for variable length <type>text</type>, a native <productname>Postgres</productname> type for variable length
...@@ -30,9 +30,9 @@ CREATE TABLE capitals ( ...@@ -30,9 +30,9 @@ CREATE TABLE capitals (
<type>float</type>, a native <productname>Postgres</productname> type for double precision <type>float</type>, a native <productname>Postgres</productname> type for double precision
floating point numbers. State capitals have an extra floating point numbers. State capitals have an extra
attribute, state, that shows their state. In <productname>Postgres</productname>, attribute, state, that shows their state. In <productname>Postgres</productname>,
a class can inherit from zero or more other classes, a table can inherit from zero or more other tables,
and a query can reference either all instances of a and a query can reference either all rows of a
class or all instances of a class plus all of its table or all rows of a table plus all of its
descendants. descendants.
<note> <note>
...@@ -90,7 +90,7 @@ SELECT name, altitude ...@@ -90,7 +90,7 @@ SELECT name, altitude
<para> <para>
Here the <quote>ONLY</quote> before cities indicates that the query should Here the <quote>ONLY</quote> before cities indicates that the query should
be run over only cities and not classes below cities in the be run over only cities and not tables below cities in the
inheritance hierarchy. Many of the commands that we inheritance hierarchy. Many of the commands that we
have already discussed -- <command>SELECT</command>, have already discussed -- <command>SELECT</command>,
<command>UPDATE</command> and <command>DELETE</command> -- <command>UPDATE</command> and <command>DELETE</command> --
...@@ -99,7 +99,7 @@ SELECT name, altitude ...@@ -99,7 +99,7 @@ SELECT name, altitude
<para> <para>
In some cases you may wish to know which table a particular tuple In some cases you may wish to know which table a particular tuple
originated from. There is a system attribute called originated from. There is a system column called
<quote>TABLEOID</quote> in each table which can tell you the <quote>TABLEOID</quote> in each table which can tell you the
originating table: originating table:
...@@ -153,7 +153,7 @@ SELECT name, altitude ...@@ -153,7 +153,7 @@ SELECT name, altitude
In previous versions of <productname>Postgres</productname>, the In previous versions of <productname>Postgres</productname>, the
default was not to get access to child tables. This was found to default was not to get access to child tables. This was found to
be error prone and is also in violation of SQL99. Under the old be error prone and is also in violation of SQL99. Under the old
syntax, to get the sub-classes you append "*" to the table name. syntax, to get the sub-tables you append "*" to the table name.
For example For example
<programlisting> <programlisting>
SELECT * from cities*; SELECT * from cities*;
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.12 2000/09/29 20:21:34 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.13 2001/01/13 23:58:55 petere Exp $
--> -->
<chapter id="intro"> <chapter id="intro">
...@@ -44,7 +44,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.12 2000/09/29 20:21:34 peter ...@@ -44,7 +44,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/intro.sgml,v 1.12 2000/09/29 20:21:34 peter
extend the system: extend the system:
<simplelist> <simplelist>
<member>classes</member> <member>tables</member>
<member>inheritance</member> <member>inheritance</member>
<member>types</member> <member>types</member>
<member>functions</member> <member>functions</member>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpq++.sgml,v 1.22 2000/12/26 00:10:37 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpq++.sgml,v 1.23 2001/01/13 23:58:55 petere Exp $
--> -->
<chapter id="libpqplusplus"> <chapter id="libpqplusplus">
...@@ -353,7 +353,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpq++.sgml,v 1.22 2000/12/26 00:10: ...@@ -353,7 +353,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/libpq++.sgml,v 1.22 2000/12/26 00:10:
<listitem> <listitem>
<para> <para>
<function>Tuples</function> <function>Tuples</function>
Returns the number of tuples (instances) in the query result. Returns the number of tuples (rows) in the query result.
<synopsis> <synopsis>
int PgDatabase::Tuples() int PgDatabase::Tuples()
</synopsis> </synopsis>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.54 2000/12/28 00:16:11 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.55 2001/01/13 23:58:55 petere Exp $
--> -->
<chapter id="libpq-chapter"> <chapter id="libpq-chapter">
...@@ -810,7 +810,7 @@ when you want to know the status from the latest operation on the connection. ...@@ -810,7 +810,7 @@ when you want to know the status from the latest operation on the connection.
<listitem> <listitem>
<para> <para>
<function>PQntuples</function> <function>PQntuples</function>
Returns the number of tuples (instances) Returns the number of tuples (rows)
in the query result. in the query result.
<synopsis> <synopsis>
int PQntuples(const PGresult *res); int PQntuples(const PGresult *res);
...@@ -2042,7 +2042,7 @@ main() ...@@ -2042,7 +2042,7 @@ main()
PQclear(res); PQclear(res);
/* /*
* fetch instances from the pg_database, the system catalog of * fetch rows from the pg_database, the system catalog of
* databases * databases
*/ */
res = PQexec(conn, "DECLARE mycursor CURSOR FOR select * from pg_database"); res = PQexec(conn, "DECLARE mycursor CURSOR FOR select * from pg_database");
...@@ -2067,7 +2067,7 @@ main() ...@@ -2067,7 +2067,7 @@ main()
printf("%-15s", PQfname(res, i)); printf("%-15s", PQfname(res, i));
printf("\n\n"); printf("\n\n");
/* next, print out the instances */ /* next, print out the rows */
for (i = 0; i &lt; PQntuples(res); i++) for (i = 0; i &lt; PQntuples(res); i++)
{ {
for (j = 0; j &lt; nFields; j++) for (j = 0; j &lt; nFields; j++)
...@@ -2315,7 +2315,7 @@ main() ...@@ -2315,7 +2315,7 @@ main()
PQclear(res); PQclear(res);
/* /*
* fetch instances from the pg_database, the system catalog of * fetch rows from the pg_database, the system catalog of
* databases * databases
*/ */
res = PQexec(conn, "DECLARE mycursor BINARY CURSOR FOR select * from test1"); res = PQexec(conn, "DECLARE mycursor BINARY CURSOR FOR select * from test1");
......
...@@ -10,7 +10,7 @@ A description of the database file default page format. ...@@ -10,7 +10,7 @@ A description of the database file default page format.
<para> <para>
This section provides an overview of the page format used by <productname>Postgres</productname> This section provides an overview of the page format used by <productname>Postgres</productname>
classes. User-defined access methods need not use this page format. tables. User-defined access methods need not use this page format.
</para> </para>
<para> <para>
...@@ -18,13 +18,13 @@ In the following explanation, a ...@@ -18,13 +18,13 @@ In the following explanation, a
<firstterm>byte</firstterm> <firstterm>byte</firstterm>
is assumed to contain 8 bits. In addition, the term is assumed to contain 8 bits. In addition, the term
<firstterm>item</firstterm> <firstterm>item</firstterm>
refers to data that is stored in <productname>Postgres</productname> classes. refers to data that is stored in <productname>Postgres</productname> tables.
</para> </para>
<para> <para>
The following table shows how pages in both normal <productname>Postgres</productname> classes The following table shows how pages in both normal <productname>Postgres</productname> tables
and <productname>Postgres</productname> index and <productname>Postgres</productname> indices
classes (e.g., a B-tree index) are structured. (e.g., a B-tree index) are structured.
<table tocentry="1"> <table tocentry="1">
<title>Sample Page Layout</title> <title>Sample Page Layout</title>
...@@ -141,7 +141,7 @@ access method. The last 2 bytes of the page header, ...@@ -141,7 +141,7 @@ access method. The last 2 bytes of the page header,
encode the page size and information on the internal fragmentation of encode the page size and information on the internal fragmentation of
the page. Page size is stored in each page because frames in the the page. Page size is stored in each page because frames in the
buffer pool may be subdivided into equal sized pages on a frame by buffer pool may be subdivided into equal sized pages on a frame by
frame basis within a class. The internal fragmentation information is frame basis within a table. The internal fragmentation information is
used to aid in determining when page reorganization should occur. used to aid in determining when page reorganization should occur.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/plsql.sgml,v 2.13 2001/01/09 15:26:16 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/plsql.sgml,v 2.14 2001/01/13 23:58:55 petere Exp $
--> -->
<chapter id="plsql"> <chapter id="plsql">
...@@ -181,12 +181,12 @@ END; ...@@ -181,12 +181,12 @@ END;
<varlistentry> <varlistentry>
<term> <term>
<replaceable>name</replaceable> <replaceable>class</replaceable>%ROWTYPE; <replaceable>name</replaceable> <replaceable>table</replaceable>%ROWTYPE;
</term> </term>
<listitem> <listitem>
<para> <para>
Declares a row with the structure of the given class. Class must be Declares a row with the structure of the given table. <replaceable>table</replaceable> must be
an existing table- or view name of the database. The fields of the row an existing table or view name of the database. The fields of the row
are accessed in the dot notation. Parameters to a function can are accessed in the dot notation. Parameters to a function can
be composite types (complete table rows). In that case, the be composite types (complete table rows). In that case, the
corresponding identifier $n will be a rowtype, but it corresponding identifier $n will be a rowtype, but it
...@@ -281,7 +281,7 @@ RENAME <replaceable>oldname</replaceable> TO <replaceable>newname</replaceable>; ...@@ -281,7 +281,7 @@ RENAME <replaceable>oldname</replaceable> TO <replaceable>newname</replaceable>;
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
<replaceable>class.field</replaceable>%TYPE <replaceable>table.field</replaceable>%TYPE
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
...@@ -292,12 +292,12 @@ RENAME <replaceable>oldname</replaceable> TO <replaceable>newname</replaceable>; ...@@ -292,12 +292,12 @@ RENAME <replaceable>oldname</replaceable> TO <replaceable>newname</replaceable>;
same function, that is visible at this point. same function, that is visible at this point.
</para> </para>
<para> <para>
<replaceable>class</replaceable> is the name of an existing table <replaceable>table</replaceable> is the name of an existing table
or view where <replaceable>field</replaceable> is the name of or view where <replaceable>field</replaceable> is the name of
an attribute. an attribute.
</para> </para>
<para> <para>
Using the <replaceable>class.field</replaceable>%TYPE Using the <replaceable>table.field</replaceable>%TYPE
causes PL/pgSQL to look up the attributes definitions at the causes PL/pgSQL to look up the attributes definitions at the
first call to the function during the lifetime of a backend. first call to the function during the lifetime of a backend.
Have a table with a char(20) attribute and some PL/pgSQL functions Have a table with a char(20) attribute and some PL/pgSQL functions
...@@ -307,7 +307,7 @@ RENAME <replaceable>oldname</replaceable> TO <replaceable>newname</replaceable>; ...@@ -307,7 +307,7 @@ RENAME <replaceable>oldname</replaceable> TO <replaceable>newname</replaceable>;
char(40) and restores the data. Ha - he forgot about the char(40) and restores the data. Ha - he forgot about the
functions. The computations inside them will truncate the values functions. The computations inside them will truncate the values
to 20 characters. But if they are defined using the to 20 characters. But if they are defined using the
<replaceable>class.field</replaceable>%TYPE <replaceable>table.field</replaceable>%TYPE
declarations, they will automagically handle the size change or declarations, they will automagically handle the size change or
if the new table schema defines the attribute as text type. if the new table schema defines the attribute as text type.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/programmer.sgml,v 1.30 2001/01/12 22:15:32 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/programmer.sgml,v 1.31 2001/01/13 23:58:55 petere Exp $
PostgreSQL Programmer's Guide. PostgreSQL Programmer's Guide.
--> -->
...@@ -35,7 +35,7 @@ PostgreSQL Programmer's Guide. ...@@ -35,7 +35,7 @@ PostgreSQL Programmer's Guide.
developed originally in the UC Berkeley Computer Science Department, developed originally in the UC Berkeley Computer Science Department,
pioneered many of the object-relational concepts pioneered many of the object-relational concepts
now becoming available in some commercial databases. now becoming available in some commercial databases.
It provides SQL92/SQL3 language support, It provides SQL92/SQL99 language support,
transaction integrity, and type extensibility. transaction integrity, and type extensibility.
<productname>PostgreSQL</productname> is an <productname>PostgreSQL</productname> is an
open-source descendant of this original Berkeley code. open-source descendant of this original Berkeley code.
......
This diff is collapsed.
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.18 2001/01/05 06:34:16 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.19 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -209,7 +209,7 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable> ...@@ -209,7 +209,7 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
</para> </para>
<para> <para>
You must own the class in order to change its schema. You must own the table in order to change it.
Renaming any part of the schema of a system Renaming any part of the schema of a system
catalog is not permitted. catalog is not permitted.
The <citetitle>PostgreSQL User's Guide</citetitle> has further The <citetitle>PostgreSQL User's Guide</citetitle> has further
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/cluster.sgml,v 1.9 2000/07/22 04:30:26 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/cluster.sgml,v 1.10 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -23,7 +23,7 @@ Postgres documentation ...@@ -23,7 +23,7 @@ Postgres documentation
<date>1999-07-20</date> <date>1999-07-20</date>
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
CLUSTER <replaceable class="PARAMETER">indexname</replaceable> ON <replaceable class="PARAMETER">table</replaceable> CLUSTER <replaceable class="PARAMETER">indexname</replaceable> ON <replaceable class="PARAMETER">tablename</replaceable>
</synopsis> </synopsis>
<refsect2 id="R2-SQL-CLUSTER-1"> <refsect2 id="R2-SQL-CLUSTER-1">
...@@ -115,18 +115,18 @@ ERROR: Relation <replaceable class="PARAMETER">table</replaceable> does not exis ...@@ -115,18 +115,18 @@ ERROR: Relation <replaceable class="PARAMETER">table</replaceable> does not exis
</title> </title>
<para> <para>
<command>CLUSTER</command> instructs <productname>Postgres</productname> <command>CLUSTER</command> instructs <productname>Postgres</productname>
to cluster the class specified to cluster the table specified
by <replaceable class="parameter">table</replaceable> approximately by <replaceable class="parameter">table</replaceable> approximately
based on the index specified by based on the index specified by
<replaceable class="parameter">indexname</replaceable>. The index must <replaceable class="parameter">indexname</replaceable>. The index must
already have been defined on already have been defined on
<replaceable class="parameter">classname</replaceable>. <replaceable class="parameter">tablename</replaceable>.
</para> </para>
<para> <para>
When a class is clustered, it is physically reordered When a table is clustered, it is physically reordered
based on the index information. The clustering is static. based on the index information. The clustering is static.
In other words, as the class is updated, the changes are In other words, as the table is updated, the changes are
not clustered. No attempt is made to keep new instances or not clustered. No attempt is made to keep new instances or
updated tuples clustered. If one wishes, one can updated tuples clustered. If one wishes, one can
re-cluster manually by issuing the command again. re-cluster manually by issuing the command again.
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/copy.sgml,v 1.19 2001/01/03 20:04:09 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/copy.sgml,v 1.20 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -590,9 +590,9 @@ ZW ZIMBABWE ...@@ -590,9 +590,9 @@ ZW ZIMBABWE
The following is the same data, output in binary format on a Linux/i586 The following is the same data, output in binary format on a Linux/i586
machine. The data is shown after filtering through machine. The data is shown after filtering through
the Unix utility <command>od -c</command>. The table has the Unix utility <command>od -c</command>. The table has
three fields; the first is <classname>char(2)</classname>, three fields; the first is <type>char(2)</type>,
the second is <classname>text</classname>, and the third is the second is <type>text</type>, and the third is
<classname>int4</classname>. All the <type>integer</type>. All the
rows have a null value in the third field. rows have a null value in the third field.
</para> </para>
<programlisting> <programlisting>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_index.sgml,v 1.17 2000/12/25 23:15:26 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_index.sgml,v 1.18 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -208,7 +208,7 @@ ERROR: Cannot create index: 'index_name' already exists. ...@@ -208,7 +208,7 @@ ERROR: Cannot create index: 'index_name' already exists.
In the second syntax shown above, an index is defined In the second syntax shown above, an index is defined
on the result of a user-specified function on the result of a user-specified function
<replaceable class="parameter">func_name</replaceable> applied <replaceable class="parameter">func_name</replaceable> applied
to one or more attributes of a single class. to one or more columns of a single table.
These <firstterm>functional indices</firstterm> These <firstterm>functional indices</firstterm>
can be used to obtain fast access to data can be used to obtain fast access to data
based on operators that would normally require some based on operators that would normally require some
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_operator.sgml,v 1.17 2000/10/10 04:42:43 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_operator.sgml,v 1.18 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -350,7 +350,7 @@ MYBOXES.description &lt;&lt;&lt; box '((0,0), (1,1))' ...@@ -350,7 +350,7 @@ MYBOXES.description &lt;&lt;&lt; box '((0,0), (1,1))'
instance variables, the query optimizer must estimate the instance variables, the query optimizer must estimate the
size of the resulting join. The function join_proc will size of the resulting join. The function join_proc will
return another floating point number which will be multiplied return another floating point number which will be multiplied
by the cardinalities of the two classes involved to by the cardinalities of the two tables involved to
compute the expected result size. compute the expected result size.
</para> </para>
<para> <para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_rule.sgml,v 1.21 2001/01/06 04:14:35 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_rule.sgml,v 1.22 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -213,7 +213,7 @@ CREATE ...@@ -213,7 +213,7 @@ CREATE
</para> </para>
<para> <para>
You must have rule definition access to a class in order You must have rule definition access to a table in order
to define a rule on it. Use <command>GRANT</command> to define a rule on it. Use <command>GRANT</command>
and <command>REVOKE</command> to change permissions. and <command>REVOKE</command> to change permissions.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v 1.15 2000/10/05 19:48:18 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v 1.16 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -336,7 +336,7 @@ CREATE ...@@ -336,7 +336,7 @@ CREATE
<title>Examples</title> <title>Examples</title>
<para> <para>
This command creates the box data type and then uses the This command creates the box data type and then uses the
type in a class definition: type in a table definition:
<programlisting> <programlisting>
CREATE TYPE box (INTERNALLENGTH = 8, CREATE TYPE box (INTERNALLENGTH = 8,
INPUT = my_procedure_1, OUTPUT = my_procedure_2); INPUT = my_procedure_1, OUTPUT = my_procedure_2);
...@@ -357,7 +357,7 @@ CREATE TABLE myarrays (id int4, numbers int4array); ...@@ -357,7 +357,7 @@ CREATE TABLE myarrays (id int4, numbers int4array);
<para> <para>
This command creates a large object type and uses it in This command creates a large object type and uses it in
a class definition: a table definition:
<programlisting> <programlisting>
CREATE TYPE bigobj (INPUT = lo_filein, OUTPUT = lo_fileout, CREATE TYPE bigobj (INPUT = lo_filein, OUTPUT = lo_fileout,
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.9 2000/03/27 17:14:42 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.10 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -123,8 +123,8 @@ CREATE VIEW vista AS SELECT text 'Hello World' ...@@ -123,8 +123,8 @@ CREATE VIEW vista AS SELECT text 'Hello World'
Description Description
</title> </title>
<para> <para>
<command>CREATE VIEW</command> will define a view of a table or <command>CREATE VIEW</command> will define a view of a table.
class. This view is not physically materialized. Specifically, a query This view is not physically materialized. Specifically, a query
rewrite retrieve rule is automatically generated to support rewrite retrieve rule is automatically generated to support
retrieve operations on views. retrieve operations on views.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createuser.sgml,v 1.15 2000/12/25 23:15:26 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/createuser.sgml,v 1.16 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -196,7 +196,7 @@ Postgres documentation ...@@ -196,7 +196,7 @@ Postgres documentation
<application>createuser</application> creates a <application>createuser</application> creates a
new <productname>Postgres</productname> user. new <productname>Postgres</productname> user.
Only users with <literal>usesuper</literal> set in Only users with <literal>usesuper</literal> set in
the <literal>pg_shadow</literal> class can create the <literal>pg_shadow</literal> table can create
new <productname>Postgres</productname> users. new <productname>Postgres</productname> users.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/delete.sgml,v 1.11 2000/06/09 01:44:00 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/delete.sgml,v 1.12 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -120,7 +120,7 @@ DELETE <replaceable class="parameter">count</replaceable> ...@@ -120,7 +120,7 @@ DELETE <replaceable class="parameter">count</replaceable>
<para> <para>
By default DELETE will delete tuples in the table specified By default DELETE will delete tuples in the table specified
and all its sub-classes. If you wish to only update the and all its sub-tables. If you wish to only update the
specific table mentioned, you should use the ONLY clause. specific table mentioned, you should use the ONLY clause.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_type.sgml,v 1.8 2000/10/22 23:32:38 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_type.sgml,v 1.9 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -113,7 +113,7 @@ ERROR: RemoveType: type '<replaceable class="parameter">typename</replaceable>' ...@@ -113,7 +113,7 @@ ERROR: RemoveType: type '<replaceable class="parameter">typename</replaceable>'
</para> </para>
<para> <para>
It is the user's responsibility to remove any operators, It is the user's responsibility to remove any operators,
functions, aggregates, access methods, subtypes, and classes functions, aggregates, access methods, subtypes, and tables
that use a deleted type. that use a deleted type.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropuser.sgml,v 1.10 2000/12/25 23:15:26 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/dropuser.sgml,v 1.11 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -148,7 +148,7 @@ Postgres documentation ...@@ -148,7 +148,7 @@ Postgres documentation
<productname>Postgres</productname> user <productname>Postgres</productname> user
<emphasis>and</emphasis> the databases which that user owned. <emphasis>and</emphasis> the databases which that user owned.
Only users with <literal>usesuper</literal> set in Only users with <literal>usesuper</literal> set in
the <literal>pg_shadow</literal> class can destroy the <literal>pg_shadow</literal> table can destroy
<productname>Postgres</productname> users. <productname>Postgres</productname> users.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/insert.sgml,v 1.12 2000/12/25 23:15:26 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/insert.sgml,v 1.13 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -129,7 +129,7 @@ INSERT 0 <replaceable>#</replaceable> ...@@ -129,7 +129,7 @@ INSERT 0 <replaceable>#</replaceable>
<para> <para>
<command>INSERT</command> allows one to insert new rows into a <command>INSERT</command> allows one to insert new rows into a
class or table. One can insert table. One can insert
a single row at a time or several rows as a result of a query. a single row at a time or several rows as a result of a query.
The columns in the target list may be listed in any order. The columns in the target list may be listed in any order.
</para> </para>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/select.sgml,v 1.36 2001/01/08 21:30:37 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/select.sgml,v 1.37 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -31,7 +31,7 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac ...@@ -31,7 +31,7 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac
[ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ] [ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ]
[ { UNION | INTERSECT | EXCEPT [ ALL ] } <replaceable class="PARAMETER">select</replaceable> ] [ { UNION | INTERSECT | EXCEPT [ ALL ] } <replaceable class="PARAMETER">select</replaceable> ]
[ ORDER BY <replaceable class="PARAMETER">expression</replaceable> [ ASC | DESC | USING <replaceable class="PARAMETER">operator</replaceable> ] [, ...] ] [ ORDER BY <replaceable class="PARAMETER">expression</replaceable> [ ASC | DESC | USING <replaceable class="PARAMETER">operator</replaceable> ] [, ...] ]
[ FOR UPDATE [ OF <replaceable class="PARAMETER">class_name</replaceable> [, ...] ] ] [ FOR UPDATE [ OF <replaceable class="PARAMETER">tablename</replaceable> [, ...] ] ]
[ LIMIT { <replaceable class="PARAMETER">count</replaceable> | ALL } [ { OFFSET | , } <replaceable class="PARAMETER">start</replaceable> ]] [ LIMIT { <replaceable class="PARAMETER">count</replaceable> | ALL } [ { OFFSET | , } <replaceable class="PARAMETER">start</replaceable> ]]
where <replaceable class="PARAMETER">from_item</replaceable> can be: where <replaceable class="PARAMETER">from_item</replaceable> can be:
...@@ -397,11 +397,11 @@ where <replaceable class="PARAMETER">from_item</replaceable> can be: ...@@ -397,11 +397,11 @@ where <replaceable class="PARAMETER">from_item</replaceable> can be:
<para> <para>
When a FROM item is a simple table name, it implicitly includes rows When a FROM item is a simple table name, it implicitly includes rows
from subclasses (inheritance children) of the table. from sub-tables (inheritance children) of the table.
<command>ONLY</command> will <command>ONLY</command> will
suppress rows from subclasses of the table. Before suppress rows from sub-tables of the table. Before
<Productname>Postgres</Productname> 7.1, <Productname>Postgres</Productname> 7.1,
this was the default result, and adding subclasses was done this was the default result, and adding sub-tables was done
by appending <command>*</command> to the table name. by appending <command>*</command> to the table name.
This old behaviour is available via the command This old behaviour is available via the command
<command>SET SQL_Inheritance TO OFF;</command> <command>SET SQL_Inheritance TO OFF;</command>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/select_into.sgml,v 1.8 2000/12/25 23:15:26 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/select_into.sgml,v 1.9 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -31,7 +31,7 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac ...@@ -31,7 +31,7 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac
[ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ] [ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ]
[ { UNION | INTERSECT | EXCEPT [ ALL ] } <replaceable class="PARAMETER">select</replaceable> ] [ { UNION | INTERSECT | EXCEPT [ ALL ] } <replaceable class="PARAMETER">select</replaceable> ]
[ ORDER BY <replaceable class="PARAMETER">expression</replaceable> [ ASC | DESC | USING <replaceable class="PARAMETER">operator</replaceable> ] [, ...] ] [ ORDER BY <replaceable class="PARAMETER">expression</replaceable> [ ASC | DESC | USING <replaceable class="PARAMETER">operator</replaceable> ] [, ...] ]
[ FOR UPDATE [ OF <replaceable class="PARAMETER">class_name</replaceable> [, ...] ] ] [ FOR UPDATE [ OF <replaceable class="PARAMETER">tablename</replaceable> [, ...] ] ]
[ LIMIT { <replaceable class="PARAMETER">count</replaceable> | ALL } [ { OFFSET | , } <replaceable class="PARAMETER">start</replaceable> ]] [ LIMIT { <replaceable class="PARAMETER">count</replaceable> | ALL } [ { OFFSET | , } <replaceable class="PARAMETER">start</replaceable> ]]
where <replaceable class="PARAMETER">from_item</replaceable> can be: where <replaceable class="PARAMETER">from_item</replaceable> can be:
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/unlisten.sgml,v 1.13 2000/12/25 23:15:26 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/unlisten.sgml,v 1.14 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -114,7 +114,7 @@ UNLISTEN { <replaceable class="PARAMETER">notifyname</replaceable> | * } ...@@ -114,7 +114,7 @@ UNLISTEN { <replaceable class="PARAMETER">notifyname</replaceable> | * }
Notes Notes
</title> </title>
<para> <para>
<replaceable class="PARAMETER">classname</replaceable> <replaceable class="PARAMETER">notifyname</replaceable>
need not be a valid class name but can be any string valid need not be a valid class name but can be any string valid
as a name up to 32 characters long. as a name up to 32 characters long.
</para> </para>
...@@ -124,13 +124,6 @@ UNLISTEN { <replaceable class="PARAMETER">notifyname</replaceable> | * } ...@@ -124,13 +124,6 @@ UNLISTEN { <replaceable class="PARAMETER">notifyname</replaceable> | * }
Each backend will automatically execute <command>UNLISTEN *</command> when Each backend will automatically execute <command>UNLISTEN *</command> when
exiting. exiting.
</para> </para>
<para>
A restriction in some previous releases of
<productname>Postgres</productname> that a
<replaceable class="PARAMETER">classname</replaceable>
which does not correspond to an actual table must be enclosed in double-quotes
is no longer present.
</para>
</refsect2> </refsect2>
</refsect1> </refsect1>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/update.sgml,v 1.13 2000/12/25 23:15:26 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/update.sgml,v 1.14 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -143,7 +143,7 @@ UPDATE <replaceable class="parameter">#</replaceable> ...@@ -143,7 +143,7 @@ UPDATE <replaceable class="parameter">#</replaceable>
<para> <para>
By default UPDATE will update tuples in the table specified By default UPDATE will update tuples in the table specified
and all its sub-classes. If you wish to only update the and all its sub-tables. If you wish to only update the
specific table mentioned, you should use the ONLY clause. specific table mentioned, you should use the ONLY clause.
</para> </para>
</refsect1> </refsect1>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuum.sgml,v 1.12 2000/10/05 19:57:23 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/vacuum.sgml,v 1.13 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -150,10 +150,10 @@ NOTICE: Index <replaceable class="PARAMETER">index</replaceable>: Pages 28; ...@@ -150,10 +150,10 @@ NOTICE: Index <replaceable class="PARAMETER">index</replaceable>: Pages 28;
</para> </para>
<para> <para>
<command>VACUUM</command> opens every class in the database, <command>VACUUM</command> opens every table in the database,
cleans out records from rolled back transactions, and updates statistics in the cleans out records from rolled back transactions, and updates statistics in the
system catalogs. The statistics maintained include the number of system catalogs. The statistics maintained include the number of
tuples and number of pages stored in all classes. tuples and number of pages stored in all tables.
</para> </para>
...@@ -181,7 +181,7 @@ NOTICE: Index <replaceable class="PARAMETER">index</replaceable>: Pages 28; ...@@ -181,7 +181,7 @@ NOTICE: Index <replaceable class="PARAMETER">index</replaceable>: Pages 28;
<para> <para>
We recommend that active production databases be We recommend that active production databases be
<command>VACUUM</command>-ed nightly, in order to remove <command>VACUUM</command>-ed nightly, in order to remove
expired rows. After copying a large class into expired rows. After copying a large table into
<productname>Postgres</productname> or after deleting a large number <productname>Postgres</productname> or after deleting a large number
of records, it may be a good idea to issue a <command>VACUUM of records, it may be a good idea to issue a <command>VACUUM
ANALYZE</command> query. This will update the system catalogs with ANALYZE</command> query. This will update the system catalogs with
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.34 2001/01/13 18:34:51 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.35 2001/01/13 23:58:55 petere Exp $
--> -->
<chapter id="sql-syntax"> <chapter id="sql-syntax">
...@@ -553,15 +553,12 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> ) ...@@ -553,15 +553,12 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> )
<sect1 id="sql-syntax-columns"> <sect1 id="sql-syntax-columns">
<title>Fields and Columns</title> <title>Columns</title>
<sect2>
<title>Fields</title>
<para> <para>
A <firstterm>field</firstterm> A <firstterm>column</firstterm>
is either a user-defined attribute of a given class or one of the is either a user-defined column of a given table or one of the
following system-defined attributes: following system-defined columns:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
...@@ -653,40 +650,29 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> ) ...@@ -653,40 +650,29 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> )
<xref linkend="STON87a" endterm="STON87a">. <xref linkend="STON87a" endterm="STON87a">.
Transaction and command identifiers are 32 bit quantities. Transaction and command identifiers are 32 bit quantities.
</para> </para>
</sect2>
<sect2>
<title>Columns</title>
<para> <para>
A <firstterm>column</firstterm> is a construct of the form: A column can be referenced in the form:
<synopsis> <synopsis>
<replaceable>instance</replaceable>{.<replaceable>composite_field</replaceable>}.<replaceable>field</replaceable> `['<replaceable>subscript</replaceable>`]' <replaceable>corelation</replaceable>.<replaceable>columnname</replaceable> `['<replaceable>subscript</replaceable>`]'
</synopsis> </synopsis>
<replaceable>instance</replaceable> <replaceable>corelation</replaceable> is either the name of a
identifies a particular class and can be thought of as standing for table, an alias for a table defined by means of a FROM clause, or
the instances of that class. An instance variable is either a class the keyword <literal>NEW</literal> or <literal>OLD</literal>.
name, an alias for a class defined by means of a FROM clause, (NEW and OLD can only appear in the action portion of a rule,
or the keyword NEW or OLD. while other corelation names can be used in any SQL statement.)
(NEW and OLD can only appear in the action portion of a rule, while The corelation name can be omitted if the column name is unique
other instance variables can be used in any SQL statement.) The across all the tables being used in the current query. If
instance name can be omitted if the first field name is unique <replaceable>column</replaceable> is of an array type, then the
across all the classes being used in the current query. optional <replaceable>subscript</replaceable> selects a specific
<replaceable>composite_field</replaceable> element in the array. If no subscript is provided, then the
is a field of of one of the Postgres composite types, whole array is selected. Refer to the description of the
while successive composite fields select attributes in the particular commands in the <citetitle>PostgreSQL Reference
class(s) to which the composite field evaluates. Lastly, Manual</citetitle> for the allowed syntax in each case.
<replaceable>field</replaceable>
is a normal (base type) field in the class(s) last addressed. If
<replaceable>field</replaceable>
is of an array type,
then the optional <replaceable>subscript</replaceable>
selects a specific element in the array. If no subscript is
provided, then the whole array is selected.
</para> </para>
</sect2>
</sect1> </sect1>
<sect1 id="sql-expressions"> <sect1 id="sql-expressions">
...@@ -861,10 +847,10 @@ sqrt(emp.salary) ...@@ -861,10 +847,10 @@ sqrt(emp.salary)
The simplest possibility for a from-expression is: The simplest possibility for a from-expression is:
<synopsis> <synopsis>
<replaceable>class_reference</replaceable> [ [ AS ] <replaceable class="PARAMETER">alias</replaceable> ] <replaceable>table_reference</replaceable> [ [ AS ] <replaceable class="PARAMETER">alias</replaceable> ]
</synopsis> </synopsis>
where <replaceable>class_reference</replaceable> is of the form where <replaceable>table_reference</replaceable> is of the form
<synopsis> <synopsis>
[ ONLY ] <replaceable class="PARAMETER">table_name</replaceable> [ * ] [ ONLY ] <replaceable class="PARAMETER">table_name</replaceable> [ * ]
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/tutorial.sgml,v 1.11 2000/11/24 17:44:22 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/tutorial.sgml,v 1.12 2001/01/13 23:58:55 petere Exp $
--> -->
<book id="tutorial"> <book id="tutorial">
...@@ -33,7 +33,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/tutorial.sgml,v 1.11 2000/11/24 17:44 ...@@ -33,7 +33,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/tutorial.sgml,v 1.11 2000/11/24 17:44
developed originally in the UC Berkeley Computer Science Department, developed originally in the UC Berkeley Computer Science Department,
pioneered many of the object-relational concepts pioneered many of the object-relational concepts
now becoming available in some commercial databases. now becoming available in some commercial databases.
It provides SQL92/SQL3 language support, It provides SQL92/SQL99 language support,
transaction integrity, and type extensibility. transaction integrity, and type extensibility.
<productname>PostgreSQL</productname> is an open-source descendant <productname>PostgreSQL</productname> is an open-source descendant
of this original Berkeley code. of this original Berkeley code.
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/user.sgml,v 1.23 2001/01/06 11:58:56 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/user.sgml,v 1.24 2001/01/13 23:58:55 petere Exp $
--> -->
<book id="user"> <book id="user">
...@@ -35,7 +35,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/user.sgml,v 1.23 2001/01/06 11:58:56 ...@@ -35,7 +35,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/user.sgml,v 1.23 2001/01/06 11:58:56
developed originally in the UC Berkeley Computer Science Department, developed originally in the UC Berkeley Computer Science Department,
pioneered many of the object-relational concepts pioneered many of the object-relational concepts
now becoming available in some commercial databases. now becoming available in some commercial databases.
It provides SQL92/SQL3 language support, It provides SQL92/SQL99 language support,
transaction integrity, and type extensibility. transaction integrity, and type extensibility.
<productname>PostgreSQL</productname> is an open-source descendant <productname>PostgreSQL</productname> is an open-source descendant
of this original Berkeley code. of this original Berkeley code.
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/xaggr.sgml,v 1.9 2000/10/23 00:46:06 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/xaggr.sgml,v 1.10 2001/01/13 23:58:55 petere Exp $
--> -->
<chapter id="xaggr"> <chapter id="xaggr">
...@@ -31,9 +31,9 @@ $Header: /cvsroot/pgsql/doc/src/sgml/xaggr.sgml,v 1.9 2000/10/23 00:46:06 tgl Ex ...@@ -31,9 +31,9 @@ $Header: /cvsroot/pgsql/doc/src/sgml/xaggr.sgml,v 1.9 2000/10/23 00:46:06 tgl Ex
<para> <para>
If we define an aggregate that does not use a final function, If we define an aggregate that does not use a final function,
we have an aggregate that computes a running function of we have an aggregate that computes a running function of
the attribute values from each instance. "Sum" is an the column values from each row. "Sum" is an
example of this kind of aggregate. "Sum" starts at example of this kind of aggregate. "Sum" starts at
zero and always adds the current instance's value to zero and always adds the current row's value to
its running total. For example, if we want to make a Sum its running total. For example, if we want to make a Sum
aggregate to work on a datatype for complex numbers, aggregate to work on a datatype for complex numbers,
we only need the addition function for that datatype. we only need the addition function for that datatype.
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.27 2001/01/12 22:15:32 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.28 2001/01/13 23:58:55 petere Exp $
--> -->
<chapter id="xfunc"> <chapter id="xfunc">
...@@ -202,7 +202,7 @@ SELECT name, double_salary(EMP) AS dream ...@@ -202,7 +202,7 @@ SELECT name, double_salary(EMP) AS dream
return composite types, we must first introduce the return composite types, we must first introduce the
function notation for projecting attributes. The simple way function notation for projecting attributes. The simple way
to explain this is that we can usually use the to explain this is that we can usually use the
notations attribute(class) and class.attribute interchangably: notations attribute(table) and table.attribute interchangably:
<programlisting> <programlisting>
-- --
...@@ -223,10 +223,10 @@ SELECT name(EMP) AS youngster ...@@ -223,10 +223,10 @@ SELECT name(EMP) AS youngster
<para> <para>
As we shall see, however, this is not always the case. As we shall see, however, this is not always the case.
This function notation is important when we want to use This function notation is important when we want to use
a function that returns a single instance. We do this a function that returns a single row. We do this
by assembling the entire instance within the function, by assembling the entire row within the function,
attribute by attribute. This is an example of a function attribute by attribute. This is an example of a function
that returns a single EMP instance: that returns a single EMP row:
<programlisting> <programlisting>
CREATE FUNCTION new_emp() CREATE FUNCTION new_emp()
...@@ -266,10 +266,10 @@ ERROR: function declared to return emp returns varchar instead of text at colum ...@@ -266,10 +266,10 @@ ERROR: function declared to return emp returns varchar instead of text at colum
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
When calling a function that returns an instance, we When calling a function that returns a row, we
cannot retrieve the entire instance. We must either cannot retrieve the entire row. We must either
project an attribute out of the instance or pass the project an attribute out of the row or pass the
entire instance into another function. entire row into another function.
<programlisting> <programlisting>
SELECT name(new_emp()) AS nobody; SELECT name(new_emp()) AS nobody;
...@@ -1012,7 +1012,7 @@ concat_text(PG_FUNCTION_ARGS) ...@@ -1012,7 +1012,7 @@ concat_text(PG_FUNCTION_ARGS)
Therefore, <productname>Postgres</productname> provides Therefore, <productname>Postgres</productname> provides
a procedural interface for accessing fields of composite types a procedural interface for accessing fields of composite types
from C. As <productname>Postgres</productname> processes from C. As <productname>Postgres</productname> processes
a set of instances, each instance will be passed into your a set of rows, each row will be passed into your
function as an opaque structure of type <literal>TUPLE</literal>. function as an opaque structure of type <literal>TUPLE</literal>.
Suppose we want to write a function to answer the query Suppose we want to write a function to answer the query
...@@ -1029,7 +1029,7 @@ WHERE name = 'Bill' OR name = 'Sam'; ...@@ -1029,7 +1029,7 @@ WHERE name = 'Bill' OR name = 'Sam';
#include "executor/executor.h" /* for GetAttributeByName() */ #include "executor/executor.h" /* for GetAttributeByName() */
bool bool
c_overpaid(TupleTableSlot *t, /* the current instance of EMP */ c_overpaid(TupleTableSlot *t, /* the current row of EMP */
int32 limit) int32 limit)
{ {
bool isnull; bool isnull;
...@@ -1066,7 +1066,7 @@ c_overpaid(PG_FUNCTION_ARGS) ...@@ -1066,7 +1066,7 @@ c_overpaid(PG_FUNCTION_ARGS)
<para> <para>
<function>GetAttributeByName</function> is the <function>GetAttributeByName</function> is the
<productname>Postgres</productname> system function that <productname>Postgres</productname> system function that
returns attributes out of the current instance. It has returns attributes out of the current row. It has
three arguments: the argument of type <type>TupleTableSlot*</type> passed into three arguments: the argument of type <type>TupleTableSlot*</type> passed into
the function, the name of the desired attribute, and a the function, the name of the desired attribute, and a
return parameter that tells whether the attribute return parameter that tells whether the attribute
...@@ -1088,8 +1088,8 @@ LANGUAGE 'c'; ...@@ -1088,8 +1088,8 @@ LANGUAGE 'c';
</para> </para>
<para> <para>
While there are ways to construct new instances or modify While there are ways to construct new rows or modify
existing instances from within a C function, these existing rows from within a C function, these
are far too complex to discuss in this manual. are far too complex to discuss in this manual.
</para> </para>
</sect2> </sect2>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/xindex.sgml,v 1.12 2000/12/26 00:10:37 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/xindex.sgml,v 1.13 2001/01/13 23:58:55 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -27,7 +27,7 @@ Postgres documentation ...@@ -27,7 +27,7 @@ Postgres documentation
</para> </para>
<para> <para>
The <filename>pg_am</filename> class contains one instance for every user The <filename>pg_am</filename> table contains one row for every user
defined access method. Support for the heap access method is built into defined access method. Support for the heap access method is built into
<productname>Postgres</productname>, but every other access method is <productname>Postgres</productname>, but every other access method is
described here. The schema is described here. The schema is
...@@ -38,7 +38,7 @@ Postgres documentation ...@@ -38,7 +38,7 @@ Postgres documentation
<tgroup cols="2"> <tgroup cols="2">
<thead> <thead>
<row> <row>
<entry>Attribute</entry> <entry>Column</entry>
<entry>Description</entry> <entry>Description</entry>
</row> </row>
</thead> </thead>
...@@ -49,7 +49,7 @@ Postgres documentation ...@@ -49,7 +49,7 @@ Postgres documentation
</row> </row>
<row> <row>
<entry>amowner</entry> <entry>amowner</entry>
<entry>object id of the owner's instance in pg_user</entry> <entry>user id of the owner</entry>
</row> </row>
<row> <row>
<entry>amstrategies</entry> <entry>amstrategies</entry>
...@@ -74,7 +74,7 @@ Postgres documentation ...@@ -74,7 +74,7 @@ Postgres documentation
<entry>...</entry> <entry>...</entry>
<entry>procedure identifiers for interface routines to the access <entry>procedure identifiers for interface routines to the access
method. For example, regproc ids for opening, closing, and method. For example, regproc ids for opening, closing, and
getting instances from the access method appear here.</entry> getting rows from the access method appear here.</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
...@@ -82,11 +82,11 @@ Postgres documentation ...@@ -82,11 +82,11 @@ Postgres documentation
</para> </para>
<para> <para>
The <acronym>object ID</acronym> of the instance in The <acronym>object ID</acronym> of the row in
<filename>pg_am</filename> is used as a foreign key in lots of other <filename>pg_am</filename> is used as a foreign key in a lot of other
classes. You don't need to add a new instance to this class; all tables. You do not need to add a new rows to this table; all that
you're interested in is the <acronym>object ID</acronym> of the access you are interested in is the <acronym>object ID</acronym> of the access
method instance you want to extend: method row you want to extend:
<programlisting> <programlisting>
SELECT oid FROM pg_am WHERE amname = 'btree'; SELECT oid FROM pg_am WHERE amname = 'btree';
...@@ -102,7 +102,7 @@ SELECT oid FROM pg_am WHERE amname = 'btree'; ...@@ -102,7 +102,7 @@ SELECT oid FROM pg_am WHERE amname = 'btree';
</para> </para>
<para> <para>
The <filename>amstrategies</filename> attribute exists to standardize The <filename>amstrategies</filename> column exists to standardize
comparisons across data types. For example, <acronym>B-tree</acronym>s comparisons across data types. For example, <acronym>B-tree</acronym>s
impose a strict ordering on keys, lesser to greater. Since impose a strict ordering on keys, lesser to greater. Since
<productname>Postgres</productname> allows the user to define operators, <productname>Postgres</productname> allows the user to define operators,
...@@ -125,7 +125,7 @@ SELECT oid FROM pg_am WHERE amname = 'btree'; ...@@ -125,7 +125,7 @@ SELECT oid FROM pg_am WHERE amname = 'btree';
Defining a new set of strategies is beyond the scope of this discussion, Defining a new set of strategies is beyond the scope of this discussion,
but we'll explain how <acronym>B-tree</acronym> strategies work because but we'll explain how <acronym>B-tree</acronym> strategies work because
you'll need to know that to add a new operator class. In the you'll need to know that to add a new operator class. In the
<filename>pg_am</filename> class, the amstrategies attribute is the <filename>pg_am</filename> table, the amstrategies column is the
number of strategies defined for this access method. For number of strategies defined for this access method. For
<acronym>B-tree</acronym>s, this number is 5. These strategies <acronym>B-tree</acronym>s, this number is 5. These strategies
correspond to correspond to
...@@ -193,8 +193,8 @@ SELECT oid FROM pg_am WHERE amname = 'btree'; ...@@ -193,8 +193,8 @@ SELECT oid FROM pg_am WHERE amname = 'btree';
<para> <para>
In order to manage diverse support routines consistently across all In order to manage diverse support routines consistently across all
<productname>Postgres</productname> access methods, <productname>Postgres</productname> access methods,
<filename>pg_am</filename> includes an attribute called <filename>pg_am</filename> includes a column called
<filename>amsupport</filename>. This attribute records the number of <filename>amsupport</filename>. This column records the number of
support routines used by an access method. For <acronym>B-tree</acronym>s, support routines used by an access method. For <acronym>B-tree</acronym>s,
this number is one -- the routine to take two keys and return -1, 0, or this number is one -- the routine to take two keys and return -1, 0, or
+1, depending on whether the first key is less than, equal +1, depending on whether the first key is less than, equal
...@@ -228,14 +228,14 @@ SELECT oid FROM pg_am WHERE amname = 'btree'; ...@@ -228,14 +228,14 @@ SELECT oid FROM pg_am WHERE amname = 'btree';
</para> </para>
<para> <para>
The next class of interest is <filename>pg_opclass</filename>. This class The next table of interest is <filename>pg_opclass</filename>. This table
exists only to associate an operator class name and perhaps a default type exists only to associate an operator class name and perhaps a default type
with an operator class oid. Some existing opclasses are <filename>int2_ops, with an operator class oid. Some existing opclasses are <filename>int2_ops,
int4_ops,</filename> and <filename>oid_ops</filename>. You need to add an int4_ops,</filename> and <filename>oid_ops</filename>. You need to add a
instance with your opclass name (for example, row with your opclass name (for example,
<filename>complex_abs_ops</filename>) to <filename>complex_abs_ops</filename>) to
<filename>pg_opclass</filename>. The <filename>oid</filename> of <filename>pg_opclass</filename>. The <filename>oid</filename> of
this instance will be a foreign key in other classes, notably this row will be a foreign key in other tables, notably
<filename>pg_amop</filename>. <filename>pg_amop</filename>.
<programlisting> <programlisting>
...@@ -252,7 +252,7 @@ SELECT oid, opcname, opcdeftype ...@@ -252,7 +252,7 @@ SELECT oid, opcname, opcdeftype
(1 row) (1 row)
</programlisting> </programlisting>
Note that the oid for your <filename>pg_opclass</filename> instance will Note that the oid for your <filename>pg_opclass</filename> row will
be different! Don't worry about this though. We'll get this number be different! Don't worry about this though. We'll get this number
from the system later just like we got the oid of the type here. from the system later just like we got the oid of the type here.
</para> </para>
...@@ -357,7 +357,7 @@ CREATE FUNCTION complex_abs_eq(complex, complex) ...@@ -357,7 +357,7 @@ CREATE FUNCTION complex_abs_eq(complex, complex)
hand, the support function returns whatever the particular access method hand, the support function returns whatever the particular access method
expects -- in this case, a signed integer.) The final routine in the expects -- in this case, a signed integer.) The final routine in the
file is the "support routine" mentioned when we discussed the amsupport file is the "support routine" mentioned when we discussed the amsupport
attribute of the <filename>pg_am</filename> class. We will use this column of the <filename>pg_am</filename> table. We will use this
later on. For now, ignore it. later on. For now, ignore it.
</para> </para>
...@@ -416,10 +416,10 @@ CREATE OPERATOR = ( ...@@ -416,10 +416,10 @@ CREATE OPERATOR = (
</para> </para>
<para> <para>
Now we're ready to update <filename>pg_amop</filename> with our new Now we are ready to update <filename>pg_amop</filename> with our new
operator class. The most important thing in this entire discussion operator class. The most important thing in this entire discussion
is that the operators are ordered, from less than through greater is that the operators are ordered, from less than through greater
than, in <filename>pg_amop</filename>. We add the instances we need: than, in <filename>pg_amop</filename>. We add the rows we need:
<programlisting> <programlisting>
INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy) INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
...@@ -440,7 +440,7 @@ CREATE OPERATOR = ( ...@@ -440,7 +440,7 @@ CREATE OPERATOR = (
The next step is registration of the "support routine" previously The next step is registration of the "support routine" previously
described in our discussion of <filename>pg_am</filename>. The described in our discussion of <filename>pg_am</filename>. The
<filename>oid</filename> of this support routine is stored in the <filename>oid</filename> of this support routine is stored in the
<filename>pg_amproc</filename> class, keyed by the access method <filename>pg_amproc</filename> table, keyed by the access method
<filename>oid</filename> and the operator class <filename>oid</filename>. <filename>oid</filename> and the operator class <filename>oid</filename>.
First, we need to register the function in First, we need to register the function in
<productname>Postgres</productname> (recall that we put the <productname>Postgres</productname> (recall that we put the
...@@ -463,7 +463,7 @@ CREATE OPERATOR = ( ...@@ -463,7 +463,7 @@ CREATE OPERATOR = (
</programlisting> </programlisting>
(Again, your <filename>oid</filename> number will probably be different.) (Again, your <filename>oid</filename> number will probably be different.)
We can add the new instance as follows: We can add the new row as follows:
<programlisting> <programlisting>
INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum) INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<para> <para>
As previously mentioned, there are two kinds of types As previously mentioned, there are two kinds of types
in <productname>Postgres</productname>: base types (defined in a programming language) in <productname>Postgres</productname>: base types (defined in a programming language)
and composite types (instances). and composite types.
Examples in this section up to interfacing indices can Examples in this section up to interfacing indices can
be found in <filename>complex.sql</filename> and <filename>complex.c</filename>. Composite examples be found in <filename>complex.sql</filename> and <filename>complex.c</filename>. Composite examples
are in <filename>funcs.sql</filename>. are in <filename>funcs.sql</filename>.
......
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