Closed basaran closed 2 years ago
It took me quite a while to figure it out, but the problem seems to be incomplete installation instructions in the readme of this repository. I got the following code to work using docker, you should be able to adapt it to your system:
FROM postgres:13.1
RUN apt-get update && \
# Install ulid extension
apt install -y build-essential \
git \
postgresql-server-dev-13 && \
cd "$HOME" && \
git clone https://github.com/edoceo/pg-ulid.git && \
cd pg-ulid && \
git clone https://github.com/skeeto/ulid-c.git && \
cd ulid-c && \
make && \
cd .. && \
make && \
make install-strip && \
#register ulid extension with postgres (this code is run right after postgres starts initially)
echo "CREATE EXTENSION pg_ulid;" \
> /docker-entrypoint-initdb.d/ulid.sql && \
# cleanup
rm -rf /tmp/* /var/tmp/* /var/lib/apt/lists/*
I had followed the same steps, it's only the SELECT ulid_create(now() - '37 days'::interval);
throwing the error, select ulid_create()
is returning the ulid without any issues.
What's more puzzling are the ulid type creation scripts are commented out, perhaps it's a personal to do for the author. I'm referring to the sql script inside the built folder:
-- CREATE FUNCTION ulid_create;
-- CREATE TYPE ulid AS {
-- a int8,
-- b int8,
-- }
-- CREATE FUNCTION base36_filter(cstring)
-- RETURNS base36
-- AS '$libdir/base36'
-- LANGUAGE C IMMUTABLE STRICT;
--
-- CREATE FUNCTION base36_out(base36)
-- RETURNS cstring
-- AS '$libdir/base36'
-- LANGUAGE C IMMUTABLE STRICT;
--
-- CREATE TYPE base36 (
-- INPUT = base36_in,
-- OUTPUT = base36_out,
-- LIKE = integer
-- );
anyhow, this seems to be the fastest generator at this time. I posted benchmarks in #3
https://github.com/schinckel/ulid-postgres/blob/master/ulid.sql
This library has some sql based functions to extract the timestamp information, so I think for the moment I will use them.
Have you been able to get the SELECT ulid_create(now() - '37 days'::interval);
working with your docker image?
Hello,
Following the readme, execution of ulid_create with a timestamp returns the following error:
SELECT ulid_create(now() - '37 days'::interval);