Date: Friday, September 29, 2006 @ 17:36:37
Author: csaba
Path: /cvsroot/carob/libmysequoia
Modified: config/mysequoia.conf (1.5 -> 1.6) include/CarobMySQL.hpp (1.35
-> 1.36) src/CarobMySQL.cpp (1.80 -> 1.81)
Set the persistent connections in the ini file. Resolve LMS-23
------------------------+
config/mysequoia.conf | 1 +
include/CarobMySQL.hpp | 2 ++
src/CarobMySQL.cpp | 37 +++++++++++++++++++++++--------------
3 files changed, 26 insertions(+), 14 deletions(-)
Index: libmysequoia/config/mysequoia.conf
diff -u libmysequoia/config/mysequoia.conf:1.5
libmysequoia/config/mysequoia.conf:1.6
--- libmysequoia/config/mysequoia.conf:1.5 Wed Jul 5 11:16:07 2006
+++ libmysequoia/config/mysequoia.conf Fri Sep 29 17:36:37 2006
@@ -6,3 +6,4 @@
;password = realpassword
;host = node1 node2
;database = DB1
+;persistent_connections = false
\ No newline at end of file
Index: libmysequoia/include/CarobMySQL.hpp
diff -u libmysequoia/include/CarobMySQL.hpp:1.35
libmysequoia/include/CarobMySQL.hpp:1.36
--- libmysequoia/include/CarobMySQL.hpp:1.35 Thu Jul 20 13:51:07 2006
+++ libmysequoia/include/CarobMySQL.hpp Fri Sep 29 17:36:37 2006
@@ -288,6 +288,8 @@
log4cxx::helpers::CriticalSection cs_carobStmts;
// character conversions
Converter conv;
+ // persistent connections
+ bool usePersistentConnections;
/**
* Private default constructor.
Index: libmysequoia/src/CarobMySQL.cpp
diff -u libmysequoia/src/CarobMySQL.cpp:1.80
libmysequoia/src/CarobMySQL.cpp:1.81
--- libmysequoia/src/CarobMySQL.cpp:1.80 Fri Jul 28 11:12:54 2006
+++ libmysequoia/src/CarobMySQL.cpp Fri Sep 29 17:36:37 2006
@@ -40,7 +40,7 @@
using namespace std;
CarobMYSQL::CarobMYSQL (MYSQL *mysql, my_bool free_me) :
- connectionPtr(0), stmtPtr(0), drsPtr(0), liveResultPtr(0)
+ connectionPtr(0), stmtPtr(0), drsPtr(0), liveResultPtr(0),
usePersistentConnections(true)
{
LOG4CXX_DEBUG(logger, "Entering constructor; mysql=" << mysql << " free_me="
<< (bool) free_me);
static char version[6];
@@ -200,7 +200,8 @@
LOG4CXX_DEBUG(logger, "Connect (adding host): host=" << hti->host << "
port=" << hti->port);
}
- ConnectionParameters connectionParameters(ctrls, to_wstring(db),
to_wstring(user), to_wstring(passwd), ht.getPolicy(), true, true);
+ // we can retrieve the warnings only if we have persistent connections
+ ConnectionParameters connectionParameters(ctrls, to_wstring(db),
to_wstring(user), to_wstring(passwd), ht.getPolicy(), usePersistentConnections,
usePersistentConnections?true:false);
Connection *newConnectionPtr = new Connection(connectionParameters);
@@ -210,7 +211,7 @@
delete_connection();
set_connect_info(host, user, passwd, db, port);
- LOG4CXX_INFO(logger, "Connected: host=" << host << " user=" << user <<
" passwd=" << passwd << " db=" << db << " port=" << port);
+ LOG4CXX_INFO(logger, "Connected: host=" << host << " user=" << user <<
" passwd=" << passwd << " db=" << db << " port=" << port << "
persistent_connections=" << usePersistentConnections);
reset_error();
@@ -404,19 +405,23 @@
unsigned int
CarobMYSQL::get_warning_count(void)
{
- unsigned int result = 0;
+ LOG4CXX_DEBUG(logger, "Entering get_warning_count");
- if (stmtPtr)
- {
- SQLWarning *warnings = stmtPtr->getWarnings();
- while (warnings)
- {
- result++;
- warnings = (SQLWarning *)warnings->getNext();
- }
- }
+ unsigned int result = 0;
+
+ // we can retrieve the warnings only if we have persistent connections
+ if (stmtPtr && usePersistentConnections)
+ {
+ SQLWarning *warnings = stmtPtr->getWarnings();
+ while (warnings)
+ {
+ result++;
+ warnings = (SQLWarning *)warnings->getNext();
+ }
+ }
- return result;
+ LOG4CXX_DEBUG(logger, "Leaving get_warning_count: result=" << result);
+ return result;
}
MYSQL_RES *
@@ -1172,6 +1177,10 @@
/* read the init_command from the config file */
push_init_command(ini.get(group, "init_command").c_str());
+ /* set persistent connections */
+ if (strncmp(ini.get(group, "persistent_connections").c_str(), "false", 5) ==
0)
+ usePersistentConnections = false;
+
LOG4CXX_DEBUG(logger, "Leaving read_ini_file.");
}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits