Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
5a01ec5
Pull pgxntool from git@github.com:decibel/pgxntool.git stable
jnasbyupgrade Nov 6, 2024
81bdb18
Squashed 'pgxntool/' changes from c0af00f..bed3604
jnasbyupgrade Nov 6, 2024
d231a58
Add support for Postgres 13
jnasbyupgrade Nov 7, 2024
e8e2717
Add pgxn-tools CI
jnasbyupgrade Nov 7, 2024
0ff8a9a
Fix CI version matrix
jnasbyupgrade Nov 7, 2024
5c59f66
Remove .travis.yml
jnasbyupgrade Nov 11, 2024
ca7c8c1
Add new relkind entries
jnasbyupgrade Aug 28, 2025
700ac3b
Add relation__is_temp and relation__is_catalog functions
jnasbyupgrade Aug 29, 2025
4addd8c
Fix relation__column_names test to use temporary table instead of pg_…
jnasbyupgrade Sep 3, 2025
b1afca2
Fix missing commits
jnasbyupgrade Sep 3, 2025
3bde4a8
Add function__arg_names()
jnasbyupgrade Sep 23, 2025
c75eb40
Rename function__arg_* to routine__parse_arg_*
jnasbyupgrade Sep 23, 2025
262434f
Remove errant function from README
jnasbyupgrade Sep 23, 2025
6ad3efb
Refactor routine__arg_names() and reorganize file structure
jnasbyupgrade Sep 25, 2025
82be5ac
Add enum types for pg_proc fields and clean up permissions
jnasbyupgrade Sep 25, 2025
7a5fe71
Add missing test file
jnasbyupgrade Nov 11, 2025
21ec71b
Add automated test workflow
jnasbyupgrade Nov 11, 2025
55db3c7
Pull pgxntool from git@github.com:decibel/pgxntool.git release
jnasbyupgrade Jan 22, 2026
5332bc5
Squashed 'pgxntool/' changes from bed3604..54793a3
jnasbyupgrade Jan 22, 2026
4b86e4f
Update .gitignore from pgxntool template
jnasbyupgrade Jan 22, 2026
4c780b0
Update to new pgxntool standards
jnasbyupgrade Feb 4, 2026
65a998b
Pull pgxntool from git@github.com:decibel/pgxntool.git release
jnasbyupgrade Feb 19, 2026
5e73ee9
Squashed 'pgxntool/' changes from 54793a3..3b8cb2a
jnasbyupgrade Feb 19, 2026
5f7e573
Pull pgxntool from git@github.com:decibel/pgxntool.git release
jnasbyupgrade Feb 19, 2026
bb6146b
Squashed 'pgxntool/' changes from 3b8cb2a..639756c
jnasbyupgrade Feb 19, 2026
a4f0695
Add placeholder comment to empty upgrade file
jnasbyupgrade Feb 26, 2026
7473aa7
Fix compatibility with PostgreSQL 15+
jnasbyupgrade Apr 6, 2026
34d6fcf
Populate upgrade script from 0.2.1 to 0.3.0
jnasbyupgrade Apr 6, 2026
ab0306c
Merge origin/master into new_functions
jnasbyupgrade Apr 6, 2026
3028c8a
Squashed 'pgxntool/' changes from 639756c..121f0b3
jnasbyupgrade Apr 6, 2026
a4e8746
Pull pgxntool from git@github.com:decibel/pgxntool.git release
jnasbyupgrade Apr 6, 2026
9e73dfb
Update .gitignore after pgxntool-sync
jnasbyupgrade Apr 6, 2026
1763a93
Switch to pgxntool built-in test/build support
jnasbyupgrade Apr 6, 2026
d910a3c
Rename zzz_build.sql to build.sql
jnasbyupgrade Apr 7, 2026
3c33da3
Install rsync in CI before running tests
jnasbyupgrade Apr 7, 2026
cd75dc6
Add upgrade test and populate 0.2.1→0.3.0 upgrade script
jnasbyupgrade Apr 7, 2026
ab5f735
Fix 0.2.1 install script for PG12+ and run upgrade test unconditionally
jnasbyupgrade Apr 7, 2026
d9fd646
Revert 0.2.1.sql changes; fix upgrade test for PG12+ compatibility
jnasbyupgrade Apr 7, 2026
a3c7476
Use explicit version number in PG12+ upgrade test
jnasbyupgrade Apr 7, 2026
84e9a0d
Fix upgrade test threshold: 0.2.1 broken on PG11+ (attmissingval), no…
jnasbyupgrade Apr 7, 2026
11fcb95
Bridge 0.2.2→0.3.0 upgrade path; cast attmissingval to text::text[]
jnasbyupgrade Apr 8, 2026
4f45664
Fix upgrade test: use ERROR to suppress deprecation WARNINGs
jnasbyupgrade Apr 14, 2026
3e290be
Release cat_tools 0.2.2: fix PG11+ and PG12+ compatibility (#7)
jnasbyupgrade Apr 27, 2026
12c5596
Remove old travis file
jnasbyupgrade Apr 27, 2026
9af1f2e
Merge branch 'master' into new_functions
jnasbyupgrade Apr 27, 2026
4b18338
Fix sql/.gitignore violations: replace tracked .sql with .sql.in
jnasbyupgrade Apr 27, 2026
5366157
Update copyright to 2026
jnasbyupgrade Apr 27, 2026
e2525b0
Merge master into new_functions; resolve version/history conflicts
jnasbyupgrade Apr 27, 2026
5400e68
Consolidate permissions tests; fix pg_attribute_v format bug; expand CI
jnasbyupgrade Apr 27, 2026
f605bb4
test/upgrade-drift: add prompt files for upgrade-drift test planning
jnasbyupgrade Apr 27, 2026
f5a65d9
Drop PostgreSQL 10 support for 0.3.0
jnasbyupgrade Apr 28, 2026
3f9070d
Enforce update/upgrade terminology; add 0.3.0 history section
jnasbyupgrade Apr 28, 2026
2d5179e
Merge remote-tracking branch 'pgext/master' into new_functions
jnasbyupgrade Apr 28, 2026
752088f
Fix two CI failures introduced by merge into new_functions
jnasbyupgrade Apr 28, 2026
a1796d5
Remove dead /test/.build/ entry from .gitignore
jnasbyupgrade Apr 28, 2026
8146d5a
Fix stale build test expected output
jnasbyupgrade Apr 28, 2026
94a29b5
Fix PG11 ALTER TYPE restriction in upgrade test and CI matrix
jnasbyupgrade Apr 29, 2026
1b31c0d
Fix binary pg_upgrade compatibility: exclude relhasoids from pg_class_v
jnasbyupgrade Apr 30, 2026
7d3d367
Also omit relhaspkey from pg_class_v (removed in PG11)
jnasbyupgrade May 1, 2026
0c54003
Also omit attcacheoff from pg_attribute_v (removed in PG18)
jnasbyupgrade May 1, 2026
312a11c
Consolidate relation__ and routine__ test suites
jnasbyupgrade May 1, 2026
56b6667
Drop PG11 support: version that can't be updated to is not truly supp…
jnasbyupgrade May 1, 2026
15c6ad6
Remove accidental commits: upgrade-drift prompts and dead test/.gitig…
jnasbyupgrade May 1, 2026
124f5b0
Move function.sql tests into routine__.sql
jnasbyupgrade May 1, 2026
f3cf9a3
Move \set s to top of relation__ and routine__ test suites
jnasbyupgrade May 1, 2026
c61bc28
Restore function.sql; remove non-routine__ tests from routine__.sql
jnasbyupgrade May 1, 2026
8f6ea7b
Merge remote-tracking branch 'pgext/master' into new_functions
jnasbyupgrade May 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 21 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
test:
strategy:
matrix:
pg: [18, 17, 16, 15, 14, 13, 12, 11, 10]
pg: [18, 17, 16, 15, 14, 13, 12]
name: 🐘 PostgreSQL ${{ matrix.pg }}
runs-on: ubuntu-latest
container: pgxn/pgxn-tools
Expand All @@ -34,14 +34,6 @@ jobs:
strategy:
matrix:
include:
- old_pg: "10"
new_pg: "11"
- old_pg: "10"
new_pg: "18"
- old_pg: "11"
new_pg: "12"
- old_pg: "11"
new_pg: "18"
- old_pg: "12"
new_pg: "13"
- old_pg: "12"
Expand All @@ -68,6 +60,9 @@ jobs:
pg_isready -t 30
- name: Check out the repo
uses: actions/checkout@v6
- name: Set expected extension version
run: |
echo "EXPECTED_VERSION=$(sed -n "s/^default_version = '\(.*\)'$/\1/p" cat_tools.control)" >> $GITHUB_ENV
- name: Install rsync
run: apt-get install -y rsync
- name: Install cat_tools into old cluster
Expand Down Expand Up @@ -104,7 +99,7 @@ jobs:
run: |
VERSION=$(psql -tAc "SELECT extversion FROM pg_extension WHERE extname = 'cat_tools'")
echo "Extension version: ${VERSION:-<not found>}"
echo "$VERSION" | grep -q "0.2.2"
echo "$VERSION" | grep -qF "$EXPECTED_VERSION"
- name: Run test suite on upgraded cluster
run: make test
# TODO: also test ALTER EXTENSION cat_tools UPDATE here, once the
Expand All @@ -115,17 +110,12 @@ jobs:
extension-update-test:
strategy:
matrix:
# Restricted to PG10 only because the pre-0.2.2 install scripts use
# unqualified SELECT * in views over pg_attribute/pg_constraint:
# - PG11 added attmissingval (pseudo-type anyarray) to pg_attribute,
# so cat_tools--0.2.0.sql and cat_tools--0.2.1.sql fail on PG11+
# with "column attmissingval has pseudo-type anyarray".
# - PG12 made the `oid` system column visible in SELECT *, causing
# "column oid specified more than once" on PG12+.
# PG10 is the only version where both old scripts install cleanly.
# TODO: when a future version's install script works on PG11+, expand
# this matrix and add tests for the upgrade path from 0.2.2 onwards.
pg: [10]
# PG12 is the oldest version where the 0.2.2→0.3.0 update works.
# PG11 (and PG10) cannot run `ALTER TYPE ... ADD VALUE` in extension
# update scripts; this restriction was lifted in PG12.
# (PG10 is dropped; the 0.2.0/0.2.1 update paths required PG10 and
# can no longer be tested.)
pg: [12]
name: ⬆️ Extension update test on PostgreSQL ${{ matrix.pg }}
runs-on: ubuntu-latest
container: pgxn/pgxn-tools
Expand All @@ -136,23 +126,19 @@ jobs:
uses: actions/checkout@v6
- name: Install rsync
run: apt-get install -y rsync
- name: Set expected extension version
run: |
echo "EXPECTED_VERSION=$(sed -n "s/^default_version = '\(.*\)'$/\1/p" cat_tools.control)" >> $GITHUB_ENV
- name: Install cat_tools (all versions)
run: make install
- name: Test upgrade from 0.2.0 (direct 0.2.0→0.2.2 path)
run: |
psql -c "CREATE EXTENSION cat_tools VERSION '0.2.0'"
psql -c "ALTER EXTENSION cat_tools UPDATE"
VERSION=$(psql -tAc "SELECT extversion FROM pg_extension WHERE extname = 'cat_tools'")
echo "Version after 0.2.0 upgrade: ${VERSION:-<not found>}"
echo "$VERSION" | grep -q "0.2.2"
- name: Test upgrade from 0.2.1 (0.2.1→0.2.2 path)
- name: Test update from 0.2.2 (0.2.2→current path)
run: |
createdb cat_tools_from_021
psql -d cat_tools_from_021 -c "CREATE EXTENSION cat_tools VERSION '0.2.1'"
psql -d cat_tools_from_021 -c "ALTER EXTENSION cat_tools UPDATE"
VERSION=$(psql -d cat_tools_from_021 -tAc "SELECT extversion FROM pg_extension WHERE extname = 'cat_tools'")
echo "Version after 0.2.1 upgrade: ${VERSION:-<not found>}"
echo "$VERSION" | grep -q "0.2.2"
createdb cat_tools_from_022
psql -d cat_tools_from_022 -c "CREATE EXTENSION cat_tools VERSION '0.2.2'"
psql -d cat_tools_from_022 -c "ALTER EXTENSION cat_tools UPDATE"
VERSION=$(psql -d cat_tools_from_022 -tAc "SELECT extversion FROM pg_extension WHERE extname = 'cat_tools'")
echo "Version after 0.2.2 update: ${VERSION:-<not found>}"
echo "$VERSION" | grep -qF "$EXPECTED_VERSION"
- name: Run test suite on updated extension
run: make test

Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ control.mk
# built targets
# Note: Version-specific files (sql/*--*.sql) are now tracked in git and should be committed

# test targets
/test/.build/

# Test artifacts
results/
regression.diffs
Expand Down
35 changes: 22 additions & 13 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,42 @@ When fixing a bug, add a comment at the fix site explaining what the bug was and

**Always open PRs against the main repo** (`Postgres-Extensions/cat_tools`), not a fork.

## Terminology

- **Extension update**: moving from one cat_tools version to another (e.g. `ALTER EXTENSION cat_tools UPDATE`). Always say "update" for this.
- **PostgreSQL upgrade**: upgrading a PostgreSQL cluster to a newer major version (e.g. `pg_upgrade`, `pg_upgradecluster`). Always say "upgrade" for this.

Never use "upgrade" to describe an extension version change, and never use "update" to describe a PostgreSQL cluster version change.

## SQL file conventions

Rules for what to track in git:

0. If a `.sql.in` file exists, track the `.sql.in` and **not** the corresponding `.sql`.
1. If no `.sql.in` exists, track the `.sql` directly (e.g. historical pre-0.2.0 files).
2. Version-specific install scripts (e.g. `sql/cat_tools--0.2.2.sql.in`) MUST be tracked.
3. Upgrade scripts (e.g. `sql/cat_tools--0.2.1--0.2.2.sql.in`) MUST be tracked.
3. Update scripts (e.g. `sql/cat_tools--0.2.1--0.2.2.sql.in`) MUST be tracked.
4. The current version'''s install script (e.g. `sql/cat_tools--0.2.2.sql.in`) is generated
by `make` from `sql/cat_tools.sql.in`, but MUST still be tracked (rule 2 applies).
5. Version-specific files MUST NEVER be edited manually — always edit `sql/cat_tools.sql.in`
and regenerate.

## CI: extension-update-test matrix
## CI: PostgreSQL version support

**Policy:** Never support a fresh install on any PostgreSQL version where the extension
update path is known to be broken — a version that cannot be updated to is not truly
supported.

The `extension-update-test` job in `.github/workflows/ci.yml` is currently restricted to
`pg: [10]` because that is the only PostgreSQL version where the pre-0.2.2 install scripts
install cleanly:
- PG 11 added `attmissingval` (pseudo-type `anyarray`) to `pg_attribute`; the old `SELECT *`
in `0.2.0`/`0.2.1` tries to include it directly, failing with "column attmissingval has
pseudo-type anyarray".
- PG 12+ exposed the `oid` system column in `SELECT *`, breaking `0.2.0`/`0.2.1` with
"column oid specified more than once".
Both PG10 and PG11 are dropped as of 0.3.0. The `ALTER TYPE ... ADD VALUE` statements in
the update script cannot run inside an extension update script on PG11 or earlier
(PROCESS_UTILITY_QUERY context); this restriction was lifted in PG12. Because a version
that cannot be updated to is not truly supported, PG10 and PG11 support is dropped
entirely. cat_tools 0.3.0 supports PG12+.

**When working on a new version:** review and expand this matrix. The new version's install
script may support more PG versions, enabling testing of the upgrade path from older
cat_tools versions on newer PostgreSQL.
The `extension-update-test` job tests `pg: [12]` — PG12 is the oldest version where the
0.2.2→0.3.0 update works. PG11 (and PG10) cannot run `ALTER TYPE ... ADD VALUE` in
extension update scripts; this restriction was lifted in PG12. The 0.2.0/0.2.1 update
paths required PG10 and can no longer be tested.

## Code Style

Expand Down
48 changes: 33 additions & 15 deletions HISTORY.asc
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
0.3.0
-----
New functions and types for working with routines and partitioned relations.

### PostgreSQL Version Support

**PostgreSQL 10 and 11 are no longer supported** as of this release. The 0.2.2→0.3.0
update script adds values to existing enum types (`ALTER TYPE ... ADD VALUE`), which
cannot run inside an extension update script on PG11 or earlier (a restriction lifted
in PG12). Because a version that cannot be updated to is not truly supported, PG10 and
PG11 support is dropped entirely.

cat_tools 0.3.0 supports **PostgreSQL 12 through 18+**.

### Changes

// TODO

0.2.2
-----
Compatibility release: fixes broken installs on PostgreSQL 11 and 12+, and
provides an upgrade path from 0.2.0 and 0.2.1.
provides an update path from 0.2.0 and 0.2.1.


### PostgreSQL Version Support
Expand All @@ -15,24 +33,24 @@ It fails on newer versions due to catalog schema changes:
* **PG 12**: System catalog `oid` columns became visible as regular columns. Views
using `SELECT c.*` alongside an explicit `c.oid` alias produce duplicate column names.

cat_tools 0.2.2 installs and upgrades correctly on **PostgreSQL 9.2 through 18+**
cat_tools 0.2.2 installs and updates correctly on **PostgreSQL 9.2 through 18+**
(all currently supported versions).

### Upgrade Path
### Update Path

**You must upgrade cat_tools to 0.2.2 before upgrading PostgreSQL to version 11 or
later.** Upgrade via `ALTER EXTENSION cat_tools UPDATE`.
**You must update cat_tools to 0.2.2 before upgrading PostgreSQL to version 11 or
later.** Update via `ALTER EXTENSION cat_tools UPDATE`.

### Upgrade Warning: Objects Depending on `cat_tools.column`
### Update Warning: Objects Depending on `cat_tools.column`

`cat_tools.column` in 0.2.0 and 0.2.1 had extra columns: an unqualified `SELECT *`
across a `LEFT JOIN pg_constraint` accidentally pulled in all `pg_constraint` columns
(`conname`, `contype`, etc.). The 0.2.2 upgrade fixes the column list by dropping and
(`conname`, `contype`, etc.). The 0.2.2 update fixes the column list by dropping and
recreating `cat_tools.column` (and its underlying `_cat_tools.column`).

**If you have created any views, functions, or other objects that depend on
`cat_tools.column`, you must drop them before upgrading and recreate them
afterward.** The upgrade will fail with an error if any such dependent objects
`cat_tools.column`, you must drop them before updating and recreate them
afterward.** The update will fail with an error if any such dependent objects
exist — this is intentional, to avoid silently breaking user-defined objects.
After dropping your dependent objects, run `ALTER EXTENSION cat_tools UPDATE` again.

Expand All @@ -56,25 +74,25 @@ to PostgreSQL 12 or later.**

### Changes

* `sql/cat_tools--0.1.4--0.1.5.sql` was empty; added `-- empty upgrade` placeholder so
PostgreSQL accepts it as a valid (no-op) upgrade script.
* `sql/cat_tools--0.1.4--0.1.5.sql` was empty; added `-- empty update` placeholder so
PostgreSQL accepts it as a valid (no-op) update script.
* `cat_tools.column` now exposes `attmissingval` as `text[]` (cast from `anyarray` on
PG 11+, or `NULL::text[]` on older versions). Any `SELECT *` on `cat_tools.column`
will now include this column.
* Views rebuilt using `omit_column()` to enumerate columns explicitly, avoiding both the
`anyarray` and duplicate-`oid` problems.
* A direct `0.2.0 → 0.2.2` upgrade path is provided (`cat_tools--0.2.0--0.2.2.sql`),
* A direct `0.2.0 → 0.2.2` update path is provided (`cat_tools--0.2.0--0.2.2.sql`),
which also applies all 0.2.1 function additions in a single step.
* `GRANT SELECT ON cat_tools.pg_extension_v TO cat_tools__usage` is now applied on the
upgrade path from 0.2.0 (it was absent in 0.2.0 and only added via the 0.2.1 upgrade).
update path from 0.2.0 (it was absent in 0.2.0 and only added via the 0.2.1 update).
* (Re-release) `_cat_tools.pg_class_v` now explicitly omits `relhasoids` (removed in PG12)
and `relhaspkey` (removed in PG17) to prevent `pg_upgrade` failures.
* (Re-release) `_cat_tools.pg_attribute_v` now explicitly omits `attcacheoff` (removed in
PG17) to prevent `pg_upgrade` failures.

0.2.1
-----
Fix significant problems with a previous upgrade script.
Fix significant problems with a previous update script.

Add pg_extension_v and related functions.

Expand Down Expand Up @@ -114,7 +132,7 @@ objects would cascede to the extension itself.

0.1.2
-----
=## BUGFIX: Install upgrade script
=## BUGFIX: Install update script

0.1.1
-----
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Jim Nasby
Copyright (c) 2016-2026 Jim Nasby

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions META.in.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "cat_tools",

"X_comment": "REQUIRED. Version of the distribution. http://pgxn.org/spec/#version",
"version": "0.2.2",
"version": "0.3.0",

"X_comment": "REQUIRED. Short description of distribution.",
"abstract": "Tools for interfacing with the Postgres catalog",
Expand All @@ -37,7 +37,7 @@
"file": "sql/cat_tools.sql",

"X_comment": "REQUIRED. Version the extension is at.",
"version": "0.2.2",
"version": "0.3.0",

"X_comment": "Optional: \"abstract\": Description of the extension.",
"abstract": "Tools for interfacing with the catalog",
Expand Down
4 changes: 2 additions & 2 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "cat_tools",

"X_comment": "REQUIRED. Version of the distribution. http://pgxn.org/spec/#version",
"version": "0.2.2",
"version": "0.3.0",

"X_comment": "REQUIRED. Short description of distribution.",
"abstract": "Tools for interfacing with the Postgres catalog",
Expand All @@ -37,7 +37,7 @@
"file": "sql/cat_tools.sql",

"X_comment": "REQUIRED. Version the extension is at.",
"version": "0.2.2",
"version": "0.3.0",

"X_comment": "Optional: \"abstract\": Description of the extension.",
"abstract": "Tools for interfacing with the catalog",
Expand Down
43 changes: 3 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ upgrade_scripts_out = $(subst sql/,$B/,$(subst .sql.in,.sql,$(wildcard sql/*--*-

# Pre-built historical install scripts (no .sql.in source available)
DATA += sql/cat_tools--0.1.0.sql sql/cat_tools--0.1.3.sql sql/cat_tools--0.1.4.sql sql/cat_tools--0.1.5.sql
# Generated historical install scripts (built from .sql.in source).
# Generated install scripts (built from .sql.in source).
# Exclude EXTENSION_VERSION_FILES (managed by control.mk) and upgrade scripts
# ($(upgrade_scripts_out), already handled by base.mk) to avoid duplicates.
DATA += $(filter-out $(EXTENSION_VERSION_FILES) $(upgrade_scripts_out), $(versioned_out))

all: $B/cat_tools.sql $(versioned_out)
installcheck: $B/cat_tools.sql $(versioned_out)
EXTRA_CLEAN += $B/cat_tools.sql $(filter-out $(EXTENSION_VERSION_FILES), $(versioned_out))
# Also clean the generated .sql.in for the current version
EXTRA_CLEAN += $(EXTENSION_VERSION_FILES:.sql=.sql.in)
EXTRA_CLEAN += $B/cat_tools.sql $(versioned_out)

# Temporary ugly hack for 9.x — remove these two blocks when 9.x support is dropped.
# $@ is deferred via = and expands to the target name at recipe time.
Expand Down Expand Up @@ -57,6 +55,7 @@ define _apply_version_seds
{print}' $@.tmp > $@.tmp2 && mv $@.tmp2 $@.tmp
endef


# TODO: refactor the version stuff into a function
#
# This initially creates $@.tmp before moving it into place atomically. That's
Expand Down Expand Up @@ -88,42 +87,6 @@ $(EXTENSION_VERSION_FILES): $(EXTENSION_VERSION_FILES:.sql=.sql.in) pgxntool/saf
$(_apply_version_seds)
mv $@.tmp $@

# Support for upgrade test
#
# TODO: Instead of all of this stuff figure out how to pass something to
# pg_regress that will alter the behavior of the test instead.
TEST_BUILD_DIR = test/.build
testdeps: $(TEST_BUILD_DIR)/dep.mk $(TEST_BUILD_DIR)/active.sql
-include $(TEST_BUILD_DIR)/dep.mk

# Ensure dep.mk exists.
$(TEST_BUILD_DIR)/dep.mk: $(TEST_BUILD_DIR)
echo 'TEST_LOAD_SOURCE = new' > $(TEST_BUILD_DIR)/dep.mk

.PHONY: set-test-new
set-test-new: $(TEST_BUILD_DIR)
echo 'TEST_LOAD_SOURCE = new' > $(TEST_BUILD_DIR)/dep.mk

.PHONY: test-upgrade
set-test-upgrade: $(TEST_BUILD_DIR)
echo 'TEST_LOAD_SOURCE = upgrade' > $(TEST_BUILD_DIR)/dep.mk


$(TEST_BUILD_DIR)/active.sql: $(TEST_BUILD_DIR)/dep.mk $(TEST_BUILD_DIR)/$(TEST_LOAD_SOURCE).sql
ln -sf $(TEST_LOAD_SOURCE).sql $@

$(TEST_BUILD_DIR)/upgrade.sql: test/load_upgrade.sql $(TEST_BUILD_DIR) old_version
(echo @generated@ && cat $< && echo @generated@) | sed -e 's#@generated@#-- GENERATED FILE! DO NOT EDIT! See $<#' > $@.tmp
mv $@.tmp $@

$(TEST_BUILD_DIR)/new.sql: test/load_new.sql $(TEST_BUILD_DIR)
(echo @generated@ && cat $< && echo @generated@) | sed -e 's#@generated@#-- GENERATED FILE! DO NOT EDIT! See $<#' > $@.tmp
mv $@.tmp $@

# TODO: figure out vpath
EXTRA_CLEAN += $(TEST_BUILD_DIR)/
$(TEST_BUILD_DIR):
[ -d $@ ] || mkdir -p $@

.PHONY: old_version
old_version: $(DESTDIR)$(datadir)/extension/cat_tools--0.2.0.sql
Expand Down
Loading