From 37cfe1fdc078b758768a121d61944d97f3b42807 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/mysql/statement.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/odb/mysql/statement.cxx b/odb/mysql/statement.cxx index 1c611c5..d4b5431 100644 --- a/odb/mysql/statement.cxx +++ b/odb/mysql/statement.cxx @@ -3,6 +3,8 @@ // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include + #include // object_not_persistent #include @@ -150,6 +152,13 @@ namespace odb { if (data_version_ != data_.version) { + // 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 (mysql_stmt_field_count (stmt_) == data_.count); + if (mysql_stmt_bind_result (stmt_, data_.bind)) translate_error (conn_, stmt_); -- cgit v1.1