Date: Wednesday, February 14, 2007 @ 17:31:49
  Author: gilles
    Path: /cvsroot/carob/carob

Modified: include/DriverResultSet.hpp (1.45 -> 1.46)
          src/DriverResultSet.cpp (1.62 -> 1.63)

data and nulls are now vectors of vector* to avoid big copies during 
deserialization
Partly fixes CAROB-127

This also was a good occasion to clean-up excessive use of parenthesis


-----------------------------+
 include/DriverResultSet.hpp |    4 
 src/DriverResultSet.cpp     |  183 +++++++++++++++++++++---------------------
 2 files changed, 94 insertions(+), 93 deletions(-)


Index: carob/include/DriverResultSet.hpp
diff -u carob/include/DriverResultSet.hpp:1.45 
carob/include/DriverResultSet.hpp:1.46
--- carob/include/DriverResultSet.hpp:1.45      Thu Jul 27 17:10:42 2006
+++ carob/include/DriverResultSet.hpp   Wed Feb 14 17:31:49 2007
@@ -481,7 +481,7 @@
    /** Number of columns */
   int                         nbOfColumns;
   /** The results */
-  std::vector< std::vector<ResultSetDataType> >  data;
+  std::vector< std::vector<ResultSetDataType>* >  data;
   /** Indicates that no data has been read yet */
   bool                        dataIsNull;
   /**
@@ -494,7 +494,7 @@
    *                           ...case x: return bit_struct.bx;
    * bit_struct would be: typedef struct { bool b0:1; bool b1:1; ...}
    */
-  std::vector< std::vector<bool> > nulls;
+  std::vector< std::vector<bool>* > nulls;
   /** Type of columns as defined by the controller */
   std::vector<TypeTag>        columnTypeTags;
   /** True if there is more data to fetch from the controller */
Index: carob/src/DriverResultSet.cpp
diff -u carob/src/DriverResultSet.cpp:1.62 carob/src/DriverResultSet.cpp:1.63
--- carob/src/DriverResultSet.cpp:1.62  Thu Jan 25 16:56:57 2007
+++ carob/src/DriverResultSet.cpp       Wed Feb 14 17:31:49 2007
@@ -66,34 +66,34 @@
     //First delete data contained in data[x][y].as_other.
     //These are void* so we need to switch on the column type to delete it
     //Let's make this switch only once per column !
