Subject Re: [ib-support] unicode BUG in Firebird (probably in InterBase too)
Author Helen Borrie
At 12:04 PM 29-01-02 +0100, you wrote:
>Hi Herbert,
>
>even if this was totally correct explanation, it is still bug, isn't it
>?

Perhaps not so much a bug as something you need to know about multi-byte characters sets? Another trap you have to watch with Unicode is that character indices are limited to 84 characters in total length...

>However, when I define the domain charset as WIN1250 (2-bytes per char),

Win1250 has one-byte characters, not 2 bytes.

>it won't allow me to execute
>
>insert into tab_country values ('aaaa', 'bbbbbbbbbbbbbbbb')

...Correctly...

>Now it checks the string length as it should => I see this as
>UNICODE_FSS related bug ...

Whether or not it should check the string length, it's implemented checking the byte length. It would be interesting to hear Claudio's view on the following:

This statement on your table:

select substring (country from 1 for 4) FROM tab_country for rows with these COUNTRY values (aaaaaa, bbbbbb, abcdef)

produced this:
SUBSTRING
------------------
aaaa
bbbb
abcd

...so it seems something is "not quite right". Maybe it should have errored.

Here is what RC2 Classic on Linux produces as the metadata source for your DDL from a utility that shows byte length:

CREATE DOMAIN COUNTRY_CODE CHAR( 2 )
CHARACTER SET UNICODE_FSS
NOT NULL

Notice that the source stores not the domain but the actual byte lengths of the columns -

CREATE TABLE TAB_COUNTRY (
COUNTRY CHAR( 6 ) NOT NULL
, NAME VARCHAR( 120 ) NOT NULL
, CONSTRAINT INTEG_2
PRIMARY KEY ( COUNTRY )
)

But the metadata shows the DDL as specified, i.e. in number of characters:

CREATE DOMAIN COUNTRY_CODE AS
CHAR(2) CHARACTER SET UNICODE_FSS
NOT NULL^

CREATE TABLE TAB_COUNTRY (
COUNTRY COUNTRY_CODE /* CHAR(2) CHARACTER SET UNICODE_FSS */ NOT NULL,
NAME /* RDB$8 */ VARCHAR(40) CHARACTER SET UNICODE_FSS NOT NULL COLLATE UNICODE_FSS
)^

I can't get an error by issuing a select on your table, either.

interesting....

Helen


All for Open and Open for All
Firebird Open SQL Database ยท http://firebirdsql.org
_______________________________________________________