aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-01-12 09:06:13 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-01-20 15:45:46 +0200
commit3cc019d0df41400f9cf921040adab0ae198b570a (patch)
tree256851e5511f1016f07f8541cf459b255e5ee6d9
parentce67e078eb0a2a867a0381d849d5b8180c1f6e25 (diff)
Implement callback data re-basing support for LOB result streaming
This is used by the query machinery when a copy of the image has to be made. In this case stream_result() needs to use data from the copy of the image, and not from the image that was bound to the bind array.
-rw-r--r--oracle/types/driver.cxx41
1 files changed, 37 insertions, 4 deletions
diff --git a/oracle/types/driver.cxx b/oracle/types/driver.cxx
index b23a757..684a46e 100644
--- a/oracle/types/driver.cxx
+++ b/oracle/types/driver.cxx
@@ -178,13 +178,15 @@ main (int argc, char* argv[])
// Test large BLOBs.
//
- blob b (1, 50000);
+ blob b1 (1, 50000);
+ blob b2 (2, 500000);
// Persist.
//
{
transaction t (db->begin ());
- db->persist (b);
+ db->persist (b1);
+ db->persist (b2);
t.commit ();
}
@@ -192,10 +194,41 @@ main (int argc, char* argv[])
//
{
transaction t (db->begin ());
- auto_ptr<blob> bl (db->load<blob> (1));
+ auto_ptr<blob> p1 (db->load<blob> (1));
+ auto_ptr<blob> p2 (db->load<blob> (2));
t.commit ();
- assert (b == *bl);
+ assert (b1 == *p1);
+ assert (b2 == *p2);
+ }
+
+ // Test image copying with LOB data.
+ //
+ {
+ typedef odb::query<blob> query;
+ typedef odb::result<blob> result;
+
+ transaction t (db->begin ());
+
+ result r (db->query<blob> (query::id < 3));
+ result::iterator i (r.begin ());
+
+ assert (i != r.end ());
+ ++i;
+ assert (i != r.end ());
+
+ {
+ result r (db->query<blob> (query::id < 2));
+ result::iterator i (r.begin ());
+ assert (i != r.end ());
+ assert (i->value_.size () == 50000);
+ assert (++i == r.end ());
+ }
+
+ assert (i->value_.size () == 500000); // Load from copy.
+ assert (++i == r.end ());
+
+ t.commit ();
}
// Test descriptor management in TIMESTAMP and INTERVAL images.