Issue:
Our service panics with slice bounds out of range [:-4] when reading CHAR columns that contain special characters from DB2. The panic originates in the third-party alexbrainman/odbc library (column.go:259, BindableColumn.Value) and propagates through database/sql.(*Rows).Next up to our DefaultDBQueryHandler.readRows in adapter_odbc.go:174.
Root Cause:
The issue is triggered when the DSN is configured with UTF-8 encoding. The ODBC library appears to miscalculate buffer/slice bounds when decoding multi-byte UTF-8 characters stored in fixed-length CHAR columns, resulting in a negative slice index.
Current Workaround:
Removing the UTF-8 encoding parameter from the DSN eliminates the panic. However, this is not a viable long-term solution since we require UTF-8 support for proper character handling.
What We Need:
A solution that preserves UTF-8 encoding in the DSN while preventing the panic. Possible directions include patching or forking the alexbrainman/odbc library to handle multi-byte characters safely in fixed-length columns, adding a recovery mechanism in our adapter layer, or evaluating an alternative DB2 driver.
Issue:
Our service panics with slice bounds out of range [:-4] when reading CHAR columns that contain special characters from DB2. The panic originates in the third-party alexbrainman/odbc library (column.go:259, BindableColumn.Value) and propagates through database/sql.(*Rows).Next up to our DefaultDBQueryHandler.readRows in adapter_odbc.go:174.
Root Cause:
The issue is triggered when the DSN is configured with UTF-8 encoding. The ODBC library appears to miscalculate buffer/slice bounds when decoding multi-byte UTF-8 characters stored in fixed-length CHAR columns, resulting in a negative slice index.
Current Workaround:
Removing the UTF-8 encoding parameter from the DSN eliminates the panic. However, this is not a viable long-term solution since we require UTF-8 support for proper character handling.
What We Need:
A solution that preserves UTF-8 encoding in the DSN while preventing the panic. Possible directions include patching or forking the alexbrainman/odbc library to handle multi-byte characters safely in fixed-length columns, adding a recovery mechanism in our adapter layer, or evaluating an alternative DB2 driver.