Teach a negative NULL expression to return NULL instead of an error#3771
Teach a negative NULL expression to return NULL instead of an error#3771alamb merged 1 commit intoapache:masterfrom
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.
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.