From: Aki Tuomi Date: Thu, 26 Nov 2015 08:36:56 +0000 (+0200) Subject: Retrieve data only once X-Git-Tag: dnsdist-1.0.0-alpha1~191^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F2934%2Fhead;p=thirdparty%2Fpdns.git Retrieve data only once --- diff --git a/modules/godbcbackend/sodbc.cc b/modules/godbcbackend/sodbc.cc index 6b03c5f099..e2af0d0dd8 100644 --- a/modules/godbcbackend/sodbc.cc +++ b/modules/godbcbackend/sodbc.cc @@ -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(coldata), std::min(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(coldata), std::min(sizeof(coldata)-1,len)); - cerr<<"len="< SQL_NULL_DATA) + strres = std::string(reinterpret_cast(coldata), std::min(sizeof(coldata)-1,len)); // do not use nil byte + row.push_back(strres); } // Done!