Skip to content

EQL v4 has no range query domains or eql_v4.between, so a Between term has no SQL operand #1237

Open

Description

@coderdan

Background

EQL (Encrypt Query Language) is the SQL library CipherStash installs into a customer's PostgreSQL. It stores encrypted values and lets the database search them. Stack Encrypt writes into EQL v4's types (ADR-0002). ADR-0009 decision 7 makes a BETWEEN query one term carrying both bounds, so a caller can't pair a bound from one column with a bound from another.

Problem

ADR-0009 decision 7 (packages/stack-encrypt/docs/adr/0009-operators-select-the-index-and-a-query-term-is-not-the-stored-term.md:571) says EQL v4 gains:

  • a function eql_v4.between(column, range);
  • a range query domain beside each ordered query domain, ORE and OPE, for example query_integer_range_ore beside query_integer_ord_ore.

Neither exists. No SQL under packages/eql/src defines a *_range_ore or *_range_ope domain, or an eql_v4.between function (checked on next). Stack Encrypt's Between already derives one RangeQuery term holding both bounds (#1208). Once the ordered types are producible, a caller will hold a Between term with no SQL operand to bind it to. The only fallback is two separate comparisons, which loses the one-term guarantee.

Proposal

  1. Add a range query domain for each ordered query domain, ORE and OPE, one per (family, term) as decision 8 has it. Generate them through eql-codegen with the rest of the catalog.
  2. Add eql_v4.between(column, range), inclusive at both ends, inlinable so an index on the order term is used (decision 7's inlining requirement). Do this for ORE and OPE.
  3. Generate the Rust and Go types for the range domains, so a Between term binds as one parameter.
  4. SQLx tests: rows inside, outside and at both bounds, and that the planner uses the functional index.

Relationship to other work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions