From b3af5d13db8c29b42436c54abd94b73b7a7f00bd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 10 Sep 2012 10:21:14 +0200 Subject: Rearrange data/size calls as recommended by SQLite documentation --- odb/sqlite/statement.cxx | 12 ++++++++---- 1 file 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 (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; } -- cgit v1.1