From f2d85ec8bb5ab5ba11f43de8c4334b6b8412a045 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 19 Sep 2011 11:11:35 +0200 Subject: Add assertion for mismatch of result set column count in MySQL and SQLite This is useful for detecting native views that happened to have stray data members. Also update comment in PostgreSQL. --- odb/sqlite/statement.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/odb/sqlite/statement.cxx b/odb/sqlite/statement.cxx index 6417b3a..9071f68 100644 --- a/odb/sqlite/statement.cxx +++ b/odb/sqlite/statement.cxx @@ -114,6 +114,13 @@ namespace odb bool statement:: bind_result (const bind* p, size_t n, bool truncated) { + // Make sure that the number of columns in the result returned by + // the database matches the number that we expect. A common cause + // of this assertion is a native view with a number of data members + // not matching the number of columns in the SELECT-list. + // + assert (static_cast (sqlite3_data_count (stmt_)) == n); + bool r (true); for (size_t i (0); i < n; ++i) -- cgit v1.1