diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-07-12 18:43:19 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-07-12 18:43:19 +0000 |
commit | 7c6df91dda27accab3097390ef0d21d93028c7a1 (patch) | |
tree | 5705b975e8de4edf82252e6df28e0bd57c83cb95 /doc/src | |
parent | 791a40f943e2a9353c5823fb4f2bd446ec623d38 (diff) | |
download | postgresql-7c6df91dda27accab3097390ef0d21d93028c7a1.tar.gz postgresql-7c6df91dda27accab3097390ef0d21d93028c7a1.zip |
Second phase of committing Rod Taylor's pg_depend/pg_constraint patch.
pg_relcheck is gone; CHECK, UNIQUE, PRIMARY KEY, and FOREIGN KEY
constraints all have real live entries in pg_constraint. pg_depend
exists, and RESTRICT/CASCADE options work on most kinds of DROP;
however, pg_depend is not yet very well populated with dependencies.
(Most of the ones that are present at this point just replace formerly
hardwired associations, such as the implicit drop of a relation's pg_type
entry when the relation is dropped.) Need to add more logic to create
dependency entries, improve pg_dump to dump constraints in place of
indexes and triggers, and add some regression tests.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/catalogs.sgml | 391 | ||||
-rw-r--r-- | doc/src/sgml/ref/alter_table.sgml | 26 | ||||
-rw-r--r-- | doc/src/sgml/ref/comment.sgml | 5 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_aggregate.sgml | 21 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_domain.sgml | 28 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_function.sgml | 33 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_index.sgml | 21 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_language.sgml | 31 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_operator.sgml | 21 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_rule.sgml | 22 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_sequence.sgml | 23 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_table.sgml | 56 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_trigger.sgml | 21 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_type.sgml | 37 | ||||
-rw-r--r-- | doc/src/sgml/ref/drop_view.sgml | 74 | ||||
-rw-r--r-- | doc/src/sgml/release.sgml | 3 |
16 files changed, 562 insertions, 251 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index c3ed19e4b2a..602680aaacb 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1,6 +1,6 @@ <!-- Documentation of the system catalogs, directed toward PostgreSQL developers - $Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.44 2002/06/20 15:44:06 momjian Exp $ + $Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.45 2002/07/12 18:43:12 tgl Exp $ --> <chapter id="catalogs"> @@ -72,11 +72,21 @@ </row> <row> + <entry>pg_constraint</entry> + <entry>check constraints, unique / primary key constraints, foreign key constraints</entry> + </row> + + <row> <entry>pg_database</entry> <entry>databases within this database cluster</entry> </row> <row> + <entry>pg_depend</entry> + <entry>dependencies between database objects</entry> + </row> + + <row> <entry>pg_description</entry> <entry>descriptions or comments on database objects</entry> </row> @@ -132,11 +142,6 @@ </row> <row> - <entry>pg_relcheck</entry> - <entry>check constraints</entry> - </row> - - <row> <entry>pg_rewrite</entry> <entry>query rewriter rules</entry> </row> @@ -680,7 +685,7 @@ <entry></entry> <entry> Number of check constraints on the table; see - <structname>pg_relcheck</structname> catalog + <structname>pg_constraint</structname> catalog </entry> </row> @@ -764,6 +769,167 @@ </table> </sect1> + <sect1 id="catalog-pg-constraint"> + <title>pg_constraint</title> + + <para> + This system catalog stores CHECK, PRIMARY KEY, UNIQUE, and FOREIGN KEY + constraints on tables. (Column + constraints are not treated specially. Every column constraint is + equivalent to some table constraint.) See under <command>CREATE + TABLE</command> for more information. + </para> + + <note> + <para> + NOT NULL constraints are represented in the <structname>pg_attribute</> + catalog. + </para> + </note> + + <para> + CHECK constraints on domains are stored here, too. Global ASSERTIONS + (a currently-unsupported SQL feature) may someday appear here as well. + </para> + + <table> + <title>pg_constraint Columns</title> + + <tgroup cols=4> + <thead> + <row> + <entry>Name</entry> + <entry>Type</entry> + <entry>References</entry> + <entry>Description</entry> + </row> + </thead> + + <tbody> + <row> + <entry>conname</entry> + <entry><type>name</type></entry> + <entry></entry> + <entry>Constraint name (not necessarily unique!)</entry> + </row> + + <row> + <entry>connamespace</entry> + <entry><type>oid</type></entry> + <entry>pg_namespace.oid</entry> + <entry> + The OID of the namespace that contains this constraint + </entry> + </row> + + <row> + <entry>contype</entry> + <entry><type>char</type></entry> + <entry></entry> + <entry> + 'c' = check constraint, + 'f' = foreign key constraint, + 'p' = primary key constraint, + 'u' = unique constraint + </entry> + </row> + + <row> + <entry>condeferrable</entry> + <entry><type>boolean</type></entry> + <entry></entry> + <entry>Is the constraint deferrable?</entry> + </row> + + <row> + <entry>condeferred</entry> + <entry><type>boolean</type></entry> + <entry></entry> + <entry>Is the constraint deferred by default?</entry> + </row> + + <row> + <entry>conrelid</entry> + <entry><type>oid</type></entry> + <entry>pg_class.oid</entry> + <entry>The table this constraint is on; 0 if not a table constraint</entry> + </row> + + <row> + <entry>contypid</entry> + <entry><type>oid</type></entry> + <entry>pg_type.oid</entry> + <entry>The domain this constraint is on; 0 if not a domain constraint</entry> + </row> + + <row> + <entry>confrelid</entry> + <entry><type>oid</type></entry> + <entry>pg_class.oid</entry> + <entry>If a foreign key, the referenced table; else 0</entry> + </row> + + <row> + <entry>confupdtype</entry> + <entry><type>char</type></entry> + <entry></entry> + <entry>Foreign key update action code</entry> + </row> + + <row> + <entry>confdeltype</entry> + <entry><type>char</type></entry> + <entry></entry> + <entry>Foreign key deletion action code</entry> + </row> + + <row> + <entry>confmatchtype</entry> + <entry><type>char</type></entry> + <entry></entry> + <entry>Foreign key match type</entry> + </row> + + <row> + <entry>conkey</entry> + <entry><type>smallint[]</type></entry> + <entry>pg_attribute.attnum</entry> + <entry>If a table constraint, list of columns which the constraint constrains</entry> + </row> + + <row> + <entry>confkey</entry> + <entry><type>smallint[]</type></entry> + <entry>pg_attribute.attnum</entry> + <entry>If a foreign key, list of the referenced columns</entry> + </row> + + <row> + <entry>conbin</entry> + <entry><type>text</type></entry> + <entry></entry> + <entry>If a check constraint, an internal representation of the expression</entry> + </row> + + <row> + <entry>consrc</entry> + <entry><type>text</type></entry> + <entry></entry> + <entry>If a check constraint, a human-readable representation of the expression</entry> + </row> + </tbody> + </tgroup> + </table> + + <note> + <para> + <structname>pg_class</structname>.<structfield>relchecks</structfield> + needs to agree with the number of check-constraint entries found in this + table for the given relation. + </para> + </note> + + </sect1> <sect1 id="catalog-pg-database"> <title>pg_database</title> @@ -903,6 +1069,151 @@ </sect1> + <sect1 id="catalog-pg-depend"> + <title>pg_depend</title> + + <para> + The <structname>pg_depend</structname> table records the dependency + relationships between database objects. This information allows + <command>DROP</> commands to find which other objects must be dropped + by <command>DROP CASCADE</>, or prevent dropping in the <command>DROP + RESTRICT</> case. + </para> + + <table> + <title>pg_depend Columns</title> + + <tgroup cols=4> + <thead> + <row> + <entry>Name</entry> + <entry>Type</entry> + <entry>References</entry> + <entry>Description</entry> + </row> + </thead> + + <tbody> + <row> + <entry>classid</entry> + <entry><type>oid</type></entry> + <entry>pg_class.oid</entry> + <entry>The oid of the system catalog the dependent object is in</entry> + </row> + + <row> + <entry>objid</entry> + <entry><type>oid</type></entry> + <entry>any oid attribute</entry> + <entry>The oid of the specific dependent object</entry> + </row> + + <row> + <entry>objsubid</entry> + <entry><type>integer</type></entry> + <entry></entry> + <entry>For a table attribute, this is the attribute's + column number (the objid and classid refer to the table itself). + For all other object types, this field is presently zero. + </entry> + </row> + + <row> + <entry>refclassid</entry> + <entry><type>oid</type></entry> + <entry>pg_class.oid</entry> + <entry>The oid of the system catalog the referenced object is in</entry> + </row> + + <row> + <entry>refobjid</entry> + <entry><type>oid</type></entry> + <entry>any oid attribute</entry> + <entry>The oid of the specific referenced object</entry> + </row> + + <row> + <entry>refobjsubid</entry> + <entry><type>integer</type></entry> + <entry></entry> + <entry>For a table attribute, this is the attribute's + column number (the objid and classid refer to the table itself). + For all other object types, this field is presently zero. + </entry> + </row> + + <row> + <entry>deptype</entry> + <entry><type>char</type></entry> + <entry></entry> + <entry> + A code defining the specific semantics of this dependency relationship. + </entry> + </row> + + </tbody> + </tgroup> + </table> + + <para> + In all cases, a <structname>pg_depend</structname> entry indicates that the + referenced object may not be dropped without also dropping the dependent + object. However, there are several subflavors identified by + <structfield>deptype</>: + + <itemizedlist> + <listitem> + <para> + DEPENDENCY_NORMAL ('n'): normal relationship between separately-created + objects. The dependent object may be dropped without affecting the + referenced object. The referenced object may only be dropped by + specifying CASCADE, in which case the dependent object is dropped too. + Example: a table column has a normal dependency on its datatype. + </para> + </listitem> + + <listitem> + <para> + DEPENDENCY_AUTO ('a'): the dependent object can be dropped separately + from the referenced object, and should be automatically dropped + (regardless of RESTRICT or CASCADE mode) if the referenced object + is dropped. + Example: a named constraint on a table is made auto-dependent on + the table, so that it will go away if the table is dropped. + </para> + </listitem> + + <listitem> + <para> + DEPENDENCY_INTERNAL ('i'): the dependent object was created as part + of creation of the referenced object, and is really just a part of + its internal implementation. A DROP of the dependent object will be + disallowed outright (we'll tell the user to issue a DROP against the + referenced object, instead). A DROP of the referenced object will be + propagated through to drop the dependent object whether CASCADE is + specified or not. + Example: a trigger that's created to enforce a foreign-key constraint + is made internally dependent on the constraint's pg_constraint entry. + </para> + </listitem> + + <listitem> + <para> + DEPENDENCY_PIN ('p'): there is no dependent object; this type of entry + is a signal that the system itself depends on the referenced object, + and so that object must never be deleted. Entries of this type are + created only during initdb. The fields for the dependent object + contain zeroes. + </para> + </listitem> + </itemizedlist> + + Other dependency flavors may be needed in future. + </para> + + </sect1> + + <sect1 id="catalog-pg-description"> <title>pg_description</title> @@ -1866,72 +2177,6 @@ </sect1> - - <sect1 id="catalog-pg-relcheck"> - <title>pg_relcheck</title> - - <para> - This system catalog stores CHECK constraints on tables. (Column - constraints are not treated specially. Every column constraint is - equivalent to some table constraint.) See under <command>CREATE - TABLE</command> for more information. - </para> - - <table> - <title>pg_relcheck Columns</title> - - <tgroup cols=4> - <thead> - <row> - <entry>Name</entry> - <entry>Type</entry> - <entry>References</entry> - <entry>Description</entry> - </row> - </thead> - - <tbody> - <row> - <entry>rcrelid</entry> - <entry><type>oid</type></entry> - <entry>pg_class.oid</entry> - <entry>The table this check constraint is on</entry> - </row> - - <row> - <entry>rcname</entry> - <entry><type>name</type></entry> - <entry></entry> - <entry>Constraint name</entry> - </row> - - <row> - <entry>rcbin</entry> - <entry><type>text</type></entry> - <entry></entry> - <entry>An internal representation of the constraint expression</entry> - </row> - - <row> - <entry>rcsrc</entry> - <entry><type>text</type></entry> - <entry></entry> - <entry>A human-readable representation of the constraint expression</entry> - </row> - </tbody> - </tgroup> - </table> - - <note> - <para> - <structname>pg_class</structname>.<structfield>relchecks</structfield> - needs to match up with the entries in this table. - </para> - </note> - - </sect1> - - <sect1 id="catalog-pg-rewrite"> <title>pg_rewrite</title> diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 4966eb757b8..9acd474203c 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.45 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.46 2002/07/12 18:43:12 tgl Exp $ PostgreSQL documentation --> @@ -39,7 +39,7 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable> ALTER TABLE <replaceable class="PARAMETER">table</replaceable> ADD <replaceable class="PARAMETER">table_constraint_definition</replaceable> ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> - DROP CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> { RESTRICT | CASCADE } + DROP CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> [ RESTRICT | CASCADE ] ALTER TABLE <replaceable class="PARAMETER">table</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable> </synopsis> @@ -316,26 +316,6 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable> </para> <para> - In DROP CONSTRAINT, the RESTRICT keyword is required, although - dependencies are not yet checked. The CASCADE option is unsupported. - Currently DROP CONSTRAINT only handles CHECK constraints. - To remove a PRIMARY or UNIQUE constraint, drop the - relevant index using the <xref linkend="SQL-DROPINDEX" endterm="sql-dropindex-title"> command. - To remove FOREIGN KEY 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> - For example, to drop all constraints on a table <literal>distributors</literal>: - <programlisting> -CREATE TABLE temp AS SELECT * FROM distributors; -DROP TABLE distributors; -CREATE TABLE distributors AS SELECT * FROM temp; -DROP TABLE temp; - </programlisting> - </para> - - <para> Changing any part of the schema of a system catalog is not permitted. </para> @@ -395,7 +375,7 @@ ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5); <para> To remove a check constraint from a table and all its children: <programlisting> -ALTER TABLE distributors DROP CONSTRAINT zipchk RESTRICT; +ALTER TABLE distributors DROP CONSTRAINT zipchk; </programlisting> </para> diff --git a/doc/src/sgml/ref/comment.sgml b/doc/src/sgml/ref/comment.sgml index 3d4041ba8ee..ea173e1741a 100644 --- a/doc/src/sgml/ref/comment.sgml +++ b/doc/src/sgml/ref/comment.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/comment.sgml,v 1.19 2002/05/13 17:45:30 tgl Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/comment.sgml,v 1.20 2002/07/12 18:43:12 tgl Exp $ PostgreSQL documentation --> @@ -26,6 +26,7 @@ COMMENT ON TABLE <replaceable class="PARAMETER">object_name</replaceable> | COLUMN <replaceable class="PARAMETER">table_name</replaceable>.<replaceable class="PARAMETER">column_name</replaceable> | AGGREGATE <replaceable class="PARAMETER">agg_name</replaceable> (<replaceable class="PARAMETER">agg_type</replaceable>) | + CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> | DATABASE <replaceable class="PARAMETER">object_name</replaceable> | DOMAIN <replaceable class="PARAMETER">object_name</replaceable> | FUNCTION <replaceable class="PARAMETER">func_name</replaceable> (<replaceable class="PARAMETER">arg1_type</replaceable>, <replaceable class="PARAMETER">arg2_type</replaceable>, ...) | @@ -52,7 +53,7 @@ COMMENT ON <variablelist> <varlistentry> <term><replaceable class="PARAMETER">object_name, - table_name.column_name, agg_name, func_name, op, rule_name, trigger_name</replaceable></term> + table_name.column_name, agg_name, constraint_name, func_name, op, rule_name, trigger_name</replaceable></term> <listitem> <para> The name of the object to be be commented. Names of tables, diff --git a/doc/src/sgml/ref/drop_aggregate.sgml b/doc/src/sgml/ref/drop_aggregate.sgml index 857a7f10f48..9913e5d8ed3 100644 --- a/doc/src/sgml/ref/drop_aggregate.sgml +++ b/doc/src/sgml/ref/drop_aggregate.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_aggregate.sgml,v 1.18 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_aggregate.sgml,v 1.19 2002/07/12 18:43:12 tgl Exp $ PostgreSQL documentation --> @@ -21,7 +21,7 @@ PostgreSQL documentation <date>1999-07-20</date> </refsynopsisdivinfo> <synopsis> -DROP AGGREGATE <replaceable class="PARAMETER">name</replaceable> ( <replaceable class="PARAMETER">type</replaceable> ) +DROP AGGREGATE <replaceable class="PARAMETER">name</replaceable> ( <replaceable class="PARAMETER">type</replaceable> ) [ CASCADE | RESTRICT ] </synopsis> <refsect2 id="R2-SQL-DROPAGGREGATE-1"> @@ -54,6 +54,23 @@ DROP AGGREGATE <replaceable class="PARAMETER">name</replaceable> ( <replaceable </para> </listitem> </varlistentry> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Automatically drop objects that depend on the aggregate. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Refuse to drop the aggregate if there are any dependent objects. + This is the default. + </para> + </listitem> + </varlistentry> </variablelist> </para> </refsect2> diff --git a/doc/src/sgml/ref/drop_domain.sgml b/doc/src/sgml/ref/drop_domain.sgml index 5bc73a065fa..b39e2493021 100644 --- a/doc/src/sgml/ref/drop_domain.sgml +++ b/doc/src/sgml/ref/drop_domain.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_domain.sgml,v 1.6 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_domain.sgml,v 1.7 2002/07/12 18:43:13 tgl Exp $ PostgreSQL documentation --> @@ -48,8 +48,8 @@ DROP DOMAIN <replaceable class="PARAMETER">domainname</replaceable> [, ...] [ C <term><literal>CASCADE</></term> <listitem> <para> - Automatically drop objects that depend on the domain. This - behavior is not currently supported. + Automatically drop objects that depend on the domain + (such as table columns). </para> </listitem> </varlistentry> @@ -58,7 +58,8 @@ DROP DOMAIN <replaceable class="PARAMETER">domainname</replaceable> [, ...] [ C <term><literal>RESTRICT</></term> <listitem> <para> - Do not drop dependent objects. This is the default. + Refuse to drop the domain if there are any dependent objects. + This is the default. </para> </listitem> </varlistentry> @@ -143,19 +144,14 @@ DROP DOMAIN box; <refsect1 id="SQL-DROPDOMAIN-compatibility"> <title>Compatibility</title> + + <refsect2 id="R2-SQL-DROPDOMAIN-sql92"> + <title> + SQL92 + </title> - <para> - A <command>DROP DOMAIN</command> statement exists in SQL99. As with - most other <quote>drop</quote> commands, <command>DROP - DOMAIN</command> in SQL99 requires a <quote>drop behavior</quote> - clause to select between dropping all dependent objects or refusing - to drop if dependent objects exist: -<synopsis> -DROP DOMAIN <replaceable>name</replaceable> { CASCADE | RESTRICT } -</synopsis> - <productname>PostgreSQL</productname> accepts only the RESTRICT - option, and currently does not check for existence of dependent objects. - </para> + <para></para> + </refsect2> </refsect1> <refsect1 id="SQL-DROPDOMAIN-see-also"> diff --git a/doc/src/sgml/ref/drop_function.sgml b/doc/src/sgml/ref/drop_function.sgml index 268d8c66e8c..5aa1b141bad 100644 --- a/doc/src/sgml/ref/drop_function.sgml +++ b/doc/src/sgml/ref/drop_function.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_function.sgml,v 1.20 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_function.sgml,v 1.21 2002/07/12 18:43:13 tgl Exp $ PostgreSQL documentation --> @@ -21,7 +21,7 @@ PostgreSQL documentation <date>1999-07-20</date> </refsynopsisdivinfo> <synopsis> -DROP FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceable class="parameter">type</replaceable> [, ...] ] ) +DROP FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceable class="parameter">type</replaceable> [, ...] ] ) [ CASCADE | RESTRICT ] </synopsis> <refsect2 id="R2-SQL-DROPFUNCTION-1"> @@ -49,6 +49,24 @@ DROP FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceable </para> </listitem> </varlistentry> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Automatically drop objects that depend on the function + (such as operators or triggers). + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Refuse to drop the function if there are any dependent objects. + This is the default. + </para> + </listitem> + </varlistentry> </variablelist> </para> </refsect2> @@ -136,15 +154,8 @@ DROP FUNCTION sqrt(integer); <title>Compatibility</title> <para> - A <command>DROP FUNCTION</command> statement is defined in SQL99. One of its syntax forms is: - -<synopsis> -DROP FUNCTION <replaceable class="parameter">name</replaceable> (<replaceable>arg</>, ...) { RESTRICT | CASCADE } -</synopsis> - - where <literal>CASCADE</> specifies dropping all objects that - depend on the function and <literal>RESTRICT</literal> refuses to - drop the function if dependent objects exist. + A <command>DROP FUNCTION</command> statement is defined in SQL99. One of + its syntax forms is similar to PostgreSQL's. </para> </refsect1> diff --git a/doc/src/sgml/ref/drop_index.sgml b/doc/src/sgml/ref/drop_index.sgml index 0db2c609461..149afff0779 100644 --- a/doc/src/sgml/ref/drop_index.sgml +++ b/doc/src/sgml/ref/drop_index.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_index.sgml,v 1.15 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_index.sgml,v 1.16 2002/07/12 18:43:13 tgl Exp $ PostgreSQL documentation --> @@ -21,7 +21,7 @@ PostgreSQL documentation <date>1999-07-20</date> </refsynopsisdivinfo> <synopsis> -DROP INDEX <replaceable class="PARAMETER">index_name</replaceable> [, ...] +DROP INDEX <replaceable class="PARAMETER">index_name</replaceable> [, ...] [ CASCADE | RESTRICT ] </synopsis> <refsect2 id="R2-SQL-DROPINDEX-1"> @@ -41,6 +41,23 @@ DROP INDEX <replaceable class="PARAMETER">index_name</replaceable> [, ...] </para> </listitem> </varlistentry> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Automatically drop objects that depend on the index. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Refuse to drop the index if there are any dependent objects. + This is the default. + </para> + </listitem> + </varlistentry> </variablelist> </para> </refsect2> diff --git a/doc/src/sgml/ref/drop_language.sgml b/doc/src/sgml/ref/drop_language.sgml index 08badab8083..e0690a88ac6 100644 --- a/doc/src/sgml/ref/drop_language.sgml +++ b/doc/src/sgml/ref/drop_language.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_language.sgml,v 1.14 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_language.sgml,v 1.15 2002/07/12 18:43:13 tgl Exp $ PostgreSQL documentation --> @@ -21,7 +21,7 @@ PostgreSQL documentation <date>1999-07-20</date> </refsynopsisdivinfo> <synopsis> -DROP [ PROCEDURAL ] LANGUAGE <replaceable class="PARAMETER">name</replaceable> +DROP [ PROCEDURAL ] LANGUAGE <replaceable class="PARAMETER">name</replaceable> [ CASCADE | RESTRICT ] </synopsis> <refsect2 id="R2-SQL-DROPLANGUAGE-1"> @@ -43,7 +43,26 @@ DROP [ PROCEDURAL ] LANGUAGE <replaceable class="PARAMETER">name</replaceable> </para> </listitem> </varlistentry> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Automatically drop objects that depend on the language + (such as functions in the language). + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Refuse to drop the language if there are any dependent objects. + This is the default. + </para> + </listitem> + </varlistentry> </variablelist> + </para> </refsect2> @@ -112,14 +131,6 @@ ERROR: Language "<replaceable class="parameter">name</replaceable>" doesn't exis <xref linkend="sql-createlanguage" endterm="sql-createlanguage-title"> for information on how to create procedural languages. </para> - - <para> - No checks are made if functions or trigger procedures registered - in this language still exist. To re-enable them without having - to drop and recreate all the functions, the pg_proc's prolang - attribute of the functions must be adjusted to the new object - ID of the recreated pg_language entry for the PL. - </para> </refsect2> </refsect1> diff --git a/doc/src/sgml/ref/drop_operator.sgml b/doc/src/sgml/ref/drop_operator.sgml index bc4657038fd..1cfb824090c 100644 --- a/doc/src/sgml/ref/drop_operator.sgml +++ b/doc/src/sgml/ref/drop_operator.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_operator.sgml,v 1.16 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_operator.sgml,v 1.17 2002/07/12 18:43:13 tgl Exp $ PostgreSQL documentation --> @@ -22,7 +22,7 @@ PostgreSQL documentation <date>1999-07-20</date> </refsynopsisdivinfo> <synopsis> -DROP OPERATOR <replaceable class="PARAMETER">id</replaceable> ( <replaceable class="PARAMETER">lefttype</replaceable> | NONE , <replaceable class="PARAMETER">righttype</replaceable> | NONE ) +DROP OPERATOR <replaceable class="PARAMETER">id</replaceable> ( <replaceable class="PARAMETER">lefttype</replaceable> | NONE , <replaceable class="PARAMETER">righttype</replaceable> | NONE ) [ CASCADE | RESTRICT ] </synopsis> <refsect2 id="R2-SQL-DROPOPERATOR-1"> @@ -60,6 +60,23 @@ DROP OPERATOR <replaceable class="PARAMETER">id</replaceable> ( <replaceable cla </para> </listitem> </varlistentry> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Automatically drop objects that depend on the operator. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Refuse to drop the operator if there are any dependent objects. + This is the default. + </para> + </listitem> + </varlistentry> </variablelist> </para> </refsect2> diff --git a/doc/src/sgml/ref/drop_rule.sgml b/doc/src/sgml/ref/drop_rule.sgml index 4f8ea97f88d..afb1b6a874b 100644 --- a/doc/src/sgml/ref/drop_rule.sgml +++ b/doc/src/sgml/ref/drop_rule.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_rule.sgml,v 1.15 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_rule.sgml,v 1.16 2002/07/12 18:43:13 tgl Exp $ PostgreSQL documentation --> @@ -21,7 +21,7 @@ PostgreSQL documentation <date>1998-09-22</date> </refsynopsisdivinfo> <synopsis> -DROP RULE <replaceable class="PARAMETER">name</replaceable> ON <replaceable class="PARAMETER">relation</replaceable> +DROP RULE <replaceable class="PARAMETER">name</replaceable> ON <replaceable class="PARAMETER">relation</replaceable> [ CASCADE | RESTRICT ] </synopsis> <refsect2 id="R2-SQL-DROPRULE-1"> @@ -50,7 +50,25 @@ DROP RULE <replaceable class="PARAMETER">name</replaceable> ON <replaceable clas </para> </listitem> </varlistentry> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Automatically drop objects that depend on the rule. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Refuse to drop the rule if there are any dependent objects. + This is the default. + </para> + </listitem> + </varlistentry> </variablelist> + </para> </refsect2> diff --git a/doc/src/sgml/ref/drop_sequence.sgml b/doc/src/sgml/ref/drop_sequence.sgml index 4c371164e1e..50623849342 100644 --- a/doc/src/sgml/ref/drop_sequence.sgml +++ b/doc/src/sgml/ref/drop_sequence.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_sequence.sgml,v 1.14 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_sequence.sgml,v 1.15 2002/07/12 18:43:13 tgl Exp $ PostgreSQL documentation --> @@ -21,7 +21,8 @@ PostgreSQL documentation <date>1999-07-20</date> </refsynopsisdivinfo> <synopsis> -DROP SEQUENCE <replaceable class="PARAMETER">name</replaceable> [, ...] +DROP SEQUENCE <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ] + </synopsis> <refsect2 id="R2-SQL-DROPSEQUENCE-1"> @@ -75,7 +76,25 @@ ERROR: sequence "<replaceable class="parameter">name</replaceable>" does not exi </para> </listitem> </varlistentry> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Automatically drop objects that depend on the sequence. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Refuse to drop the sequence if there are any dependent objects. + This is the default. + </para> + </listitem> + </varlistentry> </variablelist> + </para> </refsect2> </refsynopsisdiv> diff --git a/doc/src/sgml/ref/drop_table.sgml b/doc/src/sgml/ref/drop_table.sgml index cae3275067d..23148ff827d 100644 --- a/doc/src/sgml/ref/drop_table.sgml +++ b/doc/src/sgml/ref/drop_table.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_table.sgml,v 1.15 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_table.sgml,v 1.16 2002/07/12 18:43:13 tgl Exp $ PostgreSQL documentation --> @@ -21,7 +21,8 @@ PostgreSQL documentation <date>1999-07-20</date> </refsynopsisdivinfo> <synopsis> -DROP TABLE <replaceable class="PARAMETER">name</replaceable> [, ...] +DROP TABLE <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ] + </synopsis> <refsect2 id="R2-SQL-DROPTABLE-1"> @@ -41,6 +42,24 @@ DROP TABLE <replaceable class="PARAMETER">name</replaceable> [, ...] </para> </listitem> </varlistentry> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Automatically drop objects that depend on the table + (such as views). + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Refuse to drop the table if there are any dependent objects. + This is the default. + </para> + </listitem> + </varlistentry> </variablelist> </para> </refsect2> @@ -136,44 +155,11 @@ DROP TABLE films, distributors; </title> <refsect2 id="R2-SQL-DROPTABLE-4"> - <refsect2info> - <date>1998-09-22</date> - </refsect2info> <title> SQL92 </title> <para> - SQL92 specifies some additional capabilities for DROP TABLE: </para> - <synopsis> -DROP TABLE <replaceable class="parameter">table</replaceable> { RESTRICT | CASCADE } - </synopsis> - <variablelist> - <varlistentry> - <term>RESTRICT</term> - <listitem> - <para> - Ensures that only a table with no dependent views or - integrity constraints can be destroyed. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term>CASCADE</term> - <listitem> - <para> - Any referencing views or integrity constraints - will also be dropped. - </para> - </listitem> - </varlistentry> - </variablelist> - <tip> - <para> - At present, to remove a referencing view you must drop - it explicitly. - </para> - </tip> </refsect2> </refsect1> </refentry> diff --git a/doc/src/sgml/ref/drop_trigger.sgml b/doc/src/sgml/ref/drop_trigger.sgml index e4f157b1d7c..c154d8117db 100644 --- a/doc/src/sgml/ref/drop_trigger.sgml +++ b/doc/src/sgml/ref/drop_trigger.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_trigger.sgml,v 1.12 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_trigger.sgml,v 1.13 2002/07/12 18:43:13 tgl Exp $ PostgreSQL documentation --> @@ -21,7 +21,7 @@ PostgreSQL documentation <date>1998-09-22</date> </refsynopsisdivinfo> <synopsis> -DROP TRIGGER <replaceable class="PARAMETER">name</replaceable> ON <replaceable class="PARAMETER">table</replaceable> +DROP TRIGGER <replaceable class="PARAMETER">name</replaceable> ON <replaceable class="PARAMETER">table</replaceable> [ CASCADE | RESTRICT ] </synopsis> <refsect2 id="R2-SQL-DROPTRIGGER-1"> @@ -50,6 +50,23 @@ DROP TRIGGER <replaceable class="PARAMETER">name</replaceable> ON <replaceable c </para> </listitem> </varlistentry> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Automatically drop objects that depend on the trigger. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Refuse to drop the trigger if there are any dependent objects. + This is the default. + </para> + </listitem> + </varlistentry> </variablelist> </para> </refsect2> diff --git a/doc/src/sgml/ref/drop_type.sgml b/doc/src/sgml/ref/drop_type.sgml index 3ac0f17ae9f..81cf010bb00 100644 --- a/doc/src/sgml/ref/drop_type.sgml +++ b/doc/src/sgml/ref/drop_type.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_type.sgml,v 1.17 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_type.sgml,v 1.18 2002/07/12 18:43:13 tgl Exp $ PostgreSQL documentation --> @@ -21,7 +21,8 @@ PostgreSQL documentation <date>1999-07-20</date> </refsynopsisdivinfo> <synopsis> -DROP TYPE <replaceable class="PARAMETER">typename</replaceable> [, ...] +DROP TYPE <replaceable class="PARAMETER">typename</replaceable> [, ...] [ CASCADE | RESTRICT ] + </synopsis> <refsect2 id="R2-SQL-DROPTYPE-1"> @@ -41,6 +42,24 @@ DROP TYPE <replaceable class="PARAMETER">typename</replaceable> [, ...] </para> </listitem> </varlistentry> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Automatically drop objects that depend on the type + (such as table columns, functions, operators, etc). + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Refuse to drop the type if there are any dependent objects. + This is the default. + </para> + </listitem> + </varlistentry> </variablelist> </para> </refsect2> @@ -75,6 +94,7 @@ ERROR: RemoveType: type '<replaceable class="parameter">typename</replaceable>' </listitem> </varlistentry> </variablelist> + </para> </refsect2> </refsynopsisdiv> @@ -133,19 +153,6 @@ DROP TYPE box; <title>Compatibility</title> <para> - A <command>DROP TYPE</command> statement exists in SQL99. As with - most other <quote>drop</quote> commands, <command>DROP - TYPE</command> in SQL99 requires a <quote>drop behavior</quote> - clause to select between dropping all dependent objects or refusing - to drop if dependent objects exist: -<synopsis> -DROP TYPE <replaceable>name</replaceable> { CASCADE | RESTRICT } -</synopsis> - <productname>PostgreSQL</productname> currently ignores - dependencies altogether. - </para> - - <para> Note that the <command>CREATE TYPE</command> command and the data type extension mechanisms in <productname>PostgreSQL</productname> differ from SQL99. diff --git a/doc/src/sgml/ref/drop_view.sgml b/doc/src/sgml/ref/drop_view.sgml index a789e38c4ce..52711d984ef 100644 --- a/doc/src/sgml/ref/drop_view.sgml +++ b/doc/src/sgml/ref/drop_view.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_view.sgml,v 1.14 2002/05/18 15:44:47 petere Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_view.sgml,v 1.15 2002/07/12 18:43:13 tgl Exp $ PostgreSQL documentation --> @@ -21,7 +21,7 @@ PostgreSQL documentation <date>1999-07-20</date> </refsynopsisdivinfo> <synopsis> -DROP VIEW <replaceable class="PARAMETER">name</replaceable> [, ...] +DROP VIEW <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ] </synopsis> <refsect2 id="R2-SQL-DROPVIEW-1"> @@ -42,7 +42,26 @@ DROP VIEW <replaceable class="PARAMETER">name</replaceable> [, ...] </para> </listitem> </varlistentry> + <varlistentry> + <term>CASCADE</term> + <listitem> + <para> + Automatically drop objects that depend on the view + (such as other views). + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>RESTRICT</term> + <listitem> + <para> + Refuse to drop the view if there are any dependent objects. + This is the default. + </para> + </listitem> + </varlistentry> </variablelist> + </para> </refsect2> @@ -134,58 +153,7 @@ DROP VIEW kinds; SQL92 </title> <para> - <acronym>SQL92</acronym> specifies some additional capabilities for - <command>DROP VIEW</command>: - - <synopsis> -DROP VIEW <replaceable class="parameter">view</replaceable> { RESTRICT | CASCADE } - </synopsis> </para> - - <refsect3 id="R3-SQL-DROPVIEW-1"> - <refsect3info> - <date>1998-09-22</date> - </refsect3info> - <title> - Inputs - </title> - <para> - <variablelist> - <varlistentry> - <term>RESTRICT</term> - <listitem> - <para> - Ensures that only a view with no dependent views or - integrity constraints can be destroyed. - </para> - </listitem> - </varlistentry> - <varlistentry> - <term>CASCADE</term> - <listitem> - <para> - Any referencing views and integrity constraints - will be dropped as well. - </para> - </listitem> - </varlistentry> - </variablelist> - </para> - </refsect3> - - <refsect3 id="R3-SQL-DROPVIEW-2"> - <refsect3info> - <date>1998-09-22</date> - </refsect3info> - <title> - Notes - </title> - <para> - At present, to remove a referencing view from a - <productname>PostgreSQL</productname> database, - you must drop it explicitly. - </para> - </refsect3> </refsect2> </refsect1> </refentry> diff --git a/doc/src/sgml/release.sgml b/doc/src/sgml/release.sgml index 9cd74fae205..7fd8c92e371 100644 --- a/doc/src/sgml/release.sgml +++ b/doc/src/sgml/release.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.139 2002/06/11 15:32:33 thomas Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.140 2002/07/12 18:43:12 tgl Exp $ --> <appendix id="release"> @@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without worries about funny characters. --> <literallayout><![CDATA[ +Most forms of DROP now support RESTRICT and CASCADE options Recursive SQL functions can be defined User-defined procedural languages can register a validator function to check new functions as they are created Functions can be executed with the privileges of the owner |