Skip to content

Commit

Permalink
Use MODULE_PATHNAME and CREATE EXTENSION
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
theory committed Jan 29, 2024
1 parent 88b3abd commit 9ed9489
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ regression.out
/src/*.bc
/semver_binary_copy.bin
/.vscode
/*.bin
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/semver.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sql/semver--0.10.0--0.11.0.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE OR REPLACE FUNCTION is_semver(text)
RETURNS bool
AS 'semver'
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT IMMUTABLE;
8 changes: 4 additions & 4 deletions sql/semver--0.15.0--0.16.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions sql/semver--0.31.2--0.32.0.sql
Original file line number Diff line number Diff line change
@@ -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
Expand Down
44 changes: 22 additions & 22 deletions sql/semver.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

--
Expand All @@ -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;

--
Expand All @@ -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)
Expand Down Expand Up @@ -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 = (
Expand All @@ -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 <> (
Expand All @@ -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 <= (
Expand All @@ -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 < (
Expand All @@ -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 >= (
Expand All @@ -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 > (
Expand All @@ -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;

--
Expand Down Expand Up @@ -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) (
Expand All @@ -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) (
Expand All @@ -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;

--
Expand All @@ -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);
2 changes: 1 addition & 1 deletion src/semver.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* + Tom Davis <tom@recursivedream.com>
* + Xavier Caron <xcaron@gmail.com>
*
* 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.
*/

Expand Down
2 changes: 1 addition & 1 deletion test/sql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
BEGIN;

\i test/pgtap-core.sql
\i sql/semver.sql
CREATE EXTENSION semver;

SELECT plan(334);
--SELECT * FROM no_plan();
Expand Down
2 changes: 1 addition & 1 deletion test/sql/corpus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 9ed9489

Please sign in to comment.