From cec3b0a9e63fd94b05dac894cca8bfa51358afec Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Mon, 21 Nov 2005 12:49:33 +0000 Subject: Implement DROP OWNED and REASSIGN OWNED. These new commands facilitate the process of dropping roles by dropping objects owned by them and privileges granted to them, or giving the owned objects to someone else, through the use of the data stored in the new pg_shdepend catalog. Some refactoring of the GRANT/REVOKE code was needed, as well as ALTER OWNER code. Further cleanup of code duplication in the GRANT code seems necessary. Implemented by me after an idea from Tom Lane, who also provided various kind of implementation advice. Regression tests pass. Some tests for the new functionality are also added, as well as rudimentary documentation. --- doc/src/sgml/ref/allfiles.sgml | 4 +- doc/src/sgml/ref/drop_owned.sgml | 99 ++++++++++++++++++++++++++++++++++++ doc/src/sgml/ref/reassign_owned.sgml | 89 ++++++++++++++++++++++++++++++++ doc/src/sgml/reference.sgml | 4 +- 4 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 doc/src/sgml/ref/drop_owned.sgml create mode 100644 doc/src/sgml/ref/reassign_owned.sgml (limited to 'doc/src') diff --git a/doc/src/sgml/ref/allfiles.sgml b/doc/src/sgml/ref/allfiles.sgml index c08b09b67d4..07dd0b0ee74 100644 --- a/doc/src/sgml/ref/allfiles.sgml +++ b/doc/src/sgml/ref/allfiles.sgml @@ -1,5 +1,5 @@ @@ -70,6 +70,7 @@ Complete list of usable sgml source files in this directory. + @@ -93,6 +94,7 @@ Complete list of usable sgml source files in this directory. + diff --git a/doc/src/sgml/ref/drop_owned.sgml b/doc/src/sgml/ref/drop_owned.sgml new file mode 100644 index 00000000000..dc8b01fe984 --- /dev/null +++ b/doc/src/sgml/ref/drop_owned.sgml @@ -0,0 +1,99 @@ + + + + + DROP OWNED + SQL - Language Statements + + + + DROP OWNED + remove database objects owned by a database role + + + + DROP OWNED + + + + +DROP OWNED name [, ...] [ RESTRICT | CASCADE ] + + + + + Description + + + The DROP OWNED instructs the system to drop those + database objects owned by one of the given roles which reside on the + current database. All privileges granted to the given roles will also be + revoked. + + + + If CASCADE is specified, DROP OWNED + will behave like a DROP ... CASCADE was issued + for each object, that is, objects dependent on the ones owned by the + given users will be dropped as well. + + + + + Notes + + The DROP OWNED command is mostly used in preparation to + drop the roles. It may be necessary to issue the command in more than one + database. + + + + Using the CASCADE option may make the command recurse to + objects owned by other users. + + + + See the REASSIGN OWNED command for an alternative that + gives the objects away to another role. + + + + + Compatibility + + + The DROP OWNED statement is a + PostgreSQL extension. + + + + + See Also + + + + + + + + + + diff --git a/doc/src/sgml/ref/reassign_owned.sgml b/doc/src/sgml/ref/reassign_owned.sgml new file mode 100644 index 00000000000..a54e4c82698 --- /dev/null +++ b/doc/src/sgml/ref/reassign_owned.sgml @@ -0,0 +1,89 @@ + + + + + REASSIGN OWNED + SQL - Language Statements + + + + REASSIGN OWNED + change ownership of database objects owned by a database role + + + + REASSIGN OWNED + + + + +REASSIGN OWNED old_role [, ...] TO new_role + + + + + Description + + + The REASSIGN OWNED instructs the system to change + the ownership of the database objects owned by one of the old_roles, + to new_role. + + + + + Notes + + + The REASSIGN OWNED command is mostly used in preparation to + drop the roles. See the DROP OWNED command for an + alternative that drops the objects. + + + + The REASSIGN OWNED command does not affect the privileges + granted to the old_roles in objects not owned by them. Use + DROP OWNED to remove them. + + + + + + Compatibility + + + The REASSIGN OWNED statement is a + PostgreSQL extension. + + + + + See Also + + + + + + + + + + diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml index 0191ec8b3c3..f320a132d04 100644 --- a/doc/src/sgml/reference.sgml +++ b/doc/src/sgml/reference.sgml @@ -1,5 +1,5 @@ @@ -102,6 +102,7 @@ PostgreSQL Reference Manual &dropLanguage; &dropOperator; &dropOperatorClass; + &dropOwned; &dropRole; &dropRule; &dropSchema; @@ -125,6 +126,7 @@ PostgreSQL Reference Manual ¬ify; &prepare; &prepareTransaction; + &reassignOwned; &reindex; &releaseSavepoint; &reset; -- cgit v1.2.3