Skip to content

Comparison predicates with row value constructors #2

Open
@glebm

Description

@glebm

SQL '92 standard, Predicates 209, defines row values comparison predicates as:

Let Rx and Ry be the two row value constructors of the comparison predicate and let RXi and RYi be the i-th row value constructor elements of Rx and Ry, respectively. "Rx comp op Ry" is true, false, or unknown as follows:

a) "x = Ry" is true if and only if RXi = RYi for all i.
b) "x <> Ry" is true if and only if RXi <> RYi for some i.
c) "x < Ry" is true if and only if RXi = RYi for all i < n and RXn < RYn for some n.
d) "x > Ry" is true if and only if RXi = RYi for all i < n and RXn > RYn for some n.

Example:

SELECT *
  FROM sales
 WHERE (sale_date, sale_id) < (?, ?)
 ORDER BY sale_date DESC, sale_id DESC

They are only on supported on certain databases (postgres yes, mysql no), and additional fiddling would probably be required to deal with array attributes (priority: high medium low) and differences in order direction between sort attributes.

I won't work on this in the near future, but this would be great to do on databases that support it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions