Skip to content

No SDK can build an EQL v4 range operand for eql_v4.between — range bindings implement no EncryptFrom #1286

Open

Description

@coderdan

Background

EQL (Encrypt Query Language) is the SQL library we install into a customer's PostgreSQL database. EQL v4 is the copy of it that Stack Encrypt, our Rust encryption engine, writes into. #1243 gives EQL v4 a range query: eql_v4.between(column, range), where range is one value holding both bounds, {"v":4,"i":{...},"lo":<term>,"hi":<term>}. It is cast to a range query domain such as eql_v4.query_integer_range_ope. The Rust bindings in eql_bindings::v4 have one struct per range domain (IntegerRangeOpeQuery, DateRangeOreQuery, …), and the Go SDK has the matching []byte types.

Problem

No SDK can build a range value yet. A customer who wants BETWEEN on an encrypted column has the SQL for it, but nothing produces its operand. So they write two predicates (col >= $1 AND col <= $2), which is the shape ADR-0009 decision 7 removed: the two bounds travel separately and can be paired across columns.

Every single-bound query operand that has a stored term Stack Encrypt can derive already derives EncryptFrom<T>, e.g. DateOrdOpeQuery: EncryptFrom<NaiveDate>. The range structs implement neither EncryptFrom nor DecryptInto, for these reasons:

Proposal

  1. Have eql-codegen emit EncryptFrom<(S, S)> for the nine …RangeOpeQuery structs, with S the family's plaintext. Each bound is the OpeCllw the single-bound …OrdOpeQuery derives, under the same context. Add a test that a range built this way finds the same rows in PostgreSQL as two single-bound queries.
  2. Add a range domain to the target table (range_query_sql_domain, per ordering term), and generate it into the Go Types table.
  3. In query_term, build the {v, i, lo, hi} envelope for between on an EQL target instead of returning Error::Internal.
  4. Once block ORE lands and stashgen refuses TextOrdOre and TextSearchOre — EQL stores block ORE terms and the engine derives CLLW ORE #1132 settles the bound shape, do the same for the nine …RangeOreQuery structs.

Steps 1 to 3 can ship before step 4.

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