summaryrefslogtreecommitdiff
path: root/doc/src/sgml/catalogs.sgml
diff options
context:
space:
mode:
authorAlvaro Herrera2021-01-14 18:32:14 +0000
committerAlvaro Herrera2021-01-14 18:32:14 +0000
commitebfe2dbd6b624e2a428e14b7ee9322cc096f63f7 (patch)
treef7556d7e17d74be5c07ab74a73a42552c7896745 /doc/src/sgml/catalogs.sgml
parent424d7a9b277c0da5ec638bf6344cda899a2e544a (diff)
Prevent drop of tablespaces used by partitioned relations
When a tablespace is used in a partitioned relation (per commits ca4103025dfe in pg12 for tables and 33e6c34c3267 in pg11 for indexes), it is possible to drop the tablespace, potentially causing various problems. One such was reported in bug #16577, where a rewriting ALTER TABLE causes a server crash. Protect against this by using pg_shdepend to keep track of tablespaces when used for relations that don't keep physical files; we now abort a tablespace if we see that the tablespace is referenced from any partitioned relations. Backpatch this to 11, where this problem has been latent all along. We don't try to create pg_shdepend entries for existing partitioned indexes/tables, but any ones that are modified going forward will be protected. Note slight behavior change: when trying to drop a tablespace that contains both regular tables as well as partitioned ones, you'd previously get ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE and now you'll get ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST. Arguably, the latter is more correct. It is possible to add protecting pg_shdepend entries for existing tables/indexes, by doing ALTER TABLE ONLY some_partitioned_table SET TABLESPACE pg_default; ALTER TABLE ONLY some_partitioned_table SET TABLESPACE original_tablespace; for each partitioned table/index that is not in the database default tablespace. Because these partitioned objects do not have storage, no file needs to be actually moved, so it shouldn't take more time than what's required to acquire locks. This query can be used to search for such relations: SELECT ... FROM pg_class WHERE relkind IN ('p', 'I') AND reltablespace <> 0 Reported-by: Alexander Lakhin <[email protected]> Discussion: https://postgr.es/m/[email protected] Author: Álvaro Herrera <[email protected]> Reviewed-by: Michael Paquier <[email protected]>
Diffstat (limited to 'doc/src/sgml/catalogs.sgml')
-rw-r--r--doc/src/sgml/catalogs.sgml13
1 files changed, 12 insertions, 1 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 3a2266526c4..43d7a1ad90e 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -6849,10 +6849,21 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><symbol>SHARED_DEPENDENCY_TABLESPACE</symbol> (<literal>t</literal>)</term>
+ <listitem>
+ <para>
+ The referenced object (which must be a tablespace) is mentioned as
+ the tablespace for a relation that doesn't have storage.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
Other dependency flavors might be needed in future. Note in particular
- that the current definition only supports roles as referenced objects.
+ that the current definition only supports roles and tablespaces as referenced
+ objects.
</para>
</sect1>