BUG? 6.6.2-RC: ZQuery.FieldByName(...).* truncates at #17
Posted: 11.01.2008, 05:16
CORRECTION: This only affects char(n) due to TrimRight(). Use varchar() as a workaround.
UPDATE1: changed #11 to #17 (it is 11 hex)
UPDATE2: added step 2.5
UPDATE3: #0 also truncates, but #1 doesn't truncate
UPDATE4: database confirmed to have non-truncated data, and works fine with non-Zeoslib program using fbclient20.dll (EMS Database Manager Lite) -- but programs using Zeoslib truncates field value
UPDATE5: changing charset to NONE for the field didn't fix this on a database created with WIN-1252 charset. But, recreating a test database with charset NONE and field charset NONE seems to avoid #17 truncation.
To reproduce in Delphi 2007:
1. create string containing #17
var binstr:AnsiString;
binstr = 'Hello' + #17 + 'World';
2. save to Firebird 2.0.3 database
2.5. CLOSE THE DATABASE! And reconnect. Otherwise, things look fine in DBGrid, etc. before you disconnect. Exit Delphi just to make sure.
3. use ZQuery with "select * from tablename;"
4. ZQuery.FieldByName('hash').Text is truncated at #17 char
ZQuery.FieldByName('hash').AsString is also truncated at #17 char
ZQuery.FieldByName('hash').Value is also truncated at #17 char
5. Zeoslib does not truncate when writing, but appears to truncate on reading from database if char/varchar field values contain #17 or #0.
Basically, I'm storing a binary hash into a 20 character field (charset OCTETS).
If the hash contains a #17 character, it gets truncated at that character.
I tested using Delphi 2007 and Firebird 2.03 embedded.
UPDATE1: changed #11 to #17 (it is 11 hex)
UPDATE2: added step 2.5
UPDATE3: #0 also truncates, but #1 doesn't truncate
UPDATE4: database confirmed to have non-truncated data, and works fine with non-Zeoslib program using fbclient20.dll (EMS Database Manager Lite) -- but programs using Zeoslib truncates field value
UPDATE5: changing charset to NONE for the field didn't fix this on a database created with WIN-1252 charset. But, recreating a test database with charset NONE and field charset NONE seems to avoid #17 truncation.
To reproduce in Delphi 2007:
1. create string containing #17
var binstr:AnsiString;
binstr = 'Hello' + #17 + 'World';
2. save to Firebird 2.0.3 database
2.5. CLOSE THE DATABASE! And reconnect. Otherwise, things look fine in DBGrid, etc. before you disconnect. Exit Delphi just to make sure.
3. use ZQuery with "select * from tablename;"
4. ZQuery.FieldByName('hash').Text is truncated at #17 char
ZQuery.FieldByName('hash').AsString is also truncated at #17 char
ZQuery.FieldByName('hash').Value is also truncated at #17 char
5. Zeoslib does not truncate when writing, but appears to truncate on reading from database if char/varchar field values contain #17 or #0.
Basically, I'm storing a binary hash into a 20 character field (charset OCTETS).
If the hash contains a #17 character, it gets truncated at that character.
I tested using Delphi 2007 and Firebird 2.03 embedded.