Prohibit ability to cast  timestamps that out of valid range to varchar
-----------------------------------------------------------------------

                 Key: CORE-4789
                 URL: http://tracker.firebirdsql.org/browse/CORE-4789
             Project: Firebird Core
          Issue Type: Bug
            Reporter: Pavel Zotov
            Priority: Minor



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;

             DATEDIFF
=====================
             86781599


SQL> select dateadd( 86781599 hour to timestamp '01.01.0100 00:00:00.0000') 
from rdb$database;

                  DATEADD
=========================
9999-12-31 23:00:00.0000


SQL> select dateadd( 867815990 hour to timestamp '01.01.0100 00:00:00.0000') 
from rdb$database;

                  DATEADD
=========================
Statement failed, SQLSTATE = 22008
value exceeds the range for valid timestamps

-- no OK.

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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to