Skip to content

DATA wildcard doesn't install historical full-version SQL scripts (breaks test-build upgrade tests) #48

Description

@jnasbyupgrade

Summary

base.mk's DATA wildcard only picks up the current version file and upgrade-diff scripts — it silently skips historical full-install version scripts (sql/EXT--OLDVERSION.sql), even though these are meant to be tracked in git (per the .gitignore comment: "Version-specific files (sql/--.sql) are now tracked in git and should be committed").

# base.mk line 40
DATA         = $(EXTENSION_VERSION_FILES) $(wildcard sql/*--*--*.sql)

$(wildcard sql/*--*--*.sql) requires two -- separators, matching upgrade scripts like count_nulls--0.9.6--1.0.0.sql. A historical full-install script like count_nulls--0.9.6.sql (one --) never matches, so make install never places it in $(datadir)/extension/, and CREATE EXTENSION count_nulls VERSION '0.9.6' fails with "extension control file ... does not exist" even though the script is present in sql/ and committed to git.

Why this matters now

pgxntool 2.1.0's new test-build feature (test/build/*.sql, auto-run via pg_regress) is the natural place to put an "install old version, then ALTER EXTENSION ... UPDATE" sanity test. That pattern requires the old version's full install script to actually be installed — which this wildcard gap prevents by default.

Two independent extensions have hit this and needed the identical manual workaround in their own Makefile:

Suggested fix

Broaden the wildcard to also pick up single--- historical version files, e.g.:

DATA = $(EXTENSION_VERSION_FILES) $(wildcard sql/*--*.sql)

(sql/*--*.sql already covers both the two-dash upgrade scripts and the one-dash historical full-install scripts; EXTENSION_VERSION_FILES — the current version — would just be redundantly matched by the wildcard too, which is harmless.)

If that's too broad for some project shapes, an alternative is documenting the DATA += workaround explicitly in CLAUDE.md/README.asc under the test-build section, so extensions don't have to rediscover it via a failing test.

Repro

  1. Any extension with a historical full-install script for a version older than current (e.g. sql/count_nulls--0.9.6.sql, current default is 1.0.0).
  2. make install (without adding it to DATA manually).
  3. psql -c "CREATE EXTENSION count_nulls VERSION '0.9.6'" → fails, file not found in the extension directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions