Subject Re: [firebird-support] Bug with character sets
Author Kjell Rilbe
Martijn Tonies wrote:

> One could wonder if knowing the bytes_per_character is something
> that needs to be fetched on the client side OR if this could be passed
> on by the server, so that decoding the client side structure would not
> require any more knowledge than passed by the server.

I had a quick look at the SQLDA struct and related other structs
(XSQLVAR, SQLVAR, XSQLDA).

Each column in a result set is described qith an XSQLVAR if I understand
things correctly. That struct looks like this (whitespace trimmed for
readability in this message):

typedef struct
{
ISC_SHORT sqltype; /* datatype of field */
ISC_SHORT sqlscale; /* scale factor */
ISC_SHORT sqlsubtype; /* datatype subtype - currently BLOBs only */
ISC_SHORT sqllen; /* length of data area */
ISC_SCHAR* sqldata; /* address of data */
ISC_SHORT* sqlind; /* address of indicator variable */
ISC_SHORT sqlname_length; /* length of sqlname field */
ISC_SCHAR sqlname[32]; /* name of field, name length + space for NULL */
ISC_SHORT relname_length; /* length of relation name */
ISC_SCHAR relname[32]; /* field's relation name + space for NULL */
ISC_SHORT ownname_length; /* length of owner name */
ISC_SCHAR ownname[32]; /* relation's owner name + space for NULL */
ISC_SHORT aliasname_length; /* length of alias name */
ISC_SCHAR aliasname[32]; /* relation's alias name + space for NULL */
} XSQLVAR;

Apparently, according to Vlad Khorsun, sqlsubtype is already filled with
info: charset id and collation id. I assume sqllen is the buffer size in
byte. But for CHAR(N), I expect sqlscale is unused. Perhaps sqlscale
could be used to pass N? It should be the right size, considering sqllen
is the same type.

The name would be rather confusing, but perhaps one could think of it
like specifying to what length the buffer should be "scaled" to give
correct data? :-)

Anyway, that's the only place I can see that could be used in a
backwards-compatible way. Legacy code that doesn't know N is passed in
sqlscale for CHAR columns would still work. New code that knows N is
passed in sqlscale from FB version X can make use of it.

Feel free to take this thread to firebird-architect if you like. I don't
personally subscribe to that list.

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