Subject Re: [firebird-support] Problems with big VARCHAR-s in FB2.1 (default charset = UTF8)
Author Adriano dos Santos Fernandes
kimon_the_athenian2 escreveu:
> Hi!
> I have a "VARCHAR(32000) CHARACTER SET ISO8859_1" field in a database
> that has UTF8 as it default charset.
> When i'm using ISO8859_1 as client charset then i can query all the
> values from that field, but when i connect with UTF8 then querying
> some longer values gives me:
> Arithmetic overflow or division by zero has occurred.Arithmetic
> exception, numeric overflow, or string truncation.
> Those values have almost only ASCII chars in them, so the byte-size of
> their UTF8 form shouldn't be much bigger than that of ISO8859_1.
> When i check the bit_length of those strings then it's 8x the number
> of chars - I thought that varchar storage is dependant on the charset
> of the field, but here it seems that it depends on database default
> charset. Is it so?
> Anyway it's strange that I can query strings whose bit_length is 63360
> but not strings with bit_length of 80192. Is there some kind of limit
> going between these numbers?
> I hope someone can explain these matters (or give a link to info).
The maximum number of *bytes* in an UTF8 varchar is 32764. You'll have
this error if your ISO8859_1 field converted to UTF8 uses more than this
number of bytes.

You'll not succeed using *_LENGTH functions on the ISO8859_1 field to
know what fails.