Subject Re: [firebird-support] 60 chars in a 50 field
Author Kjell Rilbe
Martijn Tonies wrote:

>>The thing that scares me is that you should never use a column for two
>>completely different things.
>
> They don't!
>
> FIELD_LENGTH now is the "byte size"
> CHARACTER_LENGTH is the length in characters.
>
> Your proposal is already done :-)

OK, trying to clear this up a bit here, without really knowing what I'm
talking about. :-)

According to Daniel Rail further up the thread, a VARCHAR(90) field
stores 90 in RDB$CHARACTER_LENGTH and 270 in RDB$FIELD_LENGTH.

The problem seems to be that when the engine tries to determine if a
string fits or not, it looks in RDB$FIELD_LENGTH instead of
RDB$CHARACTER_LENGTH. This is probably an attempt to use a generic
"sizecheck" function - it would have to check RDB$FIELD_LENGTH because
that's the only one that's relevant for all data types.

So what's needed is a better sizecheck function that works at the
conceptual level instead of at the implementation level. It should check
if the *specified* size is large enough for the data. The *actual* size
of the field should then be made sure to be large enough in all cases,
irrespective of character encoding and actual data content.

In other words, it has to be aware of what unit the size is measured in
to determine the *conceptual* size of the data that is to be entered. If
the data is UTF8 it has to parse the string to count the number of
characters instead of the number of bytes.

I guess this could be done with the existing system tables & fields -
it's the way they're used that has to be fixed.

Kjell
--
--------------------------------------
Kjell Rilbe
Adressmarknaden AM AB
E-post: kjell.rilbe@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64