Mysql
 sql >> Baza danych >  >> RDS >> Mysql

MySql 5.7 Funkcja Domyślne sortowanie UUID() - Niedozwolona mieszanka sortowań

(To nie jest tak naprawdę odpowiedź, ale próba wyizolowania przyczyny problemu i tego, co może go naprawić).

Pobierz DATABASE z całkowicie nieistotnym CHARACTER SET i COLLATION .

mysql> CREATE DATABASE `so40064402` /*!40100 DEFAULT CHARACTER SET ucs2 COLLATE ucs2_bin */
mysql> USE so40064402;
Database changed

Ustaw utf8_polish dla klienta:

mysql> SET NAMES utf8 COLLATE utf8_polish_ci;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE 'c%a%t%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       | -- from SET NAMES
| character_set_connection | utf8                       | -- from SET NAMES
| character_set_database   | ucs2                       | -- from DATABASE
| character_set_filesystem | binary                     | -- (constant)
| character_set_results    | utf8                       | -- from SET NAMES
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       | -- (constant)
| character_sets_dir       | /usr/share/mysql/charsets/ |
| collation_connection     | utf8_polish_ci             | -- from SET NAMES
| collation_database       | ucs2_bin                   | -- from DATABASE
| collation_server         | utf8mb4_unicode_520_ci     |
+--------------------------+----------------------------+
11 rows in set (0.00 sec)

mysql> select charset(uuid()), collation(uuid());
+-----------------+-------------------+
| charset(uuid()) | collation(uuid()) |
+-----------------+-------------------+
| utf8            | utf8_general_ci   |  -- part of the problem, but can't fix this
+-----------------+-------------------+
1 row in set (0.00 sec)

mysql> select replace(uuid(),'-','');
ERROR 1270 (HY000): Illegal mix of collations
                 (utf8_general_ci,COERCIBLE),
                 (utf8_polish_ci,COERCIBLE),
                 (utf8_polish_ci,COERCIBLE) for operation 'replace'
mysql> 
mysql> 
mysql> 
mysql> SET NAMES utf8mb4 COLLATE utf8mb4_polish_ci;
Query OK, 0 rows affected (0.00 sec)

Teraz zmieńmy SET NAMES tylko. Teraz działa!?? Pomimo UUID() będąc utf8 !?

mysql> SHOW VARIABLES LIKE 'c%a%t%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    | -- from SET NAMES
| character_set_connection | utf8mb4                    | -- from SET NAMES
| character_set_database   | ucs2                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    | -- from SET NAMES
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
| collation_connection     | utf8mb4_polish_ci          | -- from SET NAMES
| collation_database       | ucs2_bin                   |
| collation_server         | utf8mb4_unicode_520_ci     |
+--------------------------+----------------------------+
11 rows in set (0.00 sec)

mysql> select replace(uuid(),'-','');
+----------------------------------+
| replace(uuid(),'-','')           |
+----------------------------------+
| ea841aacf83b11e8a66580fa5b3669ce |
+----------------------------------+
1 row in set (0.00 sec)

mysql> 


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Dlaczego nie miałbyś użyć DISTINCT, skoro możesz użyć GROUP BY?

  2. Formularz PHP zwraca Uwaga:Konwersja z tablicy na ciąg znaków

  3. Wykorzystanie wyliczenia MyBatis

  4. Wypełnianie treści modalnej za pomocą PHP i AJAX?

  5. Odmowa dostępu Java JDBC dla użytkownika