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
Provide same results for date arithmetics when date is changed by values near +/-max(bigint) [CORE6504] #6734
Comments
Modified by: @pavel-zotovpriority: Major [ 3 ] => Minor [ 4 ] |
Modified by: @pavel-zotovAttachment: date-arithmetic-with-changing-date-for-power_2_63-days_-_overall-results-for-FB-3.x-and-4.x.xlsx [ 13553 ] |
Commented by: @asfernandes What is the problem with FB 4? Why it's not correct raising error? You probably wanted to mention another ticket as CORE624 has nothing to do with this. |
Commented by: @pavel-zotov > What is the problem with FB 4? IMO, raising error is exactly what must be done. But FB 4.x allows this: > You probably wanted to mention another ticket as CORE624 has nothing to do with thi Yes, sorry for unprinted character: I meant CORE6241. |
Commented by: @asfernandes Pavel, are you sure? I've tested this command in v4 RC1, master and 4.0.0.2379 (all in Linux - with gcc and clang) and in all versions it raises an error. |
Commented by: @asfernandes Alex, official Linux binaries presents this problem (no error is raised), while my own binaries and one download from github action raises error. May be we're having a compiler problem? We're talking about ExprNodes.cpp:
And utils_proto.h:
The code does not appear for me to have undefined behaviors. |
Modified by: @AlexPeshkoffassignee: Alexander Peshkov [ alexpeshkoff ] |
Commented by: @AlexPeshkoff Definitely compiler issue, moreover - optimization issue, in DEV_BUILD error is raised. |
Commented by: @AlexPeshkoff Very old and long-existed bug, was fixed only in gcc10 (i.e. gcc 6, 7, 8, 9 are vulnerable). Luckily installing gcc10 does not require upgrade of glibc & binutils. |
Commented by: @AlexPeshkoff Added check for values causing buggy result in a case when compiler has that bug |
Modified by: @AlexPeshkoffstatus: Open [ 1 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: 4.0.0 [ 10931 ] |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Resolved [ 5 ] QA Status: No test => Done successfully Test Specifics: [Platform (Windows/Linux) specific] |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Closed [ 6 ] |
Submitted by: @pavel-zotov
Attachments:
date-arithmetic-with-changing-date-for-power_2_63-days_-_overall-results-for-FB-3.x-and-4.x.xlsx
Ticked was created after discuss results of test for CORE624 with Alex and Vlad.
Following statements show different results on FB 3.x and 4.x when date is decremented by values = ~2^63.
See also attached .xlsx with overall results in one table.
Database and client dialect = 3.
### A. DECREMENT date ###
Linux
1) LI-V4.0.0.2379
echo "set heading off; select date '01.02.2020' + -9223372036854775807 from rdb\$database;" | /var/tmp/fb40tmp/bin/isql employee
Statement failed, SQLSTATE = 22008
value exceeds the range for valid dates
echo "set heading off; select date '01.02.2020' + -9223372036854775808 from rdb\$database;" | /var/tmp/fb40tmp/bin/isql employee
2020-02-01
--------------------------------------------
2) LI-V3.0.8.33415
echo "set heading off; select date '01.02.2020' + -9223372036854775807 from rdb\$database;" | /var/tmp/fb30tmp/bin/isql employee -z
2020-02-02
echo "set heading off; select date '01.02.2020' + -9223372036854775808 from rdb\$database;" | /var/tmp/fb30tmp/bin/isql employee -z
2020-02-01
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Windows
1) WI-V4.0.0.2377
C:\FB\40SS>echo set heading off; select date '01.02.2020' - +9223372036854775807 from rdb$database; | isql employee
Statement failed, SQLSTATE = 22008
value exceeds the range for valid dates
C:\FB\40SS>echo set heading off; select date '01.02.2020' + -9223372036854775808 from rdb$database; | isql /:employee
Statement failed, SQLSTATE = 22008
value exceeds the range for valid dates
--------------------------------------------
2) WI-V3.0.8.33423
C:\FB\30SS>echo set heading off; select date '01.02.2020' - -9223372036854775807 from rdb$database; | isql employee -z
2020-01-31
SQL>
C:\FB\30SS>echo set heading off; select date '01.02.2020' - -9223372036854775808 from rdb$database; | isql employee -z
2020-02-01
### B. INCREMENT date ###
Linux
1)build LI-V4.0.0.2379
echo "set heading off; select date '01.02.2020' + 9223372036854775807 from rdb\$database;" | /var/tmp/fb40tmp/bin/isql employee -z
Statement failed, SQLSTATE = 22008
value exceeds the range for valid dates
echo "set heading off; select date '01.02.2020' - (-9223372036854775808) from rdb\$database;" | /var/tmp/fb40tmp/bin/isql employee -z
2020-02-01
--------------------------------------------
2) LI-V3.0.8.33415
echo "set heading off; select date '01.02.2020' + 9223372036854775807 from rdb\$database;" | /var/tmp/fb30tmp/bin/isql employee -z
2020-01-31
echo "set heading off; select date '01.02.2020' - (-9223372036854775808) from rdb\$database;" | /var/tmp/fb30tmp/bin/isql employee -z
2020-02-01
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Windows
1) WI-V4.0.0.2377
C:\FB\40SS>echo set heading off; select date '01.02.2020' + 9223372036854775807 from rdb$database; | isql employee -z
Statement failed, SQLSTATE = 22008
value exceeds the range for valid dates
C:\FB\40SS>echo set heading off; select date '01.02.2020' - (-9223372036854775808) from rdb$database; | isql employee -z
Statement failed, SQLSTATE = 22008
value exceeds the range for valid dates
2) WI-V3.0.8.33423
C:\FB\30SS>echo set heading off; select date '01.02.2020' + 9223372036854775807 from rdb$database; | isql employee -z
2020-01-31
SQL>
C:\FB\30SS>echo set heading off; select date '01.02.2020' - (-9223372036854775808) from rdb$database; | isql employee -z
2020-02-01
Commits: 7d2b34e
The text was updated successfully, but these errors were encountered: