[MDEV-33108] TABLE_STATISTICS and INDEX_STATISTICS are case insensitive with lower-case-table-names=0 Created: 2023-12-22  Updated: 2023-12-22

Status: Open
Project: MariaDB Server
Component/s: Character Sets
Affects Version/s: 10.4, 11.4
Fix Version/s: 10.4, 11.4

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


 Description   

I execute the following SQL script with a Linux MariaDB server running with --lower-case-table-names=0:

SET GLOBAL userstat=1;
CREATE TABLE t1 (a INT, KEY(a));
INSERT INTO t1 VALUES (1),(2),(3),(4);
SELECT * FROM t1 ORDER BY a;
CREATE TABLE T1 (a INT, KEY(a));
INSERT INTO T1 VALUES (1),(2),(3),(4);
SELECT * FROM T1 ORDER BY a;

+--------------+------------+-----------+--------------+------------------------+
| TABLE_SCHEMA | TABLE_NAME | ROWS_READ | ROWS_CHANGED | ROWS_CHANGED_X_INDEXES |
+--------------+------------+-----------+--------------+------------------------+
| test         | T1         |         1 |            1 |                      1 |
+--------------+------------+-----------+--------------+------------------------+

Looks wrong. The statistics for t1 and T1 should have separate records.

INDEX_STATISTICS has the same problem:

SELECT * FROM INFORMATION_SCHEMA.INDEX_STATISTICS;

+--------------+------------+------------+-----------+
| TABLE_SCHEMA | TABLE_NAME | INDEX_NAME | ROWS_READ |
+--------------+------------+------------+-----------+
| test         | T1         | a          |         1 |
+--------------+------------+------------+-----------+

The problem is in these function in sql_connect.cc:

void init_global_table_stats(void)
{
  my_hash_init(PSI_INSTRUMENT_ME, &global_table_stats, system_charset_info,
               max_connections, 0, 0, (my_hash_get_key) get_key_table_stats,
              (my_hash_free_key) free_table_stats, 0);
}

void init_global_index_stats(void)
{
  my_hash_init(PSI_INSTRUMENT_ME, &global_index_stats, system_charset_info,
               max_connections, 0, 0, (my_hash_get_key) get_key_index_stats,
               (my_hash_free_key) free_index_stats, 0);
}


Generated at Thu Feb 08 10:36:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.