問題を再現できません。
LENGTH()とCHAR_LENGTH()の違いに注意してください。
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 5.7.13 |
+-----------+
1 row in set (0.00 sec)
mysql> DROP TABLE IF EXISTS `tmpTable`;
Query OK, 0 rows affected (0.00 sec)
mysql> DROP PROCEDURE IF EXISTS `demo_sp`;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE IF NOT EXISTS `tmpTable` (
-> `element_utf8` VARCHAR(50),
-> `element_latin1` VARCHAR(50) CHARACTER SET latin1 COLLATE latin1_spanish_ci
->) CHARACTER SET=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO `tmpTable`
-> (`element_utf8`, `element_latin1`)
-> VALUES
-> (CONCAT('1234', SPACE(5)), CONCAT('1234', SPACE(5))),
-> ('áéíóú', 'áéíóú');
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> SELECT
-> `element_utf8`,
-> `element_latin1`,
-> LENGTH(`element_utf8`),
-> CHAR_LENGTH(`element_utf8`),
-> LENGTH(`element_latin1`),
-> CHAR_LENGTH(`element_latin1`)
-> FROM
-> `tmpTable`\G
*************************** 1. row ***************************
element_utf8: 1234
element_latin1: 1234
LENGTH(`element_utf8`): 9
CHAR_LENGTH(`element_utf8`): 9
LENGTH(`element_latin1`): 9
CHAR_LENGTH(`element_latin1`): 9
*************************** 2. row ***************************
element_utf8: áéíóú
element_latin1: áéíóú
LENGTH(`element_utf8`): 10
CHAR_LENGTH(`element_utf8`): 5
LENGTH(`element_latin1`): 5
CHAR_LENGTH(`element_latin1`): 5
2 rows in set (0.00 sec)
mysql> DELIMITER //
mysql> CREATE PROCEDURE `demo_sp`()
-> BEGIN
-> DECLARE `_not_found` BOOL DEFAULT FALSE;
-> DECLARE `_length_utf8`,
-> `_char_length_utf8`,
-> `_length_latin1`,
-> `_char_length_latin1` INT UNSIGNED;
->
-> DECLARE `demo_cursor` CURSOR FOR
-> SELECT
-> LENGTH(`element_utf8`),
-> CHAR_LENGTH(`element_utf8`),
-> LENGTH(`element_latin1`),
-> CHAR_LENGTH(`element_latin1`)
-> FROM
-> `tmpTable`;
-> DECLARE CONTINUE HANDLER FOR NOT FOUND SET `_not_found` := TRUE;
->
-> OPEN `demo_cursor`;
->
-> `read_loop`: LOOP
-> FETCH `demo_cursor` INTO `_length_utf8`,
-> `_char_length_utf8`,
-> `_length_latin1`,
-> `_char_length_latin1`;
->
-> IF (`_not_found`) THEN
-> CLOSE `demo_cursor`;
-> LEAVE `read_loop`;
-> END IF;
->
-> SELECT `_length_utf8`,
-> `_char_length_utf8`,
-> `_length_latin1`,
-> `_char_length_latin1`;
-> END LOOP;
-> END//
Query OK, 0 rows affected (0.00 sec)
mysql> DELIMITER ;
mysql> CALL `demo_sp`;
+----------------+---------------------+------------------+-----------------------+
| `_length_utf8` | `_char_length_utf8` | `_length_latin1` | `_char_length_latin1` |
+----------------+---------------------+------------------+-----------------------+
| 9 | 9 | 9 | 9 |
+----------------+---------------------+------------------+-----------------------+
1 row in set (0.01 sec)
+----------------+---------------------+------------------+-----------------------+
| `_length_utf8` | `_char_length_utf8` | `_length_latin1` | `_char_length_latin1` |
+----------------+---------------------+------------------+-----------------------+
| 10 | 5 | 5 | 5 |
+----------------+---------------------+------------------+-----------------------+
1 row in set (0.01 sec)
Query OK, 0 rows affected (0.01 sec)
あなたの質問は私の下で回答しましたか?コメント、upvote、downvote、受け入れる答え、または何か。ありがとう。 – Drew