Hello,
On 2026-Oct-05, Fujii Masao wrote:
> repack_dropped isolation test should also be listed in Makefile, in
> addition to meson.build?
Oh, right.
> +teardown {
> + DROP TABLE repack_dropped;
> + DROP FUNCTION repack_dropped_f;
> +}
>
> Should teardown also drop the injection_points extension created by
> setup, as the other tests that create the injection_points extension
> do?
>
> This missing DROP seems harmless with the current Meson test order, since
> repack_missingval runs next, uses CREATE EXTENSION IF NOT EXISTS, and
> then drops the extension. However, that seems fragile.
Hmm, agreed, let's do this also.
I think the repeated creating/dropping is a bit wasteful though and we
don't need it. Wouldn't it make more sense to have all tests use CREATE
IF NOT EXISTS and then remove all the DROPs of it? We would end up
having the extension after the tests are run, but since the database is
specifically created to run the isolation tests, it's not a problem if
it remains there. The attached patch would do that. (I am proposing
this change just for pg20.)
Thanks!
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
diff --git a/src/test/modules/injection_points/specs/basic.spec b/src/test/modules/injection_points/specs/basic.spec
index 13d2793f6e4..509572ae9ea 100644
--- a/src/test/modules/injection_points/specs/basic.spec
+++ b/src/test/modules/injection_points/specs/basic.spec
@@ -6,11 +6,7 @@
setup
{
- CREATE EXTENSION injection_points;
-}
-teardown
-{
- DROP EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
}
# Wait happens in the first session, wakeup in the second session.
diff --git a/src/test/modules/injection_points/specs/heap_lock_update.spec b/src/test/modules/injection_points/specs/heap_lock_update.spec
index b3992a1eb7a..6184ed9f5b7 100644
--- a/src/test/modules/injection_points/specs/heap_lock_update.spec
+++ b/src/test/modules/injection_points/specs/heap_lock_update.spec
@@ -22,7 +22,7 @@
# output, to verify that the test exercises the scenario we want.
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE TABLE t (id int PRIMARY KEY);
do $$
@@ -43,7 +43,6 @@ setup
teardown
{
DROP TABLE t;
- DROP EXTENSION injection_points;
}
session s1
diff --git a/src/test/modules/injection_points/specs/inplace.spec b/src/test/modules/injection_points/specs/inplace.spec
index 86539a5bd2f..090166ebb0c 100644
--- a/src/test/modules/injection_points/specs/inplace.spec
+++ b/src/test/modules/injection_points/specs/inplace.spec
@@ -9,7 +9,7 @@
# Just to save on filesystem syscalls, use relkind=c for every other rel.
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE SCHEMA vactest;
CREATE FUNCTION vactest.mkrels(text, int, int) RETURNS void
LANGUAGE plpgsql SET search_path = vactest AS $$
@@ -35,7 +35,6 @@ setup
teardown
{
DROP SCHEMA vactest CASCADE;
- DROP EXTENSION injection_points;
}
# Wait during inplace update, in a VACUUM of vactest.orig50.
diff --git a/src/test/modules/injection_points/specs/on_conflict_probe_window.spec b/src/test/modules/injection_points/specs/on_conflict_probe_window.spec
index 78dddbe8b92..443a30b217a 100644
--- a/src/test/modules/injection_points/specs/on_conflict_probe_window.spec
+++ b/src/test/modules/injection_points/specs/on_conflict_probe_window.spec
@@ -13,7 +13,7 @@
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE TABLE probe_a (key int PRIMARY KEY, val int);
CREATE TABLE probe_b (key int PRIMARY KEY, val int);
INSERT INTO probe_a VALUES (1, 0);
@@ -24,7 +24,6 @@ setup
teardown
{
DROP TABLE probe_a, probe_b;
- DROP EXTENSION injection_points;
}
session s1
diff --git a/src/test/modules/injection_points/specs/reindex_concurrently_deferred.spec b/src/test/modules/injection_points/specs/reindex_concurrently_deferred.spec
index 4b95e1da2a7..748b8dee604 100644
--- a/src/test/modules/injection_points/specs/reindex_concurrently_deferred.spec
+++ b/src/test/modules/injection_points/specs/reindex_concurrently_deferred.spec
@@ -9,7 +9,7 @@
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE TABLE reind_deferred (id int, val int,
CONSTRAINT uq_val UNIQUE(val) DEFERRABLE INITIALLY DEFERRED);
INSERT INTO reind_deferred VALUES (1, 1), (2, 2);
@@ -18,7 +18,6 @@ setup
teardown
{
DROP TABLE reind_deferred;
- DROP EXTENSION injection_points;
}
session s1
diff --git a/src/test/modules/injection_points/specs/repack.spec b/src/test/modules/injection_points/specs/repack.spec
index 7896d1456ad..500140b0fc0 100644
--- a/src/test/modules/injection_points/specs/repack.spec
+++ b/src/test/modules/injection_points/specs/repack.spec
@@ -1,7 +1,7 @@
# REPACK (CONCURRENTLY) ... USING INDEX ...;
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE TABLE repack_test(i int PRIMARY KEY, j int,
k int GENERATED ALWAYS AS (j * 2) STORED);
@@ -16,7 +16,6 @@ setup
teardown
{
DROP TABLE repack_test;
- DROP EXTENSION injection_points;
DROP TABLE relfilenodes;
DROP TABLE data_s1;
diff --git a/src/test/modules/injection_points/specs/repack_commit_race.spec b/src/test/modules/injection_points/specs/repack_commit_race.spec
index 9926a45839e..05627fcda82 100644
--- a/src/test/modules/injection_points/specs/repack_commit_race.spec
+++ b/src/test/modules/injection_points/specs/repack_commit_race.spec
@@ -5,7 +5,7 @@
# for MVCC correctness.
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE TABLE repack_race(i int PRIMARY KEY, j int);
INSERT INTO repack_race(i, j) VALUES (1, 1), (2, 2);
@@ -14,7 +14,6 @@ setup
teardown
{
DROP TABLE repack_race;
- DROP EXTENSION injection_points;
}
session s1
diff --git a/src/test/modules/injection_points/specs/repack_decode.spec b/src/test/modules/injection_points/specs/repack_decode.spec
index 04f0df83a0a..522ec41cbac 100644
--- a/src/test/modules/injection_points/specs/repack_decode.spec
+++ b/src/test/modules/injection_points/specs/repack_decode.spec
@@ -1,6 +1,6 @@
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
BEGIN;
-- Generate a string of random characters that is not likely to be
@@ -22,7 +22,6 @@ setup
teardown
{
DROP TABLE repack_toast;
- DROP EXTENSION injection_points;
DROP FUNCTION gen_external();
SELECT pg_drop_replication_slot('s');
}
diff --git a/src/test/modules/injection_points/specs/repack_dropped.spec b/src/test/modules/injection_points/specs/repack_dropped.spec
index 099cf744202..784497b0f30 100644
--- a/src/test/modules/injection_points/specs/repack_dropped.spec
+++ b/src/test/modules/injection_points/specs/repack_dropped.spec
@@ -4,7 +4,7 @@
# they'll comfortably fit in a single page. The OLD tuple 1 is propagated
# through the concurrent update because of the trigger.
setup {
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE TABLE repack_dropped (id int PRIMARY KEY, a text, b text);
ALTER TABLE repack_dropped ALTER COLUMN b SET STORAGE EXTERNAL;
diff --git a/src/test/modules/injection_points/specs/repack_missingval.spec b/src/test/modules/injection_points/specs/repack_missingval.spec
index 4b70d810afd..df7b1f8d839 100644
--- a/src/test/modules/injection_points/specs/repack_missingval.spec
+++ b/src/test/modules/injection_points/specs/repack_missingval.spec
@@ -29,7 +29,6 @@ teardown
{
DROP TABLE repack_missingval;
DROP FUNCTION repack_return_old();
- DROP EXTENSION injection_points;
}
session s1
diff --git a/src/test/modules/injection_points/specs/repack_temporal.spec b/src/test/modules/injection_points/specs/repack_temporal.spec
index c9fd3f61a84..f29b7e573c4 100644
--- a/src/test/modules/injection_points/specs/repack_temporal.spec
+++ b/src/test/modules/injection_points/specs/repack_temporal.spec
@@ -6,7 +6,7 @@
# target row.
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE TABLE repack_temporal (
id int4range,
@@ -28,7 +28,6 @@ setup
teardown
{
DROP TABLE repack_temporal;
- DROP EXTENSION injection_points;
DROP TABLE relfilenodes;
}
diff --git a/src/test/modules/injection_points/specs/repack_temporal_multirange.spec b/src/test/modules/injection_points/specs/repack_temporal_multirange.spec
index 8150c0b4ba8..e1328409a9d 100644
--- a/src/test/modules/injection_points/specs/repack_temporal_multirange.spec
+++ b/src/test/modules/injection_points/specs/repack_temporal_multirange.spec
@@ -6,7 +6,7 @@
# can produce both as candidates and requires exact recheck.
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE TABLE repack_temporal_multirange (
id int4multirange,
@@ -34,7 +34,6 @@ setup
teardown
{
DROP TABLE repack_temporal_multirange;
- DROP EXTENSION injection_points;
DROP TABLE relfilenodes;
}
diff --git a/src/test/modules/injection_points/specs/repack_toast.spec b/src/test/modules/injection_points/specs/repack_toast.spec
index bce4d85f4d9..187ba0616e3 100644
--- a/src/test/modules/injection_points/specs/repack_toast.spec
+++ b/src/test/modules/injection_points/specs/repack_toast.spec
@@ -67,7 +67,6 @@ setup
teardown
{
DROP TABLE repack_toast;
- DROP EXTENSION injection_points;
DROP FUNCTION gen_compressible(int);
DROP FUNCTION gen_compressible_external(int);
DROP FUNCTION gen_external();
diff --git a/src/test/modules/injection_points/specs/ri_fastpath_reindex.spec b/src/test/modules/injection_points/specs/ri_fastpath_reindex.spec
index bc1ec6e2819..01127c8cf7d 100644
--- a/src/test/modules/injection_points/specs/ri_fastpath_reindex.spec
+++ b/src/test/modules/injection_points/specs/ri_fastpath_reindex.spec
@@ -1,4 +1,3 @@
-# A foreign key check racing a rebuild of the index it resolves through.
#
# Pause the RI fast path before it locks the referenced table, allowing
# REINDEX CONCURRENTLY to repoint the constraint. Verify that the check
@@ -7,7 +6,7 @@
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE TABLE ri_pk (id int PRIMARY KEY);
INSERT INTO ri_pk SELECT g FROM generate_series(1, 100) g;
CREATE TABLE ri_fk (id int PRIMARY KEY, pid int REFERENCES ri_pk(id));
@@ -19,7 +18,6 @@ setup
teardown
{
DROP TABLE ri_fk, ri_pk, ri_old_index;
- DROP EXTENSION injection_points;
}
# The rebuild, stopped just before it repoints the constraint.
diff --git a/src/test/modules/injection_points/specs/ri_fastpath_snapshot.spec b/src/test/modules/injection_points/specs/ri_fastpath_snapshot.spec
index a3cf6c30fb4..8381d441915 100644
--- a/src/test/modules/injection_points/specs/ri_fastpath_snapshot.spec
+++ b/src/test/modules/injection_points/specs/ri_fastpath_snapshot.spec
@@ -6,7 +6,7 @@
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE ROLE regress_ri_snapshot;
CREATE TABLE ri_snapshot_pk (id int PRIMARY KEY);
CREATE TABLE ri_snapshot_fk (pid int);
@@ -20,7 +20,6 @@ teardown
{
DROP TABLE ri_snapshot_fk, ri_snapshot_pk;
DROP ROLE regress_ri_snapshot;
- DROP EXTENSION injection_points;
}
session s1
diff --git a/src/test/modules/injection_points/specs/syscache-update-pruned.spec b/src/test/modules/injection_points/specs/syscache-update-pruned.spec
index e3a4295bd12..367780eba93 100644
--- a/src/test/modules/injection_points/specs/syscache-update-pruned.spec
+++ b/src/test/modules/injection_points/specs/syscache-update-pruned.spec
@@ -25,7 +25,7 @@
# on filesystem syscalls, use relkind=c for every other rel.
setup
{
- CREATE EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
CREATE SCHEMA vactest;
-- Ensure a leader RELOID catcache entry. PARALLEL RESTRICTED since a
-- parallel worker running pg_relation_filenode() would lack that effect.
@@ -94,7 +94,6 @@ setup
teardown
{
DROP SCHEMA vactest CASCADE;
- DROP EXTENSION injection_points;
}
# Wait during GRANT. Disable debug_discard_caches, since we're here to
diff --git a/src/test/modules/injection_points/specs/wait_cleanup.spec b/src/test/modules/injection_points/specs/wait_cleanup.spec
index ed7d21c4de4..beefa4e4a71 100644
--- a/src/test/modules/injection_points/specs/wait_cleanup.spec
+++ b/src/test/modules/injection_points/specs/wait_cleanup.spec
@@ -5,11 +5,7 @@
setup
{
- CREATE EXTENSION injection_points;
-}
-teardown
-{
- DROP EXTENSION injection_points;
+ CREATE EXTENSION IF NOT EXISTS injection_points;
}
# The first waiter, that gets canceled or terminated. This does not