Change "tag" table collation to "utf8mb4_bin"
The collation "utf8mb4_bin" is case sensitive and is present in: * MariaDB: all released versions. * MySQL: since 5.5.3 (2010). Closes-Bug: #2115629 Related-Bug: #2114819 Change-Id: Ice1cf5f03437a470b4732a009a4cf60471ab0021
This commit is contained in:
@@ -14,9 +14,15 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
from oslo_log import log as logging
|
||||||
|
from sqlalchemy import exc
|
||||||
|
|
||||||
|
|
||||||
# Make "tag" resources case sensitive, using collate "utf8mb4_0900_as_cs"
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
# Make "tag" resources case sensitive, using collate/charset
|
||||||
|
# "utf8mb4_bin/utf8mb4"
|
||||||
#
|
#
|
||||||
# Revision ID: d553edeb540f
|
# Revision ID: d553edeb540f
|
||||||
# Revises: ad80a9f07c5c
|
# Revises: ad80a9f07c5c
|
||||||
@@ -28,7 +34,14 @@ down_revision = 'ad80a9f07c5c'
|
|||||||
|
|
||||||
|
|
||||||
def upgrade():
|
def upgrade():
|
||||||
op.execute('ALTER TABLE tags CONVERT TO CHARACTER SET utf8mb4 '
|
try:
|
||||||
'COLLATE utf8mb4_0900_as_cs')
|
op.execute('ALTER TABLE tags CONVERT TO CHARACTER SET utf8mb4 '
|
||||||
op.execute('ALTER TABLE tags CHARACTER SET utf8mb4 '
|
'COLLATE utf8mb4_bin')
|
||||||
'COLLATE utf8mb4_0900_as_cs')
|
op.execute('ALTER TABLE tags CHARACTER SET utf8mb4 '
|
||||||
|
'COLLATE utf8mb4_bin')
|
||||||
|
except exc.OperationalError as _exc:
|
||||||
|
if 'Unknown collation' in str(_exc):
|
||||||
|
LOG.error('Collation "utf8mb4_bin" does not exist; the Neutron '
|
||||||
|
'"tag" table will remain case insensitive.')
|
||||||
|
else:
|
||||||
|
raise _exc
|
||||||
|
@@ -3,4 +3,6 @@ features:
|
|||||||
- |
|
- |
|
||||||
The resource tags are now case sensitive, following the `OpenStack
|
The resource tags are now case sensitive, following the `OpenStack
|
||||||
guidelines <https://specs.openstack.org/openstack/api-wg/guidelines/tags.html>`_
|
guidelines <https://specs.openstack.org/openstack/api-wg/guidelines/tags.html>`_
|
||||||
for tags.
|
for tags. "tag" table is now using case sensitive collate/charset
|
||||||
|
``utf8mb4_bin``/``utf8mb4``, that are present in all MariaDB releases and
|
||||||
|
since MySQL 5.5.3 (2010).
|
||||||
|
Reference in New Issue
Block a user