From 3f1f20ad70f38293c0e425d202418c5ffb540e2e Mon Sep 17 00:00:00 2001 From: fboulnois Date: Tue, 28 Nov 2023 18:50:54 -0500 Subject: [PATCH] feat: bump extension metadata to 1.4.0 --- Dockerfile | 8 ++++---- META.json | 6 +++--- Makefile | 2 +- README.md | 6 +++--- pg_uuidv7.control | 2 +- sql/pg_uuidv7--1.4.sql | 20 ++++++++++++++++++++ 6 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 sql/pg_uuidv7--1.4.sql diff --git a/Dockerfile b/Dockerfile index ac95f8b..3775a7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,10 +8,10 @@ COPY . /srv RUN for v in `seq 13 16`; do pg_buildext build-$v $v; done -RUN cp sql/pg_uuidv7--1.3.sql . && TARGETS=$(find * -name pg_uuidv7.so) \ - && tar -czvf pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.3.sql pg_uuidv7.control \ - && sha256sum pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.3.sql pg_uuidv7.control > SHA256SUMS +RUN cp sql/pg_uuidv7--1.4.sql . && TARGETS=$(find * -name pg_uuidv7.so) \ + && tar -czvf pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.4.sql pg_uuidv7.control \ + && sha256sum pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.4.sql pg_uuidv7.control > SHA256SUMS RUN cp ${PG_MAJOR}/pg_uuidv7.so /usr/lib/postgresql/${PG_MAJOR}/lib \ && cp pg_uuidv7.control /usr/share/postgresql/${PG_MAJOR}/extension \ - && cp pg_uuidv7--1.3.sql /usr/share/postgresql/${PG_MAJOR}/extension + && cp pg_uuidv7--1.4.sql /usr/share/postgresql/${PG_MAJOR}/extension diff --git a/META.json b/META.json index ab6c737..a142f0b 100644 --- a/META.json +++ b/META.json @@ -1,15 +1,15 @@ { "name": "pg_uuidv7", "abstract": "Create UUIDv7 values in Postgres", - "version": "1.3.0", + "version": "1.4.0", "maintainer": "fboulnois ", "license": "open_source", "provides": { "pg_uuidv7": { "abstract": "Create UUIDv7 values in Postgres", - "file": "sql/pg_uuidv7--1.3.sql", + "file": "sql/pg_uuidv7--1.4.sql", "docfile": "README.md", - "version": "1.3.0" + "version": "1.4.0" } }, "resources": { diff --git a/Makefile b/Makefile index 4bb18dc..a3941b4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ MODULES = pg_uuidv7 EXTENSION = pg_uuidv7 -DATA = sql/pg_uuidv7--1.3.sql +DATA = sql/pg_uuidv7--1.4.sql TESTS = $(wildcard test/sql/*.sql) REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS)) diff --git a/README.md b/README.md index df40305..66adc30 100644 --- a/README.md +++ b/README.md @@ -59,19 +59,19 @@ can be created in parallel in a distributed system. and extract it to a temporary directory 2. Copy `pg_uuidv7.so` for your Postgres version into the Postgres module directory -3. Copy `pg_uuidv7--1.3.sql` and `pg_uuidv7.control` into the Postgres extension +3. Copy `pg_uuidv7--1.4.sql` and `pg_uuidv7.control` into the Postgres extension directory 4. Enable the extension in the database using `CREATE EXTENSION pg_uuidv7;` ```sh # example shell script to install pg_uuidv7 cd "$(mktemp -d)" -curl -LO "https://github.com/fboulnois/pg_uuidv7/releases/download/v1.3.0/{pg_uuidv7.tar.gz,SHA256SUMS}" +curl -LO "https://github.com/fboulnois/pg_uuidv7/releases/download/v1.4.0/{pg_uuidv7.tar.gz,SHA256SUMS}" tar xf pg_uuidv7.tar.gz sha256sum -c SHA256SUMS PG_MAJOR=$(pg_config --version | sed 's/^.* \([0-9]\{1,\}\).*$/\1/') cp "$PG_MAJOR/pg_uuidv7.so" "$(pg_config --pkglibdir)" -cp pg_uuidv7--1.3.sql pg_uuidv7.control "$(pg_config --sharedir)/extension" +cp pg_uuidv7--1.4.sql pg_uuidv7.control "$(pg_config --sharedir)/extension" psql -c "CREATE EXTENSION pg_uuidv7;" ``` diff --git a/pg_uuidv7.control b/pg_uuidv7.control index bb28d99..08e1e67 100644 --- a/pg_uuidv7.control +++ b/pg_uuidv7.control @@ -1,4 +1,4 @@ comment = 'pg_uuidv7: create UUIDv7 values in postgres' -default_version = '1.3' +default_version = '1.4' module_pathname = '$libdir/pg_uuidv7' relocatable = true diff --git a/sql/pg_uuidv7--1.4.sql b/sql/pg_uuidv7--1.4.sql new file mode 100644 index 0000000..8ac4c99 --- /dev/null +++ b/sql/pg_uuidv7--1.4.sql @@ -0,0 +1,20 @@ +-- complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use '''CREATE EXTENSION "pg_uuidv7"''' to load this file. \quit + +-- 48 bits for ms since unix epoch (rollover in 10899), 74 bits of randomness +CREATE FUNCTION uuid_generate_v7() +RETURNS uuid +AS 'MODULE_PATHNAME', 'uuid_generate_v7' +VOLATILE STRICT LANGUAGE C PARALLEL SAFE; + +-- extract the timestamp from a v7 uuid +CREATE FUNCTION uuid_v7_to_timestamptz(uuid) +RETURNS timestamptz +AS 'MODULE_PATHNAME', 'uuid_v7_to_timestamptz' +VOLATILE STRICT LANGUAGE C PARALLEL SAFE; + +-- create a v7 uuid from a timestamp +CREATE FUNCTION uuid_timestamptz_to_v7(timestamptz, zero bool = false) +RETURNS uuid +AS 'MODULE_PATHNAME', 'uuid_timestamptz_to_v7' +VOLATILE STRICT LANGUAGE C PARALLEL SAFE;