From 74e8a65c87606354184dda27c05af531e4b8abbd Mon Sep 17 00:00:00 2001 From: Aman Ganapathy Date: Thu, 3 Dec 2026 18:51:21 +0000 Subject: [PATCH v1 2/2] Add a test for ALTER COLUMN TYPE with a concurrently dropped view. Add an injection point in RememberAllDependentForRebuilding() and an isolation test that drops a view while ALTER COLUMN TYPE waits there. Discussion: https://postgr.es/m/19968-d24000922918f552@postgresql.org --- src/backend/commands/tablecmds.c | 3 ++ src/test/modules/injection_points/Makefile | 3 +- .../expected/alter_type_dropped.out | 22 ++++++++++++++ src/test/modules/injection_points/meson.build | 1 + .../specs/alter_type_dropped.spec | 30 +++++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/test/modules/injection_points/expected/alter_type_dropped.out create mode 100644 src/test/modules/injection_points/specs/alter_type_dropped.spec diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 2dc8ed7..a810efb 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -102,6 +102,7 @@ #include "utils/acl.h" #include "utils/builtins.h" #include "utils/fmgroids.h" +#include "utils/injection_point.h" #include "utils/inval.h" #include "utils/lsyscache.h" #include "utils/memutils.h" @@ -16219,6 +16220,8 @@ RememberAllDependentForRebuilding(AlteredTableInfo *tab, AlterTableType subtype, foundObject.objectId = foundDep->objid; foundObject.objectSubId = foundDep->objsubid; + INJECTION_POINT("alter-column-type-dependent-found", NULL); + switch (foundObject.classId) { case RelationRelationId: diff --git a/src/test/modules/injection_points/Makefile b/src/test/modules/injection_points/Makefile index e30740a..90eaf09 100644 --- a/src/test/modules/injection_points/Makefile +++ b/src/test/modules/injection_points/Makefile @@ -38,7 +38,8 @@ ISOLATION = basic \ $(WAIT_CLEANUP_TST) \ heap_lock_update \ on_conflict_probe_window \ - multixact-aborted-updater + multixact-aborted-updater \ + alter_type_dropped # some isolation tests require wal_level=replica ISOLATION_OPTS = --temp-config $(top_srcdir)/src/test/modules/injection_points/extra.conf diff --git a/src/test/modules/injection_points/expected/alter_type_dropped.out b/src/test/modules/injection_points/expected/alter_type_dropped.out new file mode 100644 index 0000000..21a3629 --- /dev/null +++ b/src/test/modules/injection_points/expected/alter_type_dropped.out @@ -0,0 +1,22 @@ +Parsed test spec with 2 sessions + +starting permutation: s1_alter s2_drop s2_wakeup +injection_points_attach +----------------------- + +(1 row) + +step s1_alter: ALTER TABLE alter_type_tab ALTER COLUMN v TYPE bigint; +step s2_drop: DROP VIEW alter_type_view; +step s2_wakeup: SELECT injection_points_wakeup('alter-column-type-dependent-found'); +injection_points_wakeup +----------------------- + +(1 row) + +step s1_alter: <... completed> +injection_points_detach +----------------------- + +(1 row) + diff --git a/src/test/modules/injection_points/meson.build b/src/test/modules/injection_points/meson.build index a6a2960..1156b18 100644 --- a/src/test/modules/injection_points/meson.build +++ b/src/test/modules/injection_points/meson.build @@ -46,6 +46,7 @@ injection_points_isolation = [ 'heap_lock_update', 'on_conflict_probe_window', 'multixact-aborted-updater', + 'alter_type_dropped', ] # wait_cleanup terminates another backend, whose FATAL message can be lost diff --git a/src/test/modules/injection_points/specs/alter_type_dropped.spec b/src/test/modules/injection_points/specs/alter_type_dropped.spec new file mode 100644 index 0000000..8ec2bdd --- /dev/null +++ b/src/test/modules/injection_points/specs/alter_type_dropped.spec @@ -0,0 +1,30 @@ +setup +{ + CREATE EXTENSION injection_points; + CREATE TABLE alter_type_tab (v int); + CREATE VIEW alter_type_view AS SELECT v FROM alter_type_tab; +} + +teardown +{ + DROP TABLE alter_type_tab; + DROP EXTENSION injection_points; +} + +session s1 +setup +{ + SELECT injection_points_set_local(); + SELECT injection_points_attach('alter-column-type-dependent-found', 'wait'); +} +step s1_alter { ALTER TABLE alter_type_tab ALTER COLUMN v TYPE bigint; } +teardown +{ + SELECT injection_points_detach('alter-column-type-dependent-found'); +} + +session s2 +step s2_drop { DROP VIEW alter_type_view; } +step s2_wakeup { SELECT injection_points_wakeup('alter-column-type-dependent-found'); } + +permutation s1_alter s2_drop s2_wakeup -- 2.47.3