aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-09-06 14:58:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-09-06 16:55:11 +0200
commit3ee1f474f72d093e27974e040372c53342702b12 (patch)
treea6fcc1da69d48f734f9b2b1fc26628bb4fdf421b
parentad288e347bb45eb7a6bcbe3ed3821d008d816a5d (diff)
Allow select statement without parameters
-rw-r--r--odb/pgsql/statement.cxx30
-rw-r--r--odb/pgsql/statement.hxx7
2 files changed, 29 insertions, 8 deletions
diff --git a/odb/pgsql/statement.cxx b/odb/pgsql/statement.cxx
index 7e5b5aa..c839e92 100644
--- a/odb/pgsql/statement.cxx
+++ b/odb/pgsql/statement.cxx
@@ -314,7 +314,7 @@ namespace odb
binding& data)
: statement (conn, name, stmt, types, types_count),
cond_ (&cond),
- native_cond_ (native_cond),
+ native_cond_ (&native_cond),
data_ (data),
row_count_ (0),
current_row_ (0)
@@ -331,7 +331,21 @@ namespace odb
binding& data)
: statement (conn, name, stmt, types, types_count),
cond_ (0),
- native_cond_ (native_cond),
+ native_cond_ (&native_cond),
+ data_ (data),
+ row_count_ (0),
+ current_row_ (0)
+ {
+ }
+
+ select_statement::
+ select_statement (connection& conn,
+ const std::string& name,
+ const std::string& stmt,
+ binding& data)
+ : statement (conn, name, stmt, 0, 0),
+ cond_ (0),
+ native_cond_ (0),
data_ (data),
row_count_ (0),
current_row_ (0)
@@ -344,15 +358,17 @@ namespace odb
result_.reset ();
if (cond_ != 0)
- bind_param (native_cond_, *cond_);
+ bind_param (*native_cond_, *cond_);
+
+ bool in (native_cond_ != 0);
result_.reset (
PQexecPrepared (conn_.handle (),
name_.c_str (),
- native_cond_.count,
- native_cond_.values,
- native_cond_.lengths,
- native_cond_.formats,
+ in ? native_cond_->count : 0,
+ in ? native_cond_->values : 0,
+ in ? native_cond_->lengths : 0,
+ in ? native_cond_->formats : 0,
1));
if (!is_good_result (result_))
diff --git a/odb/pgsql/statement.hxx b/odb/pgsql/statement.hxx
index 6e5484a..d7cf6dc 100644
--- a/odb/pgsql/statement.hxx
+++ b/odb/pgsql/statement.hxx
@@ -90,6 +90,11 @@ namespace odb
native_binding& native_cond,
binding& data);
+ select_statement (connection& conn,
+ const std::string& name,
+ const std::string& stmt,
+ binding& data);
+
// Common select interface expected by the generated code.
//
public:
@@ -154,7 +159,7 @@ namespace odb
private:
binding* cond_;
- native_binding& native_cond_;
+ native_binding* native_cond_;
binding& data_;