From 0fba3bc7e0747e23ca2698e0acc82e80b569e531 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 5 Jul 2011 13:02:03 +0200 Subject: Implement PostgreSQL specific fetch operations for select_statement --- odb/pgsql/statement.hxx | 52 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'odb/pgsql/statement.hxx') diff --git a/odb/pgsql/statement.hxx b/odb/pgsql/statement.hxx index 146a34f..09779b4 100644 --- a/odb/pgsql/statement.hxx +++ b/odb/pgsql/statement.hxx @@ -36,14 +36,6 @@ namespace odb void deallocate (); - protected: - statement (connection&, - const std::string& name, - const std::string& stmt, - const Oid* types, - std::size_t types_count); - - protected: // Adapt an ODB binding to a native PostgreSQL parameter binding. // static void @@ -63,6 +55,13 @@ namespace odb bool truncated = false); protected: + statement (connection&, + const std::string& name, + const std::string& stmt, + const Oid* types, + std::size_t types_count); + + protected: connection& conn_; std::string name_; @@ -85,6 +84,14 @@ namespace odb native_binding& native_cond, binding& data); + select_statement (connection& conn, + const std::string& name, + const std::string& stmt, + const Oid* types, + std::size_t types_count, + native_binding& native_cond, + binding& data); + // Common select interface expected by the generated code. // public: @@ -112,24 +119,47 @@ namespace odb // Load next row columns into bound buffers. // result - fetch (); + fetch () + { + return next () ? load () : no_data; + } // Reload truncated columns into bound buffers. // void - refetch (); + refetch () + { + reload (); + } // Free the result set. // void free_result (); + // Finer grained control of PostgreSQL-specific interface that + // splits fetch() into next() and load(). + // + public: + // Return false if there is no more rows. You should call next() + // until it returns false or, alternatively, call free_result (). + // Otherwise the statement will remain unfinished. + // + bool + next (); + + result + load (); + + void + reload (); + private: select_statement (const select_statement&); select_statement& operator= (const select_statement&); private: - binding& cond_; + binding* cond_; native_binding& native_cond_; binding& data_; -- cgit v1.1