aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-09-10 10:21:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-09-10 10:21:14 +0200
commitb3af5d13db8c29b42436c54abd94b73b7a7f00bd (patch)
tree7f9c8f8e852345c010a83f53454eb2b8519f54e5
parenta15eb05821b1ae5b40b24bfa3efa0c70a095b3e9 (diff)
Rearrange data/size calls as recommended by SQLite documentation
-rw-r--r--odb/sqlite/statement.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx
index e917ac8..60cf410 100644
--- a/odb/sqlite/statement.cxx
+++ b/odb/sqlite/statement.cxx
@@ -191,6 +191,14 @@ namespace odb
case bind::text:
case bind::blob:
{
+ // SQLite documentation recommends that we first call *_text()
+ // or *_blob() function in order to force the type conversion,
+ // if any.
+ //
+ const void* d (b.type == bind::text
+ ? sqlite3_column_text (stmt_, j)
+ : sqlite3_column_blob (stmt_, j));
+
*b.size = static_cast<size_t> (sqlite3_column_bytes (stmt_, j));
if (*b.size > b.capacity)
@@ -202,10 +210,6 @@ namespace odb
continue;
}
- const void* d (b.type == bind::text
- ? sqlite3_column_text (stmt_, j)
- : sqlite3_column_blob (stmt_, j));
-
memcpy (b.buffer, d, *b.size);
break;
}