Skip to content

Conversation

@katzyn
Copy link
Contributor

@katzyn katzyn commented Aug 4, 2023

Closes #3089.

GREATEST and LEAST are part of SQL:2023 Standard. Many database systems, including the H2, historically have these functions with various implementations, sometimes not fully compliant with the new Standard.

A default implementation is changed to be fully compliant with the Standard.
An implementation for Legacy compatibility mode is almost the same as it was in H2 historically¹, so it is possible to use this mode in applications if they need old behavior.
Implementations for PostgreSQL and MSSQLServer compatibility modes are also the same as they were before because these systems have the same incompatibility as H2.
Implementations for all other compatibility modes are also standard-compliant.

Optional non-standard clauses are introduced to have a possibility to use both standard and historic implementations if they are needed. These clauses were suggested here:
https://modern-sql.com/caniuse/greatest-least#null

With RESPECT NULLS standard-compliant implementation will be used in any compatibility mode.

With IGNORE NULLS old-style implementation will be used in any compatibility mode.

¹ There is also a difference in comparison operations with row values or array data types. These operations now use the same rules as regular comparison operations, earlier they incorrectly used rules of ordering operations.

@katzyn katzyn merged commit 9850f60 into h2database:master Aug 5, 2023
@katzyn katzyn deleted the T054 branch August 5, 2023 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GREATEST and LEAST aren't fully compliant with the SQL Standard

1 participant