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
Prohibit ability to cast timestamps that out of valid range to varchar [CORE4789] #5088
Comments
Modified by: @asfernandesassignee: Adriano dos Santos Fernandes [ asfernandes ] |
Modified by: @pavel-zotovdescription:
===================== SQL> select dateadd( 86781599 hour to timestamp '01.01.0100 00:00:00.0000') from rdb$database;
========================= SQL> select dateadd( 867815990 hour to timestamp '01.01.0100 00:00:00.0000') from rdb$database;
========================= -- no OK. But: SQL> select cast(dateadd( 867815990 hour to timestamp '01.01.0100 00:00:00.0000') as varchar(32)) from rdb$database; CAST99099-12-24 14:00:00.0000 SQL> select cast(dateadd( 86781599000 hour to timestamp '01.01.0100 00:00:00.0000') as varchar(32)) from rdb$database; CAST1080682-01-16 08:00:00.0000 SQL> select cast(dateadd( 8678159900000 hour to timestamp '01.01.0100 00:00:00.0000') as varchar(32)) from rdb$database; CAST-802195--01--13 12:16:02.2528 Casting of such timestamps is allowed but can lead to meaningless output. It will be nice to completely forbit any operations with date if it's value out of range. => SQL> SELECT datediff(hour from timestamp '01.01.0100 00:00:00.0000' to timestamp '31.12.9999 23:59:59.9999' ) FROM RDB$DATABASE;
===================== SQL> select dateadd( 86781599 hour to timestamp '01.01.0100 00:00:00.0000') from rdb$database;
========================= SQL> select dateadd( 867815990 hour to timestamp '01.01.0100 00:00:00.0000') from rdb$database;
========================= -- here it works fine. But: SQL> select cast(dateadd( 867815990 hour to timestamp '01.01.0100 00:00:00.0000') as varchar(32)) from rdb$database; CAST99099-12-24 14:00:00.0000 SQL> select cast(dateadd( 86781599000 hour to timestamp '01.01.0100 00:00:00.0000') as varchar(32)) from rdb$database; CAST1080682-01-16 08:00:00.0000 SQL> select cast(dateadd( 8678159900000 hour to timestamp '01.01.0100 00:00:00.0000') as varchar(32)) from rdb$database; CAST-802195--01--13 12:16:02.2528 Casting of such timestamps is allowed but can lead to meaningless output. It will be nice to completely forbit any operations with date if it's value out of range. |
Modified by: @asfernandesstatus: Open [ 1 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: 3.0 Beta 2 [ 10586 ] Fix Version: 2.5.5 [ 10670 ] |
Commented by: @pavel-zotov What is minimum value of DATE & TIMESTAMP ? set list on; Output:D1 0001-01-01 |
Commented by: @pavel-zotov One more question: when I issue this echo show version; select dateadd( 1 second to cast('00:00:00' as time) ) from rdb$database rows 1; | isql host/port:alias -- then I get: 1) on snapshot that was built before fix for this ticket was committed: ISQL Version: WI-T3.0.0.31836 Firebird 3.0 Beta 2
============= 2) on current snapshot: ISQL Version: WI-T3.0.0.31836 Firebird 3.0 Beta 2
============= (this also is displayed by fault here: http://web.firebirdsql.org/download/prerelease/results/3.0.0.31836/bugs.core_1173.html ) |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Resolved [ 5 ] QA Status: Done successfully Test Details: Block for 2.5 is simplified vs 3.0: no bigint values as arguments to dateadd(). |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Resolved [ 5 ] Test Details: Block for 2.5 is simplified vs 3.0: no bigint values as arguments to dateadd(). => Block for 2.5 is simplified vs 3.0: no bigint values as arguments to dateadd(). |
Submitted by: @pavel-zotov
SQL> SELECT datediff(hour from timestamp '01.01.0100 00:00:00.0000' to timestamp '31.12.9999 23:59:59.9999' ) FROM RDB$DATABASE;
=====================
86781599
SQL> select dateadd( 86781599 hour to timestamp '01.01.0100 00:00:00.0000') from rdb$database;
=========================
9999-12-31 23:00:00.0000
SQL> select dateadd( 867815990 hour to timestamp '01.01.0100 00:00:00.0000') from rdb$database;
=========================
Statement failed, SQLSTATE = 22008
value exceeds the range for valid timestamps
-- here it works fine.
But:
SQL> select cast(dateadd( 867815990 hour to timestamp '01.01.0100 00:00:00.0000') as varchar(32)) from rdb$database;
CAST
99099-12-24 14:00:00.0000
SQL> select cast(dateadd( 86781599000 hour to timestamp '01.01.0100 00:00:00.0000') as varchar(32)) from rdb$database;
CAST
1080682-01-16 08:00:00.0000
SQL> select cast(dateadd( 8678159900000 hour to timestamp '01.01.0100 00:00:00.0000') as varchar(32)) from rdb$database;
CAST
-802195--01--13 12:16:02.2528
Casting of such timestamps is allowed but can lead to meaningless output. It will be nice to completely forbit any operations with date if it's value out of range.
Commits: a2b2d63 45dbb01 4a48682 2e932a5 FirebirdSQL/fbt-repository@483b08e FirebirdSQL/fbt-repository@5122471 FirebirdSQL/fbt-repository@26e352f FirebirdSQL/fbt-repository@5d4d9bc
====== Test Details ======
Block for 2.5 is simplified vs 3.0: no bigint values as arguments to dateadd().
This test is also related to CORE2174
The text was updated successfully, but these errors were encountered: