Ticket #990 (closed defect: fixed)
OGR ODBC driver unable to read large text fields properly
| Reported by: | szekerest@… | Owned by: | warmerdam |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | default | Version: | unspecified |
| Severity: | critical | Keywords: | |
| Cc: | amagnum2@… |
Description
It seems that the OGR ODBC driver does not handle large text fields
(like large WKT) properly. The OGR driver loads the data by 511 byte chunks
but leaves the terminating zero byte in the buffer after reading the
next chunk. It causes that only the first 511 byte will be considered
as the field value have been read.
This problem related to the Microsoft's ODBC driver implementation which
places one or two zero terminators into the returned buffer when calling
SQLGetData on text field and the size of the data to be returned is larger
then the buffer size. For unicode text fields (ntext with MSSQL) two extra
terminators reside in the returning buffer.
To fix this problem cpl_odbc.cpp should be modified as to trim the
terminators,like the followings:
if( cbDataLen > (int) (sizeof(szWrkData)-1) )
{
cbDataLen = (int) (sizeof(szWrkData)-1);
if (nFetchType == SQL_C_CHAR)
while ((cbDataLen > 1) && (szWrkData[cbDataLen - 1] == 0)) --
cbDataLen; // trimming the extra terminators
}
Tamas Szekeres
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

