-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Results of negation must be the same for each datatype (smallint / int /bigint / int128) when argument is least possible value for this type #7025
Comments
So there is no inconsistency in this case. |
But -32768 is expected to be SMALLINT, thus -(-32768) should also be a SMALLINT (by SQL spec) and raise an error. The problem here is that our parser does not support SMALLINT constants at all, they're described as INT (or bigger) instead. |
Do the standard defines that a small numeric constant like |
So we're compliant regarding -32768 being an INT. IMO, the only real issue is that -2147483648 is described as BIGINT but calculated as INT. It should be either INT everywhere or BIGINT everywhere. |
SQL:2016-2 section 5.3 <literal> says:
So the current behaviour for -32768 and -(-32768) is correct, as the |
Made it INT everywhere. |
Following examples are based on messages in fb-devel, Vol 186, Issue 18 (date: 11-oct-2021).
Example #1.
No error.
This means that rule from SQL:2016 which was mentioned by Mark:
"rule 2 establishes that the type of a negation is the type of the negated expression" - is broken here. Type of negation must remain smallint and thus negation of -32768 should raise exception.
Example #2.
This result looks also not clear:
/* Dmitry replied me privately about this and now I understand the reason: generating of BLR forces this value to "go back" to INT type. */
Shortly speaking, both examples must behave like this:
(i.e. produce exception and do not change type of argument that is subject for negation).
The text was updated successfully, but these errors were encountered: