From f2fcad27d59c8e5c48f8fa0a96c8355e40f24273 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Tue, 5 Apr 2016 18:38:54 -0300 Subject: Support ALTER THING .. DEPENDS ON EXTENSION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- doc/src/sgml/catalogs.sgml | 13 +++++++++++++ doc/src/sgml/ref/alter_function.sgml | 20 ++++++++++++++++++++ doc/src/sgml/ref/alter_index.sgml | 20 ++++++++++++++++++++ doc/src/sgml/ref/alter_materialized_view.sgml | 17 +++++++++++++++++ doc/src/sgml/ref/alter_trigger.sgml | 20 +++++++++++++++++++- 5 files changed, 89 insertions(+), 1 deletion(-) (limited to 'doc/src') 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 @@ -2876,6 +2876,19 @@ + + DEPENDENCY_AUTO_EXTENSION (x) + + + 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. + + + + DEPENDENCY_PIN (p) 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 name ( [ [ argmode ] [ argname ] argtype [, ...] ] ) SET SCHEMA new_schema +ALTER FUNCTION name ( [ [ argmode ] [ argname ] argtype [, ...] ] ) + DEPENDS ON EXTENSION extension_name where action is one of: @@ -148,6 +150,15 @@ ALTER FUNCTION name ( [ [ extension_name + + + The name of the extension that the function is to depend on. + + + + CALLED ON NULL INPUT RETURNS NULL ON NULL INPUT @@ -299,6 +310,15 @@ ALTER FUNCTION sqrt(integer) SET SCHEMA maths; + + To mark the function sqrt for type + integer as being dependent on the extension + mathlib: + +ALTER FUNCTION sqrt(integer) DEPENDS ON EXTENSION mathlib; + + + To adjust the search path that is automatically set for a function: 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 ALTER INDEX [ IF EXISTS ] name RENAME TO new_name ALTER INDEX [ IF EXISTS ] name SET TABLESPACE tablespace_name +ALTER INDEX name DEPENDS ON EXTENSION extension_name ALTER INDEX [ IF EXISTS ] name SET ( storage_parameter = value [, ... ] ) ALTER INDEX [ IF EXISTS ] name RESET ( storage_parameter [, ... ] ) ALTER INDEX ALL IN TABLESPACE name [ OWNED BY role_name [, ... ] ] @@ -82,6 +83,16 @@ ALTER INDEX ALL IN TABLESPACE name + + DEPENDS ON EXTENSION + + + 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. + + + + SET ( storage_parameter = value [, ... ] ) @@ -147,6 +158,15 @@ ALTER INDEX ALL IN TABLESPACE name + + extension_name + + + The name of the extension that the index is to depend on. + + + + storage_parameter 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 ALTER MATERIALIZED VIEW [ IF EXISTS ] name action [, ... ] +ALTER MATERIALIZED VIEW name + DEPENDS ON EXTENSION extension_name ALTER MATERIALIZED VIEW [ IF EXISTS ] name RENAME [ COLUMN ] column_name TO new_column_name ALTER MATERIALIZED VIEW [ IF EXISTS ] name @@ -67,6 +69,12 @@ ALTER MATERIALIZED VIEW ALL IN TABLESPACE name + + The DEPENDS ON EXTENSION form marks the materialized view + as dependent on an extension, such that the materialized view will + automatically be dropped if the extension is dropped. + + The statement subforms and actions available for ALTER MATERIALIZED VIEW are a subset of those available @@ -99,6 +107,15 @@ ALTER MATERIALIZED VIEW ALL IN TABLESPACE name + + extension_name + + + The name of the extension that the materialized view is to depend on. + + + + new_column_name 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 ALTER TRIGGER name ON table_name RENAME TO new_name +ALTER TRIGGER name ON table_name DEPENDS ON EXTENSION extension_name @@ -32,7 +33,9 @@ ALTER TRIGGER name ON ALTER TRIGGER changes properties of an existing trigger. The RENAME clause changes the name of the given trigger without otherwise changing the trigger - definition. + definition. The DEPENDS ON EXTENSION clause marks + the trigger as dependent on an extension, such that if the extension is + dropped, the trigger will automatically be dropped as well. @@ -70,6 +73,15 @@ ALTER TRIGGER name ON + + + extension_name + + + The name of the extension that the trigger is to depend on. + + + @@ -92,6 +104,12 @@ ALTER TRIGGER name ON ALTER TRIGGER emp_stamp ON emp RENAME TO emp_track_chgs; + + + + To mark a trigger as being dependent on an extension: + +ALTER TRIGGER emp_stamp ON emp DEPENDS ON EXTENSION emplib; -- cgit v1.2.3