Edgewall Software
Modify

Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#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)

0001-fix-http-trac.edgewall.org-ticket-10537.patch (1.4 KB ) - added by ludovic.belliere@… 12 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 by anonymous, 12 years ago

Running MySQL 5.0.67 and Trac 0.12.2.

comment:2 by Stefan, 12 years ago

Version: 0.12.2

Updated version number according to comment:1.

comment:3 by Christian Boos, 12 years ago

See also ticket:10548#comment:5 for information on the 1093 error.

comment:4 by Dirk Stöcker, 12 years ago

I have no idea how to fix this issue.

comment:5 by ludovic.belliere@…, 12 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:6 by Dirk Stöcker, 12 years ago

Can you test it and supply a patch? I have no MySQL.

comment:7 by ludovic.belliere@…, 12 years ago

Cc: ludovic.belliere@… 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 ludovic.belliere@…, 12 years ago

comment:8 by Christian Boos, 12 years ago

A stylistic note: we're using multiline """...""" strings for long SQL queries.

comment:9 by ludovic.belliere@…, 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:10 by Dirk Stöcker, 12 years ago

Resolution: fixed
Status: newclosed

In r11108.

comment:11 by Ryan J Ollos, 10 years ago

Milestone: plugin - spam-filter

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Dirk Stöcker.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Dirk Stöcker to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.