pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: wieck@debis.com
To: Bruce Momjian <pgman@candle.pha.pa.us>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: PostgreSQL-documentation <docs@postgresql.org>
Subject: Re: Updated docs needed for 7.0
Date: Tue, 11 Apr 2000 13:39:56 +0200 (CEST)
Message-ID: <m12ez1Q-0003knC@orion.SAPserv.Hamburg.dsh.de> (raw)
In-Reply-To: <200004110356.XAA24372@candle.pha.pa.us>

> OK, I have talked to Thomas and have found which items need work for
> 7.0.  Comments please.
>
> ---------------------------------------------------------------------------
>
> > Add CmdTuples() to libpq++(Vince)
>
> > New CREATE CONSTRAINT TRIGGER and SET CONSTRAINTS commands(Jan)
> > ALTER TABLE CONSTRAINT
> > First real FOREIGN KEY constraint trigger functionality (Jan)
> > Add FOREIGN KEY ... MATCH FULL ... ON DELETE CASCADE (Jan)
> > Add FOREIGN KEY ... MATCH  referential actions (Don Baccus)
> > Add ALTER TABLE ... ADD FOREIGN KEY (Stephan Szabo)

    Attached  is  are  diffs  for  CREATE/ALTER  table  doc  I've
    forgotten in my mailbox (sorry). Haven't tried to  apply  and
    since I don't have working sgml stuff cannot check.

> > New lztext data type for compressed text fields
>
> Not documented.  I think we want to document it, no?

    If  at  all,  only  in the release notes because it has to be
    removed again as soon as we implement TOAST.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#========================================= wieck@debis.com (Jan Wieck) #

Attachments:

