diff --git a/packages/eql/docs/reference/eql-functions.md b/packages/eql/docs/reference/eql-functions.md index 103ecffbf..2b5e0f027 100644 --- a/packages/eql/docs/reference/eql-functions.md +++ b/packages/eql/docs/reference/eql-functions.md @@ -166,7 +166,7 @@ SELECT * FROM users WHERE eql_v4.between(age, $1::eql_v4.query_integer_range_ope ``` - `eql_v4.between` is an inlinable SQL function, so the planner sees `ord_term(age) >= lo AND ord_term(age) <= hi`, and a btree on the column's order term serves it as one range scan: `eql_v4.ord_term(col)` for an OPE column (`_ord`, `_ord_ope`, and `_search` for text), `eql_v4.ord_term_ore(col)` for an ORE one (`_ord_ore`, and `_search_ore` for text). -- **An ORE column needs the `eql_v4_internal.ore_block_256` btree operator class**, for its index and so for an ORE range scan. The installer creates that class only when it runs with superuser privileges. Otherwise (on Supabase and other managed roles) it skips it and disables the ORE column domains and the ORE range domains: a value cast to `_ord_ore` or `_search_ore` raises `feature_not_supported`, naming the OPE and equality alternatives, and a value cast to a `query__range_ore` domain raises the same error, naming the family's `_range_ope` domain. On such an install, use an OPE column and its `_range_ope` domain, which need nothing more. +- **An ORE column needs the `eql_v4_internal.ore_block_v2_operator_class` btree operator class**, for its index and so for an ORE range scan. The installer creates that class only when it runs with superuser privileges. Some platforms, such as Supabase, give the install role no way to create an operator class. There, the installer skips the class and disables the ORE column domains and the ORE range domains. A value cast to `_ord_ore` or `_search_ore` raises `feature_not_supported`, naming the OPE and equality alternatives. A value cast to a `query__range_ore` domain raises the same error, naming the family's `_range_ope` domain. On such an install, use an OPE column and its `_range_ope` domain. Neither needs the operator class. - Always write it schema-qualified. `BETWEEN` is an SQL keyword, so a bare `between(...)` does not parse. - **Always cast the range parameter to its exact range domain**, as in `$1::eql_v4.query_integer_range_ore`. PostgreSQL resolves a function's domain arguments as their base type, `jsonb`, and every `between` overload takes jsonb domains. So an uncast `$1`, a `jsonb` parameter, or a range of the wrong term (an OPE range on an `_ord_ore` column) or the wrong family matches several overloads, and the statement fails with SQLSTATE 42725 (`function eql_v4.between(...) is not unique`) when it is parsed, before it runs. This differs from the single-bound operators: `col < $1` resolves an untyped `$1`. - A `NULL` range matches no row. So does a range whose low bound is above its high bound, as with SQL `BETWEEN`; the SQL does not reorder the bounds. diff --git a/packages/eql/docs/reference/json-tree.md b/packages/eql/docs/reference/json-tree.md index 9ed303a97..18ebdad85 100644 --- a/packages/eql/docs/reference/json-tree.md +++ b/packages/eql/docs/reference/json-tree.md @@ -86,16 +86,25 @@ with `{"name": "Ada"}` at the path. ```sql SELECT id, profile FROM customers WHERE profile @> $1::eql_v4.query_json; SELECT id, profile FROM customers WHERE profile <@ $1::eql_v4.query_json; +SELECT id, profile FROM customers WHERE $1::eql_v4.query_json <@ profile; ``` Containment is answered by `jsonb @>` over the projection `eql_v4.json_tree_query(profile)`. A GIN index on that expression serves -both operators: +`profile @> $1::eql_v4.query_json`. The index also serves +`$1::eql_v4.query_json <@ profile`, the same test written the other way +round: ```sql CREATE INDEX ON customers USING gin ((eql_v4.json_tree_query(profile)) jsonb_path_ops); ``` +No index serves `profile <@ $1::eql_v4.query_json`, so that query reads +every row. PostgreSQL runs it as a `jsonb @>` test with +`eql_v4.json_tree_query(profile)` on the right. A GIN index on `jsonb`, +with `jsonb_path_ops` or `jsonb_ops`, serves `@>` only when the indexed +value is on the left. + Two containment needles on one array can be answered by different elements. To test several members of one element together, use the element function in the [section below](#one-array-element-and-a-whole-predicate).