Modify ↓
#10537 closed defect (fixed)
"You can't specify target table 'session_attribute' for update in FROM clause" when using MySQL
Reported by: | anonymous | Owned by: | Dirk Stöcker |
---|---|---|---|
Priority: | normal | Milestone: | plugin - spam-filter |
Component: | plugin/spamfilter | Version: | 0.12.2 |
Severity: | normal | Keywords: | |
Cc: | ludovic.belliere@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
2012-01-22 12:06:23,218 Trac[main] ERROR: Internal Server Error: Traceback (most recent call last): File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 511, in _dispatch_request dispatcher.dispatch(req) File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 237, in dispatch resp = chosen_handler.process_request(req) File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 170, in process_request return self._process_newticket_request(req) File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 396, in _process_newticket_request valid = self._validate_ticket(req, ticket) File "build/bdist.linux-x86_64/egg/trac/ticket/web_ui.py", line 1182, in _validate_ticket for field, message in manipulator.validate_ticket(req, ticket): File "/srv/trac/lib/python2.6/site-packages/TracSpamFilter-0.4.8dev_r10888-py2.6.egg/tracspamfilter/adapters.py", line 77, in validate_ticket FilterSystem(self.env).test(req, author, changes, ip) File "/srv/trac/lib/python2.6/site-packages/TracSpamFilter-0.4.8dev_r10888-py2.6.egg/tracspamfilter/api.py", line 193, in test 'potential spam %s' % msg) File "/srv/trac/lib/python2.6/site-packages/TracSpamFilter-0.4.8dev_r10888-py2.6.egg/tracspamfilter/captcha/api.py", line 78, in reject_content self._cleanup() File "/srv/trac/lib/python2.6/site-packages/TracSpamFilter-0.4.8dev_r10888-py2.6.egg/tracspamfilter/captcha/api.py", line 205, in _cleanup db.cast('value', 'int')), (tc,t)) File "build/bdist.linux-x86_64/egg/trac/db/util.py", line 65, in execute return self.cursor.execute(sql_escape_percent(sql), args) File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 166, in execute self.errorhandler(self, exc, value) File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler raise errorclass, errorvalue OperationalError: (1093, "You can't specify target table 'session_attribute' for update in FROM clause")
TracSpamFilter is not usable with MySQL currently as a result.
Attachments (1)
Change History (12)
comment:1 by , 13 years ago
comment:5 by , 13 years ago
I believe you need to use a temporary table :
DELETE FROM session_attribute WHERE name LIKE 'captcha%%' AND (name != 'captcha_verified' OR %s < %%s) AND ( sid IN ( SELECT * FROM ( SELECT sid FROM session_attribute WHERE name = 'captcha_reject_time' AND %s < %%s ) AS tmp1 ) OR sid NOT IN ( SELECT * FROM ( SELECT sid FROM session_attribute WHERE name = 'captcha_reject_time' ) AS tmp2 ) )
comment:7 by , 12 years ago
Cc: | added |
---|
I've been running it for quite some times now. And it seems to work. I don't know if this query will work with anything else than mysql though.
by , 12 years ago
Attachment: | 0001-fix-http-trac.edgewall.org-ticket-10537.patch added |
---|
comment:8 by , 12 years ago
A stylistic note: we're using multiline """..."""
strings for long SQL queries.
comment:9 by , 12 years ago
I must admit that in this state, the query is unreadable. For my defence I just copied the previous style, not knowing what do to or how to format the query.
My apologies.
comment:11 by , 10 years ago
Milestone: | → plugin - spam-filter |
---|
Note:
See TracTickets
for help on using tickets.
Running MySQL 5.0.67 and Trac 0.12.2.