diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2016-04-05 18:38:54 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2016-04-05 18:38:54 -0300 |
commit | f2fcad27d59c8e5c48f8fa0a96c8355e40f24273 (patch) | |
tree | 8630b838513cbd3e2d846a68bf9db6a5f2f9c7b1 /doc/src | |
parent | 41ea0c23761ca108e2f08f6e3151e3cb1f9652a1 (diff) |
Support ALTER THING .. DEPENDS ON EXTENSION
This introduces a new dependency type which marks an object as depending
on an extension, such that if the extension is dropped, the object
automatically goes away; and also, if the database is dumped, the object
is included in the dump output. Currently the grammar supports this for
indexes, triggers, materialized views and functions only, although the
utility code is generic so adding support for more object types is a
matter of touching the parser rules only.
Author: Abhijit Menon-Sen
Reviewed-by: Alexander Korotkov, Álvaro Herrera
Discussion: http://www.postgresql.org/message-id/20160115062649.GA5068@toroid.org
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/catalogs.sgml | 13 | ||||
-rw-r--r-- | doc/src/sgml/ref/alter_function.sgml | 20 | ||||
-rw-r--r-- | doc/src/sgml/ref/alter_index.sgml | 20 | ||||
-rw-r--r-- | doc/src/sgml/ref/alter_materialized_view.sgml | 17 | ||||
-rw-r--r-- | doc/src/sgml/ref/alter_trigger.sgml | 20 |
5 files changed, 89 insertions, 1 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index bb752294c3f..725bacee5dd 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -2877,6 +2877,19 @@ </varlistentry> <varlistentry> + <term><symbol>DEPENDENCY_AUTO_EXTENSION</> (<literal>x</>)</term> + <listitem> + <para> + The dependent object is not a member of the extension that is the + referenced object (and so should not be ignored by pg_dump), but + cannot function without it and should be dropped when the + extension itself is. The dependent object may be dropped on its + own as well. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><symbol>DEPENDENCY_PIN</> (<literal>p</>)</term> <listitem> <para> diff --git a/doc/src/sgml/ref/alter_function.sgml b/doc/src/sgml/ref/alter_function.sgml index f40363e4aa5..865d52b5919 100644 --- a/doc/src/sgml/ref/alter_function.sgml +++ b/doc/src/sgml/ref/alter_function.sgml @@ -29,6 +29,8 @@ ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="paramet OWNER TO { <replaceable>new_owner</replaceable> | CURRENT_USER | SESSION_USER } ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) SET SCHEMA <replaceable>new_schema</replaceable> +ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) + DEPENDS ON EXTENSION <replaceable>extension_name</replaceable> <phrase>where <replaceable class="PARAMETER">action</replaceable> is one of:</phrase> @@ -148,6 +150,15 @@ ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="paramet </listitem> </varlistentry> + <varlistentry> + <term><replaceable class="parameter">extension_name</replaceable></term> + <listitem> + <para> + The name of the extension that the function is to depend on. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><literal>CALLED ON NULL INPUT</literal></term> <term><literal>RETURNS NULL ON NULL INPUT</literal></term> @@ -300,6 +311,15 @@ ALTER FUNCTION sqrt(integer) SET SCHEMA maths; </para> <para> + To mark the function <literal>sqrt</literal> for type + <type>integer</type> as being dependent on the extension + <literal>mathlib</literal>: +<programlisting> +ALTER FUNCTION sqrt(integer) DEPENDS ON EXTENSION mathlib; +</programlisting> + </para> + + <para> To adjust the search path that is automatically set for a function: <programlisting> ALTER FUNCTION check_password(text) SET search_path = admin, pg_temp; diff --git a/doc/src/sgml/ref/alter_index.sgml b/doc/src/sgml/ref/alter_index.sgml index ee3e3de4d6f..54f3a56d3c0 100644 --- a/doc/src/sgml/ref/alter_index.sgml +++ b/doc/src/sgml/ref/alter_index.sgml @@ -23,6 +23,7 @@ PostgreSQL documentation <synopsis> ALTER INDEX [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable class="PARAMETER">new_name</replaceable> ALTER INDEX [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> SET TABLESPACE <replaceable class="PARAMETER">tablespace_name</replaceable> +ALTER INDEX <replaceable class="PARAMETER">name</replaceable> DEPENDS ON EXTENSION <replaceable class="PARAMETER">extension_name</replaceable> ALTER INDEX [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> SET ( <replaceable class="PARAMETER">storage_parameter</replaceable> = <replaceable class="PARAMETER">value</replaceable> [, ... ] ) ALTER INDEX [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> RESET ( <replaceable class="PARAMETER">storage_parameter</replaceable> [, ... ] ) ALTER INDEX ALL IN TABLESPACE <replaceable class="PARAMETER">name</replaceable> [ OWNED BY <replaceable class="PARAMETER">role_name</replaceable> [, ... ] ] @@ -83,6 +84,16 @@ ALTER INDEX ALL IN TABLESPACE <replaceable class="PARAMETER">name</replaceable> </varlistentry> <varlistentry> + <term><literal>DEPENDS ON EXTENSION</literal></term> + <listitem> + <para> + This form marks the index as dependent on the extension, such that if the + extension is dropped, the index will automatically be dropped as well. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><literal>SET ( <replaceable class="PARAMETER">storage_parameter</replaceable> = <replaceable class="PARAMETER">value</replaceable> [, ... ] )</literal></term> <listitem> <para> @@ -148,6 +159,15 @@ ALTER INDEX ALL IN TABLESPACE <replaceable class="PARAMETER">name</replaceable> </varlistentry> <varlistentry> + <term><replaceable class="PARAMETER">extension_name</replaceable></term> + <listitem> + <para> + The name of the extension that the index is to depend on. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><replaceable class="PARAMETER">storage_parameter</replaceable></term> <listitem> <para> diff --git a/doc/src/sgml/ref/alter_materialized_view.sgml b/doc/src/sgml/ref/alter_materialized_view.sgml index 8807e01c365..b5c44bfabf4 100644 --- a/doc/src/sgml/ref/alter_materialized_view.sgml +++ b/doc/src/sgml/ref/alter_materialized_view.sgml @@ -23,6 +23,8 @@ PostgreSQL documentation <synopsis> ALTER MATERIALIZED VIEW [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> <replaceable class="PARAMETER">action</replaceable> [, ... ] +ALTER MATERIALIZED VIEW <replaceable class="PARAMETER">name</replaceable> + DEPENDS ON EXTENSION <replaceable class="PARAMETER">extension_name</replaceable> ALTER MATERIALIZED VIEW [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> RENAME [ COLUMN ] <replaceable class="PARAMETER">column_name</replaceable> TO <replaceable class="PARAMETER">new_column_name</replaceable> ALTER MATERIALIZED VIEW [ IF EXISTS ] <replaceable class="parameter">name</replaceable> @@ -68,6 +70,12 @@ ALTER MATERIALIZED VIEW ALL IN TABLESPACE <replaceable class="parameter">name</r </para> <para> + The <literal>DEPENDS ON EXTENSION</literal> form marks the materialized view + as dependent on an extension, such that the materialized view will + automatically be dropped if the extension is dropped. + </para> + + <para> The statement subforms and actions available for <command>ALTER MATERIALIZED VIEW</command> are a subset of those available for <command>ALTER TABLE</command>, and have the same meaning when used for @@ -100,6 +108,15 @@ ALTER MATERIALIZED VIEW ALL IN TABLESPACE <replaceable class="parameter">name</r </varlistentry> <varlistentry> + <term><replaceable class="PARAMETER">extension_name</replaceable></term> + <listitem> + <para> + The name of the extension that the materialized view is to depend on. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><replaceable class="PARAMETER">new_column_name</replaceable></term> <listitem> <para> diff --git a/doc/src/sgml/ref/alter_trigger.sgml b/doc/src/sgml/ref/alter_trigger.sgml index c63b5dfa02b..47eef6e5e88 100644 --- a/doc/src/sgml/ref/alter_trigger.sgml +++ b/doc/src/sgml/ref/alter_trigger.sgml @@ -22,6 +22,7 @@ PostgreSQL documentation <refsynopsisdiv> <synopsis> ALTER TRIGGER <replaceable class="PARAMETER">name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> RENAME TO <replaceable class="PARAMETER">new_name</replaceable> +ALTER TRIGGER <replaceable class="PARAMETER">name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> DEPENDS ON EXTENSION <replaceable class="PARAMETER">extension_name</replaceable> </synopsis> </refsynopsisdiv> @@ -32,7 +33,9 @@ ALTER TRIGGER <replaceable class="PARAMETER">name</replaceable> ON <replaceable <command>ALTER TRIGGER</command> changes properties of an existing trigger. The <literal>RENAME</literal> clause changes the name of the given trigger without otherwise changing the trigger - definition. + definition. The <literal>DEPENDS ON EXTENSION</literal> clause marks + the trigger as dependent on an extension, such that if the extension is + dropped, the trigger will automatically be dropped as well. </para> <para> @@ -70,6 +73,15 @@ ALTER TRIGGER <replaceable class="PARAMETER">name</replaceable> ON <replaceable </para> </listitem> </varlistentry> + + <varlistentry> + <term><replaceable class="PARAMETER">extension_name</replaceable></term> + <listitem> + <para> + The name of the extension that the trigger is to depend on. + </para> + </listitem> + </varlistentry> </variablelist> </refsect1> @@ -93,6 +105,12 @@ ALTER TRIGGER <replaceable class="PARAMETER">name</replaceable> ON <replaceable <programlisting> ALTER TRIGGER emp_stamp ON emp RENAME TO emp_track_chgs; </programlisting></para> + + <para> + To mark a trigger as being dependent on an extension: +<programlisting> +ALTER TRIGGER emp_stamp ON emp DEPENDS ON EXTENSION emplib; +</programlisting></para> </refsect1> <refsect1> |