Skip to content

Variables forced after PGXS include cannot be overridden by users (CONTRIB_TESTDB / REGRESS_DBNAME) #29

@jnasbyupgrade

Description

@jnasbyupgrade

Problem

Some pgxntool variables are set with plain = after include $(PGXS) in base.mk, which means there is no way for a user to override them regardless of where they set values in their own Makefile. The most impactful case:

# base.mk — after include $(PGXS)
CONTRIB_TESTDB = $(REGRESS_DBNAME)

where REGRESS_DBNAME is computed as:

REGRESS_DBNAME = $(or $(PGXN),regression)_$(REGRESS_DBHASH)

and REGRESS_DBHASH is a hash of $(CURDIR). The result is a database name like cat_tools_dd113 — automatically derived, with no supported way to specify a different name.

Why this matters

  • Users running tests in environments with a specific pre-existing database (e.g. CI setups, shared servers) cannot tell pgxntool which database to use.
  • The ?= pattern works for variables set before PGXS is included, but once PGXS runs and pgxntool reassigns with =, any prior user setting is silently clobbered.
  • PGXNTOOL_NO_PGXS_INCLUDE=1 is the only current escape hatch, but it disables all of PGXS — a sledgehammer for what should be a simple knob.

Scope

This is a specific instance of a more general pattern: any variable that pgxntool sets with = or := after include $(PGXS) is effectively non-overridable. A systematic review of post-PGXS assignments should identify all such cases and decide for each whether ?= is appropriate or whether a separate user-facing override variable is needed.

Proposed fix

For CONTRIB_TESTDB / REGRESS_DBNAME specifically, one approach:

PGXNTOOL_REGRESS_DBNAME ?= $(or $(PGXN),regression)_$(REGRESS_DBHASH)
# ... after include $(PGXS) ...
CONTRIB_TESTDB = $(PGXNTOOL_REGRESS_DBNAME)

This preserves the auto-computed default while giving users a clean override point that won't be clobbered by PGXS.

More broadly, the fix should establish a convention: pgxntool should never use plain =/:= for a variable a user might reasonably want to control, unless there is a documented, tested override mechanism for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions