[
https://issues.apache.org/jira/browse/TRAFODION-1262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15701140#comment-15701140
]
ASF GitHub Bot commented on TRAFODION-1262:
-------------------------------------------
GitHub user rwbzx opened a pull request:
https://github.com/apache/incubator-trafodion/pull/853
[TRAFODION-1262]ODBC:Varchar col operation fails
Issue Causes:
1. Dealing with Varchar-oriented data input, if length of input string(end
with '\0') is larger than 32767, then there will be 4-byte memory assigned to
indicate data length, otherwise, 2-byte space will do the job. While odbc
driver only allocates varchar-col-length+2 bytes to store input data as well as
its length, and when length of input string equals 199999, the insert will
return SQL_SUCCESS but input data will be truncated.
2. Say that input data type is Char, and db column type is Varchar, while
odbc driver decides how many bytes in memory to indicate length of input data
by length of input string, mxosrvr decides how many bytes to retrieve the
length of input data by length of column type. Thus, when length of input
string is smaller than 32768, odbc assigns 2 bytes for the length but mxosrvr
retrieves 4 bytes including first two bytes of input data, and this causes
error 8402-string overflow.
Code Modification:
1. Calculate memory space according to varchar-col-length: if
varchar-col-length is bigger than 32767, then varchar-col-length+4 bytes of
space will be allocated when building value list.
2. Odbc driver decides how many bytes in memory to indicate length of input
data by length of column type, thus the assign&retrieve principal will be
identical.
3. Modify sqltocconvert files to acommendate sql-c conversion with c-sql
conversion in case of select failures.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/rwbzx/incubator-trafodion TRAFODION-1262
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-trafodion/pull/853.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #853
----
commit c4a39d4d2c5c8d952e9c4b4b87d962332183d34f
Author: rwbzx <[email protected]>
Date: 2016-11-28T06:21:51Z
[TRAFODION-1262]ODBC:Varchar col operation fails
fix bugs on varchar col(>32k) insert/select failure
----
> LP Bug: 1461677 - Insert small data into large varchar column(>32K) failed
> with error 8402- string overflow
> -----------------------------------------------------------------------------------------------------------
>
> Key: TRAFODION-1262
> URL: https://issues.apache.org/jira/browse/TRAFODION-1262
> Project: Apache Trafodion
> Issue Type: Bug
> Components: client-odbc-linux, client-odbc-windows
> Reporter: JiepingZhang
> Assignee: Daniel Lu
> Priority: Critical
> Fix For: 2.1-incubating
>
>
> 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.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)