diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-09-19 11:11:35 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-09-19 11:11:35 +0200 |
commit | 37cfe1fdc078b758768a121d61944d97f3b42807 (patch) | |
tree | d8a9e2f24917ca6c41e82f0eb3989b28f461d928 | |
parent | 2a270b8424d91e58b17b5d5f77ce9f135198569a (diff) |
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.
-rw-r--r-- | odb/mysql/statement.cxx | 9 |
1 files changed, 9 insertions, 0 deletions
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 <cassert> + #include <odb/exceptions.hxx> // object_not_persistent #include <odb/mysql/mysql.hxx> @@ -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_); |