Opened 8 years ago
Last modified 7 months ago
#12363 new enhancement
Support utf16/utf32 charset and utf16_bin/utf32_bin collation in MySQL — at Initial Version
Reported by: | Jun Omae | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | next-stable-1.6.x |
Component: | database backend | Version: | |
Severity: | normal | Keywords: | mysql |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
In Trac 1.0.10 with MySQL utf16/utf32, initenv command crashes:
Database connection string [sqlite:db/trac.db]> mysql://tracuser:password@127.0.0.1/trac_utf16 Creating and Initializing Project Initenv for '/dev/shm/trac-1.0.10-mysql-utf16' failed. Failed to create environment. (1231, "Variable 'character_set_client' can't be set to the value of 'utf16'") Traceback (most recent call last): File "/venv/trac/1.0.10/lib/python2.5/site-packages/trac/admin/console.py", line 461, in do_initenv options=options) File "/venv/trac/1.0.10/lib/python2.5/site-packages/trac/core.py", line 124, in __call__ self.__init__(*args, **kwargs) File "/venv/trac/1.0.10/lib/python2.5/site-packages/trac/env.py", line 280, in __init__ self.create(options) File "/venv/trac/1.0.10/lib/python2.5/site-packages/trac/env.py", line 602, in create DatabaseManager(self).init_db() File "/venv/trac/1.0.10/lib/python2.5/site-packages/trac/db/api.py", line 253, in init_db connector.init_db(**args) File "/venv/trac/1.0.10/lib/python2.5/site-packages/trac/db/mysql_backend.py", line 117, in init_db params) File "/venv/trac/1.0.10/lib/python2.5/site-packages/trac/db/mysql_backend.py", line 98, in get_connection cnx = MySQLConnection(path, log, user, password, host, port, params) File "/venv/trac/1.0.10/lib/python2.5/site-packages/trac/db/mysql_backend.py", line 374, in __init__ cnx.query("SET NAMES %s" % self.charset) OperationalError: (1231, "Variable 'character_set_client' can't be set to the value of 'utf16'")
If supplementary characters is needed, we have to use utf8mb4 charset. However, max size of column would be short because 1 character requires 4 bytes for index. Since MySQL 5.5.3, utf16 supports supplementary characters using surrogate pair. 1 character in utf16 requires 2 bytes for index.
Note:
See TracTickets
for help on using tickets.