aboutsummaryrefslogtreecommitdiff
path: root/odb/pgsql/statement.hxx
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-07-05 13:02:03 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-07-05 13:02:03 +0200
commit0fba3bc7e0747e23ca2698e0acc82e80b569e531 (patch)
treeb39290a6334adc2b451a9e7fd397c35a09389487 /odb/pgsql/statement.hxx
parent283fec23e49a9e62a8717879808343420338d01e (diff)
Implement PostgreSQL specific fetch operations for select_statement
Diffstat (limited to 'odb/pgsql/statement.hxx')
-rw-r--r--odb/pgsql/statement.hxx52
1 files changed, 41 insertions, 11 deletions
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_;