[ODBC-115] Message wrong. Numeric data type report "String data, right-truncated" Created: 2017-09-22  Updated: 2020-12-08  Resolved: 2017-10-04

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: None
Affects Version/s: 2.0.15
Fix Version/s: 3.0.2, 2.0.16

Type: Bug Priority: Major
Reporter: haijun Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Environment:

DB2 linuxamd64
MariaDB v10


Issue Links:
Blocks
blocks MDEV-13857 Use the 10.2 libmariadb in 10.3 Closed

 Description   

When DB2 using mariadb-connector-odbc-2.0.15-ga-rhel6-x86_64.tar.gz connect to Mariadb 10.0.31, we create a bigint unsigned on maraidb table, insert a data larger than DB2 bigint 9223372036854807, such as 9223372036854809

create table table(col1 bigint unsigned);
insert into table values(9223372036854809);

select * form table(on DB2 which is connected with maraidb via odbc connector)

ODBC trace is as following:

EXIT SQLFetch with return code 1 (SQL_SUCCESS_WITH_INFO)
HSTMT 0x0069f960

ENTER SQLGetDiagRec
SQLSMALLINT 3
SQLHANDLE 0x0069f960
SQLSMALLINT 1
SQLCHAR * 0x5c2c285e (NYI)
SQLINTEGER * 0x5c2c2058
SQLCHAR * 0x5c2c205c (NYI)
SQLSMALLINT 1025
SQLSMALLINT * 0x5c2c1f12

EXIT SQLGetDiagRec with return code 0 (SQL_SUCCESS)
SQLSMALLINT 3
SQLHANDLE 0x0069f960
SQLSMALLINT 1
SQLCHAR * 0x5c2c285e [ 5] "01004"
SQLINTEGER * 0x5c2c2058 (0)
SQLCHAR * 0x5c2c205c [ 56] "[ma-2.0.15][10.0.31-MariaDB]String data, right-truncated"
SQLSMALLINT 1025
SQLSMALLINT * 0x5c2c1f12 (56)

We think the error message is wrong, it should be 22003, because the datatype is numeric not Sting data.

https://mariadb.com/kb/en/library/sql-99/error-sqlstates/

22003 data exception-numeric value out of range

Suggested error message: "the numeric value <> is too big to fit in the target <>". Often this is the result of an arithmetic overflow — for example, "UPDATE ... SET SMALLINT_COLUMN = 9999999999", or you're trying to retrieve a value of 5 billion into a host variable defined in Pascal as "Word". Fractional truncation won't cause this error, see SQLSTATE 01S07



 Comments   
Comment by Lawrin Novitsky [ 2017-10-04 ]

For numeric overflow we now set SQL state 22003, and return corresponding to this state SQL_ERROR. Also for fractional truncation the sql state is 01S07 now.
The fix and the testcase have been pushed to the odbc-2.0 branch as commit 69d2299ed5c0182b3a5e32b3d268ac05050011ff, and to the odbc-3.0 - as f7904119868ed012cfca30f186d1c3fe5c750548

Generated at Thu Feb 08 03:26:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.