dynamobi/dynamobi — Issue #346: [FRG-418] Character set of unicode character literals is incorrect
Author: dynamobi-build
Created: 2011-12-30 02:33:39+00:00
State: open
Labels: FRG, Type System

[reporter="jhyde", created="Wed, 4 May 2011 16:42:04 -0500 (GMT-05:00)"]
If I write a unicode character literal, for example u&'foo', farrago assigns it a unicode character set. Thus I can't insert it into a regular varchar column. But according to the SQL standard, a unicode character literal should have the same character set as a regular character literal.

Unicode character literals give the ability to include escape characters (for linefeeds, for example). (Arguably, the SQL standard has chosen a misleading term. They are not necessarily unicode. Like regular character literals, you can specify the character set for the literal. However, we are talking here about the character set that is assigned if you don't specify explicitly.) Since unicode columns are not currently implemented, this bug means that unicode character literals cannot be used as widely as we would like to.

Test case:

> create table sales.foo(i int not null primary key, v varchar(10));

No rows affected (0.526 seconds)

> insert into sales.foo values (1, 'foo');

1 row affected (0.604 seconds)

> insert into sales.foo values (2, u&'foo');

Error: At line 0, column 0: Cannot assign to target field 'V' of type VARCHAR(10) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" from source field 'EXPR$1' of type CHAR(3) CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" NOT NULL (state=,code=0)

The last statement should succeed. The deduced character set of u&'foo' should be the same as 'foo' (whatever that is!).

This issue also applies to other places where types are checked, e.g. passing values to UDFs.