|CC:||Philipp-Michael.Guehring [...] unicreditgroup.at,|
I discovered an incompatibility between DBD::DB2 1.71 (with DB2-Connect V9.5) and DB2 v9 on z/OS. When I SELECT a CHAR field that includes characters that are multi-byte characters in UTF-8, then DBD::DB2 only allocates the number of characters that the field has in general (SQL_DESC_DISPLAY_SIZE) as the amount of bytes, retrieves that many bytes from DB2, and cuts off the rest of the field. Example: A field has the content "Gühring" and is defined as CHAR(7). The ü is a multi-byte character in UTF-8, therefore the string is 8 Bytes long in UTF-8. DBD::DB2 allocates only 7 bytes, discards the 8th byte, and returns "Gührin" to my application, which completely breaks the application.. There are several issues: · For querying, how much memory is needed, you should use SQL_DESC_OCTET_LENGTH instead of SQL_DESC_DISPLAY_SIZE, I guess. · Due to UTF-8 being dynamically multi-byte, the same CHAR field can have various different lengthes for every row, so if you want to allocate the needed memory dynamically, you have to allocate it on every row individually (like BLOB´s I guess), you can´t pre-allocate it for all rows. A workaround that helps a bit is to do fbh->dsize*=4; on line 1199 in the dbdimp.c , but that´s not the whole solution yet.