List:Commits« Previous MessageNext Message »
From:jbalint Date:February 1 2007 12:43am
Subject:Connector/ODBC 5 commit: r783 - trunk/SDK/MYSQLPlus/Library
View as plain text  
Modified:
   trunk/SDK/MYSQLPlus/Library/MResult.h
   trunk/SDK/MYSQLPlus/Library/MResult_data_toC.cpp
Log:
Fixed returned length of data (string/bin) retrieved in chunks.

Modified: trunk/SDK/MYSQLPlus/Library/MResult.h
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResult.h	2007-01-31 20:15:58 UTC (rev 782)
+++ trunk/SDK/MYSQLPlus/Library/MResult.h	2007-01-31 23:43:18 UTC (rev 783)
@@ -43,6 +43,7 @@
     BOOL                    bInUse;                 /*!< true if we hold a valid get
data state (false if just cleared)     */
     SQLSMALLINT             nTargetTypeAdjusted;    /*!< is nTargetType, SQL_C_DEFAULT
derived, or ARD derived              */
     SQLINTEGER              nBytesTotal;            /*!< bytes of data available
(after conversion - before any truncation) */
+    SQLINTEGER              nBytesPrev;             /*!< bytes of data available
before current call, updated after getData */
     SQLINTEGER              nIndicator;             /*!< value indicates whether or
not the cell is NULL as per SQLGetData  */
     SQLUINTEGER             nRow;                   /*!< index into vectorRows
(0-based)                                    */
     MDescriptorRecordIRD *  pImpRowDescRec;         /*!< descriptor describing the
resultset column                         */

Modified: trunk/SDK/MYSQLPlus/Library/MResult_data_toC.cpp
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResult_data_toC.cpp	2007-01-31 20:15:58 UTC (rev 782)
+++ trunk/SDK/MYSQLPlus/Library/MResult_data_toC.cpp	2007-01-31 23:43:18 UTC (rev 783)
@@ -30,6 +30,7 @@
     nTargetTypeAdjusted     = SQL_C_CHAR;
     /* we do not know the total number of bytes to be returned yet */
     nBytesTotal             = SQL_NO_TOTAL;
+    nBytesPrev              = 0;
     /* init to unused value - it must not default to SQL_NULL_DATA or
      * else we will mess up merge of ind and len */
     nIndicator              = 0;
@@ -413,7 +414,19 @@
             MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::STATE_HY003 ) );
     }
 
-    MYODBCCSet( pnLength, stateGetData.nBytesTotal );
+    /* if its retrieved in chunks,
+     * we need to send whats available before getData() */
+    if ( stateGetData.nBytesPrev )
+    {
+        MYODBCCSet( pnLength, stateGetData.nBytesPrev );
+        /* adjust for data taken */
+        stateGetData.nBytesPrev -=
+            (stateGetData.nBytesPrev - stateGetData.nBytesRemaining);
+    }
+    else
+    {
+        MYODBCCSet( pnLength, stateGetData.nBytesTotal );
+    }
 
     MYODBCDbgReturn( nReturn );
 }
@@ -1044,12 +1057,15 @@
         /* make a copy we can easily work with (avoid re-convert) in case of chunking
(optimize this later) */
         pResultGetData->stringData  =
vectorRows[pResultGetData->nRow][pResultGetData->nColumn - 1].toString();
         pResultGetData->nBytesTotal = pResultGetData->stringData.length(); /* bytes
= chars in this case */
+        pResultGetData->nBytesPrev = pResultGetData->nBytesTotal; /* init
prev-bytes */
     }
 
     /* do we even need to do the data bit (or just looking for len)? */
     if ( pResultGetData->pTarget && pResultGetData->nBytesMax )
     {
-        if ( MYODBCC::doStringCopyOut( (SQLCHAR*)pResultGetData->pTarget,
pResultGetData->nBytesMax,
(SQLCHAR*)pResultGetData->stringData.toLocal8Bit().data() ) )
+        if ( MYODBCC::doStringCopyOut( (SQLCHAR*)pResultGetData->pTarget,
+                    pResultGetData->nBytesMax,
+                    (SQLCHAR*)pResultGetData->stringData.toLocal8Bit().data() ) )
         {
             pResultGetData->nBytesRemaining = 0;
         }
@@ -1113,12 +1129,15 @@
         /* make a copy we can easily work with (avoid re-convert) in case of chunking
(optimize this later) */
         pResultGetData->stringData  =
vectorRows[pResultGetData->nRow][pResultGetData->nColumn - 1].toString();
         pResultGetData->nBytesTotal = pResultGetData->stringData.length() *
sizeof(SQLWCHAR); /* >1 bytes = char in this case */
+        pResultGetData->nBytesPrev = pResultGetData->nBytesTotal; /* init
prev-bytes */
     }
 
     /* do we even need to do the data bit (or just looking for len)? */
     if ( pResultGetData->pTarget && pResultGetData->nBytesMax )
     {
-        if ( MYODBCC::doStringCopyOut( (SQLWCHAR*)pResultGetData->pTarget,
pResultGetData->nBytesMax / sizeof(SQLWCHAR), pResultGetData->stringData ) )
+        if ( MYODBCC::doStringCopyOut( (SQLWCHAR*)pResultGetData->pTarget,
+                    pResultGetData->nBytesMax / sizeof(SQLWCHAR),
+                    pResultGetData->stringData ) )
         {
             pResultGetData->nBytesRemaining = 0;
         }
@@ -1589,6 +1608,7 @@
         /* make a copy we can easily work with (avoid re-convert) in case of chunking
(optimize this later) */
         pResultGetData->bytearrayData =
vectorRows[pResultGetData->nRow][pResultGetData->nColumn - 1].toByteArray();
         pResultGetData->nBytesTotal   = pResultGetData->bytearrayData.size();
+        pResultGetData->nBytesPrev = pResultGetData->nBytesTotal; /* init
prev-bytes */
     }
 
     /* do we even need to do the data bit (or just looking for len)? */

Thread
Connector/ODBC 5 commit: r783 - trunk/SDK/MYSQLPlus/Libraryjbalint1 Feb