pgsql: Delete deleteWhatDependsOn() in favor of more performDeletion()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Delete deleteWhatDependsOn() in favor of more performDeletion()
Date: 2016-12-02 19:58:11
Message-ID: E1cCtyF-0002oT-OF@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Delete deleteWhatDependsOn() in favor of more performDeletion() flag bits.

deleteWhatDependsOn() had grown an uncomfortably large number of
assumptions about what it's used for. There are actually only two minor
differences between what it does and what a regular performDeletion() call
can do, so let's invent additional bits in performDeletion's existing flags
argument that specify those behaviors, and get rid of deleteWhatDependsOn()
as such. (We'd probably have done it this way from the start, except that
performDeletion didn't originally have a flags argument, IIRC.)

Also, add a SKIP_EXTENSIONS flag bit that prevents ever recursing to an
extension, and use that when dropping temporary objects at session end.
This provides a more general solution to the problem addressed in a hacky
way in commit 08dd23cec: if an extension script creates temp objects and
forgets to remove them again, the whole extension went away when its
contained temp objects were deleted. The previous solution only covered
temp relations, but this solves it for all object types.

These changes require minor additions in dependency.c to pass the flags
to subroutines that previously didn't get them, but it's still a net
savings of code, and it seems cleaner than before.

Having done this, revert the special-case code added in 08dd23cec that
prevented addition of pg_depend records for temp table extension
membership, because that caused its own oddities: dropping an extension
that had created such a table didn't automatically remove the table,
leading to a failure if the table had another dependency on the extension
(such as use of an extension data type), or to a duplicate-name failure if
you then tried to recreate the extension. But we keep the part that
prevents the pg_temp_nnn schema from becoming an extension member; we never
want that to happen. Add a regression test case covering these behaviors.

Although this fixes some arguable bugs, we've heard few field complaints,
and any such problems are easily worked around by explicitly dropping temp
objects at the end of extension scripts (which seems like good practice
anyway). So I won't risk a back-patch.

Discussion: https://postgr.es/m/e51f4311-f483-4dd0-1ccc-abec3c405110@BlueTreble.com

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/b3427dade14cc31eb48740bc9ea98b5954470b24

Modified Files
--------------
doc/src/sgml/extend.sgml | 12 +-
src/backend/catalog/dependency.c | 174 ++++++++-------------
src/backend/catalog/heap.c | 7 +-
src/backend/catalog/namespace.c | 11 +-
src/backend/postmaster/autovacuum.c | 5 +-
src/include/catalog/dependency.h | 13 +-
src/include/commands/extension.h | 11 +-
src/test/modules/test_extensions/Makefile | 4 +-
.../test_extensions/expected/test_extensions.out | 58 +++++++
.../test_extensions/sql/test_extensions.sql | 39 +++++
.../modules/test_extensions/test_ext8--1.0.sql | 21 +++
src/test/modules/test_extensions/test_ext8.control | 4 +
12 files changed, 229 insertions(+), 130 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2016-12-02 20:08:40 pgsql: Fix thinko in b3427dade14cc31eb48740bc9ea98b5954470b24.
Previous Message Robert Haas 2016-12-02 17:36:07 pgsql: Introduce dynamic shared memory areas.