Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
81bdb18
Squashed 'pgxntool/' changes from c0af00f..bed3604
jnasbyupgrade Nov 6, 2024
5a01ec5
Pull pgxntool from git@github.com:decibel/pgxntool.git stable
jnasbyupgrade Nov 6, 2024
cb9b8a4
Add cat_tools 0.2.2: fix PG11+ and PG12+ compatibility via dynamic views
jnasbyupgrade Apr 8, 2026
3290094
Use block comment format for pg_class_v upgrade warning
jnasbyupgrade Apr 14, 2026
bdb5068
Fix attmissingval: consistent view schema across PG versions
jnasbyupgrade Apr 14, 2026
9ae32d8
Add pgxn-tools CI
jnasbyupgrade Nov 7, 2024
18b8ee5
Fix CI version matrix
jnasbyupgrade Nov 7, 2024
5b4b027
Add automated test workflow
jnasbyupgrade Nov 11, 2025
48a9e69
Install rsync in CI before running tests
jnasbyupgrade Apr 7, 2026
35be60b
Remove .travis.yml
jnasbyupgrade Nov 11, 2024
f691b98
Fix test failures on PG11+/PG12+/PG15+; add CLAUDE.md coding standards
jnasbyupgrade Apr 14, 2026
e4cdd3f
Makefile: drop .in pipeline; use wildcard for historical install scripts
jnasbyupgrade Apr 15, 2026
bac7018
Merge master into v0.2.2: extend CI matrix to PG 9.2-18
jnasbyupgrade Apr 17, 2026
ea08b38
Avoid DROP CASCADE in upgrade script; move attmissingval to end of view
jnasbyupgrade Apr 17, 2026
943c8ac
Merge pgext/master into v0.2.2: resolve .gitignore and Makefile confl…
jnasbyupgrade Apr 17, 2026
73f4066
Merge CLAUDE.md: combine git and code style sections
jnasbyupgrade Apr 17, 2026
3c45da2
Remove redundant include control.mk; base.mk already includes it
jnasbyupgrade Apr 17, 2026
ec3f771
Fix upgrade script: runtime detection for extschema on PG < 9.5
jnasbyupgrade Apr 17, 2026
3363ffe
Convert upgrade script to .sql.in with SED markers for extschema
jnasbyupgrade Apr 17, 2026
af7170a
Replace runtime attmissingval detection with SED markers
jnasbyupgrade Apr 17, 2026
1d58ff6
Fix pre-processed SED marker in cat_tools.sql.in
jnasbyupgrade Apr 17, 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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test:
strategy:
matrix:
pg: [17, 16, 15, 14, 13, 12, 11, 10, 9.6, 9.5, 9.4, 9.3, 9.2]
pg: [18, 17, 16, 15, 14, 13, 12, 11, 10, 9.6, 9.5, 9.4, 9.3, 9.2]
name: 🐘 PostgreSQL ${{ matrix.pg }}
runs-on: ubuntu-latest
container: pgxn/pgxn-tools
Expand All @@ -13,5 +13,7 @@ jobs:
run: pg-start ${{ matrix.pg }}
- name: Check out the repo
uses: actions/checkout@v4
- name: Install rsync
run: apt-get install -y rsync
- name: Test on PostgreSQL ${{ matrix.pg }}
run: pg-build-test
run: make test PGUSER=postgres
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test/install/schedule
# Misc
tmp/
.DS_Store
.claude/worktrees/

# pg_tle generated files
/pg_tle/
14 changes: 14 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,17 @@
**Never delete a branch without explicit user approval.** This includes `git push origin --delete`, `git branch -d`, and `git branch -D`. Always ask first.

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

## Code Style

### Comments
Always use block comment format for multi-line comments in SQL files:

```sql
/*
* First line of comment.
* Second line of comment.
*/
```

Never use `--` line comments for multi-line explanations.
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.1",
"version": "0.2.2",

"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.1",
"version": "0.2.2",

"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.1",
"version": "0.2.2",

"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.1",
"version": "0.2.2",

"X_comment": "Optional: \"abstract\": Description of the extension.",
"abstract": "Tools for interfacing with the catalog",
Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ include pgxntool/base.mk

LT95 = $(call test, $(MAJORVER), -lt, 95)
LT93 = $(call test, $(MAJORVER), -lt, 93)
LT12 = $(call test, $(MAJORVER), -lt, 120)
LT11 = $(call test, $(MAJORVER), -lt, 110)

