檢查11.1 Character Set Support在表格中。在Rextester
mysql> DROP PROCEDURE IF EXISTS `sp_test`;
Query OK, 0 rows affected (0.00 sec)
mysql> DROP TABLE IF EXISTS `_article`;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> CREATE TABLE IF NOT EXISTS `_article` (
-> `brand` VARCHAR(255)
->) DEFAULT CHARACTER SET=latin1 COLLATE=latin1_bin;
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO `_article`
-> (`brand`)
-> VALUES
-> ('àéëË'),
-> ('aeE');
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> DELIMITER //
mysql> CREATE PROCEDURE `sp_test` (`index` TINYINT, `argument` VARCHAR(255))
-> BEGIN
-> SET @`query` := CONCAT('SELECT ', `index`, ' `index`, `brand`
'> FROM `_article`
'> WHERE `brand` REGEXP \'[', `argument`, ']\'');
-> PREPARE `stmt` FROM @`query`;
-> EXECUTE `stmt`;
-> SET @`query` := NULL;
-> DEALLOCATE PREPARE `stmt`;
-> END//
Query OK, 0 rows affected (0.00 sec)
mysql> DELIMITER ;
mysql> CALL `sp_test`(1, 'àéëË');
+-------+----------+
| index | brand |
+-------+----------+
| 1 | àéëË |
+-------+----------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> CALL `sp_test`(2, 'e');
+-------+-------+
| index | brand |
+-------+-------+
| 2 | aeE |
+-------+-------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> CALL `sp_test`(3, 'á');
Empty set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> CALL `sp_test`(4, 'A');
Empty set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> CALL `sp_test`(5, 'Ë');
+-------+----------+
| index | brand |
+-------+----------+
| 5 | àéëË |
+-------+----------+
1 row in set (0.01 sec)
Query OK, 0 rows affected (0.01 sec)
實施例:
我不能與字符集和整理在表中使用重現該問題。