diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-11-09 14:09:52 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-11-09 14:09:52 +0200 |
commit | 40ea54d2eda9b7d6d8f3d3f9c2e4dc56a2592538 (patch) | |
tree | eed03d7b084e3da5e01f521a4c9e649954f0e8f3 /odb/mysql/statement.hxx | |
parent | 57d5d8fe9dc4c0d6b4ef21754c5a3539e4c01cf9 (diff) |
Avoid copying statement text if it is statically allocated
Diffstat (limited to 'odb/mysql/statement.hxx')
-rw-r--r-- | odb/mysql/statement.hxx | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/odb/mysql/statement.hxx b/odb/mysql/statement.hxx index ee1284b..91faa65 100644 --- a/odb/mysql/statement.hxx +++ b/odb/mysql/statement.hxx @@ -50,10 +50,16 @@ namespace odb protected: statement (connection&, const std::string& text); + statement (connection&, const char* text, bool copy_text); + + private: + void + init (std::size_t text_size); protected: connection& conn_; - const std::string text_; + std::string text_copy_; + const char* text_; auto_handle<MYSQL_STMT> stmt_; }; @@ -64,14 +70,25 @@ namespace odb ~select_statement (); select_statement (connection& conn, - const std::string& statement, + const std::string& text, binding& param, binding& result); select_statement (connection& conn, - const std::string& statement, + const char* text, + binding& param, + binding& result, + bool copy_text = true); + + select_statement (connection& conn, + const std::string& text, binding& result); + select_statement (connection& conn, + const char* text, + binding& result, + bool copy_text = true); + enum result { success, @@ -147,9 +164,14 @@ namespace odb ~insert_statement (); insert_statement (connection& conn, - const std::string& statement, + const std::string& text, binding& param); + insert_statement (connection& conn, + const char* text, + binding& param, + bool copy_text = true); + // Return true if successful and false if the row is a duplicate. // All other errors are reported by throwing exceptions. // @@ -174,12 +196,15 @@ namespace odb virtual ~update_statement (); - // Asssumes that param.bind is a suffix of data.bind. - // update_statement (connection& conn, - const std::string& statement, + const std::string& text, binding& param); + update_statement (connection& conn, + const char* text, + binding& param, + bool copy_text = true); + unsigned long long execute (); @@ -199,9 +224,14 @@ namespace odb ~delete_statement (); delete_statement (connection& conn, - const std::string& statement, + const std::string& text, binding& param); + delete_statement (connection& conn, + const char* text, + binding& param, + bool copy_text = true); + unsigned long long execute (); |