$B:
@mkdir -p $@
Expand Down Expand Up @@ -44,6 +46,16 @@ ifeq ($(LT93),yes)
pgxntool/safesed $@.tmp -E -e 's/(.*)-- SED: REQUIRES 9.3!/-- Requires 9.3: \1/'
else
pgxntool/safesed $@.tmp -E -e 's/(.*)-- SED: PRIOR TO 9.3!/-- Not used prior to 9.3: \1/'
endif
ifeq ($(LT12),yes)
pgxntool/safesed $@.tmp -E -e 's/(.*)-- SED: REQUIRES 12!/-- Requires 12: \1/'
else
pgxntool/safesed $@.tmp -E -e 's/(.*)-- SED: PRIOR TO 12!/-- Not used prior to 12: \1/'
endif
ifeq ($(LT11),yes)
pgxntool/safesed $@.tmp -E -e 's/(.*)-- SED: REQUIRES 11!/-- Requires 11: \1/'
else
pgxntool/safesed $@.tmp -E -e 's/(.*)-- SED: PRIOR TO 11!/-- Not used prior to 11: \1/'
endif
mv $@.tmp $@

Expand Down
2 changes: 1 addition & 1 deletion cat_tools.control
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
comment = 'Tools for intorfacing with the catalog'
default_version = '0.2.1'
default_version = '0.2.2'
relocatable = false
schema = 'cat_tools'
5 changes: 5 additions & 0 deletions control.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
EXTENSION_cat_tools_VERSION := 0.2.2
$(EXTENSION_cat_tools_VERSION_FILE): sql/cat_tools.sql cat_tools.control
@echo '/* DO NOT EDIT - AUTO-GENERATED FILE */' > $(EXTENSION_cat_tools_VERSION_FILE)
@cat sql/cat_tools.sql >> $(EXTENSION_cat_tools_VERSION_FILE)

4 changes: 4 additions & 0 deletions sql/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# cat_tools.sql is generated from cat_tools.sql.in by `make` and should not be committed.
# Version-specific install/upgrade scripts (cat_tools--X.Y.Z.sql, cat_tools--X--Y.sql)
# ARE committed and tracked in git — see the parent .gitignore for details.
cat_tools.sql
# The following are generated by make from their .sql.in counterparts.
# Versions 0.1.0-0.1.5 have no .sql.in (pre-dates the conditional SED system
# or only pre-built SQL was published to PGXN), so they are committed as-is.
cat_tools--0.2.0.sql
cat_tools--0.2.1.sql
cat_tools--0.2.1--0.2.2.sql
150 changes: 150 additions & 0 deletions sql/cat_tools--0.2.1--0.2.2.sql.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
CREATE SCHEMA __cat_tools;

CREATE FUNCTION __cat_tools.exec(
sql text
) RETURNS void LANGUAGE plpgsql AS $body$
BEGIN
RAISE DEBUG 'sql = %', sql;
EXECUTE sql;
END
$body$;

CREATE FUNCTION __cat_tools.omit_column(
rel text
, omit name[] DEFAULT array['oid']
) RETURNS text LANGUAGE sql IMMUTABLE AS $body$
SELECT array_to_string(array(
SELECT attname
FROM pg_attribute a
WHERE attrelid = rel::regclass
AND NOT attisdropped
AND attnum >= 0
AND attname != ANY( omit )
ORDER BY attnum
)
, ', '
)
$body$;

ALTER DEFAULT PRIVILEGES IN SCHEMA cat_tools GRANT USAGE ON TYPES TO cat_tools__usage;

/*
* Recreate _cat_tools.pg_class_v with dynamic column list to handle PG12+ oid visibility.
* On PG < 12, oid was already hidden so the effective column list is unchanged;
* CREATE OR REPLACE VIEW works without disturbing dependent views.
*/
SELECT __cat_tools.exec(format($fmt$
CREATE OR REPLACE VIEW _cat_tools.pg_class_v AS
SELECT c.oid AS reloid
, %s
, n.nspname AS relschema
FROM pg_class c
LEFT JOIN pg_namespace n ON( n.oid = c.relnamespace )
;
$fmt$
, __cat_tools.omit_column('pg_catalog.pg_class')
));
REVOKE ALL ON _cat_tools.pg_class_v FROM public;

