@@ -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
5354AGE_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
5556AGE_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
5960AGE_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
196197REGRESS_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
198199ag_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
201202GEN_KEYWORDLIST = $(PERL ) -I ./tools/ ./tools/gen_keywordlist.pl
202203GEN_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
226227src/backend/parser/cypher_keywords.o : src/backend/parser/cypher_gram.c src/include/parser/cypher_gram_def.h
227228src/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 ) > $@
252236ifeq ($(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
257239endif
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.
261244ifneq ($(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 > $@
265250ifeq ($(SIZEOF_DATUM ) ,4)
266251 @sed 's/^ PASSEDBYVALUE,$$/ -- PASSEDBYVALUE removed for 32-bit (see Makefile)/' $@ > $@.tmp && mv $@.tmp $@
267252endif
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" $< > $@
273258endif
274259
275260src/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)
293279installcheck : export LC_COLLATE=C
294280ifneq ($(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
302288installcheck : _install_upgrade_test_files
0 commit comments