13 #include <boost/lexical_cast.hpp>
30 : conn_(conn), committed_(false) {
55 const char* host =
"localhost";
64 unsigned int port = 0;
73 if (sport.size() > 0) {
77 port = boost::lexical_cast<unsigned int>(sport);
86 if (port > numeric_limits<uint16_t>::max()) {
91 const char* user = NULL;
100 const char* password = NULL;
104 password = spassword.c_str();
109 const char* name = NULL;
113 name = sname.c_str();
128 if (stimeout.size() > 0) {
132 connect_timeout = boost::lexical_cast<unsigned int>(stimeout);
149 if ((connect_timeout == 0) ||
150 (connect_timeout > numeric_limits<int>::max())) {
152 stimeout <<
") must be an integer greater than 0");
163 int result = mysql_options(
mysql_, MYSQL_OPT_RECONNECT, &auto_reconnect);
170 const char *wait_time =
"SET SESSION wait_timeout = 30 * 86400";
171 result = mysql_options(
mysql_, MYSQL_INIT_COMMAND, wait_time);
181 const char *sql_mode =
"SET SESSION sql_mode ='STRICT_ALL_TABLES'";
182 result = mysql_options(
mysql_, MYSQL_INIT_COMMAND, sql_mode);
190 result = mysql_options(
mysql_, MYSQL_OPT_CONNECT_TIMEOUT, &connect_timeout);
206 MYSQL* status = mysql_real_connect(
mysql_, host, user, password, name,
207 port, NULL, CLIENT_FOUND_ROWS);
227 static_cast<int>(index) <<
") or indexed prepared " <<
228 "statement is not null");
236 "statement structure, reason: " << mysql_error(
mysql_));
239 int status = mysql_stmt_prepare(
statements_[index], text, strlen(text));
242 text <<
">, reason: " << mysql_error(
mysql_));
251 tagged_statement != end_statement; ++tagged_statement) {
252 if (tagged_statement->index >=
statements_.size()) {
253 statements_.resize(tagged_statement->index + 1, NULL);
258 tagged_statement->text);
294 MYSQL_TIME& output_time) {
300 const uint32_t valid_lifetime,
301 MYSQL_TIME& expire) {
307 uint32_t valid_lifetime, time_t& cltt) {
316 int status = mysql_query(
mysql_,
"START TRANSACTION");
319 "reason: " << mysql_error(
mysql_));
326 if (mysql_commit(
mysql_) != 0) {
335 if (mysql_rollback(
mysql_) != 0) {