If I change the ClientCodePage to UTF16 on an Oracle connection I consistently get ORA-01406: fetched column value was truncated (#1406).
What I know so far:
- Oracle client library and server version does not matter as the test host was upgraded to 19.0 and the issue still persists
- Listing the columns explicitly instead of SELECT * does not solve the issue, it's not the metadata collection
- Removing random (varchar) columns from the SELECT one-by-one will lead to a sweet-spot, causing the query to execute
So I went back to my dev machine to start debugging once again, and behold - the same query executed without issues on the same database! See if you can spot the difference in the logs:
Code: Select all
[2022.02.04 10:40:20] MYDB: Oracle 19.0.0, client version: 19.8.0, database access component version: 8.0.0-a846f83a8
[2022.02.04 10:40:20] MYDB: Connected to database ***, schema *** at host *** as user ***
[2022.02.04 10:40:20] MYDB: Loaded library: C:\DRVOracle\oci.dll
[2022.02.04 10:40:20] MYDB: Transaction isolation level: Read committed
[2022.02.04 10:40:20] MYDB: RawStringEncoding: DB_CP
[2022.02.04 10:40:20] MYDB: codepage: UTF16
[2022.02.04 10:40:20] MYDB: OCIMultiThreaded: True
[...]
[2022.02.04 10:40:20] MYDB: Opening dataset in background thread #11400 started.
[2022.02.04 10:40:20] MYDB: Prepare Statement 71 : SELECT * FROM MYTABLE
[2022.02.04 10:40:20] MYDB: Prepare Statement 72 : SELECT ALL_TAB_COLUMNS.OWNER, ALL_TAB_COLUMNS.TABLE_NAME, ALL_TAB_COLUMNS.COLUMN_NAME, ALL_TAB_COLUMNS.DATA_TYPE, ALL_TAB_COLUMNS.DATA_LENGTH, ALL_TAB_COLUMNS.DATA_PRECISION, ALL_TAB_COLUMNS.DATA_SCALE, ALL_TAB_COLUMNS.NULLABLE, ALL_TAB_COLUMNS.DATA_DEFAULT, ALL_TAB_COLUMNS.COLUMN_ID, ALL_COL_COMMENTS.COMMENTS, ALL_TAB_COLUMNS.CHAR_LENGTH FROM ALL_TAB_COLUMNS JOIN ALL_COL_COMMENTS ON ALL_COL_COMMENTS.TABLE_NAME = ALL_TAB_COLUMNS.TABLE_NAME AND ALL_COL_COMMENTS.COLUMN_NAME = ALL_TAB_COLUMNS.COLUMN_NAME AND ALL_COL_COMMENTS.OWNER = ALL_TAB_COLUMNS.OWNER WHERE ALL_TAB_COLUMNS.TABLE_NAME like 'MYTABLE' ORDER BY ALL_TAB_COLUMNS.COLUMN_ID
[2022.02.04 10:40:21] MYDB: Execute prepared Statement 72 in 516 ms
[2022.02.04 10:40:21] MYDB: Fetch Statement 72, affected 145 row(s) in 765 ms
[2022.02.04 10:40:21] MYDB: Fetch FETCH ROW ORA-01406: fetched column value was truncated (#1406)
[2022.02.04 10:40:21] EZSQLException was raised while Opening dataset with the message SQL Error: ORA-01406: fetched column value was truncated Code: 1406 Message: FETCH ROW
Code: Select all
[2022.02.04 10:40:38] MYDB: Oracle 19.0.0, client version: 19.8.0, database access component version: 8.0.0-a846f83a8
[2022.02.04 10:40:38] MYDB: Connected to database ***, schema *** at *** as user ***
[2022.02.04 10:40:38] MYDB: Loaded library: C:\DRVOracle\oci.dll
[2022.02.04 10:40:38] MYDB: Transaction isolation level: Read committed
[2022.02.04 10:40:38] MYDB: RawStringEncoding: DB_CP
[2022.02.04 10:40:38] MYDB: codepage: UTF16
[2022.02.04 10:40:38] MYDB: internal_buffer_size: 300000
[2022.02.04 10:40:38] MYDB: OCIMultiThreaded: True
[...]
[2022.02.04 10:41:01] MYDB: Opening dataset in background thread #6312 started.
[2022.02.04 10:41:01] MYDB: Prepare Statement 77 : SELECT * FROM MYTABLE
[2022.02.04 10:41:01] MYDB: Prepare Statement 78 : SELECT ALL_TAB_COLUMNS.OWNER, ALL_TAB_COLUMNS.TABLE_NAME, ALL_TAB_COLUMNS.COLUMN_NAME, ALL_TAB_COLUMNS.DATA_TYPE, ALL_TAB_COLUMNS.DATA_LENGTH, ALL_TAB_COLUMNS.DATA_PRECISION, ALL_TAB_COLUMNS.DATA_SCALE, ALL_TAB_COLUMNS.NULLABLE, ALL_TAB_COLUMNS.DATA_DEFAULT, ALL_TAB_COLUMNS.COLUMN_ID, ALL_COL_COMMENTS.COMMENTS, ALL_TAB_COLUMNS.CHAR_LENGTH FROM ALL_TAB_COLUMNS JOIN ALL_COL_COMMENTS ON ALL_COL_COMMENTS.TABLE_NAME = ALL_TAB_COLUMNS.TABLE_NAME AND ALL_COL_COMMENTS.COLUMN_NAME = ALL_TAB_COLUMNS.COLUMN_NAME AND ALL_COL_COMMENTS.OWNER = ALL_TAB_COLUMNS.OWNER WHERE ALL_TAB_COLUMNS.TABLE_NAME like 'MYTABLE' ORDER BY ALL_TAB_COLUMNS.COLUMN_ID
[2022.02.04 10:41:02] MYDB: Execute prepared Statement 78 in 525 ms
[2022.02.04 10:41:02] MYDB: Fetch Statement 78, affected 145 row(s) in 649 ms
[2022.02.04 10:41:02] MYDB: Execute prepared Statement 77 in 669 ms
[2022.02.04 10:41:52] MYDB: Fetch Statement 77, affected 206733 row(s) in 50717 ms
[2022.02.04 10:41:53] MYDB: Query returned 206 733 record(s) in 50 seconds
[2022.02.04 10:41:53] MYDB: Opening dataset in background thread #6312 ended.
So it seems yes, we are not providing a big enough buffer for the data to be filled in - fortunately this can be controlled with a property on the connection.
This leaves us (me?) with one question only. Is this behavior expected, or Zeos should be able to determine the necessary buffer size based on the maximum amount of data expected?