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

Kathey Marsden commented on DERBY-2910:
---------------------------------------

Mamta asked
>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?

I think it should pick up the collation of the current compilation schema for 
implicit casts as it does for explicit casts.
Here is an exaple of a statement that I think should execute but currently does 
not because of the UCS_BASIC default.

ij> create table a (vc varchar(30));
0 rows inserted/updated/deleted
ij> insert into a values(CURRENT_DATE);
1 row inserted/updated/deleted

ij> select vc from a where vc = UPPER(CURRENT_DATE);
ERROR 42818: Comparisons between 'VARCHAR (TERRITORY_BASED)' and 'VARCHAR 
(UCS_BASIC)' are not supported. Types must be
comparable. String types must also have matching collation. If collation does 
not match, a possible solution is to cast
operands to force them to the default collation (e.g. select tablename from 
sys.systables where CAST(tablename as VARCHAR(128))


This implicit cast is ok:
ij> select vc from a where vc = CURRENT_DATE;
VC
------------------------------
2007-08-27




> 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
>          Components: SQL
>    Affects Versions: 10.3.1.4, 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