CREATE OR REPLACE VIEW cat_tools.pg_class_v AS
SELECT *
FROM _cat_tools.pg_class_v
WHERE NOT pg_is_other_temp_schema(relnamespace)
AND relkind IN( 'r', 'v', 'f' )
;
GRANT SELECT ON cat_tools.pg_class_v TO cat_tools__usage;

/*
* Recreate _cat_tools.pg_attribute_v to handle PG11+ attmissingval.
* attmissingval is appended at the end so CREATE OR REPLACE VIEW can add it
* without invalidating dependent views — no DROP CASCADE needed.
* On PG < 11 (where attmissingval doesn't exist) it is exposed as NULL::text[].
*/
SELECT __cat_tools.exec(format($fmt$
CREATE OR REPLACE VIEW _cat_tools.pg_attribute_v AS
SELECT %s
, c.*
, t.oid AS typoid
, %s
, a.attmissingval::text::text[] AS attmissingval -- SED: REQUIRES 11!
, NULL::text[] AS attmissingval -- SED: PRIOR TO 11!
FROM pg_attribute a
LEFT JOIN _cat_tools.pg_class_v c ON ( c.reloid = a.attrelid )
LEFT JOIN pg_type t ON ( t.oid = a.atttypid )
;
$fmt$
, __cat_tools.omit_column('pg_catalog.pg_attribute', array['attmissingval'])
, __cat_tools.omit_column('pg_catalog.pg_type')
));
REVOKE ALL ON _cat_tools.pg_attribute_v FROM public;

-- Refresh _cat_tools.column and cat_tools.column to pick up the new attmissingval column.
CREATE OR REPLACE VIEW _cat_tools.column AS
SELECT *
, pg_catalog.format_type(typoid, atttypmod) AS column_type
, CASE typtype
WHEN 'd' THEN pg_catalog.format_type(typbasetype, typtypmod)
WHEN 'e' THEN 'text'
ELSE pg_catalog.format_type(typoid, atttypmod)
END AS base_type
, pk.conkey AS pk_columns
, ARRAY[attnum] <@ pk.conkey AS is_pk_member
, (SELECT pg_catalog.pg_get_expr(d.adbin, d.adrelid)
FROM pg_catalog.pg_attrdef d
WHERE d.adrelid = a.attrelid
AND d.adnum = a.attnum
AND a.atthasdef
) AS column_default
FROM _cat_tools.pg_attribute_v a
LEFT JOIN pg_constraint pk
ON ( reloid = pk.conrelid )
AND pk.contype = 'p'
;
REVOKE ALL ON _cat_tools.column FROM public;

CREATE OR REPLACE VIEW cat_tools.column AS
SELECT *
FROM _cat_tools.column
WHERE NOT pg_is_other_temp_schema(relnamespace)
AND attnum > 0
AND NOT attisdropped
AND relkind IN( 'r', 'v', 'f' )
AND (
pg_has_role(SESSION_USER, relowner, 'USAGE'::text)
OR has_column_privilege(SESSION_USER, reloid, attnum, 'SELECT, INSERT, UPDATE, REFERENCES'::text)
)
ORDER BY relschema, relname, attnum
;
GRANT SELECT ON cat_tools.column TO cat_tools__usage;

/*
* Fix cat_tools.pg_extension_v for PG12+ oid visibility.
* On PG < 12, oid was already hidden so the effective column list is unchanged;
* CREATE OR REPLACE VIEW works without disturbing pg_extension__get or other dependents.
*/
SELECT __cat_tools.exec(format($fmt$
CREATE OR REPLACE VIEW cat_tools.pg_extension_v AS
SELECT e.oid
, %s

, extnamespace::regnamespace AS extschema -- SED: REQUIRES 9.5!
, nspname AS extschema -- SED: PRIOR TO 9.5!

, extconfig::pg_catalog.regclass[] AS ext_config_tables
FROM pg_catalog.pg_extension e
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace
;
$fmt$
, __cat_tools.omit_column('pg_catalog.pg_extension')
));
GRANT SELECT ON cat_tools.pg_extension_v TO cat_tools__usage;

-- Drop temporary helper objects
DROP FUNCTION __cat_tools.omit_column(
rel text
, omit name[]
);
DROP FUNCTION __cat_tools.exec(
sql text
);
DROP SCHEMA __cat_tools;
Loading
Loading