Skip to content

Extract versioned-SQL generation into sql.mk; install generated upgrade scripts (fixes #28)#32

Merged
jnasbyupgrade merged 1 commit into
Postgres-Extensions:masterfrom
jnasbyupgrade:fix-28-install-upgrade-scripts
Jul 17, 2026
Merged

Extract versioned-SQL generation into sql.mk; install generated upgrade scripts (fixes #28)#32
jnasbyupgrade merged 1 commit into
Postgres-Extensions:masterfrom
jnasbyupgrade:fix-28-install-upgrade-scripts

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What this is

Pure build-system refactor: moves the versioned-SQL generation machinery out of Makefile into a new, documented sql.mk, and fixes #28 so generated update scripts reliably land in DATA on a clean build.

What moved into sql.mk

sql.mk owns the versioned-SQL machinery and does include pgxntool/base.mk itself (the Makefile just include sql.mk):

Plus a sql.mk cleanup: trimmed comments, dropped the $B indirection, removed the now-unneeded sql/ dir-creation rule.

Why #28 happens

GNU Make is two-phase. The .sql we install are generated and gitignored, so they're absent when the makefile is parsed — any parse-time $(wildcard) over them (including base.mk's DATA seed) silently misses them, and Make's cached directory listing never picks them up later. So on a clean build the generated update scripts never reach DATA, make install skips them, and a later ALTER EXTENSION cat_tools UPDATE fails with "no update path". Fix: name-derive lists from the .sql.in sources, feed generated names into DATA explicitly, and $(sort).

Verification

On a clean tree the generated 0.2.0--0.2.1 / 0.2.0--0.2.2 / 0.2.1--0.2.2 update scripts now appear in DATA and make install copies them (they didn't before). make print-DATA is byte-identical clean vs. fully-built.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 466f7e5c-6475-489a-bd89-e5a3dc1b7dfc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jnasbyupgrade
jnasbyupgrade force-pushed the fix-28-install-upgrade-scripts branch 2 times, most recently from 2136cb5 to cb4c207 Compare July 15, 2026 23:11
@jnasbyupgrade jnasbyupgrade changed the title Install generated upgrade scripts on a clean build (fixes #28) Extract versioned-SQL generation into sql.mk; install generated upgrade scripts (fixes #28) Jul 15, 2026
@jnasbyupgrade
jnasbyupgrade force-pushed the fix-28-install-upgrade-scripts branch from cb4c207 to 077c091 Compare July 15, 2026 23:18
@jnasbyupgrade
jnasbyupgrade force-pushed the fix-28-install-upgrade-scripts branch 5 times, most recently from c6fd9e1 to f2a194f Compare July 16, 2026 23:37
…de scripts (fixes Postgres-Extensions#28)

The machinery that generates our versioned SQL (the cat_tools--X.Y.Z.sql
install scripts and cat_tools--A.B.C--X.Y.Z.sql update scripts) from .sql.in
sources, and the DATA list that installs it, is moved out of the Makefile into
a new, documented sql.mk. sql.mk now OWNS `include pgxntool/base.mk` (at its
top, so it can use EXTENSION_VERSION_FILES, PG_CONFIG, MAJORVER, datadir, ...);
the Makefile just does `include sql.mk`. base.mk has no include guard, so it
must be included exactly once -- see
Postgres-Extensions/pgxntool#50.

sql.mk documents the GNU Make two-phase (parse vs. recipe) hazard at the root
of the bug: we GENERATE the .sql we install, the generated files are gitignored
and absent on a clean tree at parse time, and any parse-time $(wildcard) over
them (including base.mk's DATA seed $(wildcard sql/*--*--*.sql)) silently comes
up short -- the cached directory listing means it never notices them later
either. The fix is to name-derive the install/update lists from the .sql.in
SOURCES (which DO exist at parse time), feed the generated names into DATA
explicitly, and $(sort) to dedup against base.mk's own wildcard. This makes the
generated upgrade scripts land in DATA reliably on a clean build, so
`make install` copies them and a later `ALTER EXTENSION cat_tools UPDATE` finds
its path.

The historical cat_tools--0.1.* install list is no longer hardcoded: it is
derived by globbing the committed install-shaped .sql and subtracting the
update scripts and everything we generate from .sql.in. Globbing COMMITTED
files at parse time is safe; the rule of thumb is glob what git tracks,
name-derive what we generate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jnasbyupgrade
jnasbyupgrade force-pushed the fix-28-install-upgrade-scripts branch from 36b6d71 to bbb42ec Compare July 17, 2026 00:01
@jnasbyupgrade
jnasbyupgrade merged commit ee48ca0 into Postgres-Extensions:master Jul 17, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean-build 'make test' fails on all PG>=12: generated upgrade scripts excluded from DATA (parse-time wildcard)

1 participant