You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Jeremy Boynes (JIRA)" <de...@db.apache.org> on 2004/12/28 19:29:04 UTC

[jira] Created: (DERBY-113) Comparison does not perform implicit type conversion

Comparison does not perform implicit type conversion
----------------------------------------------------

         Key: DERBY-113
         URL: http://nagoya.apache.org/jira/browse/DERBY-113
     Project: Derby
        Type: Bug
  Components: SQL  
    Reporter: Jeremy Boynes


The operands to a comparision operator are not implictly converted to the dominant type resulting in an unexpected exception:

For example:

ij> select * from dual where '1' = 1;
ERROR 42818: Comparisons between 'CHAR' and 'INTEGER' are not supported.

fails whereas

ij> select * from dual where cast('1' as int) = 1;
DUM&
----
X

works. The type escalation should be implicit.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-113) Comparison does not perform implicit type conversion

Posted by "Shreyas Kaushik (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-113?page=comments#action_59699 ]
     
Shreyas Kaushik commented on DERBY-113:
---------------------------------------

shouldn't this be closed, as per the earlier comment.

> Comparison does not perform implicit type conversion
> ----------------------------------------------------
>
>          Key: DERBY-113
>          URL: http://issues.apache.org/jira/browse/DERBY-113
>      Project: Derby
>         Type: Bug
>   Components: SQL
>     Reporter: Jeremy Boynes

>
> The operands to a comparision operator are not implictly converted to the dominant type resulting in an unexpected exception:
> For example:
> ij> select * from dual where '1' = 1;
> ERROR 42818: Comparisons between 'CHAR' and 'INTEGER' are not supported.
> fails whereas
> ij> select * from dual where cast('1' as int) = 1;
> DUM&
> ----
> X
> works. The type escalation should be implicit.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-113) Comparison does not perform implicit type conversion

Posted by "Amit Handa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-113?page=comments#action_57490 ]
     
Amit Handa commented on DERBY-113:
----------------------------------

First, this was filed by Jeremy as a separate bug coming out from Derby-7 bug.
So we need to understand how promotion happens(read built in broadening) when two differrent datatypes are compared as part of a function say NULLIF(A,B). A, B are two differrent types.

Otherwise also as Jeremy points out select * from dual where '1' = 1; 
if we compare where a defined function is not involved, how the datatypes should behave.

[1] can give help about datatypes and promotions but is not very explicit or in detail.
Also see [2] where I have commenetd on built in broadening according to types compared.

[1] http://incubator.apache.org/derby/manuals/reference/sqlj122.html#HDRSII-SQLJ-31068
[2] http://issues.apache.org/jira/browse/DERBY-7

Further the derby documentation uses terms like built in broadening at places but is not very explicit. If we are clear on that, I guess it can lead to a solution for this.
Just some pointers which can help lead to a solution.

> Comparison does not perform implicit type conversion
> ----------------------------------------------------
>
>          Key: DERBY-113
>          URL: http://issues.apache.org/jira/browse/DERBY-113
>      Project: Derby
>         Type: Bug
>   Components: SQL
>     Reporter: Jeremy Boynes

>
> The operands to a comparision operator are not implictly converted to the dominant type resulting in an unexpected exception:
> For example:
> ij> select * from dual where '1' = 1;
> ERROR 42818: Comparisons between 'CHAR' and 'INTEGER' are not supported.
> fails whereas
> ij> select * from dual where cast('1' as int) = 1;
> DUM&
> ----
> X
> works. The type escalation should be implicit.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


Re: [jira] Commented: (DERBY-113) Comparison does not perform implicit type conversion

Posted by Shreyas Kaushik <Sh...@Sun.COM>.
Any comments on this?

thanks
Shreyas

Shreyas Kaushik (JIRA) wrote:

>     [ http://issues.apache.org/jira/browse/DERBY-113?page=comments#action_57493 ]
>     
>Shreyas Kaushik commented on DERBY-113:
>---------------------------------------
>
>In the link http://incubator.apache.org/derby/manuals/reference/sqlj125.html#HDRSII-SQLJ-58560 there are two tables. 
>
>Table 5 - Assignments allowed by Derby
>Table 6 - Comparisions allowed by Derby
>
>In case of this bug when a comparision is done between '1' and 1, such a comparision is not allowed as per the matrix given in Table  6. 
>
>Moreover Table 5 also mentions assignments are not allowed between integer and char types.
>
>Looks like this might not be a bug after all.
>
>  
>
>>Comparison does not perform implicit type conversion
>>----------------------------------------------------
>>
>>         Key: DERBY-113
>>         URL: http://issues.apache.org/jira/browse/DERBY-113
>>     Project: Derby
>>        Type: Bug
>>  Components: SQL
>>    Reporter: Jeremy Boynes
>>    
>>
>
>  
>
>>The operands to a comparision operator are not implictly converted to the dominant type resulting in an unexpected exception:
>>For example:
>>ij> select * from dual where '1' = 1;
>>ERROR 42818: Comparisons between 'CHAR' and 'INTEGER' are not supported.
>>fails whereas
>>ij> select * from dual where cast('1' as int) = 1;
>>DUM&
>>----
>>X
>>works. The type escalation should be implicit.
>>    
>>
>
>  
>

[jira] Commented: (DERBY-113) Comparison does not perform implicit type conversion

Posted by "Shreyas Kaushik (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-113?page=comments#action_57493 ]
     
Shreyas Kaushik commented on DERBY-113:
---------------------------------------

In the link http://incubator.apache.org/derby/manuals/reference/sqlj125.html#HDRSII-SQLJ-58560 there are two tables. 

Table 5 - Assignments allowed by Derby
Table 6 - Comparisions allowed by Derby

In case of this bug when a comparision is done between '1' and 1, such a comparision is not allowed as per the matrix given in Table  6. 

Moreover Table 5 also mentions assignments are not allowed between integer and char types.

Looks like this might not be a bug after all.

> Comparison does not perform implicit type conversion
> ----------------------------------------------------
>
>          Key: DERBY-113
>          URL: http://issues.apache.org/jira/browse/DERBY-113
>      Project: Derby
>         Type: Bug
>   Components: SQL
>     Reporter: Jeremy Boynes

>
> The operands to a comparision operator are not implictly converted to the dominant type resulting in an unexpected exception:
> For example:
> ij> select * from dual where '1' = 1;
> ERROR 42818: Comparisons between 'CHAR' and 'INTEGER' are not supported.
> fails whereas
> ij> select * from dual where cast('1' as int) = 1;
> DUM&
> ----
> X
> works. The type escalation should be implicit.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-113) Comparison does not perform implicit type conversion

Posted by "Shreyas Kaushik (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-113?page=comments#action_57461 ]
     
Shreyas Kaushik commented on DERBY-113:
---------------------------------------

Adding to my question below, what I meant by "more cases" was, cases other than those involving character and numeric ( ineteger, decimal, etc) comparisions where type escalation is needed.

> Comparison does not perform implicit type conversion
> ----------------------------------------------------
>
>          Key: DERBY-113
>          URL: http://issues.apache.org/jira/browse/DERBY-113
>      Project: Derby
>         Type: Bug
>   Components: SQL
>     Reporter: Jeremy Boynes

>
> The operands to a comparision operator are not implictly converted to the dominant type resulting in an unexpected exception:
> For example:
> ij> select * from dual where '1' = 1;
> ERROR 42818: Comparisons between 'CHAR' and 'INTEGER' are not supported.
> fails whereas
> ij> select * from dual where cast('1' as int) = 1;
> DUM&
> ----
> X
> works. The type escalation should be implicit.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Closed: (DERBY-113) Comparison does not perform implicit type conversion

Posted by "Satheesh Bandaram (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-113?page=history ]
     
Satheesh Bandaram closed DERBY-113:
-----------------------------------

    Resolution: Invalid

Everyone agreed that is not a bug, so closing it..

> Comparison does not perform implicit type conversion
> ----------------------------------------------------
>
>          Key: DERBY-113
>          URL: http://issues.apache.org/jira/browse/DERBY-113
>      Project: Derby
>         Type: Bug
>   Components: SQL
>     Reporter: Jeremy Boynes

>
> The operands to a comparision operator are not implictly converted to the dominant type resulting in an unexpected exception:
> For example:
> ij> select * from dual where '1' = 1;
> ERROR 42818: Comparisons between 'CHAR' and 'INTEGER' are not supported.
> fails whereas
> ij> select * from dual where cast('1' as int) = 1;
> DUM&
> ----
> X
> works. The type escalation should be implicit.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-113) Comparison does not perform implicit type conversion

Posted by "Shreyas Kaushik (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-113?page=comments#action_57460 ]
     
Shreyas Kaushik commented on DERBY-113:
---------------------------------------

Just clarifying on this. 

Should the patch for this take care of this specific type escalation? Are there many more possible cases where type escaltion is needed?



> Comparison does not perform implicit type conversion
> ----------------------------------------------------
>
>          Key: DERBY-113
>          URL: http://issues.apache.org/jira/browse/DERBY-113
>      Project: Derby
>         Type: Bug
>   Components: SQL
>     Reporter: Jeremy Boynes

>
> The operands to a comparision operator are not implictly converted to the dominant type resulting in an unexpected exception:
> For example:
> ij> select * from dual where '1' = 1;
> ERROR 42818: Comparisons between 'CHAR' and 'INTEGER' are not supported.
> fails whereas
> ij> select * from dual where cast('1' as int) = 1;
> DUM&
> ----
> X
> works. The type escalation should be implicit.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DERBY-113) Comparison does not perform implicit type conversion

Posted by "Jeremy Boynes (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-113?page=comments#action_57704 ]
     
Jeremy Boynes commented on DERBY-113:
-------------------------------------

Digging deeper, the specification does not imply any form of automatic promotion. Given that, I don't think this is a really bug so Derby is correct in reporting this as an error.

> Comparison does not perform implicit type conversion
> ----------------------------------------------------
>
>          Key: DERBY-113
>          URL: http://issues.apache.org/jira/browse/DERBY-113
>      Project: Derby
>         Type: Bug
>   Components: SQL
>     Reporter: Jeremy Boynes

>
> The operands to a comparision operator are not implictly converted to the dominant type resulting in an unexpected exception:
> For example:
> ij> select * from dual where '1' = 1;
> ERROR 42818: Comparisons between 'CHAR' and 'INTEGER' are not supported.
> fails whereas
> ij> select * from dual where cast('1' as int) = 1;
> DUM&
> ----
> X
> works. The type escalation should be implicit.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira