Insert small data into large varchar column(>32K) failed with error 8402- string overflow
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Trafodion |
New
|
High
|
Daniel Lu |
Bug Description
Test scenario:
Create table: CREATE TABLE ODBC32K.LargeColTbl ( C1 varchar (200000) NOT NULL, C2 CHAR(200000));
insert into ODBC32K.LargeColTbl values ('Saaaaaaaaaaaa
ODBC will return error below:
Inserting data using SQLBindParameter, SQLPrepare, SQLExecute
Function SQLExecute returned SQL_ERROR
Diagnostics associated with statmement handle:
SQL Diag 1
Native Error: 4294958894
SQL State: 22001
Message: [Trafodion ODBC Driver][Trafodion Database] SQL ERROR:*** ERROR[8402] A string overflow occurred during the evaluation of a character expression. [2015-06-03 17:36:41]
PS: If try from ODBCTest, insert will be successful, seems this only fails when done thru application.
Changed in trafodion: | |
assignee: | nobody → Daniel Lu (ping-lu) |
Additional info on how to reproduce the issue:
1. Client and server revisions: client revision(Linux ODBC driver): 20150603 server revision: 20150524 hstmt, (SQLCHAR*)"CREATE SCHEMA ODBC32K", SQL_NTS);
if(!SQL_ SUCCEEDED( returnCode) )
LogDiagnostic s("SQLExecDirec t of CREATE", returnCode); hstmt, (SQLCHAR*)"CREATE TABLE ODBC32K. LargeColSmDataT bl ( C1 varchar (200000) NOT NULL, C2 CHAR(200000))", SQL_NTS);
if(!SQL_ SUCCEEDED( returnCode) )
LogDiagnosti cs("SQLExecDire ct of CREATE", returnCode);
printf( "Table LargeColSmDataTbl created using SQLExecDirect.\n");
2. String overflow error (error 8402) returned at SQLExecute on the insert statement, i.e. after SQLBindParameter, SQLPrepare, SQLExecute returned error 8403. Below is part of the code:
//CREATE TABLE LargeColTbl (ID INT NOT NULL, TASK VARCHAR(10), LAST_UPDATE TIMESTAMP, PRIMARY KEY (C1));
returnCode = SQLExecDirect(
returnCode = SQLExecDirect(
//Insert few rows into test table using bound parameters
//INSERT INTO TASKS VALUES (?, ?);
SQLLEN cbC1 = SQL_NTS, cbC2 = SQL_NTS;
SQLCHAR strC1[20], strC2[20];
returnCode = SQLBindParamete r(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 0, 0, &strC1, 0, &cbC1);
if(!SQL_ SUCCEEDED( returnCode) )
LogDiagnostic s("SQLBindParam eter 1", returnCode);
returnCode = SQLBindParamete r(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0, &strC2, 0, &cbC2);
if(!SQL_ SUCCEEDED( returnCode) )
LogDiagnostic s("SQLBindParam eter 2", returnCode);
returnCode = SQLPrepare(hstmt, (SQLCHAR*)"INSERT INTO ODBC32K. LargeColSmDataT bl VALUES (?, ?)", SQL_NTS);
if(!SQL_ SUCCEEDED( returnCode) )
LogDiagnostic s("SQLPrepare of INSERT", returnCode);
strcpy ((char*)strC1, "S");
for (int i = 0; i < 16; i++){
strcat ((char*)strC1, "a");
}
strcat ((char*)strC1, "E");
strcpy ((char*)strC2, "S");
for (int i = 0; i < 16; i++) {
strcat ((char*)strC2, "b");
}
strcat ((char*)strC2, "E");
returnCode = SQLExecute(hstmt);
if(!SQL_ SUCCEEDED( returnCode) )
LogDiagnostic s("SQLExecute" , returnCode);
3. Seems this issue will show only when SQLBindParameter is involved, if the insert is done via SQLExecDirect, insert will be successful.