-    for (size_t col=0; col<data[0].size(); col++)
+    for (size_t col=0; col<data[0]->size(); col++)
     {
       switch (columnTypeTags[col])
       {
         case TT_STRING:
           for (cnt=0; cnt<data.size(); cnt++)
           {
-            if (!nulls[cnt][col])
+            if (!(*nulls[cnt])[col])
             {
-              delete (static_cast<wstring*>((data[cnt][col]).as_other));
+              delete static_cast<wstring*>((*data[cnt])[col].as_other);
             }
           }
         break;
         case TT_BIGDECIMAL:
           for (cnt=0; cnt<data.size(); cnt++)
           {
-            if (!nulls[cnt][col])
+            if (!(*nulls[cnt])[col])
             {
-              delete (static_cast<BigDecimal*>((data[cnt][col]).as_other));
+              delete static_cast<BigDecimal*>((*data[cnt])[col].as_other);
             }
           }
         break;
         case TT_SQL_TIMESTAMP:
           for (cnt=0; cnt<data.size(); cnt++)
           {
-            if (!nulls[cnt][col])
+            if (!(*nulls[cnt])[col])
             {
-              delete (static_cast<SQLTimeStamp*>((data[cnt][col]).as_other));
+              delete static_cast<SQLTimeStamp*>((*data[cnt])[col].as_other);
             }
           }
         break;
@@ -102,9 +102,9 @@
         case TT_CLOB:
           for (cnt=0; cnt<data.size(); cnt++)
           {
-            if (!nulls[cnt][col])
+            if (!(*nulls[cnt])[col])
             {
-              LargeData* ld = 
static_cast<LargeData*>((data[cnt][col]).as_other);
+              LargeData* ld = 
static_cast<LargeData*>((*data[cnt])[col].as_other);
               delete[] ld->data;
               delete ld;
             }
@@ -115,14 +115,18 @@
     //Now remove data from the vector
     for (cnt=0; cnt<data.size(); cnt++)
     {
-      data[cnt].clear();
+      data[cnt]->clear();
+      delete data[cnt];
     }
     data.clear();
     //The types
     columnTypeTags.clear();
     //And finally the nulls
     for (cnt=0; cnt<nulls.size(); cnt++)
-      nulls[cnt].clear();
+    {
+      nulls[cnt]->clear();
+      delete nulls[cnt];
+    }
     nulls.clear();
     delete warningsPtr;
     warningsPtr = NULL;
@@ -262,7 +266,7 @@
     throw (DriverException(L"getString: value at row " + 
toUserString(currentRow)
         + L" column " + toUserString(columnIndex) + L" is not of type 
string"));
   }
-  return (*(static_cast<wstring*>((data[currentRow][columnIndex - 
1].as_other))));
+  return *(static_cast<wstring*>((*data[currentRow])[columnIndex - 
1].as_other));
 }
 
 wstring DriverResultSet::getAsString(int columnIndex, const std::locale& 
loc/*=std::locale()*/)
@@ -283,37 +287,37 @@
   switch (columnTypeTags[columnIndex - 1])
   {
     case TT_STRING:
-      buffer << *(static_cast<wstring*>((data[currentRow][columnIndex - 
1].as_other)));
+      buffer << *(static_cast<wstring*>((*data[currentRow])[columnIndex - 
1].as_other));
     break;
     case TT_BIGDECIMAL:
     {
-      BigDecimal* bd = (static_cast<BigDecimal*>((data[currentRow][columnIndex 
- 1].as_other)));
+      BigDecimal* bd = 
static_cast<BigDecimal*>((*data[currentRow])[columnIndex - 1].as_other);
       buffer << bd->toString(loc);
       break;
     }
     case TT_BOOLEAN:
-      buffer << ((data[currentRow])[columnIndex - 1]).as_bool;
+      buffer << (*data[currentRow])[columnIndex - 1].as_bool;
     break;
     case TT_INTEGER:
-      buffer << ((data[currentRow])[columnIndex - 1]).as_int;
+      buffer << (*data[currentRow])[columnIndex - 1].as_int;
     break;
     case TT_LONG:
-      buffer << ((data[currentRow])[columnIndex - 1]).as_long;
+      buffer << (*data[currentRow])[columnIndex - 1].as_long;
     break;
     case TT_FLOAT:
-      buffer << ((data[currentRow])[columnIndex - 1]).as_float;
+      buffer << (*data[currentRow])[columnIndex - 1].as_float;
     break;
     case TT_DOUBLE:
-      buffer << ((data[currentRow])[columnIndex - 1]).as_double;
+      buffer << (*data[currentRow])[columnIndex - 1].as_double;
     break;
     case TT_BYTE_ARRAY:
       throw NotImplementedException(L"ByteArray to string conversion not 
implemented yet.");
     break;
     case TT_SQL_DATE:
-      buffer << ((data[currentRow])[columnIndex - 1]).as_long;
+      buffer << (*data[currentRow])[columnIndex - 1].as_long;
     break;
     case TT_SQL_TIME:
-      buffer << ((data[currentRow])[columnIndex - 1]).as_int;
+      buffer << (*data[currentRow])[columnIndex - 1].as_int;
     break;
     case TT_SQL_TIMESTAMP:
       throw NotImplementedException(L"SQL TimeStamp to string conversion not 
implemented yet.");
@@ -347,7 +351,7 @@
         + L" column " + toUserString(columnIndex) + L" is not of type 
integer"));
   }
   
-  return ((data[currentRow])[columnIndex - 1]).as_int;
+  return (*data[currentRow])[columnIndex - 1].as_int;
 }
 
 int DriverResultSet::getAsInt(int columnIndex) throw (DriverException,
@@ -368,7 +372,7 @@
   {
     case TT_STRING:
     { //these brackets to be able to declare loc var without warns
-      wstring valAsString = 
trim(*static_cast<wstring*>((data[currentRow][columnIndex - 1].as_other)));
+      wstring valAsString = 
trim(*static_cast<wstring*>((*data[currentRow])[columnIndex - 1].as_other));
       //Tries to parse the string as an integer
       if(!wstringTo<int>(ret, valAsString))
       {
@@ -388,39 +392,39 @@
     break;
     case TT_BIGDECIMAL:
     {
-      BigDecimal* bd = (static_cast<BigDecimal*>((data[currentRow][columnIndex 
- 1].as_other)));
+      BigDecimal* bd = 
static_cast<BigDecimal*>((*data[currentRow])[columnIndex - 1].as_other);
       ret = static_cast<int>(*bd);
       break;
     }
     case TT_BOOLEAN:
-      if (((data[currentRow])[columnIndex - 1]).as_bool)
+      if ((*data[currentRow])[columnIndex - 1].as_bool)
         ret = 1;
       else
         ret = 0;
     break;
     case TT_INTEGER:
-      ret = ((data[currentRow])[columnIndex - 1]).as_int;
+      ret = (*data[currentRow])[columnIndex - 1].as_int;
     break;
     case TT_LONG:
-      ret = static_cast<int>(((data[currentRow])[columnIndex - 1]).as_long);
+      ret = static_cast<int>((*data[currentRow])[columnIndex - 1].as_long);
     break;
     case TT_FLOAT:
-      ret = static_cast<int>(((data[currentRow])[columnIndex - 1]).as_float);
+      ret = static_cast<int>((*data[currentRow])[columnIndex - 1].as_float);
     break;
     case TT_DOUBLE:
-      ret = static_cast<int>(((data[currentRow])[columnIndex - 1]).as_double);
+      ret = static_cast<int>((*data[currentRow])[columnIndex - 1].as_double);
     break;
     case TT_BYTE_ARRAY:
       throw NotImplementedException(L"ByteArray to int conversion not 
implemented yet.");
     break;
     case TT_SQL_DATE:
-      ret = static_cast<int>(((data[currentRow])[columnIndex - 1]).as_long);
+      ret = static_cast<int>((*data[currentRow])[columnIndex - 1].as_long);
     break;
     case TT_SQL_TIME:
-      ret = ((data[currentRow])[columnIndex - 1]).as_int;
+      ret = (*data[currentRow])[columnIndex - 1].as_int;
     break;
     case TT_SQL_TIMESTAMP:
-      ret = static_cast<SQLTimeStamp*>((data[currentRow][columnIndex - 
1].as_other))->time;
+      ret = static_cast<SQLTimeStamp*>((*data[currentRow])[columnIndex - 
1].as_other)->time;
     break;
     case TT_BLOB:
       throw NotImplementedException(L"Blob to int conversion not implemented 
yet.");
@@ -451,7 +455,7 @@
         + L" column " + toUserString(columnIndex) + L" is not of type 
integer"));
   }
   
-  return ((data[currentRow])[columnIndex - 1]).as_long;
+  return (*data[currentRow])[columnIndex - 1].as_long;
 }
 
 int64_t DriverResultSet::getAsInt64(int columnIndex) throw (DriverException,
@@ -472,7 +476,7 @@
   {
     case TT_STRING:
     { //these bracket to be able to declare loc var without warns
-      wstring valAsString = 
trim(*static_cast<wstring*>((data[currentRow][columnIndex - 1].as_other)));
+      wstring valAsString = 
trim(*static_cast<wstring*>((*data[currentRow])[columnIndex - 1].as_other));
       //Tries to parse the string as an integer
       if(!wstringTo<int64_t>(ret, valAsString))
       {
@@ -492,39 +496,39 @@
     break;
     case TT_BIGDECIMAL:
     {
-      BigDecimal* bd = (static_cast<BigDecimal*>((data[currentRow][columnIndex 
- 1].as_other)));
+      BigDecimal* bd = 
static_cast<BigDecimal*>((*data[currentRow])[columnIndex - 1].as_other);
       ret = static_cast<int64_t>(*bd);
       break;
     }
     case TT_BOOLEAN:
-      if (((data[currentRow])[columnIndex - 1]).as_bool)
+      if ((*data[currentRow])[columnIndex - 1].as_bool)
         ret = 1;
       else
         ret = 0;
     break;
     case TT_INTEGER:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 1]).as_int);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 1].as_int);
     break;
     case TT_LONG:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 
1]).as_long);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 1].as_long);
     break;
     case TT_FLOAT:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 
1]).as_float);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 
1].as_float);
     break;
     case TT_DOUBLE:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 
