Date: Friday, February 24, 2006 @ 18:34:19
Author: gilles
Path: /cvsroot/carob/carob
Modified: include/SQLDataSerialization.hpp (1.12 -> 1.13)
src/DriverResultSet.cpp (1.40 -> 1.41)
src/SQLDataSerialization.cpp (1.26 -> 1.27)
Introduced LargeData serialization type (for byte arrays and blobs)
Fixed byteArrayDeserializer to use this new type and new
DriverSocket::receiveBytes functions. Fixes CAROB-66
Added delete of LargeData type in resultset memory freeing function
----------------------------------+
include/SQLDataSerialization.hpp | 9 +++++++++
src/DriverResultSet.cpp | 13 +++++++++++++
src/SQLDataSerialization.cpp | 15 +++++----------
3 files changed, 27 insertions(+), 10 deletions(-)
Index: carob/include/SQLDataSerialization.hpp
diff -u carob/include/SQLDataSerialization.hpp:1.12
carob/include/SQLDataSerialization.hpp:1.13
--- carob/include/SQLDataSerialization.hpp:1.12 Tue Feb 14 12:05:05 2006
+++ carob/include/SQLDataSerialization.hpp Fri Feb 24 18:34:19 2006
@@ -26,6 +26,8 @@
#include "CarobException.hpp"
+#include "Common.hpp" // for java_byte: cannot forward declare typedefs
+
namespace CarobNS {
class TypeTag;
@@ -85,6 +87,13 @@
int32_t nanos;
} SQLTimeStamp;
+/** Large Data: byte array, blob, clob */
+typedef struct
+{
+ int32_t length; //int32 to reflect java
+ java_byte* data;
+} LargeData;
+
/**
* Defines data type that can be found in ResultSets
*/
Index: carob/src/DriverResultSet.cpp
diff -u carob/src/DriverResultSet.cpp:1.40 carob/src/DriverResultSet.cpp:1.41
--- carob/src/DriverResultSet.cpp:1.40 Fri Feb 24 12:43:44 2006
+++ carob/src/DriverResultSet.cpp Fri Feb 24 18:34:19 2006
@@ -85,6 +85,19 @@
}
}
break;
+ case TT_BYTE_ARRAY:
+ case TT_BLOB:
+ case TT_CLOB:
+ for (cnt=0; cnt<data.size(); cnt++)
+ {
+ if (!nulls[cnt][col])
+ {
+ LargeData* ld =
static_cast<LargeData*>((data[cnt][col]).as_other);
+ delete[] ld->data;
+ delete ld;
+ }
+ }
+ break;
}
}
//Now remove data from the vector
Index: carob/src/SQLDataSerialization.cpp
diff -u carob/src/SQLDataSerialization.cpp:1.26
carob/src/SQLDataSerialization.cpp:1.27
--- carob/src/SQLDataSerialization.cpp:1.26 Tue Feb 14 12:05:05 2006
+++ carob/src/SQLDataSerialization.cpp Fri Feb 24 18:34:19 2006
@@ -224,16 +224,11 @@
throw (SocketIOException, UnexpectedException)
{
ResultSetDataType res;
- int baLength = 0;
- input>>baLength;
- uint8_t* byteArrayRead = new uint8_t[baLength];
- int32_t byteRead = 0;
- for (int i=0; i<baLength; i++)
- {
- input>>byteRead;
- byteArrayRead[i] = byteRead&0xFF;
- }
- res.as_other = static_cast<void*>(byteArrayRead);
+ LargeData* ld = new LargeData;
+ input>>ld->length;
+ ld->data = new java_byte[ld->length];
+ input.readBytes(ld->length, ld->data);
+ res.as_other = static_cast<void*>(ld);
return res;
}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits