Skip to content

Add support for BETWEEN SYMMETRIC (Feature T461, “Symmetric BETWEEN predicate”) #7840

Open
@mrotteveel

Description

@mrotteveel

The current implementation of BETWEEN is the (implicit) BETWEEN ASYMMETRIC behaviour defined in the SQL standard. Also add the SYMMETRIC behaviour (and make it possible to specify ASYMMETRIC explicitly), also know as Feature T461, “Symmetric BETWEEN predicate”.

ISO-9075-2:2023 specifies (8.3 <between predicate>):

<between predicate> ::=
  <row value predicand> <between predicate part 2>

<between predicate part 2> ::=
  [ NOT ] BETWEEN [ ASYMMETRIC | SYMMETRIC ]
    <row value predicand> AND <row value predicand>

Syntax Rules

  1. If neither SYMMETRIC nor ASYMMETRIC is specified, then ASYMMETRIC is implicit.
  2. Let X, Y, and Z be the first, second, and third <row value predicand>s, respectively.
  3. “X NOT BETWEEN SYMMETRIC Y AND Z” is equivalent to “NOT ( X BETWEEN SYMMETRIC Y AND Z )”.
  4. “X BETWEEN SYMMETRIC Y AND Z” is equivalent to “((X BETWEEN ASYMMETRIC Y AND Z) OR (X BETWEEN ASYMMETRIC Z AND Y))”.
  5. “X NOT BETWEEN ASYMMETRIC Y AND Z” is equivalent to “NOT ( X BETWEEN ASYMMETRIC Y AND Z )”.
  6. “X BETWEEN ASYMMETRIC Y AND Z” is equivalent to “X>=Y AND X<=Z”.
  7. The Conformance Rules of Subclause 8.2, “<comparison predicate>”, are applied to the result of all syntactic transformations specified in this Subclause.

(no access rules and general rules)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions