[MDEV-6588] VIEW do not work well with national character strings Created: 2014-08-15  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.3.12, 5.5.37, 10.0.13
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This SQL script:

SET NAMES latin1;
DROP VIEW IF EXISTS v1;
CREATE VIEW v1 AS
SELECT CHARSET('a'),CHARSET(_utf8'a'),CHARSET(N'a');
SHOW CREATE VIEW v1;
SELECT * FROM v1;

produces the following output for SHOW CREATE VIEW:

+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| View | Create View                                                                                                                                                                                            | character_set_client | collation_connection |
+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| v1   | CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select charset('a') AS `CHARSET('a')`,charset(_utf8'a') AS `CHARSET(_utf8'a')`,charset('a') AS `CHARSET(N'a')` | latin1               | latin1_swedish_ci    |
+------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+

and this output for SELECT:

+--------------+-------------------+---------------+
| CHARSET('a') | CHARSET(_utf8'a') | CHARSET(N'a') |
+--------------+-------------------+---------------+
| latin1       | utf8              | latin1        |
+--------------+-------------------+---------------+
1 row in set (0.00 sec)

Both results are wrong:

  • The national character string loses the "N" prefix in SHOW CREATE.
    It should preserve the "N" prefix.
  • The national character string is reported as being latin1.
    It should always be reported as utf8, not matter what
    @@character_set_connection or @@character_set_client are set to.

Generated at Thu Feb 08 07:13:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.