Insert small data into large varchar column(>32K) failed with error 8402- string overflow

Bug #1461677 reported by Jieping Zhang
6
This bug affects 1 person
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 ('SaaaaaaaaaaaaaaaaE', 'SbbbbbbbbbbbbbbbbbE');

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.

Revision history for this message
Jieping Zhang (jieping-zhang) wrote :

Additional info on how to reproduce the issue:

1. Client and server revisions: client revision(Linux ODBC driver): 20150603 server revision: 20150524
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(hstmt, (SQLCHAR*)"CREATE SCHEMA ODBC32K", SQL_NTS);
        if(!SQL_SUCCEEDED(returnCode))
                LogDiagnostics("SQLExecDirect of CREATE", returnCode);
        returnCode = SQLExecDirect(hstmt, (SQLCHAR*)"CREATE TABLE ODBC32K.LargeColSmDataTbl ( C1 varchar (200000) NOT NULL, C2 CHAR(200000))", SQL_NTS);
        if(!SQL_SUCCEEDED(returnCode))
                 LogDiagnostics("SQLExecDirect of CREATE", returnCode);
        printf("Table LargeColSmDataTbl created using SQLExecDirect.\n");

        printf("Inserting data using SQLBindParameter, SQLPrepare, SQLExecute\n");
        //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 = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 0, 0, &strC1, 0, &cbC1);
        if(!SQL_SUCCEEDED(returnCode))
                LogDiagnostics("SQLBindParameter 1", returnCode);

        returnCode = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0, &strC2, 0, &cbC2);
        if(!SQL_SUCCEEDED(returnCode))
                LogDiagnostics("SQLBindParameter 2", returnCode);

        returnCode = SQLPrepare(hstmt, (SQLCHAR*)"INSERT INTO ODBC32K.LargeColSmDataTbl VALUES (?, ?)", SQL_NTS);
        if(!SQL_SUCCEEDED(returnCode))
                LogDiagnostics("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))
                LogDiagnostics("SQLExecute", returnCode);

3. Seems this issue will show only when SQLBindParameter is involved, if the insert is done via SQLExecDirect, insert will be successful.

Changed in trafodion:
assignee: nobody → Daniel Lu (ping-lu)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.