-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Teach a negative NULL expression to return NULL instead of an error #3771
Conversation
There is a tradeoff, namely PG returns an error for the expression, however Oracle, MariaDB/MySQL returns NULL for -NULL expression. The behavior depends on what is the exemplar DB is. |
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.
Great job.
There is a tradeoff, namely PG returns an error for the expression, however Oracle, MariaDB/MySQL returns NULL for -NULL expression. The behavior depends on what is the exemplar DB is.
I think that behavior of PG
is caused by PG forgot to implement it, handle about NULL Literal is complex.
From the type system, -NULL is also NULL.
PG will deduce the type of null based on other parameters. we can specify the null type, it will ok. jackwener=# select -null::int;
?column?
----------
(1 row) deduce the type of null based on other parameters. jackwener=# select 1+null;
?column?
----------
(1 row) error, can't deduce jackwener=# select null+null;
ERROR: operator is not unique: unknown + unknown
LINE 1: select null+null;
^
HINT: Could not choose a best candidate operator. You might need to add explicit type casts.
jackwener=# |
Thank you @drrtuy -- I agree with @jackwener that being more permissive than PG is a good thing. |
Benchmark runs are scheduled for baseline = 8022827 and contender = c02e9d4. c02e9d4 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Which issue does this PR close?
Closes #1192.
Rationale for this change
This is a bug fix.
What changes are included in this PR?
Are there any user-facing changes?
The expression -null now returns NULL.
There are no API changes that I am aware #of.