Dialect 1 casting date to string breaks when in the presence a domain with a 
check constraint
---------------------------------------------------------------------------------------------

                 Key: CORE-4943
                 URL: http://tracker.firebirdsql.org/browse/CORE-4943
             Project: Firebird Core
          Issue Type: Bug
          Components: Engine
    Affects Versions: 2.5.4, 2.1.5 Update 1
         Environment: Tested on a Dialect 1 database using Firebird 64-bit 
Classic 2.1.5 and also on Classic 2.5.4, both on CentOS linux
            Reporter: Steve Wiser


If you run the script below it will generate 3 stored procedures to test this.  
Basically if you cast a date to a varchar in Dialect 1 it will return the date 
without the timestamp on it.  However, once the stored procedure also includes 
a variable that is declared from a domain with a CHECK constraint on it the 
date casting will now include the timestamp.  I am not sure why it exhibits 
different behaviors based on whether a variable is used with a domain that 
contains the check constraint.  Removing the check constraint from the domain 
allows the date casting to not include the timestamp.

set term !! ;

create or alter procedure TEST_WORKS_AS_EXPECTED
returns (
    retDate    date,
    retDateStr varchar(15),
    retSuccess varchar(5))
AS
begin
  retSuccess = 'True';

  select cast('today' as date)
  from   rdb$database
  into   retDate;

  retDateStr = cast(retDate as varchar(15));
end!!

create domain bool_flag as VARCHAR(5) CHARACTER SET NONE
       CHECK (value is null or value in ('True', 'False'))
       COLLATE NONE!!

create or alter procedure TEST_FAILS
returns (
    retDate    date,
    retDateStr varchar(15),
    retSuccess bool_flag)
AS
begin
  retSuccess = 'True';

  select cast('today' as date)
  from   rdb$database
  into   retDate;

  retDateStr = cast(retDate as varchar(15));
end!!

create or alter procedure TEST_FAILS_FIXED
returns (
    retDate    date,
    retDateStr varchar(50),
    retSuccess bool_flag)
AS
begin
  retSuccess = 'True';

  select cast('today' as date)
  from   rdb$database
  into   retDate;

  retDateStr = cast(retDate as varchar(50));
end!!

set term ; !!


-- 
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

        

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to