From 839a2d3b5ba9ff1bc021bfb91cde25f050b5d379 Mon Sep 17 00:00:00 2001 From: Silvan <27845747+adlerhurst@users.noreply.github.com> Date: Tue, 24 Feb 2026 10:51:22 +0100 Subject: [PATCH] Prevent failure in setup step 69 if `cache.objects` does not exist (#11673) # Which Problems Are Solved If the `cache.objects`-table does not exist setup failes with the following error: `ERROR: relation "cache.objects" does not exist at character 44` # How the Problems Are Solved Changed statement to prevent immediately throw an error if the table is missing. # Additional Context - reported in https://discord.com/channels/927474939156643850/1473769282880934089 - backport to v4 --- cmd/setup/69.sql | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/cmd/setup/69.sql b/cmd/setup/69.sql index 1cbf9b2b4..a5c68757f 100644 --- a/cmd/setup/69.sql +++ b/cmd/setup/69.sql @@ -1,22 +1,14 @@ DO $do$ BEGIN - -- Convert objects to logged first (if unlogged) - IF EXISTS (SELECT 1 FROM pg_class WHERE oid = 'cache.objects'::REGCLASS AND relpersistence = 'u') THEN - ALTER TABLE IF EXISTS cache.objects - SET LOGGED; - END IF; + -- Convert objects to logged first (if unlogged) + IF EXISTS (SELECT 1 FROM pg_class WHERE oid = to_regclass('cache.objects') AND relpersistence = 'u') THEN + ALTER TABLE IF EXISTS cache.objects SET LOGGED; + END IF; - -- Convert string_keys to logged (if unlogged) - -- Drop the FK constraint first to allow converting cache.string_keys (and avoid loggedness-change restrictions involving the FK) - IF EXISTS (SELECT 1 FROM pg_class WHERE oid = to_regclass('cache.objects') AND relpersistence = 'u') THEN - ALTER TABLE IF EXISTS cache.objects - SET LOGGED; - END IF; - - -- Convert string_keys to logged (if unlogged) - -- Drop the FK constraint first to avoid conflict with parent table conversion - IF EXISTS (SELECT 1 FROM pg_class WHERE oid = to_regclass('cache.string_keys') AND relpersistence = 'u') THEN + -- Convert string_keys to logged (if unlogged) + -- Drop the FK constraint first to avoid conflict with parent table conversion + IF EXISTS (SELECT 1 FROM pg_class WHERE oid = to_regclass('cache.string_keys') AND relpersistence = 'u') THEN ALTER TABLE IF EXISTS cache.string_keys DROP CONSTRAINT IF EXISTS fk_object; ALTER TABLE IF EXISTS cache.string_keys @@ -26,12 +18,16 @@ BEGIN FOREIGN KEY(cache_name, object_id) REFERENCES cache.objects(cache_name, id) ON DELETE CASCADE; - END IF; + END IF; - CREATE UNLOGGED TABLE IF NOT EXISTS cache.objects_default - PARTITION OF cache.objects DEFAULT; + IF to_regclass('cache.objects') IS NOT NULL THEN + CREATE UNLOGGED TABLE IF NOT EXISTS cache.objects_default + PARTITION OF cache.objects DEFAULT; + END IF; - CREATE UNLOGGED TABLE IF NOT EXISTS cache.string_keys_default - PARTITION OF cache.string_keys DEFAULT; + IF to_regclass('cache.string_keys') IS NOT NULL THEN + CREATE UNLOGGED TABLE IF NOT EXISTS cache.string_keys_default + PARTITION OF cache.string_keys DEFAULT; + END IF; END $do$