diff4 (text/plain, 26.2K) download Index: alter_table.sgml =================================================================== RCS file: /usr/local/cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v retrieving revision 1.10 diff -c -r1.10 alter_table.sgml *** alter_table.sgml 2000/01/29 16:58:27 1.10 --- alter_table.sgml 2000/02/08 21:55:01 *************** *** 34,39 **** --- 34,41 ---- class="PARAMETER">newcolumn</replaceable> ALTER TABLE <replaceable class="PARAMETER">table</replaceable> RENAME TO <replaceable class="PARAMETER">newtable</replaceable> + ALTER TABLE <replaceable class="PARAMETER">table</replaceable> + ADD <replaceable class="PARAMETER">table constraint definition</replaceable> </synopsis> <refsect2 id="R2-SQL-ALTERTABLE-1"> *************** *** 89,94 **** --- 91,105 ---- </para> </listitem> </varlistentry> + + <varlistentry> + <term><replaceable class="PARAMETER"> table constraint definition </replaceable></term> + <listitem> + <para> + New table constraint for the table + </para> + </listitem> + </varlistentry> </variablelist> </para> </refsect2> *************** *** 144,149 **** --- 155,163 ---- the affected table. Thus, the table or column will remain of the same type and size after this command is executed. + The ADD <replaceable class="PARAMETER">table constraint definition</replaceable> clause + adds a new constraint to the table using the same syntax as <xref + linkend="SQL-CREATETABLE" endterm="SQL-CREATETABLE-title">. </para> <para> *************** *** 189,194 **** --- 203,218 ---- </para> <para> + In the current implementation, only FOREIGN KEY constraints can + be added to a table. To create or remove a unique constraint, create + a unique index (see <xref linkend="SQL-CREATEINDEX" + endterm="SQL-CREATEINDEX-title">). To add check constraints + you need to recreate and reload the table, using other + parameters to the <xref linkend="SQL-CREATETABLE" + endterm="SQL-CREATETABLE-title"> command. + </para> + + <para> You must own the class in order to change its schema. Renaming any part of the schema of a system catalog is not permitted. *************** *** 227,232 **** --- 251,263 ---- ALTER TABLE distributors RENAME TO suppliers; </programlisting> </para> + + <para> + To add a foreign key constraint to a table: + <programlisting> + ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) REFERENCES addresses(address) MATCH FULL + </programlisting> + </para> </refsect1> <refsect1 id="R1-SQL-ALTERTABLE-3"> *************** *** 253,269 **** <varlistentry> <term> <synopsis> - ALTER TABLE <replaceable class="PARAMETER">table</replaceable> ADD <replaceable class="PARAMETER">table constraint definition</replaceable> ALTER TABLE <replaceable class="PARAMETER">table</replaceable> DROP CONSTRAINT <replaceable class="PARAMETER">constraint</replaceable> { RESTRICT | CASCADE } </synopsis> </term> <listitem> <para> ! Adds or removes a table constraint (such as a check constraint, ! unique constraint, or foreign key constraint). To create ! or remove a unique constraint, create or drop a unique index, ! respectively (see <xref linkend="SQL-CREATEINDEX" endterm="SQL-CREATEINDEX-title">). ! To change other kinds of constraints you need to recreate and reload the table, using other parameters to the <xref linkend="SQL-CREATETABLE" endterm="SQL-CREATETABLE-title"> command. --- 284,298 ---- <varlistentry> <term> <synopsis> ALTER TABLE <replaceable class="PARAMETER">table</replaceable> DROP CONSTRAINT <replaceable class="PARAMETER">constraint</replaceable> { RESTRICT | CASCADE } </synopsis> </term> <listitem> <para> ! Removes a table constraint (such as a check constraint, ! unique constraint, or foreign key constraint). To ! remove a unique constraint, drop a unique index, ! To remove other kinds of constraints you need to recreate and reload the table, using other parameters to the <xref linkend="SQL-CREATETABLE" endterm="SQL-CREATETABLE-title"> command. Index: create_table.sgml =================================================================== RCS file: /usr/local/cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v retrieving revision 1.17 diff -c -r1.17 create_table.sgml *** create_table.sgml 1999/07/22 15:09:08 1.17 --- create_table.sgml 2000/02/08 21:55:02 *************** *** 477,483 **** <synopsis> [ CONSTRAINT <replaceable class="parameter">name</replaceable> ] { [ NULL | NOT NULL ] | UNIQUE | PRIMARY KEY | CHECK <replaceable ! class="parameter">constraint</replaceable> } [, ...] </synopsis> </para> --- 477,491 ---- <synopsis> [ CONSTRAINT <replaceable class="parameter">name</replaceable> ] { [ NULL | NOT NULL ] | UNIQUE | PRIMARY KEY | CHECK <replaceable ! class="parameter">constraint</replaceable> | REFERENCES ! <replaceable class="parameter">referenced table</replaceable> ! (<replaceable class="parameter">referenced column</replaceable>) ! [ MATCH <replaceable class="parameter">match type</replaceable> ] ! [ ON DELETE <replaceable class="parameter">action</replaceable> ] ! [ ON UPDATE <replaceable class="parameter">action</replaceable> ] ! [ [ NOT ] DEFERRABLE ] ! [ INITIALLY <replaceable class="parameter"> check time </replaceable> ] } ! [, ...] </synopsis> </para> *************** *** 602,615 **** <member>CHECK</member> <member>NOT NULL</member> </simplelist></para> - <note> - <para> - <productname>Postgres</productname> does not yet - (at release 6.5) support - REFERENCES integrity constraints. The parser - accepts the REFERENCES syntax but ignores the clause. - </para> - </note> </refsect2> <refsect2 id="R2-SQL-NOTNULL-1"> --- 610,615 ---- *************** *** 956,962 **** Only one PRIMARY KEY can be specified for a table. </para> </refsect3> ! <refsect3 id="R3-SQL-PRIMARYKEY-3"> <refsect3info> <date>1998-09-11</date> --- 956,962 ---- Only one PRIMARY KEY can be specified for a table. </para> </refsect3> ! <refsect3 id="R3-SQL-PRIMARYKEY-3"> <refsect3info> <date>1998-09-11</date> *************** *** 979,984 **** --- 979,1256 ---- </para> </refsect3> </refsect2> + + <refsect2 id="R2-SQL-REFERENCES-1"> + <refsect2info> + <date>2000-02-04</date> + </refsect2info> + <title> + REFERENCES Constraint + </title> + <synopsis> + [ CONSTRAINT <replaceable class="parameter">name</replaceable> ] REFERENCES + <replaceable class="parameter">referenced table</replaceable> [ ( <replaceable class="parameter"> referenced column</replaceable> ) ] + [ MATCH <replaceable class="parameter">matchtype</replaceable> ] + [ ON DELETE <replaceable class="parameter">action</replaceable> ] + [ ON UPDATE <replaceable class="parameter">action</replaceable> ] + [ [ NOT ] DEFERRABLE ] + [ INITIALLY <replaceable class="parameter"> check time </replaceable> ] + </synopsis> + <para> + The REFERENCES constraint specifies a rule that a column + value is checked against the values of another column. + REFERENCES can also be specified as part of + a FOREIGN KEY table constraint. + </para> + + <refsect3 id="R3-SQL-REFERENCES-1"> + <title>Inputs</title> + <para> + <variablelist> + <varlistentry> + <term>CONSTRAINT <replaceable class="PARAMETER">name</replaceable></term> + <listitem> + <para> + An arbitrary name for the constraint. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><replaceable class="parameter">referenced table</replaceable></term> + <listitem> + <para> + The table that contains the data to check against. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><replaceable class="parameter">referenced column</replaceable></term> + <listitem> + <para> + The column in the <replaceable class="parameter">referenced table</replaceable> + to check the data against. If this is not specified, the PRIMARY KEY of the + <replaceable class="parameter">referenced table</replaceable> is used. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>MATCH <replaceable class="parameter">matchtype</replaceable></term> + <listitem> + <para> + The type of comparison to do between the table data. There are three + types of matching, MATCH FULL, MATCH PARTIAL, and the unspecified match type + used if no match type is specified. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>ON DELETE <replaceable class="parameter">action</replaceable></term> + <listitem> + <para> + The action to do when a referenced row in the referenced table is being + deleted. There are the following actions. + <variablelist> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Delete any rows referencing the deleted row. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Disallow deletion of rows being referenced. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>SET NULL</term> + <listitem> + <para> + Set the referencing column values to NULL. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>SET DEFAULT</term> + <listitem> + <para> + Set the referencing column values to their default value. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>NO ACTION</term> + <listitem> + <para> + Do nothing. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>ON UPDATE <replaceable class="parameter">action</replaceable></term> + <listitem> + <para> + The action to do when a referenced column in the referenced table is being + updated to a new value. If the row is updated, but the referenced column + is not changed, no action is done. There are the following actions. + <variablelist> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Update the value of the referencing column to the new value of the + referenced column. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Disallow update of row being referenced. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>SET NULL</term> + <listitem> + <para> + Set the referencing column values to NULL. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>SET DEFAULT</term> + <listitem> + <para> + Set the referencing column values to their default value. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>NO ACTION</term> + <listitem> + <para> + Do nothing. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> [ NOT ] DEFERRABLE </term> + <listitem> + <para> + Tells the trigger manager whether this constraint may be + deferred to the end of transaction. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>INITIALLY <replaceable class="parameter"> check time </replaceable></term> + <listitem> + <para> + <replaceable class="parameter">check time</replaceable> has two possible values + which specify the default time to check the constraint. + <variablelist> + <varlistentry> + <term>DEFERRED</term> + <para> + Check this constraint at the end of the transaction. + </para> + </varlistentry> + <varlistentry> + <term>IMMEDIATE</term> + <para> + Check this constraint after each statement. + </para> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect3> + + + <refsect3 id="R3-SQL-REFERENCES-2"> + <refsect3info> + <date>2000-02-04</date> + </refsect3info> + <title> + Outputs + </title> + <para> + <variablelist> + <varlistentry> + <term><replaceable>status</replaceable></term> + <listitem> + <para> + <variablelist> + <varlistentry> + <term><computeroutput> + ERROR: <replaceable class="parameter">name</replaceable> referential integrity violation - key referenced from + <replaceable class="parameter">table</replaceable> not found in <replaceable class="parameter">referenced table</replaceable> + </computeroutput></term> + <listitem> + <para> + This error occurs at runtime if one tries to insert a value + into a column which does not have a matching column in the + referenced table. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect3> + + <refsect3 id="R3-SQL-REFERENCES-3"> + <title>Description</title> + <para> + The REFERENCES column constraint specifies that a column of a + table must only contain values which match against values + in a referenced column of a referenced table. + </para> + <para> + A value added to this column are matched against the + values of the referenced table and referenced column using + the given match type. + In addition, when the referenced column data is changed, + actions are run upon this column's matching data. + </para> + </refsect3> + + <refsect3 id="R3-SQL-REFERENCES-4"> + <refsect3info> + <date>1998-09-11</date> + </refsect3info> + <title> + Notes + </title> + <para> + Currently <productname>Postgres</productname> only supports + MATCH FULL and an unspecified MATCH type. + In addition, the referenced columns are supposed to be + the columns of a UNIQUE constraint in the referenced table, + however <productname>Postgres</productname> does not + enforce this. + </para> + </refsect3> </refsect1> <refsect1 id="R1-SQL-TABLECONSTRAINT-1"> *************** *** 992,997 **** --- 1264,1277 ---- <synopsis> [ CONSTRAINT name ] { PRIMARY KEY | UNIQUE } ( <replaceable class="parameter">column</replaceable> [, ...] ) [ CONSTRAINT name ] CHECK ( <replaceable>constraint</replaceable> ) + [ CONSTRAINT name ] FOREIGN KEY ( <replaceable class="parameter">column</replaceable> [, ...] ) + REFERENCES <replaceable class="parameter">referenced table</replaceable> + (<replaceable class="parameter">referenced column</replaceable> [, ...] ) + [ MATCH <match type> ] + [ ON DELETE <replaceable class="parameter">action</replaceable> ] + [ ON UPDATE <replaceable class="parameter">action</replaceable> ] + [ [ NOT ] DEFERRABLE ] + [ INITIALLY <replaceable class="parameter"> check time </replaceable> ] </synopsis> </para> <refsect2 id="R2-SQL-TABLECONSTRAINT-1"> *************** *** 1253,1259 **** --- 1533,1803 ---- information. </para> </refsect3> + </refsect2> + <refsect2 id="R2-SQL-REFERENCES-1"> + <refsect2info> + <date>2000-02-04</date> + </refsect2info> + <title> + REFERENCES Constraint + </title> + <synopsis> + [ CONSTRAINT <replaceable class="parameter">name</replaceable> ] + FOREIGN KEY ( <replaceable class="parameter">column</replaceable> [, ...] ) REFERENCES + <replaceable class="parameter">referenced table</replaceable> [ ( <replaceable class="parameter">referenced column</replaceable> [, ...] ) ] + [ MATCH <replaceable class="parameter">matchtype</replaceable> ] + [ ON DELETE <replaceable class="parameter">action</replaceable> ] + [ ON UPDATE <replaceable class="parameter">action</replaceable> ] + [ [ NOT ] DEFERRABLE ] + [ INITIALLY <replaceable class="parameter"> check time </replaceable> ] + </synopsis> + <para> + The REFERENCES constraint specifies a rule that a column + value is checked against the values of another column. + REFERENCES can also be specified as part of + a FOREIGN KEY table constraint. + </para> + + <refsect3 id="R3-SQL-REFERENCES-1"> + <title>Inputs</title> + <para> + <variablelist> + <varlistentry> + <term>CONSTRAINT <replaceable class="PARAMETER">name</replaceable></term> + <listitem> + <para> + An arbitrary name for the constraint. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><replaceable class="PARAMETER">column</replaceable> [, ...]</term> + <listitem> + <para> + The names of one or more columns in the table. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><replaceable class="parameter">referenced table</replaceable></term> + <listitem> + <para> + The table that contains the data to check against. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><replaceable class="parameter">referenced column</replaceable> [, ...]</term> + <listitem> + <para> + One or more column in the <replaceable class="parameter">referenced table</replaceable> + to check the data against. If this is not specified, the PRIMARY KEY of the + <replaceable class="parameter">referenced table</replaceable> is used. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>MATCH <replaceable class="parameter">matchtype</replaceable></term> + <listitem> + <para> + The type of comparison to do between the table data. There are three + types of matching, MATCH FULL, MATCH PARTIAL, and the unspecified match type + used if no match type is specified. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>ON DELETE <replaceable class="parameter">action</replaceable></term> + <listitem> + <para> + The action to do when a referenced row in the referenced table is being + deleted. There are the following actions. + <variablelist> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Delete any rows referencing the deleted row. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Disallow deletion of rows being referenced. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>SET NULL</term> + <listitem> + <para> + Set the referencing column values to NULL. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>SET DEFAULT</term> + <listitem> + <para> + Set the referencing column values to their default value. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>NO ACTION</term> + <listitem> + <para> + Do nothing. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>ON UPDATE <replaceable class="parameter">action</replaceable></term> + <listitem> + <para> + The action to do when a referenced column in the referenced table is being + updated to a new value. If the row is updated, but the referenced column + is not changed, no action is done. There are the following actions. + <variablelist> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Update the value of the referencing column to the new value of the + referenced column. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Disallow update of row being referenced. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>SET NULL</term> + <listitem> + <para> + Set the referencing column values to NULL. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>SET DEFAULT</term> + <listitem> + <para> + Set the referencing column values to their default value. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>NO ACTION</term> + <listitem> + <para> + Do nothing. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> [ NOT ] DEFERRABLE </term> + <listitem> + <para> + Tells the trigger manager whether this constraint may be + deferred to the end of transaction. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>INITIALLY <replaceable class="parameter"> check time </replaceable></term> + <listitem> + <para> + <replaceable class="parameter">check time</replaceable> has two possible values + which specify the default time to check the constraint. + <variablelist> + <varlistentry> + <term>DEFERRED</term> + <para> + Check this constraint at the end of the transaction. + </para> + </varlistentry> + <varlistentry> + <term>IMMEDIATE</term> + <para> + Check this constraint after each statement. + </para> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect3> + <refsect3 id="R3-SQL-REFERENCES-2"> + <refsect3info> + <date>2000-02-04</date> + </refsect3info> + <title> + Outputs + </title> + <para> + <variablelist> + <varlistentry> + <term><replaceable>status</replaceable></term> + <listitem> + <para> + <variablelist> + <varlistentry> + <term><computeroutput> + ERROR: <replaceable class="parameter">name</replaceable> referential integrity violation - key referenced from + <replaceable class="parameter">table</replaceable> not found in <replaceable class="parameter">referenced table</replaceable> + </computeroutput></term> + <listitem> + <para> + This error occurs at runtime if one tries to insert a value + into a column which does not have a matching column in the + referenced table. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect3> + <refsect3> + <title>Description</title> + <para> + The FOREIGN KEY constraint specifies a rule that a group of one + or more distinct columns of a table are related to a group + of distinct columns in the referenced table. + </para> + + <para> + The FOREIGN KEY table constraint is similar to that for column constraints, + with the additional capability of encompassing multiple columns. + </para> + <para> + Refer to the section on the FOREIGN KEY column constraint for more + information. + </para> + </refsect3> + </refsect2> </refsect1> Index: pg_dump.sgml =================================================================== RCS file: /usr/local/cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v retrieving revision 1.14 diff -c -r1.14 pg_dump.sgml *** pg_dump.sgml 2000/01/24 19:34:13 1.14 --- pg_dump.sgml 2000/02/08 21:55:03 *************** *** 345,350 **** --- 345,360 ---- Large objects are ignored and must be dealt with manually. </para> </listitem> + + <listitem> + <para> + When doing a data only dump, <application>pg_dump</application> emits queries + to disable triggers on user tables before inserting the data and queries to + reenable them after the data has been inserted. If the restore is stopped + in the middle, the system catalogs may be left in the wrong state. + </para> + </listitem> + </itemizedlist> </para> </refsect1>

view thread (11+ messages)  latest in thread

Message-ID: <m12ez1Q-0003knC@orion.SAPserv.Hamburg.dsh.de>
Permalink:  ../m12ez1Q-0003knC@orion.SAPserv.Hamburg.dsh.de/
Also on:    postgresql.org/message-id/m12ez1Q-0003knC@orion.SAPserv.Hamburg.dsh.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: wieck@debis.com, pgman@candle.pha.pa.us, pgsql-hackers@postgresql.org, docs@postgresql.org
  Subject: Re: Updated docs needed for 7.0
  In-Reply-To: <m12ez1Q-0003knC@orion.SAPserv.Hamburg.dsh.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox