Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion META.in.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
},
"runtime": {
"requires": {
"cat_tools": 0,
"cat_tools": "0.3.0",
"plpgsql": 0
}
},
Expand Down
2 changes: 1 addition & 1 deletion META.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
},
"runtime": {
"requires": {
"cat_tools": 0,
"cat_tools": "0.3.0",
"plpgsql": 0
}
},
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Good documentation should be like good code comments - explain things concisely

# Installation

This extension depends on the `cat_tools` extension.
This extension requires the `cat_tools` extension, version 0.3.0 or later.

```sql
CREATE EXTENSION object_reference CASCADE;
Expand Down
20 changes: 20 additions & 0 deletions sql/object_reference--0.1.0--stable.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*
* Requires cat_tools 0.3+ (a control file's `requires` can't carry a
* version). Only major.minor is compared; a version without a numeric
* major.minor, such as 'stable', is a development build and is let through.
*/
DO $$
DECLARE
c_version CONSTANT text := (SELECT extversion FROM pg_catalog.pg_extension WHERE extname = 'cat_tools');
c_major_minor CONSTANT text := substring(c_version FROM '^[0-9]+\.[0-9]+');
BEGIN
IF c_major_minor IS NOT NULL AND string_to_array(c_major_minor, '.')::int[] < '{0,3}' THEN
RAISE 'object_reference requires cat_tools 0.3.0 or later'
USING ERRCODE = 'object_not_in_prerequisite_state'
, DETAIL = format('installed cat_tools version is %s', c_version)
, HINT = 'Run ALTER EXTENSION cat_tools UPDATE first.'
;
END IF;
END
$$;

/*
* Disables all three event triggers for this script (a hand-written copy of
* event_trigger__disable(), which 0.1.0 lacks); event_trigger__enable() at the
Expand Down
20 changes: 20 additions & 0 deletions sql/object_reference.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ END
$$;
*/

/*
* Requires cat_tools 0.3+ (a control file's `requires` can't carry a
* version). Only major.minor is compared; a version without a numeric
* major.minor, such as 'stable', is a development build and is let through.
*/
DO $$
DECLARE
c_version CONSTANT text := (SELECT extversion FROM pg_catalog.pg_extension WHERE extname = 'cat_tools');
c_major_minor CONSTANT text := substring(c_version FROM '^[0-9]+\.[0-9]+');
BEGIN
IF c_major_minor IS NOT NULL AND string_to_array(c_major_minor, '.')::int[] < '{0,3}' THEN
RAISE 'object_reference requires cat_tools 0.3.0 or later'
USING ERRCODE = 'object_not_in_prerequisite_state'
, DETAIL = format('installed cat_tools version is %s', c_version)
, HINT = 'Run ALTER EXTENSION cat_tools UPDATE first.'
;
END IF;
END
$$;

DO $$
BEGIN
CREATE ROLE object_reference__usage NOLOGIN;
Expand Down
10 changes: 5 additions & 5 deletions test/build/expected/build.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ This extension must be loaded via CREATE EXTENSION object_reference;
You really, REALLY do NOT want to try and load this via psql!!!


psql:test/temp_load.not_sql:212: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
psql:test/temp_load.not_sql:232: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!

psql:test/temp_load.not_sql:213: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
psql:test/temp_load.not_sql:233: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!






psql:test/temp_load.not_sql:461: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
psql:test/temp_load.not_sql:481: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!



Expand All @@ -22,9 +22,9 @@ psql:test/temp_load.not_sql:461: WARNING: I promise you will be sorry if you tr



psql:test/temp_load.not_sql:573: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
psql:test/temp_load.not_sql:593: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!

psql:test/temp_load.not_sql:580: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
psql:test/temp_load.not_sql:600: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!



Expand Down
Loading