Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaping underscores in LIKE isn't working properly #46287

Closed
dveeden opened this issue Aug 21, 2023 · 2 comments · Fixed by #46741
Closed

Escaping underscores in LIKE isn't working properly #46287

dveeden opened this issue Aug 21, 2023 · 2 comments · Fixed by #46741

Comments

@dveeden
Copy link
Contributor

dveeden commented Aug 21, 2023

Bug Report

In SQL for LIKE a % is a wildcard of zero or more characters and _ is a wildcard for a single character.

However in TiDB this doesn't seem to work consistently for variables.

1. Minimal reproduce step (Required)

SHOW SESSION VARIABLES LIKE 'character\_set\_%';
SHOW SESSION VARIABLES LIKE 'character\_set\\\_%';

2. What did you expect to see? (Required)

With MySQL 8.1.0

sql> SHOW SESSION VARIABLES LIKE 'character\_set\_%';
+--------------------------+---------+
| Variable_name            | Value   |
+--------------------------+---------+
| character_set_client     | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database   | utf8mb4 |
| character_set_filesystem | binary  |
| character_set_results    | utf8mb4 |
| character_set_server     | utf8mb4 |
| character_set_system     | utf8mb3 |
+--------------------------+---------+
7 rows in set (0.0053 sec)

sql> SHOW SESSION VARIABLES LIKE 'character\_set\\\_%';
Empty set (0.0023 sec)

3. What did you see instead (Required)

With TiDB v7.3.0:

sql> SHOW SESSION VARIABLES LIKE 'character\_set\_%';
+--------------------------+--------------------------------------------------------+
| Variable_name            | Value                                                  |
+--------------------------+--------------------------------------------------------+
| character_set_client     | utf8mb4                                                |
| character_set_connection | utf8mb4                                                |
| character_set_database   | utf8mb4                                                |
| character_set_filesystem | binary                                                 |
| character_set_results    | utf8mb4                                                |
| character_set_server     | utf8mb4                                                |
| character_set_system     | utf8                                                   |
| character_sets_dir       | /usr/local/mysql-5.6.25-osx10.8-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
8 rows in set (0.0010 sec)

sql> SHOW SESSION VARIABLES LIKE 'character\_set\\\_%';
+--------------------------+---------+
| Variable_name            | Value   |
+--------------------------+---------+
| character_set_client     | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database   | utf8mb4 |
| character_set_filesystem | binary  |
| character_set_results    | utf8mb4 |
| character_set_server     | utf8mb4 |
| character_set_system     | utf8    |
+--------------------------+---------+
7 rows in set (0.0029 sec)

4. What is your TiDB version? (Required)

sql> SELECT TIDB_VERSION()\G
*************************** 1. row ***************************
TIDB_VERSION(): Release Version: v7.3.0
Edition: Community
Git Commit Hash: 40b72e7a9a4fc9670d4c5d974dd503a3c6097471
Git Branch: heads/refs/tags/v7.3.0
UTC Build Time: 2023-08-08 10:08:14
GoVersion: go1.20.7
Race Enabled: false
Check Table Before Drop: false
Store: tikv
1 row in set (0.0012 sec)
@dveeden dveeden added type/bug The issue is confirmed as a bug. severity/major labels Aug 21, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Aug 21, 2023
@dveeden
Copy link
Contributor Author

dveeden commented Aug 21, 2023

For the SHOW SESSION VARIABLES LIKE 'character\_set\_%' the character_sets_dir variable shouldn't match:

sql> SELECT 'character_sets_dir' LIKE 'character\_set\_%';
+-----------------------------------------------+
| 'character_sets_dir' LIKE 'character\_set\_%' |
+-----------------------------------------------+
|                                             0 |
+-----------------------------------------------+
1 row in set (0.0005 sec)

sql> SELECT 'character_set_client' LIKE 'character\_set\_%';
+-------------------------------------------------+
| 'character_set_client' LIKE 'character\_set\_%' |
+-------------------------------------------------+
|                                               1 |
+-------------------------------------------------+
1 row in set (0.0012 sec)

@djshow832
Copy link
Contributor

I don't think it's major and I'll close all the cherry pick PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants