[ 
https://issues.apache.org/jira/browse/DERBY-2910?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12511170
 ] 

Mamta A. Satoor commented on DERBY-2910:
----------------------------------------

I guess what I would like to discuss is what should be the collation of the 
resultant character string of UPPER when it's operand is not of type character 
string. Derby internally generate a CAST to generate the character string 
(following our rules for type conversions) for a case like UPPER(CURRENT_DATE) 
because UPPER works on character string type operand.

For instance in UPPER(CURRENT_USER), the operand CURRENT_USER is character 
string type with collation of UCS_BASIC and hence the result of UPPER has 
collation type of UCS_BASIC. But in UPPER(CURRENT_DATE), CURRENT_DATE is of 
date type and hence we internally generate a CAST node on date to generate 
character string type and that internal CAST always generates a character 
string of type UCS_BASIC collation. My question is is that the right thing to 
do? Should we have such internal CASTs (from non-character string type to 
character string types) pick up the collation of the current compilation schema?

> SimpleStringOperatorNode in it's bindExpression method generates a character 
> string CAST if required but does not set the correct collation.
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-2910
>                 URL: https://issues.apache.org/jira/browse/DERBY-2910
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions: 10.3.1.1, 10.4.0.0
>            Reporter: Mamta A. Satoor
>
> Following query should run into error if run in a territory based database 
> SELECT TABLENAME FROM SYS.SYSTABLES WHERE UPPER(CURRENT_DATE) = TABLENAME;
> When a CAST node is generated on top of CURRENT_DATE to create a character 
> string type, we do not set the collation of that character string type and 
> hence it always ends up getting the default which is collation derivation 
> IMPLICIT and collation type UCS_BASIC. That does not sound right. 
> There might be other places where we generate CAST node to create a character 
> string type. We should check if the collation is set correctly for them.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to