Ticket #986: mysql_charset_patch.diff
| File mysql_charset_patch.diff, 1.5 kB (added by Jim Nanney <jnanney@…>, 2 years ago) |
|---|
-
trac/db/mysql_backend.py
56 56 57 57 Some Versions of MySQL limit each index prefix to 500 bytes total, with 58 58 a max of 255 bytes per column. 59 60 1000 bytes was the limit for mine, but for utf8 charset that means 4 bytes 61 per character. So I brought it down to 250 59 62 """ 60 63 cols = [] 61 limit = 500 / len(columns)62 if limit > 25 5:63 limit = 25 564 limit = 250 / len(columns) 65 if limit > 250: 66 limit = 250 64 67 for c in columns: 65 68 name = '`%s`' % c 66 69 table_col = filter((lambda x: x.name == c), table.columns) … … 85 88 if len(table.key) > 0: 86 89 coldefs.append(' PRIMARY KEY (%s)' % 87 90 self._collist(table, table.key)) 88 sql.append(',\n'.join(coldefs) + '\n) ')91 sql.append(',\n'.join(coldefs) + '\n) DEFAULT CHARSET=utf8') 89 92 yield '\n'.join(sql) 90 93 91 94 for index in table.indices: … … 116 119 vers = tuple([ int(n) for n in cnx.get_server_info().split('.')[:2] ]) 117 120 if vers < (4, 1): 118 121 raise TracError, 'MySQL servers older than 4.1 are not supported!' 122 cnx.query('SET CHARACTER SET UTF8'); 123 cnx.store_result() 119 124 cnx.query('SET NAMES %s' % charset) 120 125 cnx.store_result() 121 126 cnx.charset = charset
