Skip to content
/ server Public

Conversation

@akshatnehra
Copy link
Contributor

Description

This PR addresses issue where tables residing in databases mysql and performance_schema were not properly identified as SYSTEM TABLE/SYSTEM VIEW in INFORMATION_SCHEMA.TABLES.

The fix involves modifying the get_schema_tables_record() function to:

  • Identify mysql schema tables as "SYSTEM TABLE" rather than "BASE TABLE"
  • Identify performance_schema tables as "SYSTEM TABLE" rather than "BASE TABLE"
  • Identify views in these schemas as "SYSTEM VIEW" rather than "VIEW"
  • Leave sys schema tables as regular tables/views as intended

NOTE: A specific exception was made for mysql.user to resolve failures in the test suite. The main.mysql_upgrade_to_100502 test failed because its mysql_upgrade script requires direct write access to mysql.user which was blocked when it was classified as a SYSTEM TABLE. Also, main.plugin_auth and manual FLUSH PRIVILEGES commands failed with ERROR 1347: 'mysql.user' is not of type 'TABLE'. This indicates that the server's internal privilege reload mechanism (acl_reload) expects to read the grant tables as standard BASE TABLEs. Classifying them as SYSTEM objects breaks this core server function, leading to privilege inconsistencies. This targeted exception for mysql.user fixed these inconsistencies. Could there be any better way of handling this?

How can this PR be tested?

NOTE: Make sure performance_schema is enabled when starting the server.

Run queries to check the table types before and after the fix:

SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE  FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA IN ('mysql', 'performance_schema', 'sys');

Results from my testing

  1. Before changes

    Result will show mysql and performance_schema tables as "BASE TABLE"

    MariaDB [(none)]> SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE  FROM INFORMATION_SCHEMA.TABLES  WHERE TABLE_SCHEMA IN ('mysql', 'performance_schema', 'sys');
    +--------------------+------------------------------------------------------+------------+
    | TABLE_SCHEMA       | TABLE_NAME                                           | TABLE_TYPE |
    +--------------------+------------------------------------------------------+------------+
    | sys                | sys_config                                           | BASE TABLE |
    | mysql              | index_stats                                          | BASE TABLE |
    ...
    | mysql              | user                                                 | VIEW       |
    | mysql              | help_category                                        | BASE TABLE |
    ...
    | performance_schema | accounts                                             | BASE TABLE |
    ...
    | performance_schema | users                                                | BASE TABLE |
    +--------------------+------------------------------------------------------+------------+
    
  2. After Changes

    Result should show:

    • mysql tables as "SYSTEM TABLE"
    • performance_schema tables as "SYSTEM TABLE"
    • sys tables still as "BASE TABLE" (unchanged)
    • mysql.user still as "VIEW" (unchanged)
    MariaDB [(none)]> SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE  FROM INFORMATION_SCHEMA.TABLES  WHERE TABLE_SCHEMA IN ('mysql', 'performance_schema', 'sys');
    +--------------------+------------------------------------------------------+--------------+
    | TABLE_SCHEMA       | TABLE_NAME                                           | TABLE_TYPE   |
    +--------------------+------------------------------------------------------+--------------+
    | sys                | sys_config                                           | BASE TABLE   |
    | mysql              | index_stats                                          | SYSTEM TABLE |
    ...
    | mysql              | user                                                 | VIEW         |
    | mysql              | help_category                                        | SYSTEM TABLE |
    ...
    | performance_schema | accounts                                             | SYSTEM TABLE |
    ...
    | performance_schema | users                                                | SYSTEM TABLE |
    +--------------------+------------------------------------------------------+--------------+
    

Basing the PR against the correct MariaDB version

  • This is a new feature and the PR is based against the latest MariaDB development branch.

PR quality check

  • I have checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am fine with the reviewer making the changes themselves.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@akshatnehra
Copy link
Contributor Author

I observed some test failures because BASE TABLE has been changed to SYSTEM TABLE, I will fix these tests and push the changes once done.

@svoj svoj added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Aug 19, 2025
Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking the time to implement and submit this.
These are some preliminary review comments. A developer will be assigned to do the final review once we get past the basics.

Before we go any further with the contribution, please consider the following:

  • sign the CLA (one of its two versions) so that the CLA bot can check and comfirm it
  • re-record funcs_1.is_tables_mysql perfschema.information_schema
  • consider justifying the non-SQL standard value for TABLE_TYPE.

@vaintroub
Copy link
Member

How much was that change had been tested with external tools and connectors that rely on I_S.TABLES? It has the potential to break a lot of things, if MySQL did not do the same thing yet. "A lot of things" are popular UIs, and at least JDBC connectors. And a lot of things I have no idea of yet.

Tables in the mysql and performance_schema databases were incorrectly
shown as "BASE TABLE" and "VIEW" in INFORMATION_SCHEMA.TABLES.
These should be marked as "SYSTEM TABLE" and "SYSTEM VIEW" respectively.
This commit modifies the get_schema_tables_record() function in sql_show.cc
to correctly identify tables belonging to mysql and performance_schema
schemas and set their TABLE_TYPE accordingly.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

5 participants