From 45539255f18a15c777627c5edcd90aa4dbdf08fc Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 31 May 2011 16:33:49 +0200 Subject: Correct statement --- odb/pgsql/statement.cxx | 35 ++++++++++++++++++----------------- odb/pgsql/statement.hxx | 17 +++++------------ 2 files changed, 23 insertions(+), 29 deletions(-) (limited to 'odb') diff --git a/odb/pgsql/statement.cxx b/odb/pgsql/statement.cxx index 98627ee..96ba0b5 100644 --- a/odb/pgsql/statement.cxx +++ b/odb/pgsql/statement.cxx @@ -45,7 +45,7 @@ namespace odb statement (connection& conn, const string& name, const string& stmt, - const oid* types, + const Oid* types, size_t types_count) : conn_ (conn), name_ (name) @@ -54,7 +54,7 @@ namespace odb name_.c_str (), stmt.c_str (), static_cast (types_count), - reinterpret_cast (types))); + types)); if (!is_good_result (r.get ())) translate_error (conn_, r.get ()); @@ -98,6 +98,7 @@ namespace odb bool truncated) { bool r (true); + int int_row (static_cast (row)); assert (static_cast (PQnfields (result)) == count); @@ -115,48 +116,48 @@ namespace odb // if (!truncated) { - *b.is_null = PQgetisnull (result, static_cast (row), i) == 1; + *b.is_null = PQgetisnull (result, int_row, i) == 1; if (*b.is_null) continue; } - const char* s (PQgetvalue (result, static_cast (row), i)); + const char* v (PQgetvalue (result, int_row, i)); switch (b.type) { case bind::smallint: { *static_cast (b.buffer) = endian_traits::ntoh ( - *reinterpret_cast (s)); + *reinterpret_cast (v)); break; } case bind::integer: { *static_cast (b.buffer) = endian_traits::ntoh ( - *reinterpret_cast (s)); + *reinterpret_cast (v)); break; } case bind::bigint: { *static_cast (b.buffer) = - endian_traits::ntoh (*reinterpret_cast (s)); + endian_traits::ntoh (*reinterpret_cast (v)); break; } case bind::real: { *static_cast (b.buffer) = endian_traits::ntoh ( - *reinterpret_cast (s)); + *reinterpret_cast (v)); break; } case bind::double_: { *static_cast (b.buffer) = endian_traits::ntoh ( - *reinterpret_cast (s)); + *reinterpret_cast (v)); break; } @@ -166,7 +167,7 @@ namespace odb default: { *b.size = static_cast ( - PQgetlength (result, static_cast (row), i)); + PQgetlength (result, int_row, i)); if (b.capacity < *b.size) { @@ -177,7 +178,7 @@ namespace odb continue; } - memcpy (b.buffer, s, *b.size); + memcpy (b.buffer, v, *b.size); break; } @@ -200,7 +201,7 @@ namespace odb select_statement (connection& conn, const std::string& name, const std::string& stmt, - const oid* types, + const Oid* types, std::size_t types_count, binding& cond, native_binding& native_cond, @@ -263,7 +264,7 @@ namespace odb if (!bind_result (data_.bind, data_.count, result_.get (), - current_row_, + current_row_++, true)) assert (false); } @@ -287,7 +288,7 @@ namespace odb insert_statement (connection& conn, const string& name, const string& stmt, - const oid* types, + const Oid* types, size_t types_count, binding& data, native_binding& native_data) @@ -333,7 +334,7 @@ namespace odb if (!is_good_result (h2)) translate_error (conn_, h2); - id_ = endian_traits::ntoh (*reinterpret_cast ( + id_ = endian_traits::ntoh (*reinterpret_cast ( PQgetvalue (h2, 0, 0))); return true; @@ -352,7 +353,7 @@ namespace odb update_statement (connection& conn, const string& name, const string& stmt, - const oid* types, + const Oid* types, size_t types_count, binding& cond, native_binding& native_cond, @@ -409,7 +410,7 @@ namespace odb delete_statement (connection& conn, const string& name, const string& stmt, - const oid* types, + const Oid* types, size_t types_count, binding& cond, native_binding& native_cond) diff --git a/odb/pgsql/statement.hxx b/odb/pgsql/statement.hxx index 3ed8116..8134862 100644 --- a/odb/pgsql/statement.hxx +++ b/odb/pgsql/statement.hxx @@ -18,7 +18,6 @@ #include #include #include -#include #include @@ -34,17 +33,11 @@ namespace odb virtual ~statement () = 0; - // @@ Check section 30.5 of manual for description of - // how to cancel queries in progress. - // - // virtual void - // cancel (); - protected: statement (connection&, const std::string& name, const std::string& stmt, - const oid* types, + const Oid* types, std::size_t types_count); protected: @@ -80,7 +73,7 @@ namespace odb select_statement (connection& conn, const std::string& name, const std::string& stmt, - const oid* types, + const Oid* types, std::size_t types_count, binding& cond, native_binding& native_cond, @@ -138,7 +131,7 @@ namespace odb insert_statement (connection& conn, const std::string& name, const std::string& stmt, - const oid* types, + const Oid* types, std::size_t types_count, binding& data, native_binding& native_data); @@ -179,7 +172,7 @@ namespace odb update_statement (connection& conn, const std::string& name, const std::string& stmt, - const oid* types, + const Oid* types, std::size_t types_count, binding& cond, native_binding& native_cond, @@ -210,7 +203,7 @@ namespace odb delete_statement (connection& conn, const std::string& name, const std::string& stmt, - const oid* types, + const Oid* types, std::size_t types_count, binding& cond, native_binding& native_cond); -- cgit v1.1