-- pg_uuid_v8 1.0 -> 1.1
-- Complain if script is sourced in psql, rather than via ALTER EXTENSION
\echo Use "ALTER EXTENSION pg_uuid_v8 UPDATE TO '1.1'" to load this file. \quit

-- Bugfix release: the embedded stego timestamp switches from microsecond to
-- millisecond internal storage granularity (2^48 ms ~= 8925 years before
-- rollover, vs. 2^48 us ~= 8.9 years). Previously, absolute-date recovery via
-- uuid_stego_extract_timestamp()/uuid_stego_in_range() was already broken in
-- practice (the 48-bit field couldn't hold current epoch-microsecond values
-- at all). Relative ordering (uuid_stego_lt/le/gt/ge, uuid_stego_compare)
-- was unaffected and remains unaffected.
--
-- No SQL-level signature changes: uuid_stego_extract_timestamp(uuid) still
-- returns a bigint scaled to microseconds for compatibility with
-- stego_time_to_timestamp()/uuid_stego_in_range(); resolution is now
-- milliseconds (the low 3 decimal digits are always zero). All function
-- bodies are reloaded against the new shared library on EXTENSION UPDATE.

CREATE OR REPLACE FUNCTION uuid_stego_generate() RETURNS uuid
  AS 'MODULE_PATHNAME', 'uuid_stego_generate'
  LANGUAGE C VOLATILE;

CREATE OR REPLACE FUNCTION uuid_stego_extract_timestamp(uuid) RETURNS bigint
  AS 'MODULE_PATHNAME', 'uuid_stego_extract_timestamp'
  LANGUAGE C IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION uuid_stego_compare(uuid, uuid) RETURNS integer
  AS 'MODULE_PATHNAME', 'uuid_stego_compare'
  LANGUAGE C IMMUTABLE STRICT;