1]).as_double);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 
1].as_double);
     break;
     case TT_BYTE_ARRAY:
       throw NotImplementedException(L"ByteArray to int64 conversion not 
implemented yet.");
     break;
     case TT_SQL_DATE:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 
1]).as_long);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 1].as_long);
     break;
     case TT_SQL_TIME:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 1]).as_int);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 1].as_int);
     break;
     case TT_SQL_TIMESTAMP:
-      ret = 
static_cast<int64_t>(static_cast<SQLTimeStamp*>((data[currentRow][columnIndex - 
1].as_other))->time);
+      ret = 
static_cast<int64_t>(static_cast<SQLTimeStamp*>((*data[currentRow])[columnIndex 
- 1].as_other)->time);
     break;
     case TT_BLOB:
       throw NotImplementedException(L"Blob to int64 conversion not implemented 
yet.");
@@ -556,7 +560,7 @@
   {
     case TT_STRING:
     { //these bracket to be able to declare loc var without warns
-      wstring valAsString = 
trim(*static_cast<wstring*>((data[currentRow][columnIndex - 1].as_other)));
+      wstring valAsString = 
trim(*static_cast<wstring*>((*data[currentRow])[columnIndex - 1].as_other));
       //Tries to parse the string as an integer
       if(!wstringTo<uint64_t>(ret, valAsString))
       {
@@ -576,40 +580,40 @@
     break;
     case TT_BIGDECIMAL:
     {
-      BigDecimal* bd = (static_cast<BigDecimal*>((data[currentRow][columnIndex 
- 1].as_other)));
+      BigDecimal* bd = 
static_cast<BigDecimal*>((*data[currentRow])[columnIndex - 1].as_other);
       ret = static_cast<uint64_t>(*bd);
       break;
     }
     case TT_BOOLEAN:
-      if (((data[currentRow])[columnIndex - 1]).as_bool)
+      if ((*data[currentRow])[columnIndex - 1].as_bool)
         ret = 1;
       else
         ret = 0;
     break;
 /* TODO: => check that the number is positive before casting it to uint
     case TT_INTEGER:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 1]).as_int);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 1].as_int);
     break;
     case TT_LONG:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 
1]).as_long);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 1].as_long);
     break;
     case TT_FLOAT:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 
1]).as_float);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 
1].as_float);
     break;
     case TT_DOUBLE:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 
1]).as_double);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 
1].as_double);
     break;
     case TT_BYTE_ARRAY:
       throw NotImplementedException(L"ByteArray to int64 conversion not 
implemented yet.");
     break;
     case TT_SQL_DATE:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 
1]).as_long);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 1].as_long);
     break;
     case TT_SQL_TIME:
-      ret = static_cast<int64_t>(((data[currentRow])[columnIndex - 1]).as_int);
+      ret = static_cast<int64_t>((*data[currentRow])[columnIndex - 1].as_int);
     break;
     case TT_SQL_TIMESTAMP:
-      ret = 
static_cast<int64_t>(static_cast<SQLTimeStamp*>((data[currentRow][columnIndex - 
1].as_other))->time);
+      ret = 
static_cast<int64_t>(static_cast<SQLTimeStamp*>((*data[currentRow])[columnIndex 
- 1].as_other)->time);
     break;
     case TT_BLOB:
       throw NotImplementedException(L"Blob to int64 conversion not implemented 
yet.");
@@ -641,7 +645,7 @@
         + L" column " + toUserString(columnIndex) + L" is not of type float"));
   }
   
-  return ((data[currentRow])[columnIndex - 1]).as_float;
+  return (*data[currentRow])[columnIndex - 1].as_float;
 }
 
 float DriverResultSet::getAsFloat(int columnIndex) throw (DriverException,
@@ -662,7 +666,7 @@
   {
     case TT_STRING:
     {
-      wstring valAsString = 
trim(*static_cast<wstring*>((data[currentRow][columnIndex - 1].as_other)));
+      wstring valAsString = 
trim(*static_cast<wstring*>((*data[currentRow])[columnIndex - 1].as_other));
       //Tries to parse the string as an integer
       if(!wstringTo<float>(ret, valAsString))
       {
@@ -682,39 +686,39 @@
     break;
     case TT_BIGDECIMAL:
     {
-      BigDecimal* bd = (static_cast<BigDecimal*>((data[currentRow][columnIndex 
- 1].as_other)));
+      BigDecimal* bd = 
static_cast<BigDecimal*>((*data[currentRow])[columnIndex - 1].as_other);
       ret = static_cast<float>(*bd);
       break;
     }
     case TT_BOOLEAN:
-      if (((data[currentRow])[columnIndex - 1]).as_bool)
+      if ((*data[currentRow])[columnIndex - 1].as_bool)
         ret = 1;
       else
         ret = 0;
     break;
     case TT_INTEGER:
-      ret = static_cast<float>(((data[currentRow])[columnIndex - 1]).as_int);
+      ret = static_cast<float>((*data[currentRow])[columnIndex - 1].as_int);
     break;
     case TT_LONG:
-      ret = static_cast<float>(((data[currentRow])[columnIndex - 1]).as_long);
+      ret = static_cast<float>((*data[currentRow])[columnIndex - 1].as_long);
     break;
     case TT_FLOAT:
-      ret = ((data[currentRow])[columnIndex - 1]).as_float;
+      ret = (*data[currentRow])[columnIndex - 1].as_float;
     break;
     case TT_DOUBLE:
-      ret = static_cast<float>(data[currentRow][columnIndex - 1].as_double);
+      ret = static_cast<float>((*data[currentRow])[columnIndex - 1].as_double);
     break;
     case TT_BYTE_ARRAY:
       throw NotImplementedException(L"ByteArray to float conversion not 
implemented yet.");
     break;
     case TT_SQL_DATE:
-      ret = static_cast<float>(((data[currentRow])[columnIndex - 1]).as_long);
+      ret = static_cast<float>((*data[currentRow])[columnIndex - 1].as_long);
     break;
     case TT_SQL_TIME:
-      ret = static_cast<float>(((data[currentRow])[columnIndex - 1]).as_int);
+      ret = static_cast<float>((*data[currentRow])[columnIndex - 1].as_int);
     break;
     case TT_SQL_TIMESTAMP:
-      ret = 
static_cast<float>(static_cast<SQLTimeStamp*>((data[currentRow][columnIndex - 
1].as_other))->time);
+      ret = 
static_cast<float>(static_cast<SQLTimeStamp*>((*data[currentRow])[columnIndex - 
1].as_other)->time);
     break;
     case TT_BLOB:
       throw NotImplementedException(L"Blob to float conversion not implemented 
yet.");
@@ -745,7 +749,7 @@
         + L" column " + toUserString(columnIndex) + L" is not of type 
double"));
   }
   
-  return ((data[currentRow])[columnIndex - 1]).as_double;
+  return (*data[currentRow])[columnIndex - 1].as_double;
 }
 
 double DriverResultSet::getAsDouble(int columnIndex) throw (DriverException,
@@ -766,7 +770,7 @@
   {
     case TT_STRING:
     {
-      wstring valAsString = 
trim(*static_cast<wstring*>((data[currentRow][columnIndex - 1].as_other)));
+      wstring valAsString = 
trim(*static_cast<wstring*>((*data[currentRow])[columnIndex - 1].as_other));
       //Tries to parse the string as an integer
       if(!wstringTo<double>(ret, valAsString))
       {
@@ -786,39 +790,39 @@
     break;
     case TT_BIGDECIMAL:
     {
-      BigDecimal* bd = (static_cast<BigDecimal*>((data[currentRow][columnIndex 
- 1].as_other)));
+      BigDecimal* bd = 
static_cast<BigDecimal*>((*data[currentRow])[columnIndex - 1].as_other);
       ret = static_cast<double>(*bd);
       break;
     }
     case TT_BOOLEAN:
-      if (((data[currentRow])[columnIndex - 1]).as_bool)
+      if ((*data[currentRow])[columnIndex - 1].as_bool)
         ret = 1;
       else
         ret = 0;
     break;
     case TT_INTEGER:
-      ret = static_cast<double>(((data[currentRow])[columnIndex - 1]).as_int);
+      ret = static_cast<double>((*data[currentRow])[columnIndex - 1].as_int);
     break;
     case TT_LONG:
-      ret = static_cast<double>(((data[currentRow])[columnIndex - 1]).as_long);
+      ret = static_cast<double>((*data[currentRow])[columnIndex - 1].as_long);
     break;
     case TT_FLOAT:
-      ret = static_cast<double>(((data[currentRow])[columnIndex - 
1]).as_float);
+      ret = static_cast<double>((*data[currentRow])[columnIndex - 1].as_float);
     case TT_DOUBLE:
-      ret = (data[currentRow][columnIndex - 1].as_double);
+      ret = (*data[currentRow])[columnIndex - 1].as_double;
     break;
     case TT_BYTE_ARRAY:
       throw NotImplementedException(L"ByteArray to double conversion not 
implemented yet.");
     break;
     break;
     case TT_SQL_DATE:
-      ret = static_cast<double>(((data[currentRow])[columnIndex - 1]).as_long);
+      ret = static_cast<double>((*data[currentRow])[columnIndex - 1].as_long);
     break;
     case TT_SQL_TIME:
-      ret = static_cast<double>(((data[currentRow])[columnIndex - 1]).as_int);
+      ret = static_cast<double>((*data[currentRow])[columnIndex - 1].as_int);
     break;
     case TT_SQL_TIMESTAMP:
-      ret = 
static_cast<double>(static_cast<SQLTimeStamp*>((data[currentRow][columnIndex - 
1].as_other))->time);
+      ret = 
static_cast<double>(static_cast<SQLTimeStamp*>((*data[currentRow])[columnIndex 
- 1].as_other)->time);
     break;
     case TT_BLOB:
       throw NotImplementedException(L"Blob to double conversion not 
implemented yet.");
@@ -849,7 +853,7 @@
         + L" column " + toUserString(columnIndex) + L" is not of type 
timestamp"));
   }
   
-  return *static_cast<SQLTimeStamp*>((data[currentRow][columnIndex - 
1].as_other));
+  return *static_cast<SQLTimeStamp*>((*data[currentRow])[columnIndex - 
1].as_other);
 }
 
 LargeData& DriverResultSet::getLargeObject(int columnIndex) throw 
(DriverException,
@@ -870,7 +874,7 @@
         + L" column " + toUserString(columnIndex) + L" is not of type blob, 
clob or byte array"));
   }
   
-  return *static_cast<LargeData*>((data[currentRow][columnIndex - 
1].as_other));
+  return *static_cast<LargeData*>((*data[currentRow])[columnIndex - 
1].as_other);
 }
 
 const BigDecimal& DriverResultSet::getBigDecimal(int columnIndex) throw 
(DriverException,
@@ -890,7 +894,7 @@
         + L" column " + toUserString(columnIndex) + L" is not of type 
BigDecimal"));
   }
   
-  return *static_cast<BigDecimal*>((data[currentRow][columnIndex - 
1].as_other));
+  return *static_cast<BigDecimal*>((*data[currentRow])[columnIndex - 
1].as_other);
 }
 
 void DriverResultSet::close() throw (SocketIOException, BackendException,
@@ -908,19 +912,19 @@
   clearAllData();
   socket>>nbOfRows;
 
-  vector<bool> nullsForThisRow;
-  vector<ResultSetDataType> rowOfData;
   //Declare empty result which is used in case of null values
   ResultSetDataType emptyResult = {0};
   //Reserve memory now so it won't be done during iterations
-  nullsForThisRow.reserve(nbOfColumns);
-  rowOfData.reserve(nbOfColumns);
   nulls.reserve(nbOfRows);
   data.reserve(nbOfRows);
 
   // Receive the actual data
   for (int rowCnt = 0; rowCnt<nbOfRows; rowCnt++)
   {
+    vector<ResultSetDataType>* rowOfData = new vector<ResultSetDataType>;
+    vector<bool>* nullsForThisRow = new vector<bool>;
+    rowOfData->reserve(nbOfColumns);
+    nullsForThisRow->reserve(nbOfColumns);
     TypeTag tt(socket);
     if (tt != TT_ROW)
     {
@@ -932,21 +936,18 @@
     {
       bool b;
       socket>>b;
-      nullsForThisRow.push_back(b);
+      nullsForThisRow->push_back(b);
     }
     nulls.push_back(nullsForThisRow);
     
     for (int colCnt2 = 0; colCnt2 < nbOfColumns; colCnt2++)
     {
-      if (!nullsForThisRow[colCnt2])
-        rowOfData.push_back(deserializers[colCnt2](socket));
+      if (!(*nullsForThisRow)[colCnt2])
+        rowOfData->push_back(deserializers[colCnt2](socket));
       else 
-        rowOfData.push_back(emptyResult);
+        rowOfData->push_back(emptyResult);
     }
     data.push_back(rowOfData);
-    //now the values are copied, so remove these elements
-    nullsForThisRow.clear();
-    rowOfData.clear();
     //now we have some data
     if (dataIsNull)
       dataIsNull = false;
@@ -987,10 +988,10 @@
     throw DriverException(L"Column Index out of range ( "
         + toUserString(columnIndex) + L" > " + toUserString(nbOfColumns) + 
L").");
 
-  if (static_cast<int>(data[currentRow].size())<columnIndex-1)
+  if (static_cast<int>(data[currentRow]->size())<columnIndex-1)
     answer = true;
   else
-    answer = nulls[currentRow][columnIndex - 1];
+    answer = (*nulls[currentRow])[columnIndex - 1];
   return answer;
 }
 

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to