Repository navigation
Releases
Releases · datastone-inc/pg_num2int_direct_comp
1.0.0
First tagged release, and the first on PGXN. A pre-release snapshot of the
code was described here as 1.0.0 in January 2026 but never tagged; this
entry replaces that description. If you built that snapshot from git, drop
and recreate the extension: there is no upgrade script from it, and it had
the wrong-result bugs listed under "Fixed in this release" below.
Added
- 108 operators:
=,<>,<,<=,>,>=for (numeric, float4, float8) × (int2, int4, int8), plus their commutators. Every comparison is exact: no value is rounded before it is compared. - Btree operator families: the operators join
integer_ops,numeric_opsandfloat_ops, with 9 cross-type comparison support functions, so indexes, indexed nested loop joins and merge joins apply to both int × numeric and int × float. See Float × Integer Btree Ops research. - Hash operator families: the equality operators are
HASHESand join thenumeric_opsandfloat_opshash families (integers are hashed as numeric or float8), so hash joins apply. - Constant predicate rewriting via
SupportRequestSimplify:- Impossible predicates:
int_col = 10.5::numeric→FALSE - Exact matches:
int_col = 100::numeric→int_col = 100(native operator) - Range boundaries:
int_col > 10.5→int_col >= 11 - Out-of-range constants:
int2_col = 99999→FALSEat plan time - The constant may be on either side, and NULL semantics are kept on nullable columns.
- Impossible predicates:
DROP EXTENSIONcleanup: an event trigger removes the extension's entries from the built-in operator families, whichpg_dependcannot track, so the extension can be reinstalled cleanly.- Type aliases (
serial,bigserial,smallserial,decimal), SQL NULL handling, and IEEE 754 special values (NaN, Infinity). - PostgreSQL 16, 17, 18 and 19. 16 is the minimum: the NULL handling uses
Var.varnullingrels, which 16 added, and building against an older server stops with an#error. PostgreSQL 19 has alternate expected outputs for itsReplaces:EXPLAIN line. - Regression suite (pg_regress), including
comparison_exactness, which checks every int × numeric/float comparison against an exact reference, constant on either side, on NOT NULL and nullable columns, plus hash/equality consistency for every hashable operator.returning_old_newruns only on PostgreSQL 18 and later. - PGXN packaging:
META.json,make dist(writes the release zip from the committed tree) andmake check-version(checksMETA.jsonagainst the control file)..gitattributeskeeps the agent and editor files out of the archive. - CI: GitHub Actions builds with warnings as errors and runs the regression tests on PostgreSQL 16 to 19, on x86_64 and arm64.
-Werroris opt-in (make WERROR=1), so a compiler with warnings this code has not met still builds it.- Documentation: README,
doc/installation.md,doc/operator-reference.md,doc/benchmark.md,doc/development.md, and research notes underspecs/.
Performance
- Numeric values are compared by reading their digit arrays directly (
numeric_cmp_int64_direct()), withoutOidFunctionCalloverhead. - Hash functions compute on stack arrays, with no palloc/pfree.
- Integer type bounds are cached as Numeric values; operator OIDs are kept in a lazy per-backend array cache, checked against the catalog by tests.
Benchmark (2026-01-02):
| Operation | Extension | Stock PostgreSQL | Speedup |
|---|---|---|---|
| Point lookup | 0.025 ms (Index) | 17.3 ms (Seq Scan) | ~690x |
| Range scan | 0.8 ms (Bitmap) | 23.4 ms (Seq Scan) | ~29x |
| Nested Loop Join | 3 ms | 49,658 ms | ~16,500x |
Fixed in this release (relative to the January 2026 snapshot)
- Wrong results with the constant on the left of a range comparison:
const OP columnwas rewritten as if it werecolumn OP const, so<,<=,>and>=returned the complement of the right answer (for example0.5 > colmatched no rows forcol = 0).=and<>were not affected. - Wrong int × float results at the integer type limits: out-of-range floats were converted back to integers (undefined behaviour in C), and
(float) INT_MAXwas used as a range bound, which rounds up to 2^31 (float4) or 2^63 (float8).2147483647::int4 = 2147483648::float4returned true, and hash joins on such values used mismatched hashes. - Missing
MERGESon int2 × float4, int2 × float8 and int4 × float8=, so the planner never chose a merge join for them. - NULL semantics were dropped by some support-function rewrites.
- Build on PostgreSQL 16 and 17:
Var.varreturningtype, which exists only from 18, is now read only there. DROP EXTENSIONcleanup ran for any extension whose name started with ours, and ignored all errors; it now matches the whole name and ignores onlyundefined_object.
Removed (relative to the January 2026 snapshot)
- The
SupportRequestIndexConditioncallback, superseded bySupportRequestSimplify. doc/api-reference.mdanddoc/user-guide.md, merged intodoc/operator-reference.md.