Commit b721632e authored by Vincent Pelletier's avatar Vincent Pelletier

CMFActivity: Prevent generation of meaningless LIMIT on SQL lock operations.

parent 593b6cf6
...@@ -100,14 +100,20 @@ def SQLLock(db, lock_name, timeout): ...@@ -100,14 +100,20 @@ def SQLLock(db, lock_name, timeout):
""" """
lock_name = db.string_literal(lock_name) lock_name = db.string_literal(lock_name)
query = db.query query = db.query
(_, ((acquired, ), )) = query('SELECT GET_LOCK(%s, %f)' % (lock_name, timeout)) (_, ((acquired, ), )) = query(
'SELECT GET_LOCK(%s, %f)' % (lock_name, timeout),
max_rows=0,
)
if acquired is None: if acquired is None:
raise ValueError('Error acquiring lock') raise ValueError('Error acquiring lock')
try: try:
yield acquired yield acquired
finally: finally:
if acquired: if acquired:
query('SELECT RELEASE_LOCK(%s)' % (lock_name, )) query(
'SELECT RELEASE_LOCK(%s)' % (lock_name, ),
max_rows=0,
)
# sqltest_dict ({'condition_name': <render_function>}) defines how to render # sqltest_dict ({'condition_name': <render_function>}) defines how to render
# condition statements in the SQL query used by SQLBase.getMessageList # condition statements in the SQL query used by SQLBase.getMessageList
def sqltest_dict(): def sqltest_dict():
......
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