-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: allow refcursor comparison with NULL values #112070
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @mgartner)
ce698e1
to
753606d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @DrewKimball)
-- commits
line 20 at r2:
Very interesting behavior! Good job getting to the bottom of it!
pkg/sql/logictest/testdata/logic_test/refcursor
line 514 at r2 (raw file):
true true true
Can you add some tests for values on the RHS that lead to errors? From my testing, anything other than an untyped NULL
will cause operator does not exist
errors: column refs, CASE expressions, typed NULLs, etc.
Most comparisons are disallowed for the REFCURSOR data type. For example, the following is not allowed in postgres: ``` SELECT 'foo'::REFCURSOR = 'bar'::REFCURSOR; ``` However, postgres does allow using `IS [NOT] DISTINCT FROM NULL` and `IS [NOT] NULL` with a refcursor-typed expression os the left operand. There are a few places where CRDB internally expects this comparison to be valid as well, so disallowing these comparisons has caused test failures. This patch removes the refcursor-specific check for invalid comparisons during type checking, and relies on execution-time checks as is done for other comparisons. This means that `IsNull` and `IsNotNull` expressions can now be executed. In addition, the `IS DISTINCT FROM NULL` comparison is now supported only for the case of type `REFCURSOR` as the left operand, and `UNKNOWN` (NULL) as the right operand. Fixes cockroachdb#112010 Fixes cockroachdb#112011 Release note: None
753606d
to
1c2d813
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @mgartner)
pkg/sql/logictest/testdata/logic_test/refcursor
line 514 at r2 (raw file):
typed NULLs,
Oh, good find. Done.
TFTRs! bors r+ |
Build succeeded: |
Most comparisons are disallowed for the REFCURSOR data type. For example, the following is not allowed in postgres:
However, postgres does allow using
IS [NOT] DISTINCT FROM NULL
andIS [NOT] NULL
with a refcursor-typed expression os the left operand. There are a few places where CRDB internally expects this comparison to be valid as well, so disallowing these comparisons has caused test failures.This patch removes the refcursor-specific check for invalid comparisons during type checking, and relies on execution-time checks as is done for other comparisons. This means that
IsNull
andIsNotNull
expressions can now be executed. In addition, theIS DISTINCT FROM NULL
comparison is now supported only for the case of typeREFCURSOR
as the left operand, andUNKNOWN
(NULL) as the right operand.Fixes #112010
Fixes #112011
Release note: None