Commit 08b24082 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

ZMySQLDA: support isolation level per connector.

parent 4346515a
......@@ -56,7 +56,7 @@
<dd>
The connection string used for Z MySQL Database Connection is of the form:
<br />
<code>[%ssl_name] [*lock] [+/-][database][@host[:port]] [user [password [unix_socket]]]</code>
<code>[%ssl_name] [*lock] [!isolation-level] [+/-][database][@host[:port]] [user [password [unix_socket]]]</code>
<br />
or typically:
<br />
......@@ -103,6 +103,12 @@
you'll get an error in the logs, and inconsistent data. In this
respect, it's equivalent to transactions turned off.
</dd>
<dd>
!<em>isolation_level</em> at the begining of the connection string
will set the transaction isolation level in each transaction. The
value should be one of REPEATABLE-READ, READ-COMMITTED,
READ-UNCOMMITTED or SERIALIZABLE.
</dd>
<dd>
Transactions are highly recommended. Using a named lock in
conjunctions with transactions is probably pointless.
......
......@@ -244,7 +244,7 @@ class DB(TM):
self._use_TM = transactional or self._mysql_lock
def _parse_connection_string(self):
self._mysql_lock = self._try_transactions = None
self._mysql_lock = self._try_transactions = self._isolation_level = None
self._kw_args = kwargs = {'conv': self.conv}
items = self._connection.split()
if not items:
......@@ -262,6 +262,8 @@ class DB(TM):
del items[0]
if items[0][0] == "*":
self._mysql_lock = items.pop(0)[1:]
if items[0][0] == "!":
self._isolation_level = items.pop(0)[1:]
db = items.pop(0)
if '@' in db:
db, host = db.split('@', 1)
......@@ -491,6 +493,8 @@ class DB(TM):
try:
self._transaction_begun = True
if self._transactions:
if self._isolation_level:
self._query("SET TRANSACTION ISOLATION LEVEL %s" % self._isolation_level.replace('-', ' '))
self._query("BEGIN", allow_reconnect=True)
if self._mysql_lock:
self._query("SELECT GET_LOCK('%s',0)" % self._mysql_lock, allow_reconnect=not self._transactions)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment