Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

Last modified 17 years ago

#2973 closed task (duplicate)

Error when adding a ticket (using Trac-Mysql DB ) - Illegal mix of collations

Reported by: amgad.mosleh@… Owned by: anonymous
Priority: highest Milestone:
Component: ticket system Version: devel
Severity: critical Keywords: ticket mysql Operational Error
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Alec Thomas)

Hi every one

I am using Trac with MySQL data base and I am getting an exception when I try to add a ticket. The Trace of the Exception is as followos:

Traceback (most recent call last):
  File "C:\engines\Python24\lib\site-packages\trac\web\main.py", line 283, in dispatch_request
    dispatcher.dispatch(req)
  File "C:\engines\Python24\lib\site-packages\trac\web\main.py", line 170, in dispatch
    resp = chosen_handler.process_request(req)
  File "C:\engines\Python24\lib\site-packages\trac\ticket\web_ui.py", line 219, in process_request
    self._insert_ticket_data(req, db, ticket, reporter_id)
  File "C:\engines\Python24\lib\site-packages\trac\ticket\web_ui.py", line 424, in _insert_ticket_data
    changelog = ticket.get_changelog(db=db)
  File "C:\engines\Python24\lib\site-packages\trac\ticket\model.py", line 271, in get_changelog
    "ORDER BY time", (self.id,  str(self.id), self.id))
  File "C:\engines\Python24\lib\site-packages\trac\db\util.py", line 47, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "C:\engines\Python24\lib\site-packages\trac\db\util.py", line 47, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "C:\engines\Python24\lib\site-packages\MySQLdb\cursors.py", line 137, in execute
    self.errorhandler(self, exc, value)
  File "C:\engines\Python24\lib\site-packages\MySQLdb\connections.py", line 33, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1267, "Illegal mix of collations (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation 'UNION'")

Thanks in advance

Attachments (0)

Change History (13)

comment:1 by anonymous, 18 years ago

Type: defecttask

comment:2 by anonymous, 18 years ago

Owner: changed from Jonas Borgström to anonymous
Status: newassigned

comment:3 by Alec Thomas, 18 years ago

Description: modified (diff)

comment:4 by anonymous, 18 years ago

Sorry I forget to mention that Iam using the following versions:

Mysql5.0.19
Trac0.10 dev - patch# 3029
Subversion1.3.0
OsWinXP Prof 2002
Python2.4

comment:5 by anonymous, 18 years ago

Resolution: fixed
Status: assignedclosed

This was solved in ticket #968

comment:6 by Matthew Good, 18 years ago

Resolution: fixed
Status: closedreopened

Don't close a ticket as fixed unless some change has been committed to SVN. This should probably be a duplicate, since the problem has been address in the patches for #968.

comment:7 by Matthew Good, 18 years ago

Resolution: duplicate
Status: reopenedclosed

Issue already raised in #968.

comment:8 by Matthew Good, 18 years ago

Milestone: 2.0

comment:9 by anonymous, 18 years ago

Actually, I believe the proper ticket is #986 and not 968.

comment:10 by troy, 17 years ago

Milestone: 0.11
Version: 0.9.4devel

I'm using a 11dev version checked out on 10-28-06. Not sure which version.

When I created my database in MySQL it defaulted to latin1_sweedish_ci charset instead of utf8 (which is normal for my setup). Heres what I did to make it work: I had to alter /usr/local/lib/python2.5/site-packages/trac/db/mysql_backend.py to the following in order to no longer throw the error mentioned above.

136 # python-mysqldb 1.2.1 added a 'charset' arg that is required for 137 # unicode stuff. We hack around that here for older versions; at 138 # some point, this hack should be removed, and a strict requirement 139 # on 1.2.1 made. -dilinger 140 if (self._mysqldb_gt_or_eq((1, 2, 1))): 141 #cnx = MySQLdb.connect(db=path, user=user, passwd=password, 142 # host=host, port=port, charset='utf8') 143 cnx = MySQLdb.connect(db=path, user=user, passwd=password, 144 host=host, port=port, charset='latin1') 145 else: 146 cnx = MySQLdb.connect(db=path, user=user, passwd=password, 147 host=host, port=port, use_unicode=True) 148 #self._set_character_set(cnx, 'utf8') 149 self._set_character_set(cnx, 'latin1')

comment:11 by troy, 17 years ago

Sorry about the formating above.

I'm using a 11dev version checked out on 10-28-06. Not sure which version.

When I created my database in MySQL it defaulted to latin1_sweedish_ci charset
instead of utf8 (which is normal for my setup).
Heres what I did to make it work:
I had to alter /usr/local/lib/python2.5/site-packages/trac/db/mysql_backend.py
to the following in order to no longer throw the error mentioned above.

136 # python-mysqldb 1.2.1 added a 'charset' arg that is required for
137 # unicode stuff. We hack around that here for older versions; at
138 # some point, this hack should be removed, and a strict requirement
139 # on 1.2.1 made. -dilinger
140 if (self._mysqldb_gt_or_eq((1, 2, 1))):
141 #cnx = MySQLdb.connect(db=path, user=user, passwd=password,
142 # host=host, port=port, charset='utf8')
143 cnx = MySQLdb.connect(db=path, user=user, passwd=password,
144 host=host, port=port, charset='latin1')
145 else:
146 cnx = MySQLdb.connect(db=path, user=user, passwd=password,
147 host=host, port=port, use_unicode=True)
148 #self._set_character_set(cnx, 'utf8')
149 self._set_character_set(cnx, 'latin1')

comment:12 by Christian Boos, 17 years ago

Hm, that's barely more readable ;) See TracDev/SubmittingPatches for some advices about how to produces patches.

IIUC, you said that setting the charset parameter to the same value is your server charset (latin1) in your case solved all the problems?

Please follow-up on #3182, I'd be interested to know if that solved all issues. In particular, what happens when using UTF-8 characters not part of the latin1 encoding, in that case.

E.g. try to insert some excerpts of TracUnicode in your tickets, and check how this behaves…

comment:13 by Christian Boos, 17 years ago

Milestone: 0.11

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain anonymous.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from anonymous 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.