Date: Thursday, August 24, 2006 @ 11:48:48
Author: gilles
Path: /cvsroot/carob/carob
Modified: include/Connection.hpp (1.71 -> 1.72) src/Connection.cpp (1.83
-> 1.84)
Updated to protocol version 7.1 introducing new command setReadOnly
------------------------+
include/Connection.hpp | 6 ++----
src/Connection.cpp | 14 +++++++++-----
2 files changed, 11 insertions(+), 9 deletions(-)
Index: carob/include/Connection.hpp
diff -u carob/include/Connection.hpp:1.71 carob/include/Connection.hpp:1.72
--- carob/include/Connection.hpp:1.71 Wed Jul 26 16:31:47 2006
+++ carob/include/Connection.hpp Thu Aug 24 11:48:48 2006
@@ -33,7 +33,7 @@
namespace {
const int32_t ProtocolVersion = (static_cast<int32_t>(7) /* major */ << 16)
- + 0 /* minor */;
+ + 1 /* minor */;
}
namespace CarobNS {
@@ -77,6 +77,7 @@
//#define SetTransactionIsolation 39
#define ConnectionGetWarnings 40
#define ConnectionClearWarnings 41
+#define SetReadOnly 42
//#define GetVirtualDatabaseName 50
//#define GetControllerVersionNumber 51
//#define DatabaseMetaDataGetTables 52
@@ -317,9 +318,6 @@
/**
* A connection can be put in read-only mode as a hint to enable database
* optimizations
- * <p>
- * <B>Note: </B> setReadOnly cannot be called while in the middle of a
- * transaction with write requests.
*
* @param readOnlyPrm <code>true</code> enables read-only mode;
* <code>false</code> disables it
Index: carob/src/Connection.cpp
diff -u carob/src/Connection.cpp:1.83 carob/src/Connection.cpp:1.84
--- carob/src/Connection.cpp:1.83 Thu Jul 27 17:10:42 2006
+++ carob/src/Connection.cpp Thu Aug 24 11:48:48 2006
@@ -469,10 +469,12 @@
DriverException, UnexpectedException)
{
checkIfConnected();
- if ((autoCommit == false) && writeExecutedInTransaction)
- throw DriverException(
- L"setReadOnly cannot be called in a transaction that has executed
write requests.");
- readOnly = readOnlyPrm;
+ FO_TRY_NTIMES(RECONNECT_RETRIES)
+ sendCommand(*driverSocketPtr, SetReadOnly);
+ *driverSocketPtr << readOnlyPrm;
+ receiveBoolOrException();
+ readOnly = readOnlyPrm;
+ FO_CATCH_NTIMES
}
void Connection::commit() throw (SocketIOException, DriverException,
@@ -628,7 +630,6 @@
void Connection::setConnectionParametersOnRequest(Request &request)
{
request.setIsAutoCommit(autoCommit);
- request.setIsReadOnly(readOnly);
}
DriverResultSet* Connection::statementExecuteQuery
@@ -1305,6 +1306,9 @@
// read ack
bool ack = false;
*driverSocketPtr>>ack;
+ // Restore read-only state (not part of RestoreConnectionState command for
+ // backward compatibility)
+ setReadOnly(readOnly);
if (isInfoEnabled())
logInfo(fctName, L"Transparent reconnection succeeded");
}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits