Skip to content

Commit d25086e

Browse files
committed
Build cat_tools from its 0.3.0 git tag; adapt to its API/enum changes
pgxn install --unstable cat_tools resolves to the newest release actually published to the PGXN package index, which is still 0.2.1 (2017) and fails standalone on modern PostgreSQL with "column oid specified more than once" at CREATE EXTENSION. A fixed release, 0.3.0, is tagged in cat_tools' own git repo but hasn't been uploaded to PGXN yet, so the Makefile's cat_tools target now clones Postgres-Extensions/cat_tools at the 0.3.0 tag and builds/installs it directly. Since this is the first time object_reference's suite has actually run against a real, working cat_tools, two small fallout fixes are needed: - cat_tools.function__arg_types_text() is deprecated in 0.3.0 in favor of cat_tools.routine__parse_arg_types_text() (identical signature/body, just renamed, deprecated one emits a WARNING on every call). Switched object_reference's one call site to the non-deprecated name. - cat_tools 0.3.0's object_type enum grew two new members, "partitioned table" and "partitioned index". pg_get_object_address() doesn't recognize either (only the base table/index types they derive from), so object_reference classifies them as unsupported, matching object_reference.unsupported()'s existing handling of "event trigger" for the same reason. test/sql/all.sql's sanity-check of the unsupported set is updated to match. sql/object_reference--stable.sql and test/expected/zzz_build.out are regenerated (make results) to match. Extracted from PR #5, which had scope-crept into also carrying this fix alongside the actual CI/pgxn-tools migration; splitting it out here so it can be reviewed and merged independently.
1 parent e68bde8 commit d25086e

5 files changed

Lines changed: 40 additions & 10 deletions

File tree

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,23 @@ extra_clean += $(wildcard test/dump/*.log)
1717
dump_test: test/dump/run.sh test/helpers/object_table.sql $(wildcard test/dump/*.sql)
1818
$< -f # Force drop of databases if they exist
1919

20+
CAT_TOOLS_VERSION = 0.3.0
21+
CAT_TOOLS_BUILD_DIR = tmp/cat_tools-$(CAT_TOOLS_VERSION)
22+
extra_clean += $(CAT_TOOLS_BUILD_DIR)
23+
2024
.PHONY: cat_tools
2125
cat_tools: $(DESTDIR)$(datadir)/extension/cat_tools.control
2226
$(DESTDIR)$(datadir)/extension/cat_tools.control:
23-
pgxn install --unstable cat_tools
27+
# `pgxn install --unstable cat_tools` resolves to the newest release
28+
# published to the PGXN package index, which is still 0.2.1 -- it fails
29+
# standalone on modern PostgreSQL with "column oid specified more than
30+
# once" at CREATE EXTENSION. A fixed release, 0.3.0, is tagged in
31+
# cat_tools' own git repo but hasn't been uploaded to PGXN yet, so build
32+
# it from that tag directly until PGXN has it.
33+
rm -rf $(CAT_TOOLS_BUILD_DIR)
34+
git clone --branch $(CAT_TOOLS_VERSION) --depth 1 https://github.com/Postgres-Extensions/cat_tools.git $(CAT_TOOLS_BUILD_DIR)
35+
$(MAKE) -C $(CAT_TOOLS_BUILD_DIR) install PG_CONFIG=$(PG_CONFIG) DESTDIR=$(DESTDIR)
36+
rm -rf $(CAT_TOOLS_BUILD_DIR)
2437

2538
.PHONY: count_nulls
2639
count_nulls: $(DESTDIR)$(datadir)/extension/count_nulls.control

sql/object_reference--stable.sql

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ CREATE FUNCTION __object_reference.create_function(
8585
, grants text DEFAULT NULL
8686
) RETURNS void LANGUAGE plpgsql AS $body$
8787
DECLARE
88-
c_clean_args text := cat_tools.function__arg_types_text(args);
88+
c_clean_args text := cat_tools.routine__parse_arg_types_text(args);
8989

9090
create_template CONSTANT text := $template$
9191
CREATE OR REPLACE FUNCTION %s(
@@ -523,7 +523,12 @@ SELECT __object_reference.create_function(
523523
, $body$
524524
SELECT cat_tools.objects__shared()
525525
|| cat_tools.objects__address_unsupported()
526-
|| '{event trigger}'
526+
/*
527+
* pg_get_object_address() doesn't recognize "partitioned table" or
528+
* "partitioned index" (only the base "table"/"index" types it derives
529+
* from), so object identity tracking can't round-trip them.
530+
*/
531+
|| '{event trigger, partitioned table, partitioned index}'
527532
$body$
528533
, 'Returns array of object types that are not supported.'
529534
, 'object_reference__usage'

sql/object_reference.sql

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ CREATE FUNCTION __object_reference.create_function(
8484
, grants text DEFAULT NULL
8585
) RETURNS void LANGUAGE plpgsql AS $body$
8686
DECLARE
87-
c_clean_args text := cat_tools.function__arg_types_text(args);
87+
c_clean_args text := cat_tools.routine__parse_arg_types_text(args);
8888

8989
create_template CONSTANT text := $template$
9090
CREATE OR REPLACE FUNCTION %s(
@@ -522,7 +522,12 @@ SELECT __object_reference.create_function(
522522
, $body$
523523
SELECT cat_tools.objects__shared()
524524
|| cat_tools.objects__address_unsupported()
525-
|| '{event trigger}'
525+
/*
526+
* pg_get_object_address() doesn't recognize "partitioned table" or
527+
* "partitioned index" (only the base "table"/"index" types it derives
528+
* from), so object identity tracking can't round-trip them.
529+
*/
530+
|| '{event trigger, partitioned table, partitioned index}'
526531
$body$
527532
, 'Returns array of object types that are not supported.'
528533
, 'object_reference__usage'

test/expected/zzz_build.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
This extension must be loaded via CREATE EXTENSION object_reference;
33
You really, REALLY do NOT want to try and load this via psql!!!
44

5-
psql:test/temp_load.not_sql:188: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
5+
psql:test/temp_load.not_sql:187: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
66

7-
psql:test/temp_load.not_sql:189: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
7+
psql:test/temp_load.not_sql:188: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
88

99

1010

1111

1212

1313

14-
psql:test/temp_load.not_sql:513: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
14+
psql:test/temp_load.not_sql:512: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
1515

1616

1717

@@ -21,9 +21,9 @@ psql:test/temp_load.not_sql:513: WARNING: I promise you will be sorry if you tr
2121

2222

2323

24-
psql:test/temp_load.not_sql:620: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
24+
psql:test/temp_load.not_sql:624: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
2525

26-
psql:test/temp_load.not_sql:627: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
26+
psql:test/temp_load.not_sql:631: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
2727

2828

2929

test/sql/all.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ SELECT bag_eq(
5353
UNION -- Intentionally not UNION ALL; we want to know if object_reference.unsupported has dupes
5454
SELECT * FROM cat_tools.objects__address_unsupported_srf()
5555
UNION SELECT 'event trigger'
56+
/*
57+
* pg_identify_object_as_address() returns these as plain "table"/"index",
58+
* and pg_get_object_address() doesn't recognize "partitioned table" or
59+
* "partitioned index" at all, so the round-trip is broken.
60+
*/
61+
UNION SELECT 'partitioned table'
62+
UNION SELECT 'partitioned index'
5663
$$
5764
, 'Verify object_reference.unsupported()'
5865
);

0 commit comments

Comments
 (0)