Hi Zsolt, Thanks for the review. v5 attached.
> This new check can cause temp tablespace cleanup to fail: This needs a permanent composite type with an attribute of a temporary type, stored in a permanent table, which is quite contrived, who'd do it? :-D. Still, internal deletions like temp namespace cleanup and autovacuum's orphan temp table removal must not fail, and the fix is small: v5 skips the check for PERFORM_DELETION_INTERNAL deletions, so DISCARD TEMP, session exit, ON COMMIT DROP and autovacuum behave as before. > And even in the previous version, BEGIN ATOMIC functions using the row > type now block DROP COLUMN, even with CASCADE: Agreed, both are bugs. find_composite_type_dependencies() was written for ALTER COLUMN TYPE, where any use of the type in a SQL body is a problem. For a drop, only values of the type held in the body matter; references to the type or its fields don't, and a use of the dropped column is already a column dependency. v5 adds find_composite_type_dependencies_for_drop(), which differs only in that a function's argument defaults and SQL body block the drop just if they contain a constant or ROW() constructor of the type. Your example now behaves as on master: dropping an unused column works, and dropping a used one gives the usual dependency error, or drops the function with CASCADE. A body like SELECT '(1,2)'::t = '(1,3)'::t still blocks it. Views and other expressions are unchanged, and already only block for such values. v5 also runs the check for every dropped column after all deletions, instead of up front in ATExecDropColumn(), so that a function or view holding such a value no longer blocks a drop whose CASCADE removes it. The restriction is now documented under ALTER TABLE ... DROP COLUMN and ALTER TYPE ... DROP ATTRIBUTE. All of these, including a ROW() constructor in a SQL body, are in the regression tests. Full meson suite passes on master; v5 also applies cleanly to REL_18_STABLE. Regards, Nikhil --- Nikhil Sontakke PlanetScale
v5-0001-Refuse-to-drop-a-column-whose-row-type-is-stored-.patch
Description: Binary data
