Subject RE: [ib-support] Firebird VARCHAR size
Author Thomas Steinmaurer
> >if you have a one byte collation then it probably should be
> >32765 for VARCHAR due to the extra two bytes holding the
> >VARCHAR length information. It's 32767 for a CHAR.
>
> Just so, Thomas! Apols to Robert di Falco for not checking the InterBase
> quote for correctness.

The InterBase quote is talking about characters in general, but
not specific to the VARCHAR data type, so it's hard to say, that
it is wrong (IMHO). ;-)

> I think possibly it is 32766 for varchar (32Kb minus 2). Char uses 1 byte
> to store length.

No. The maximal length for the CHAR datatype *is* 32767 minus 2 bytes
for VARCHAR, thus 32765.

This works:

alter table mytable add bigvarchar varchar(32765)
alter table mytable add bigchar char(32767)

Whereas this doesn't:

alter table mytable add bigvarchar varchar(32766)
alter table mytable add bigchar char(32768)


Regards,
Thomas.