Changelog

All notable changes to pg_num2int_direct_comp will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

1.0.1 - 2026-11-30

Existing installations upgrade with ALTER EXTENSION pg_num2int_direct_comp UPDATE after installing the new files; no DROP EXTENSION is needed. There is no full 1.0.1 install script: CREATE EXTENSION runs the 1.0.0 script and then pg_num2int_direct_comp--1.0.0--1.0.1.sql.

Fixed

  • A join chain linking two integer columns of different widths through a float column, such as a.i2 = f.f8 AND f.f8 = b.i4, failed to plan with ERROR: operator 532 is not a member of opfamily 1970 (the operator and family numbers vary), under default settings, including in EXPLAIN. The three columns form one equivalence class whose btree families are float_ops and integer_ops. The planner derives a.i2 = b.i4 and checks merge joins on it with float_ops, which had no entries comparing two different integer widths. 1.0.1 adds those 30 operators and 6 support functions (all core objects) to float_ops, and float4 × float8 (10 operators, 2 functions) to integer_ops. Btree float_ops now passes amvalidate(); integer_ops lacks only numeric × float, which the extension does not provide. Workaround on 1.0.0: cast one integer side to the float type, or SET enable_mergejoin = off.
  • Plan change in 1.0.1: a chain through two integer widths and a numeric column, such as a.i2 = b.i4 AND b.i4 = n.n AND a.i2 = 5, still derives b.i4 = 5 but no longer derives n.n = 5; the numeric side is probed with the join value instead. Results are unchanged, and stock PostgreSQL derives no such clause either.
  • The support-function switch is now registered as pg_num2int_direct_comp.enable_support_functions, the name the README documents. 1.0.0 registered it as pg_num2int_direct_comp.enableSupportFunctions, so the documented SET ... = off created a placeholder and had no effect. The library also reserves the pg_num2int_direct_comp prefix, so a misspelled setting is now an error instead of a silent no-op.
  • Action needed if you set the camelCase name. There is no alias. A pg_num2int_direct_comp.enableSupportFunctions value persisted in postgresql.conf or with ALTER DATABASE ... SET / ALTER ROLE ... SET is now an unknown name under the reserved prefix: when the library loads, PostgreSQL drops it with a WARNING and the setting reverts to its default, so the optimization turns back on. Re-set it under pg_num2int_direct_comp.enable_support_functions (and RESET or remove the old name).
  • README: <> is not in the btree operator families (btree has strategies 1-5 only); the GUC example’s EXPLAIN output now matches what the server prints.

Changed

  • The DROP EXTENSION cleanup trigger lists only the operator family entries whose operator or support function is a core object: 90 from 1.0.0 and the 48 that 1.0.1 adds. The 156 DROPs it no longer has targeted entries that PostgreSQL already removes when DROP EXTENSION drops the extension’s own operators and functions (every int × float entry and every hash family entry). The 1.0.0 install script is trimmed in place; the 1.0.0 release on PGXN keeps the longer list, which removes the same entries. ALTER EXTENSION ... UPDATE replaces it with the 1.0.1 list.
  • README: the numeric × float limitation now gives its actual reasons (how existing numeric = float8 comparisons resolve, and the cost of hashing), instead of saying exact comparison is infeasible.
  • make check-version accepts an update script that ends at the default version in place of a full install script, and fails if an install or update script is missing from DATA.

Tests

  • cross_width_chains (new): 3-way joins int × float × int for every integer pair and both float types (18 combinations), counted and with ORDER BY ... LIMIT, at default settings and with merge joins forced, expecting no error; on 1.0.0 the 12 different-width combinations fail. It also records amvalidate() for the three btree families and the exact pairs integer_ops still lacks.
  • float_int_ops, merge_joins: the whole-family pg_amop counts are removed. They counted core PostgreSQL’s own entries too, so a PostgreSQL release changing those families would have broken them; extension_lifecycle’s footprint counts only what the extension adds.
  • float_int_ops: the per-pair check now checks which operator holds each strategy (1:< 2:<= 3:= 4:>= 5:>), not only that strategies 1-5 exist, and a new check does the same for every btree entry in float_ops, integer_ops and numeric_ops. The MERGES check now starts from the expected int × float pairs, so a missing = is reported instead of passing.

  • float_int_ops: transitivity tests now check stored float values at the float4 (224) and float8 (253) precision limits, where rounding comparisons would break transitivity, for int4 × float4, int8 × float8 and int8 × float4 (each reports how many nearby integers equal the stored value, expected at most 1); NaN and ±Infinity ordering is checked for all six float × int pairs in both operand orders; per-pair btree family completeness and MERGES checks list offenders instead of recording a count.

  • extension_lifecycle: the GUC test now runs against the registered name (it recorded an error and identical plans before) and checks that a misspelled name is rejected; the post-DROP EXTENSION check also covers the same-type entries added to float_ops and integer_ops.
  • comparison_exactness: Check 3 (operator functions, column vs column) now covers both operand orders, so the float OP int operators are checked against the exact reference too; it reports how many cases it ran. ex_float now has Infinity and -Infinity for both float types. The hand-written NaN/Infinity checks in float_int_ops (T018/T019) now point here.
  • extension_lifecycle: the post-DROP EXTENSION check no longer lists the entries it expects to be gone. It snapshots pg_amop and pg_amproc (all access methods and families) in a fresh database made from template0, installs the extension, prints what it added, and checks that DROP EXTENSION restores the snapshot exactly, that a reinstall matches the first install, and that every upgrade path to the default version matches a fresh install (1.0.0 → 1.0.1; since 1.0.1 has no full install script, a fresh install takes the same path). The comparison also covers the extension’s member objects and the planner-relevant properties of its operators and functions.
  • extension_lifecycle, doc_examples: the GUC blocks LOAD the library first, so SHOW and the misspelled-name check no longer depend on earlier statements in the file having used an operator.

1.0.0 - 2026-11-27

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_ops and float_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 HASHES and join the numeric_ops and float_ops hash 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 → FALSE at plan time
    • The constant may be on either side, and NULL semantics are kept on nullable columns.
  • DROP EXTENSION cleanup: an event trigger removes the extension’s entries from the built-in operator families, which pg_depend cannot 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 its Replaces: 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_new runs only on PostgreSQL 18 and later.
  • PGXN packaging: META.json, make dist (writes the release zip from the committed tree) and make check-version (checks META.json against the control file). .gitattributes keeps 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.
  • -Werror is 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 under specs/.

Performance

  • Numeric values are compared by reading their digit arrays directly (numeric_cmp_int64_direct()), without OidFunctionCall overhead.
  • 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 column was rewritten as if it were column OP const, so <, <=, > and >= returned the complement of the right answer (for example 0.5 > col matched no rows for col = 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_MAX was used as a range bound, which rounds up to 231 (float4) or 263 (float8). 2147483647::int4 = 2147483648::float4 returned true, and hash joins on such values used mismatched hashes.
  • Missing MERGES on 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 EXTENSION cleanup ran for any extension whose name started with ours, and ignored all errors; it now matches the whole name and ignores only undefined_object.

Removed (relative to the January 2026 snapshot)

  • The SupportRequestIndexCondition callback, superseded by SupportRequestSimplify.
  • doc/api-reference.md and doc/user-guide.md, merged into doc/operator-reference.md.