mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
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
This commit is contained in:
@ -2876,6 +2876,19 @@
|
||||
</listitem>
|
||||
</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>
|
||||
|
@ -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>
|
||||
@ -299,6 +310,15 @@ ALTER FUNCTION sqrt(integer) SET SCHEMA maths;
|
||||
</programlisting>
|
||||
</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>
|
||||
|
@ -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> [, ... ] ]
|
||||
@ -82,6 +83,16 @@ ALTER INDEX ALL IN TABLESPACE <replaceable class="PARAMETER">name</replaceable>
|
||||
</listitem>
|
||||
</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>
|
||||
@ -147,6 +158,15 @@ ALTER INDEX ALL IN TABLESPACE <replaceable class="PARAMETER">name</replaceable>
|
||||
</listitem>
|
||||
</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>
|
||||
|
@ -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>
|
||||
@ -67,6 +69,12 @@ ALTER MATERIALIZED VIEW ALL IN TABLESPACE <replaceable class="parameter">name</r
|
||||
anyway.)
|
||||
</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
|
||||
@ -99,6 +107,15 @@ ALTER MATERIALIZED VIEW ALL IN TABLESPACE <replaceable class="parameter">name</r
|
||||
</listitem>
|
||||
</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>
|
||||
|
@ -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>
|
||||
|
||||
@ -92,6 +104,12 @@ ALTER TRIGGER <replaceable class="PARAMETER">name</replaceable> ON <replaceable
|
||||
To rename an existing trigger:
|
||||
<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>
|
||||
|
||||
|
Reference in New Issue
Block a user