Skip to content

Commit f1a9b1d

Browse files
authored
Fix upgrade test: build default install SQL from HEAD, not initial commit (#2397)
The upgrade test previously built age--<CURR>.sql from the initial version-bump commit, meaning CREATE EXTENSION installed 'day-one' SQL. This caused all 31 non-upgrade regression tests to run WITHOUT SQL functions added after the version bump (e.g., age_invalidate_graph_cache, age_prepare_pg_upgrade, age_vertex_stats, etc.). These functions were never registered in pg_proc, so features depending on them (like VLE cache invalidation triggers) were silently disabled during testing. Fix by inverting the upgrade test direction: Before (installs incomplete SQL, upgrades to complete): age--1.7.0.sql built from version-bump commit (incomplete) age--1.7.0_upgrade_test.sql built from HEAD (complete) age--1.7.0--1.7.0_upgrade_test.sql stamped from template Test: CREATE EXTENSION age -> data -> ALTER EXTENSION UPDATE TO '1.7.0_upgrade_test' After (installs complete SQL, upgrades from synthetic initial): age--1.7.0.sql built from HEAD (complete) age--1.7.0_initial.sql built from version-bump commit (synthetic) age--1.7.0_initial--1.7.0.sql stamped from template Test: CREATE EXTENSION age VERSION '1.7.0_initial' -> data -> ALTER EXTENSION UPDATE TO '1.7.0' This ensures: - All 31 non-upgrade tests run with every SQL function registered - The upgrade template is still validated (initial -> current) - The test ends at the default version (clean state for drop test) - Tarball builds (no git) work identically (cat sql/sql_files) - All synthetic files are cleaned up after the test Makefile changes: - age_sql rule: cat current HEAD sql/sql_files (was: git show from commit) - New age_init_sql rule: git show from version-bump commit - age_upgrade_test_sql: stamps template as INIT->CURR (was CURR->NEXT) - EXTRA_CLEAN, _install_upgrade_test_files: updated filenames - Removed AGE_NEXT_VER, age_next_sql; added AGE_INIT_VER, age_init_sql Test SQL changes: - Step 3: CREATE EXTENSION age VERSION '<init>' (was: CREATE EXTENSION age) - Step 6: ALTER EXTENSION age UPDATE TO default_version (was: LIKE '%_upgrade_test') - Step 7: Check installed = default (was: installed <> default) - Comments updated throughout to reflect inverted direction All 32 regression tests pass. modified: Makefile modified: regress/expected/age_upgrade.out modified: regress/sql/age_upgrade.sql
1 parent 1847644 commit f1a9b1d

3 files changed

Lines changed: 109 additions & 97 deletions

File tree

Makefile

Lines changed: 39 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,25 @@ age_sql = age--1.7.0.sql
2424
# Validates the upgrade template (age--<VER>--y.y.y.sql) by simulating an
2525
# extension version upgrade entirely within "make installcheck". The test:
2626
#
27-
# 1. Builds the install SQL from the INITIAL version-bump commit (the "from"
28-
# version). This is the age--<CURR>.sql used by CREATE EXTENSION age.
29-
# 2. Builds the install SQL from current HEAD as a synthetic "next" version
30-
# (the "to" version). This is age--<NEXT>.sql where NEXT = CURR_upgrade_test.
31-
# 3. Stamps the upgrade template with the synthetic version, producing the
32-
# upgrade script age--<CURR>--<NEXT>.sql.
33-
# 4. Temporarily installs both synthetic files into the PG extension directory
34-
# so that ALTER EXTENSION age UPDATE TO '<NEXT>' can find them.
27+
# 1. Builds the default install SQL (age--<CURR>.sql) from current HEAD's
28+
# sql/sql_files. This is what CREATE EXTENSION age installs.
29+
# 2. Builds a synthetic "initial" version install SQL from the version-bump
30+
# commit in git history. This represents the pre-upgrade state.
31+
# 3. Stamps the upgrade template to upgrade from the initial version to the
32+
# current version.
33+
# 4. Temporarily installs the synthetic files into the PG extension directory
34+
# so that CREATE EXTENSION age VERSION '<INIT>' and ALTER EXTENSION
35+
# age UPDATE TO '<CURR>' can find them.
3536
# 5. The age_upgrade regression test exercises the full upgrade path: install
36-
# at CURR, create data, ALTER EXTENSION UPDATE to NEXT, verify data.
37+
# at INIT, create data, ALTER EXTENSION UPDATE to CURR, verify data.
3738
# 6. The test SQL cleans up the synthetic files via a generated shell script.
3839
#
3940
# This forces developers to keep the upgrade template in sync: any SQL object
4041
# added after the version-bump commit must also appear in the template, or the
4142
# upgrade test will fail (the object will be missing after ALTER EXTENSION UPDATE).
4243
#
43-
# The .so (shared library) is always built from current HEAD, so C-level changes
44-
# in the PR are tested by every regression test, not just the upgrade test.
44+
# Because the default install SQL comes from HEAD, all 31 non-upgrade tests
45+
# run with every SQL function registered — no functions are missing.
4546
#
4647
# Graceful degradation — the upgrade test is silently skipped when:
4748
# - No git history (tarball build): AGE_VER_COMMIT is empty.
@@ -53,15 +54,15 @@ age_sql = age--1.7.0.sql
5354
AGE_CURR_VER := $(shell awk -F"'" '/default_version/ {print $$2}' age.control 2>/dev/null)
5455
# Git commit that last changed age.control — the "initial release" commit
5556
AGE_VER_COMMIT := $(shell git log -1 --format=%H -- age.control 2>/dev/null)
56-
# Synthetic next version: current version with _upgrade_test suffix (e.g., 1.7.0 -> 1.7.0_upgrade_test)
57-
AGE_NEXT_VER := $(AGE_CURR_VER)_upgrade_test
57+
# Synthetic initial version: current version with _initial suffix
58+
AGE_INIT_VER := $(AGE_CURR_VER)_initial
5859
# The upgrade template file (e.g., age--1.7.0--y.y.y.sql); empty if not present
5960
AGE_UPGRADE_TEMPLATE := $(wildcard age--$(AGE_CURR_VER)--y.y.y.sql)
6061

6162
# Synthetic filenames — these are NOT installed permanently; they are temporarily
6263
# placed in $(SHAREDIR)/extension/ during installcheck and removed after.
63-
age_next_sql = $(if $(AGE_NEXT_VER),age--$(AGE_NEXT_VER).sql)
64-
age_upgrade_test_sql = $(if $(AGE_NEXT_VER),age--$(AGE_CURR_VER)--$(AGE_NEXT_VER).sql)
64+
age_init_sql = $(if $(AGE_INIT_VER),age--$(AGE_INIT_VER).sql)
65+
age_upgrade_test_sql = $(if $(AGE_INIT_VER),age--$(AGE_INIT_VER)--$(AGE_CURR_VER).sql)
6566

6667
# Real (git-tracked, non-template) upgrade scripts FROM the current version.
6768
# If any exist (e.g., age--1.7.0--1.8.0.sql is committed), the synthetic
@@ -196,7 +197,7 @@ ag_regress_dir = $(srcdir)/regress
196197
REGRESS_OPTS = --load-extension=age --inputdir=$(ag_regress_dir) --outputdir=$(ag_regress_dir) --temp-instance=$(ag_regress_dir)/instance --port=61958 --encoding=UTF-8 --temp-config $(ag_regress_dir)/age_regression.conf
197198

198199
ag_regress_out = instance/ log/ results/ regression.*
199-
EXTRA_CLEAN = $(addprefix $(ag_regress_dir)/, $(ag_regress_out)) src/backend/parser/cypher_gram.c src/include/parser/cypher_gram_def.h src/include/parser/cypher_kwlist_d.h $(all_age_sql) $(age_next_sql) $(age_upgrade_test_sql) $(ag_regress_dir)/age_upgrade_cleanup.sh
200+
EXTRA_CLEAN = $(addprefix $(ag_regress_dir)/, $(ag_regress_out)) src/backend/parser/cypher_gram.c src/include/parser/cypher_gram_def.h src/include/parser/cypher_kwlist_d.h $(all_age_sql) $(age_init_sql) $(age_upgrade_test_sql) $(ag_regress_dir)/age_upgrade_cleanup.sh
200201

201202
GEN_KEYWORDLIST = $(PERL) -I ./tools/ ./tools/gen_keywordlist.pl
202203
GEN_KEYWORDLIST_DEPS = ./tools/gen_keywordlist.pl tools/PerfectHash.pm
@@ -226,59 +227,44 @@ src/backend/parser/cypher_parser.bc: src/backend/parser/cypher_gram.c src/includ
226227
src/backend/parser/cypher_keywords.o: src/backend/parser/cypher_gram.c src/include/parser/cypher_gram_def.h
227228
src/backend/parser/cypher_keywords.bc: src/backend/parser/cypher_gram.c src/include/parser/cypher_gram_def.h
228229

229-
# Build the default install SQL (age--<VER>.sql) from the INITIAL version-bump
230-
# commit in git history. This means CREATE EXTENSION age installs the "day-one
231-
# release" SQL — the state of sql/ at the moment the version was bumped in
232-
# age.control. All other regression tests run against this SQL + the current
233-
# HEAD .so, implicitly validating that the .so is backward-compatible with the
234-
# initial release SQL.
235-
#
236-
# The current HEAD SQL goes into the synthetic next version (age--<NEXT>.sql)
237-
# which is only reachable via ALTER EXTENSION UPDATE in the upgrade test.
238-
ifneq ($(AGE_VER_COMMIT),)
239-
$(age_sql): age.control
240-
@echo "Building initial-release install SQL: $@ from commit $(AGE_VER_COMMIT)"
241-
@for f in $$(git show $(AGE_VER_COMMIT):sql/sql_files 2>/dev/null); do \
242-
git show $(AGE_VER_COMMIT):sql/$${f}.sql 2>/dev/null; \
243-
done > $@
244-
ifeq ($(SIZEOF_DATUM),4)
245-
@echo "32-bit build: removing PASSEDBYVALUE from graphid type"
246-
@sed 's/^ PASSEDBYVALUE,$$/ -- PASSEDBYVALUE removed for 32-bit (see Makefile)/' $@ > $@.tmp && mv $@.tmp $@
247-
endif
248-
else
249-
# Fallback: no git history (tarball build) — use current HEAD SQL fragments
230+
# Build the default install SQL (age--<VER>.sql) from current HEAD's sql/sql_files.
231+
# This is what CREATE EXTENSION age installs — it contains ALL current functions.
232+
# All 31 non-upgrade regression tests run against this complete SQL.
250233
$(age_sql): $(SQLS)
234+
@echo "Building install SQL: $@ from HEAD"
251235
@cat $(SQLS) > $@
252236
ifeq ($(SIZEOF_DATUM),4)
253237
@echo "32-bit build: removing PASSEDBYVALUE from graphid type"
254238
@sed 's/^ PASSEDBYVALUE,$$/ -- PASSEDBYVALUE removed for 32-bit (see Makefile)/' $@ > $@.tmp && mv $@.tmp $@
255-
@grep -q 'PASSEDBYVALUE removed for 32-bit' $@ || { echo "Error: PASSEDBYVALUE replacement failed in $@"; exit 1; }
256-
endif
257239
endif
258240

259-
# Build synthetic "next" version install SQL from current HEAD's sql/sql_files.
260-
# This represents what the extension SQL looks like in the PR being tested.
241+
# Build synthetic "initial" version install SQL from the version-bump commit.
242+
# This represents the pre-upgrade state — the SQL at the time the version was
243+
# bumped in age.control. Used only by the upgrade test.
261244
ifneq ($(AGE_HAS_UPGRADE_TEST),)
262-
$(age_next_sql): $(SQLS)
263-
@echo "Building synthetic next version install SQL: $@ ($(AGE_NEXT_VER))"
264-
@cat $(SQLS) > $@
245+
$(age_init_sql): age.control
246+
@echo "Building synthetic initial version install SQL: $@ from commit $(AGE_VER_COMMIT)"
247+
@for f in $$(git show $(AGE_VER_COMMIT):sql/sql_files 2>/dev/null); do \
248+
git show $(AGE_VER_COMMIT):sql/$${f}.sql 2>/dev/null; \
249+
done > $@
265250
ifeq ($(SIZEOF_DATUM),4)
266251
@sed 's/^ PASSEDBYVALUE,$$/ -- PASSEDBYVALUE removed for 32-bit (see Makefile)/' $@ > $@.tmp && mv $@.tmp $@
267252
endif
268253

269-
# Stamp upgrade template as upgrade from current to synthetic next version
254+
# Stamp upgrade template as upgrade from initial to current version
270255
$(age_upgrade_test_sql): $(AGE_UPGRADE_TEMPLATE)
271-
@echo "Stamping upgrade template: $< -> $@"
272-
@sed -e "s/1\.X\.0/$(AGE_NEXT_VER)/g" -e "s/y\.y\.y/$(AGE_NEXT_VER)/g" $< > $@
256+
@echo "Stamping upgrade template: $< -> $@ ($(AGE_INIT_VER) -> $(AGE_CURR_VER))"
257+
@sed -e "s/1\.X\.0/$(AGE_CURR_VER)/g" -e "s/y\.y\.y/$(AGE_CURR_VER)/g" $< > $@
273258
endif
274259

275260
src/backend/parser/ag_scanner.c: FLEX_NO_BACKUP=yes
276261

277262
# --- Upgrade test file lifecycle during installcheck ---
278263
#
279-
# Problem: The upgrade test needs age--<NEXT>.sql and age--<CURR>--<NEXT>.sql
280-
# in the PG extension directory for ALTER EXTENSION UPDATE to find them, but
281-
# we must not leave them installed permanently (they would confuse users).
264+
# Problem: The upgrade test needs age--<INIT>.sql and age--<INIT>--<CURR>.sql
265+
# in the PG extension directory for CREATE EXTENSION VERSION and ALTER
266+
# EXTENSION UPDATE to find them, but we must not leave them installed
267+
# permanently (they would confuse users).
282268
#
283269
# Solution: A Make prerequisite installs them before pg_regress runs, and the
284270
# test SQL removes them at the end via \! (shell escape in psql). A generated
@@ -293,10 +279,10 @@ SHAREDIR = $(shell $(PG_CONFIG) --sharedir)
293279
installcheck: export LC_COLLATE=C
294280
ifneq ($(AGE_HAS_UPGRADE_TEST),)
295281
.PHONY: _install_upgrade_test_files
296-
_install_upgrade_test_files: $(age_next_sql) $(age_upgrade_test_sql) ## Build, install synthetic files, generate cleanup script
282+
_install_upgrade_test_files: $(age_init_sql) $(age_upgrade_test_sql) ## Build, install synthetic files, generate cleanup script
297283
@echo "Installing upgrade test files to $(SHAREDIR)/extension/"
298-
@$(INSTALL_DATA) $(age_next_sql) $(age_upgrade_test_sql) '$(SHAREDIR)/extension/'
299-
@printf '#!/bin/sh\nrm -f "$(SHAREDIR)/extension/$(age_next_sql)" "$(SHAREDIR)/extension/$(age_upgrade_test_sql)"\nrm -f "$(age_next_sql)" "$(age_upgrade_test_sql)" "$(ag_regress_dir)/age_upgrade_cleanup.sh"\n' > $(ag_regress_dir)/age_upgrade_cleanup.sh
284+
@$(INSTALL_DATA) $(age_init_sql) $(age_upgrade_test_sql) '$(SHAREDIR)/extension/'
285+
@printf '#!/bin/sh\nrm -f "$(SHAREDIR)/extension/$(age_init_sql)" "$(SHAREDIR)/extension/$(age_upgrade_test_sql)"\nrm -f "$(age_init_sql)" "$(age_upgrade_test_sql)" "$(ag_regress_dir)/age_upgrade_cleanup.sh"\n' > $(ag_regress_dir)/age_upgrade_cleanup.sh
300286
@chmod +x $(ag_regress_dir)/age_upgrade_cleanup.sh
301287

302288
installcheck: _install_upgrade_test_files

regress/expected/age_upgrade.out

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
-- Extension upgrade regression test
2121
--
2222
-- This test validates the upgrade template (age--<VER>--y.y.y.sql) by:
23-
-- 1. Installing AGE at the current version (built from the initial
24-
-- version-bump commit's SQL — the "day-one release" state)
23+
-- 1. Dropping AGE and reinstalling at the synthetic "initial" version
24+
-- (built from the version-bump commit's SQL — the "day-one" state)
2525
-- 2. Creating three graphs with multiple labels, edges, GIN indexes,
2626
-- and numeric properties that serve as integrity checksums
27-
-- 3. Upgrading to a synthetic "next" version via the stamped template
27+
-- 3. Upgrading to the current (default) version via the stamped template
2828
-- 4. Verifying all data, structure, and checksums survived the upgrade
2929
--
3030
-- The Makefile builds:
31-
-- age--<CURR>.sql from the initial version-bump commit (git history)
32-
-- age--<NEXT>.sql from current HEAD's sql/sql_files
33-
-- age--<CURR>--<NEXT>.sql stamped from the upgrade template
31+
-- age--<CURR>.sql from current HEAD's sql/sql_files (default)
32+
-- age--<CURR>_initial.sql from the version-bump commit (synthetic)
33+
-- age--<CURR>_initial--<CURR>.sql stamped from the upgrade template
3434
--
3535
-- All version discovery is dynamic — no hardcoded versions anywhere.
3636
-- This test is version-agnostic and works on any branch for any version.
@@ -39,7 +39,7 @@ LOAD 'age';
3939
SET search_path TO ag_catalog;
4040
-- Step 1: Clean up any state left by prior tests, then drop AGE entirely.
4141
-- The --load-extension=age flag installed AGE at the current (default) version.
42-
-- We need to remove it so we can cleanly re-create for this test.
42+
-- We need to remove it so we can reinstall at the synthetic initial version.
4343
SELECT drop_graph(name, true) FROM ag_graph ORDER BY name;
4444
drop_graph
4545
------------
@@ -54,8 +54,22 @@ FROM pg_available_extension_versions WHERE name = 'age';
5454
t
5555
(1 row)
5656

57-
-- Step 3: Install AGE at the default version (the initial release SQL).
58-
CREATE EXTENSION age;
57+
-- Step 3: Install AGE at the synthetic initial version (pre-upgrade state).
58+
DO $$
59+
DECLARE init_ver text;
60+
BEGIN
61+
SELECT version INTO init_ver
62+
FROM pg_available_extension_versions
63+
WHERE name = 'age' AND version LIKE '%_initial'
64+
ORDER BY version DESC
65+
LIMIT 1;
66+
IF init_ver IS NULL THEN
67+
RAISE EXCEPTION 'No initial version available for upgrade test';
68+
END IF;
69+
70+
EXECUTE format('CREATE EXTENSION age VERSION %L', init_ver);
71+
END;
72+
$$;
5973
SELECT extversion IS NOT NULL AS version_installed FROM pg_extension WHERE extname = 'age';
6074
version_installed
6175
-------------------
@@ -248,27 +262,26 @@ WHERE ag.name <> '_ag_catalog';
248262
21
249263
(1 row)
250264

251-
-- Step 6: Upgrade AGE to the synthetic next version via the stamped template.
265+
-- Step 6: Upgrade AGE from the initial version to the current (default) version
266+
-- via the stamped upgrade template.
252267
DO $$
253-
DECLARE next_ver text;
268+
DECLARE curr_ver text;
254269
BEGIN
255-
SELECT version INTO next_ver
256-
FROM pg_available_extension_versions
257-
WHERE name = 'age' AND version LIKE '%_upgrade_test'
258-
ORDER BY version DESC
259-
LIMIT 1;
260-
IF next_ver IS NULL THEN
261-
RAISE EXCEPTION 'No next version available for upgrade test';
270+
SELECT default_version INTO curr_ver
271+
FROM pg_available_extensions
272+
WHERE name = 'age';
273+
IF curr_ver IS NULL THEN
274+
RAISE EXCEPTION 'No default version found for upgrade test';
262275
END IF;
263276

264-
EXECUTE format('ALTER EXTENSION age UPDATE TO %L', next_ver);
277+
EXECUTE format('ALTER EXTENSION age UPDATE TO %L', curr_ver);
265278
END;
266279
$$;
267-
-- Step 7: Confirm version changed.
268-
SELECT installed_version <> default_version AS upgraded_past_default
280+
-- Step 7: Confirm version is now the default (current HEAD) version.
281+
SELECT installed_version = default_version AS upgraded_to_current
269282
FROM pg_available_extensions WHERE name = 'age';
270-
upgraded_past_default
271-
-----------------------
283+
upgraded_to_current
284+
---------------------
272285
t
273286
(1 row)
274287

regress/sql/age_upgrade.sql

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
-- Extension upgrade regression test
2222
--
2323
-- This test validates the upgrade template (age--<VER>--y.y.y.sql) by:
24-
-- 1. Installing AGE at the current version (built from the initial
25-
-- version-bump commit's SQL — the "day-one release" state)
24+
-- 1. Dropping AGE and reinstalling at the synthetic "initial" version
25+
-- (built from the version-bump commit's SQL — the "day-one" state)
2626
-- 2. Creating three graphs with multiple labels, edges, GIN indexes,
2727
-- and numeric properties that serve as integrity checksums
28-
-- 3. Upgrading to a synthetic "next" version via the stamped template
28+
-- 3. Upgrading to the current (default) version via the stamped template
2929
-- 4. Verifying all data, structure, and checksums survived the upgrade
3030
--
3131
-- The Makefile builds:
32-
-- age--<CURR>.sql from the initial version-bump commit (git history)
33-
-- age--<NEXT>.sql from current HEAD's sql/sql_files
34-
-- age--<CURR>--<NEXT>.sql stamped from the upgrade template
32+
-- age--<CURR>.sql from current HEAD's sql/sql_files (default)
33+
-- age--<CURR>_initial.sql from the version-bump commit (synthetic)
34+
-- age--<CURR>_initial--<CURR>.sql stamped from the upgrade template
3535
--
3636
-- All version discovery is dynamic — no hardcoded versions anywhere.
3737
-- This test is version-agnostic and works on any branch for any version.
@@ -42,16 +42,30 @@ SET search_path TO ag_catalog;
4242

4343
-- Step 1: Clean up any state left by prior tests, then drop AGE entirely.
4444
-- The --load-extension=age flag installed AGE at the current (default) version.
45-
-- We need to remove it so we can cleanly re-create for this test.
45+
-- We need to remove it so we can reinstall at the synthetic initial version.
4646
SELECT drop_graph(name, true) FROM ag_graph ORDER BY name;
4747
DROP EXTENSION age;
4848

4949
-- Step 2: Verify we have multiple installable versions.
5050
SELECT count(*) > 1 AS has_upgrade_path
5151
FROM pg_available_extension_versions WHERE name = 'age';
5252

53-
-- Step 3: Install AGE at the default version (the initial release SQL).
54-
CREATE EXTENSION age;
53+
-- Step 3: Install AGE at the synthetic initial version (pre-upgrade state).
54+
DO $$
55+
DECLARE init_ver text;
56+
BEGIN
57+
SELECT version INTO init_ver
58+
FROM pg_available_extension_versions
59+
WHERE name = 'age' AND version LIKE '%_initial'
60+
ORDER BY version DESC
61+
LIMIT 1;
62+
IF init_ver IS NULL THEN
63+
RAISE EXCEPTION 'No initial version available for upgrade test';
64+
END IF;
65+
66+
EXECUTE format('CREATE EXTENSION age VERSION %L', init_ver);
67+
END;
68+
$$;
5569
SELECT extversion IS NOT NULL AS version_installed FROM pg_extension WHERE extname = 'age';
5670

5771
-- Step 4: Create three test graphs with diverse labels, edges, and data.
@@ -194,25 +208,24 @@ SELECT count(*)::int AS total_labels_before
194208
FROM ag_label al JOIN ag_graph ag ON al.graph = ag.graphid
195209
WHERE ag.name <> '_ag_catalog';
196210

197-
-- Step 6: Upgrade AGE to the synthetic next version via the stamped template.
211+
-- Step 6: Upgrade AGE from the initial version to the current (default) version
212+
-- via the stamped upgrade template.
198213
DO $$
199-
DECLARE next_ver text;
214+
DECLARE curr_ver text;
200215
BEGIN
201-
SELECT version INTO next_ver
202-
FROM pg_available_extension_versions
203-
WHERE name = 'age' AND version LIKE '%_upgrade_test'
204-
ORDER BY version DESC
205-
LIMIT 1;
206-
IF next_ver IS NULL THEN
207-
RAISE EXCEPTION 'No next version available for upgrade test';
216+
SELECT default_version INTO curr_ver
217+
FROM pg_available_extensions
218+
WHERE name = 'age';
219+
IF curr_ver IS NULL THEN
220+
RAISE EXCEPTION 'No default version found for upgrade test';
208221
END IF;
209222

210-
EXECUTE format('ALTER EXTENSION age UPDATE TO %L', next_ver);
223+
EXECUTE format('ALTER EXTENSION age UPDATE TO %L', curr_ver);
211224
END;
212225
$$;
213226

214-
-- Step 7: Confirm version changed.
215-
SELECT installed_version <> default_version AS upgraded_past_default
227+
-- Step 7: Confirm version is now the default (current HEAD) version.
228+
SELECT installed_version = default_version AS upgraded_to_current
216229
FROM pg_available_extensions WHERE name = 'age';
217230

218231
-- Step 8: Verify all data survived — reload and recheck.

0 commit comments

Comments
 (0)