pg_hlc
pg_hlc · PostgreSQL HLC (Hybrid Logical Clock) extension in Rust compatible with Dart CRDT library.
Overview
Usage
Sources:
- Official upstream README
- Official extension control file (pg_hlc.control)
- Official extension SQL (pg_hlc–0.1.0.sql)
pg_hlc — A PostgreSQL extension (pg_hlc) that provides Hybrid Logical Clock (HLC) functionality with 100% compatibility with the Dart CRDT library. The extension is built using the pgrx framework and implements the exact same HLC algorithm and API as the Dart reference implementation. Use it when application data needs this type, domain, or its operators. Use the pinned upstream revision linked above as the API boundary and test it on the target PostgreSQL build.
Core Workflow
Install the extension in the intended database, run the smallest upstream example above when available, and verify the installed version and returned values before integrating it into application SQL.
Important Objects
hlc_compare(hlctimestamp, hlctimestamp)is an extension function and returnsinteger.hlc_eq(hlctimestamp, hlctimestamp)is an extension function and returnsboolean.hlc_from_date(text, text)is an extension function and returnshlctimestamp.hlc_gt(hlctimestamp, hlctimestamp)is an extension function and returnsboolean.hlc_gte(hlctimestamp, hlctimestamp)is an extension function and returnsboolean.hlc_increment(text)is an extension function and returnshlctimestamp.hlc_lt(hlctimestamp, hlctimestamp)is an extension function and returnsboolean.hlc_lte(hlctimestamp, hlctimestamp)is an extension function and returnsboolean.hlc_merge(text, hlctimestamp)is an extension function and returnshlctimestamp.hlc_ne(hlctimestamp, hlctimestamp)is an extension function and returnsboolean.hlc_now(text)is an extension function and returnshlctimestamp.hlc_parse(text)is an extension function and returnshlctimestamp.hlc_reset(text)is an extension function and returnsboolean.hlc_to_string(hlctimestamp)is an extension function and returnstext.
Requirements and Caveats
- The catalog records version
0.1.0. - The control file marks the extension as non-relocatable.
- The control file requires a superuser for installation.
- The control file marks the extension as not trusted.
- Confirm privileges, supported PostgreSQL versions, upgrade behavior, and failure cases against the pinned source before production use.