mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
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 commit08dd23cec
: 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 in08dd23cec
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
This commit is contained in:
@ -390,6 +390,15 @@
|
||||
schema(s) its member objects are within.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If an extension's script creates any temporary objects (such as temp
|
||||
tables), those objects are treated as extension members for the
|
||||
remainder of the current session, but are automatically dropped at
|
||||
session end, as any temporary object would be. This is an exception
|
||||
to the rule that extension member objects cannot be dropped without
|
||||
dropping the whole extension.
|
||||
</para>
|
||||
|
||||
<sect2>
|
||||
<title>Extension Files</title>
|
||||
|
||||
@ -803,7 +812,8 @@ SELECT pg_catalog.pg_extension_config_dump('my_config', 'WHERE NOT standard_entr
|
||||
environment that <command>CREATE EXTENSION</> provides for installation
|
||||
scripts: in particular, <varname>search_path</> is set up in the same
|
||||
way, and any new objects created by the script are automatically added
|
||||
to the extension.
|
||||
to the extension. Also, if the script chooses to drop extension member
|
||||
objects, they are automatically dissociated from the extension.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
Reference in New Issue
Block a user