Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
139
Merge Requests
139
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
08b24082
Commit
08b24082
authored
Nov 13, 2023
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZMySQLDA: support isolation level per connector.
parent
4346515a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
product/ZMySQLDA/connectionAdd.dtml
product/ZMySQLDA/connectionAdd.dtml
+7
-1
product/ZMySQLDA/db.py
product/ZMySQLDA/db.py
+5
-1
No files found.
product/ZMySQLDA/connectionAdd.dtml
View file @
08b24082
...
...
@@ -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.
...
...
product/ZMySQLDA/db.py
View file @
08b24082
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment