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:
Rodolfo Alonso Hernandez
2025-06-30 13:33:42 +00:00
parent e152a07074
commit e5606b776e
2 changed files with 21 additions and 6 deletions

View File

@@ -14,9 +14,15 @@
#
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
# Revises: ad80a9f07c5c
@@ -28,7 +34,14 @@ down_revision = 'ad80a9f07c5c'
def upgrade():
op.execute('ALTER TABLE tags CONVERT TO CHARACTER SET utf8mb4 '
'COLLATE utf8mb4_0900_as_cs')
op.execute('ALTER TABLE tags CHARACTER SET utf8mb4 '
'COLLATE utf8mb4_0900_as_cs')
try:
op.execute('ALTER TABLE tags CONVERT TO CHARACTER SET utf8mb4 '
'COLLATE utf8mb4_bin')
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

View File

@@ -3,4 +3,6 @@ features:
- |
The resource tags are now case sensitive, following the `OpenStack
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).