]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Retrieve data only once 2934/head
authorAki Tuomi <cmouse@cmouse.fi>
Thu, 26 Nov 2015 08:36:56 +0000 (10:36 +0200)
committerAki Tuomi <cmouse@cmouse.fi>
Thu, 26 Nov 2015 11:10:55 +0000 (13:10 +0200)
modules/godbcbackend/sodbc.cc

index 6b03c5f09956fbb547caf39084ad9ff66f161276..e2af0d0dd8432d54467bf2c19a61dded6404ae98 100644 (file)
@@ -270,23 +270,13 @@ SSqlStatement* SODBCStatement::nextRow(row_t& row)
     for ( int i = 0; i < m_columncount; i++ )
     {
       SQLLEN len;
-      result = SQLGetData( d_statement, i + 1, SQL_C_CHAR, (SQLPOINTER)0, 0, &len );
-      if ( len == SQL_NULL_DATA ) {
-        // Column is NULL, so we can skip the converting part.
-        row.push_back( "" );
-      } else {
-        SQLCHAR coldata[128*1024];
-        result = SQLGetData( d_statement, i + 1, SQL_C_CHAR, (SQLPOINTER) coldata, sizeof(coldata), &len);
-        std::string strres = std::string(reinterpret_cast<const char*>(coldata), std::min<SQLLEN>(sizeof(coldata)-1,len)); // do not use nil byte
-        while(result == SQL_SUCCESS_WITH_INFO && len > 0) { // all data is consumed if len < 1
-           result = SQLGetData( d_statement, i + 1, SQL_C_CHAR, (SQLPOINTER) coldata, sizeof(coldata), &len );
-           strres = strres + std::string(reinterpret_cast<const char*>(coldata), std::min<SQLLEN>(sizeof(coldata)-1,len));
-           cerr<<"len="<<len<<endl;
-        }
-        // cerr<<"len="<<len<<endl;
-        testResult( result, SQL_HANDLE_STMT, d_statement, "Could not get data." );
-        row.push_back(strres);
-      }
+      SQLCHAR coldata[128*1024];
+      std::string strres = "";
+      result = SQLGetData( d_statement, i + 1, SQL_C_CHAR, (SQLPOINTER) coldata, sizeof(coldata), &len);
+      testResult( result, SQL_HANDLE_STMT, d_statement, "Could not get data." );
+      if (len > SQL_NULL_DATA)
+        strres = std::string(reinterpret_cast<const char*>(coldata), std::min<SQLLEN>(sizeof(coldata)-1,len)); // do not use nil byte
+      row.push_back(strres);
     }
 
     // Done!