aboutsummaryrefslogtreecommitdiff
path: root/odb/pgsql/statement.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-11-09 14:09:52 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-11-09 14:09:52 +0200
commit6e71fee5bdb0fe338c7b9c3259a07d317ba36679 (patch)
tree3dfc0d07eee98c0c3742819c4fa20eeb38f9c2ff /odb/pgsql/statement.hxx
parent0e37272b9ab8f37ad2f3d37bf6a09c68e5117d02 (diff)
Avoid copying statement text if it is statically allocated
Diffstat (limited to 'odb/pgsql/statement.hxx')
-rw-r--r--odb/pgsql/statement.hxx81
1 files changed, 70 insertions, 11 deletions
diff --git a/odb/pgsql/statement.hxx b/odb/pgsql/statement.hxx
index 3230bb2..5620ac0 100644
--- a/odb/pgsql/statement.hxx
+++ b/odb/pgsql/statement.hxx
@@ -36,7 +36,7 @@ namespace odb
const char*
name () const
{
- return name_.c_str ();
+ return name_;
}
virtual const char*
@@ -69,10 +69,25 @@ namespace odb
const Oid* types,
std::size_t types_count);
+ statement (connection&,
+ const char* name,
+ const char* text,
+ bool copy_name_text,
+ const Oid* types,
+ std::size_t types_count);
+
+ private:
+ void
+ init (const Oid* types, std::size_t types_count);
+
protected:
connection& conn_;
- std::string name_;
- std::string text_;
+
+ std::string name_copy_;
+ const char* name_;
+
+ std::string text_copy_;
+ const char* text_;
private:
bool deallocated_;
@@ -86,7 +101,7 @@ namespace odb
select_statement (connection& conn,
const std::string& name,
- const std::string& stmt,
+ const std::string& text,
const Oid* types,
std::size_t types_count,
binding& param,
@@ -94,16 +109,32 @@ namespace odb
binding& result);
select_statement (connection& conn,
- const std::string& name,
- const std::string& stmt,
+ const char* name,
+ const char* stmt,
const Oid* types,
std::size_t types_count,
+ binding& param,
native_binding& native_param,
+ binding& result,
+ bool copy_name_text = true);
+
+ select_statement (connection& conn,
+ const std::string& name,
+ const std::string& text,
binding& result);
select_statement (connection& conn,
+ const char* name,
+ const char* text,
+ binding& result,
+ bool copy_name_text = true);
+
+ select_statement (connection& conn,
const std::string& name,
- const std::string& stmt,
+ const std::string& text,
+ const Oid* types,
+ std::size_t types_count,
+ native_binding& native_param,
binding& result);
// Common select interface expected by the generated code.
@@ -187,13 +218,23 @@ namespace odb
insert_statement (connection& conn,
const std::string& name,
- const std::string& stmt,
+ const std::string& text,
const Oid* types,
std::size_t types_count,
binding& param,
native_binding& native_param,
bool returning);
+ insert_statement (connection& conn,
+ const char* name,
+ const char* text,
+ const Oid* types,
+ std::size_t types_count,
+ binding& param,
+ native_binding& native_param,
+ bool returning,
+ bool copy_name_text = true);
+
// Return true if successful and false if the row is a duplicate.
// All other errors are reported by throwing exceptions.
//
@@ -226,12 +267,21 @@ namespace odb
update_statement (connection& conn,
const std::string& name,
- const std::string& stmt,
+ const std::string& text,
const Oid* types,
std::size_t types_count,
binding& param,
native_binding& native_param);
+ update_statement (connection& conn,
+ const char* name,
+ const char* text,
+ const Oid* types,
+ std::size_t types_count,
+ binding& param,
+ native_binding& native_param,
+ bool copy_name_text = true);
+
unsigned long long
execute ();
@@ -252,15 +302,24 @@ namespace odb
delete_statement (connection& conn,
const std::string& name,
- const std::string& stmt,
+ const std::string& text,
const Oid* types,
std::size_t types_count,
binding& param,
native_binding& native_param);
delete_statement (connection& conn,
+ const char* name,
+ const char* text,
+ const Oid* types,
+ std::size_t types_count,
+ binding& param,
+ native_binding& native_param,
+ bool copy_name_text = true);
+
+ delete_statement (connection& conn,
const std::string& name,
- const std::string& stmt,
+ const std::string& text,
const Oid* types,
std::size_t types_count,
native_binding& native_param);