From 9ed9489fb350cf0199511c27415d04967e60ffc3 Mon Sep 17 00:00:00 2001 From: "David E. Wheeler" Date: Mon, 29 Jan 2024 15:30:29 -0500 Subject: [PATCH] Use MODULE_PATHNAME and CREATE EXTENSION Use `MODULE_PATHNAME` in the SQL files to refer to the static library to build. This allows for the library to be renamed --- e.g., by a packaging system --- without having to change the source code, just the control file. Also use `CREATE EXTENSION` in the tests instead of loading the `sql/semver.sql` file directly. The latter was required before extension support was added to Postgres in 9.1, and 9.2 has been required since v0.20.0 back in 2018. Also note the change to the module directory in the previous commit (88b3abd), ignore generated `*.bin` files, and update the copyright year. --- .gitignore | 1 + Changes | 5 ++++ LICENSE | 2 +- Makefile | 2 +- README.md | 2 +- doc/semver.mmd | 2 +- sql/semver--0.10.0--0.11.0.sql | 2 +- sql/semver--0.15.0--0.16.0.sql | 8 +++---- sql/semver--0.31.2--0.32.0.sql | 4 ++-- sql/semver.sql | 44 +++++++++++++++++----------------- src/semver.c | 2 +- test/sql/base.sql | 2 +- test/sql/corpus.sql | 2 +- 13 files changed, 42 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 9853a12..d7adc64 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ regression.out /src/*.bc /semver_binary_copy.bin /.vscode +/*.bin diff --git a/Changes b/Changes index 14a0557..d2d4ecb 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,11 @@ Revision history for PostgreSQL extension semver. 0.32.2 + - Updated the installation configuration to install the SQL and + documentation files into `semver` subdirectories. + - Changed the tests to use `CREATE EXTENSION` instead of loading the + SQL source file directory. The latter was required for Postgres 9.0 + and lower, which have not been supported since v0.20.0 back in 2018. 0.32.1 2023-08-01T23:20:31Z - Fixed compilation issue on Postgres 16. diff --git a/LICENSE b/LICENSE index 3fe2a12..363b490 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2010-2023 The pg-semver Maintainers: David E. Wheeler, Sam +Copyright (c) 2010-2024 The pg-semver Maintainers: David E. Wheeler, Sam Vilain, Tom Davis, and Xavier Caron. This module is free software; you can redistribute it and/or modify it under diff --git a/Makefile b/Makefile index e70adb7..8777ed1 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ EXTVERSION = $(shell grep -m 1 '[[:space:]]\{8\}"version":' META.json | \ DISTVERSION = $(shell grep -m 1 '[[:space:]]\{3\}"version":' META.json | \ sed -e 's/[[:space:]]*"version":[[:space:]]*"\([^"]*\)",\{0,1\}/\1/') -MODULEDIR = semver +MODULEDIR = $(EXTENSION) DATA = $(wildcard sql/*.sql) DOCS = $(wildcard doc/*.mmd) TESTS = $(wildcard test/sql/*.sql) diff --git a/README.md b/README.md index 4bd4312..d8956e2 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ for testing, PL/pgSQL. Copyright and License --------------------- -Copyright (c) 2010-2023 The pg-semver Maintainers: David E. Wheeler, Sam +Copyright (c) 2010-2024 The pg-semver Maintainers: David E. Wheeler, Sam Vilain, Tom Davis, and Xavier Caron. This module is free software; you can redistribute it and/or modify it under diff --git a/doc/semver.mmd b/doc/semver.mmd index a223fd2..5f5544d 100644 --- a/doc/semver.mmd +++ b/doc/semver.mmd @@ -342,7 +342,7 @@ Authors Copyright and License --------------------- -Copyright (c) 2010-2023 The pg-semver Maintainers: David E. Wheeler, Sam +Copyright (c) 2010-2024 The pg-semver Maintainers: David E. Wheeler, Sam Vilain, Tom Davis, and Xavier Caron. This module is free software; you can redistribute it and/or modify it under diff --git a/sql/semver--0.10.0--0.11.0.sql b/sql/semver--0.10.0--0.11.0.sql index 66e09ff..ec5ee72 100644 --- a/sql/semver--0.10.0--0.11.0.sql +++ b/sql/semver--0.10.0--0.11.0.sql @@ -1,4 +1,4 @@ CREATE OR REPLACE FUNCTION is_semver(text) RETURNS bool - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; diff --git a/sql/semver--0.15.0--0.16.0.sql b/sql/semver--0.15.0--0.16.0.sql index a298c81..5b99014 100644 --- a/sql/semver--0.15.0--0.16.0.sql +++ b/sql/semver--0.15.0--0.16.0.sql @@ -4,20 +4,20 @@ CREATE OR REPLACE FUNCTION get_semver_major(semver) RETURNS int4 - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION get_semver_minor(semver) RETURNS int4 - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION get_semver_patch(semver) RETURNS int4 - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION get_semver_prerelease(semver) RETURNS text - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; diff --git a/sql/semver--0.31.2--0.32.0.sql b/sql/semver--0.31.2--0.32.0.sql index adda88a..d316051 100644 --- a/sql/semver--0.31.2--0.32.0.sql +++ b/sql/semver--0.31.2--0.32.0.sql @@ -1,11 +1,11 @@ CREATE OR REPLACE FUNCTION semver_recv(internal) RETURNS semver - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION semver_send(semver) RETURNS bytea - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; ALTER TYPE semver SET diff --git a/sql/semver.sql b/sql/semver.sql index cd23b47..11b3de6 100644 --- a/sql/semver.sql +++ b/sql/semver.sql @@ -26,22 +26,22 @@ CREATE TYPE semver; -- CREATE OR REPLACE FUNCTION semver_in(cstring) RETURNS semver - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION semver_out(semver) RETURNS cstring - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION semver_recv(internal) RETURNS semver - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION semver_send(semver) RETURNS bytea - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; -- @@ -67,7 +67,7 @@ CREATE TYPE semver ( CREATE OR REPLACE FUNCTION to_semver(text) RETURNS semver - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; -- @@ -76,12 +76,12 @@ CREATE OR REPLACE FUNCTION to_semver(text) CREATE OR REPLACE FUNCTION semver(text) RETURNS semver - AS 'semver', 'text_to_semver' + AS 'MODULE_PATHNAME', 'text_to_semver' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION text(semver) RETURNS text - AS 'semver', 'semver_to_text' + AS 'MODULE_PATHNAME', 'semver_to_text' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION semver(numeric) @@ -127,7 +127,7 @@ CREATE CAST (bigint AS semver) WITH FUNCTION semver(bigint); CREATE OR REPLACE FUNCTION semver_eq(semver, semver) RETURNS bool - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OPERATOR = ( @@ -143,7 +143,7 @@ CREATE OPERATOR = ( CREATE OR REPLACE FUNCTION semver_ne(semver, semver) RETURNS bool - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OPERATOR <> ( @@ -157,7 +157,7 @@ CREATE OPERATOR <> ( CREATE OR REPLACE FUNCTION semver_le(semver, semver) RETURNS bool - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OPERATOR <= ( @@ -169,7 +169,7 @@ CREATE OPERATOR <= ( CREATE OR REPLACE FUNCTION semver_lt(semver, semver) RETURNS bool - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OPERATOR < ( @@ -181,7 +181,7 @@ CREATE OPERATOR < ( CREATE OR REPLACE FUNCTION semver_ge(semver, semver) RETURNS bool - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OPERATOR >= ( @@ -193,7 +193,7 @@ CREATE OPERATOR >= ( CREATE OR REPLACE FUNCTION semver_gt(semver, semver) RETURNS bool - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OPERATOR > ( @@ -209,12 +209,12 @@ CREATE OPERATOR > ( CREATE OR REPLACE FUNCTION semver_cmp(semver, semver) RETURNS int4 - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION hash_semver(semver) RETURNS int4 - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; -- @@ -245,7 +245,7 @@ DEFAULT FOR TYPE semver USING hash AS CREATE OR REPLACE FUNCTION semver_smaller(semver, semver) RETURNS semver - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE AGGREGATE min(semver) ( @@ -256,7 +256,7 @@ CREATE AGGREGATE min(semver) ( CREATE OR REPLACE FUNCTION semver_larger(semver, semver) RETURNS semver - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE AGGREGATE max(semver) ( @@ -271,7 +271,7 @@ CREATE AGGREGATE max(semver) ( CREATE OR REPLACE FUNCTION is_semver(text) RETURNS bool - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; -- @@ -280,22 +280,22 @@ CREATE OR REPLACE FUNCTION is_semver(text) CREATE OR REPLACE FUNCTION get_semver_major(semver) RETURNS int4 - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION get_semver_minor(semver) RETURNS int4 - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION get_semver_patch(semver) RETURNS int4 - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE OR REPLACE FUNCTION get_semver_prerelease(semver) RETURNS text - AS 'semver' + AS 'MODULE_PATHNAME' LANGUAGE C STRICT IMMUTABLE; CREATE TYPE semverrange AS RANGE (SUBTYPE = semver); diff --git a/src/semver.c b/src/semver.c index 319f679..482f115 100644 --- a/src/semver.c +++ b/src/semver.c @@ -6,7 +6,7 @@ * + Tom Davis * + Xavier Caron * - * Copyright 2010-2023 The pg-semver Maintainers. This program is Free + * Copyright 2010-2024 The pg-semver Maintainers. This program is Free * Software; see the LICENSE file for the license conditions. */ diff --git a/test/sql/base.sql b/test/sql/base.sql index af599d8..53adb30 100644 --- a/test/sql/base.sql +++ b/test/sql/base.sql @@ -2,7 +2,7 @@ BEGIN; \i test/pgtap-core.sql -\i sql/semver.sql +CREATE EXTENSION semver; SELECT plan(334); --SELECT * FROM no_plan(); diff --git a/test/sql/corpus.sql b/test/sql/corpus.sql index 1f5f637..b3fdd8b 100644 --- a/test/sql/corpus.sql +++ b/test/sql/corpus.sql @@ -4,7 +4,7 @@ BEGIN; -- Test the SemVer corpus from https://regex101.com/r/Ly7O1x/3/. \i test/pgtap-core.sql -\i sql/semver.sql +CREATE EXTENSION semver; SELECT plan(71); --SELECT * FROM no_plan();