From 3ee1f474f72d093e27974e040372c53342702b12 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 6 Sep 2011 14:58:16 +0200 Subject: Allow select statement without parameters --- odb/pgsql/statement.cxx | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'odb/pgsql/statement.cxx') 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_)) -- cgit v1.1