Creates a ULID datatype as a 128bit integer, which we hope operates faster than text.
Creates some helper functions to create, compare and format
The ULID function is taken from [XXX] and other inspiration from [THE GO ONE]
Get this code, say make
, copy the .so file to your PGHOME/xxx
sudo apt install build-essential postgresql-server-dev-NN
git clone https://github.com/skeeto/ulid-c.git
make
sudo make install-strip
CREATE EXTENSION pg_ulid;
SELECT ulid_create();
SELECT ulid_create(now() - '37 days'::interval);
CREATE TABLE ulid_pk_example (
id ulid not null default ulid_create(),
meta jsonb
);
-
http://big-elephants.com/2015-10/writing-postgres-extensions-part-i/ http://big-elephants.com/2015-10/writing-postgres-extensions-part-ii/ http://sebastian-mader.net/databases-gis/creating-building-and-using-postgresql-extensions-in-c-c/ https://github.com/adjust/postgresql_extension_demo/tree/part_i
-
https://github.com/postgres/postgres/tree/master/contrib/uuid-ossp