Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-11943

I_S.TABLES inconsistencies with tables with unknown storage engine

Details

    • 10.1.22

    Description

      When having tables with unknown storage engine, e.g. due to a missing plugin, information for such tables is only read from INFORMATION_SCHEMA.TABLES on SELECT * FROM TABLES ...", not when trying to get the count of tables with SELECT COUNT(*) or when trying to read specific tables only. (found while trying to come up with a fix for MDEV-11942)

      How to reproduce:

      INSTALL SONAME 'ha_blackhole';
      CREATE TABLE test.t1 (id int primary key) ENGINE=BLACKHOLE;
      UNINSTALL PLUGIN BLACKHOLE;
      

      Now we have a table with unknown engine.

      MariaDB [information_schema]> select * from tables where table_schema="test"\G
      *************************** 1. row ***************************
        TABLE_CATALOG: def
         TABLE_SCHEMA: test
           TABLE_NAME: t1
           TABLE_TYPE: BASE TABLE
               ENGINE: NULL
              VERSION: NULL
           ROW_FORMAT: NULL
           TABLE_ROWS: NULL
       AVG_ROW_LENGTH: NULL
          DATA_LENGTH: NULL
      MAX_DATA_LENGTH: NULL
         INDEX_LENGTH: NULL
            DATA_FREE: NULL
       AUTO_INCREMENT: NULL
          CREATE_TIME: NULL
          UPDATE_TIME: NULL
           CHECK_TIME: NULL
      TABLE_COLLATION: NULL
             CHECKSUM: NULL
       CREATE_OPTIONS: NULL
        TABLE_COMMENT: Unknown storage engine 'BLACKHOLE'
      1 row in set, 1 warning (0.00 sec)
      

      SELECT * found the table entry just fine and correctly reported the engine as unknown.

      Now lets try to only read specific columns instead of '*'

      MariaDB [information_schema]> select table_name, table_comment from tables where table_schema="test"\G
      Empty set (0.00 sec)
      

      The table is no longer found, but COUNT(*) works here:

      MariaDB [information_schema]> select count(*) from tables where table_schema="test"\G
      *************************** 1. row ***************************
      count(*): 1
      1 row in set (0.00 sec)
      

      Now instead of searching by schema lets search by table comment instead:

      MariaDB [information_schema]> select * from tables where table_comment like "Unknown storage engine %"\G
      *************************** 1. row ***************************
        TABLE_CATALOG: def
         TABLE_SCHEMA: test
           TABLE_NAME: t1
           TABLE_TYPE: BASE TABLE
               ENGINE: NULL
              VERSION: NULL
           ROW_FORMAT: NULL
           TABLE_ROWS: NULL
       AVG_ROW_LENGTH: NULL
          DATA_LENGTH: NULL
      MAX_DATA_LENGTH: NULL
         INDEX_LENGTH: NULL
            DATA_FREE: NULL
       AUTO_INCREMENT: NULL
          CREATE_TIME: NULL
          UPDATE_TIME: NULL
           CHECK_TIME: NULL
      TABLE_COLLATION: NULL
             CHECKSUM: NULL
       CREATE_OPTIONS: NULL
        TABLE_COMMENT: Unknown storage engine 'BLACKHOLE'
      1 row in set, 1 warning (0.01 sec)
      

      This worked, but asking for specific columns again doesn't:

      MariaDB [information_schema]> select table_name, table_comment from tables where table_comment like "Unknown storage engine %"\G
      Empty set (0.00 sec)
      

      And now COUNT(*) doesn't work anymore either:

      MariaDB [information_schema]> select count(*) from tables where table_comment like "Unknown storage engine %"\G
      *************************** 1. row ***************************
      count(*): 0
      1 row in set (0.01 sec)
      

      Expected result: changes in the filed list, but not on the WHERE condition, should not change the query results

      Attachments

        Issue Links

          Activity

            Inconsistencies are reproducible easily, except for this one:

            And now COUNT(*) doesn't work anymore either.

            MariaDB [information_schema]> select count(*) from tables where table_comment like "Unknown storage engine %"\G
            

            It's not "anymore", this particular COUNT didn't work before. The one that worked was different:

            MariaDB [information_schema]> select count(*) from tables where table_schema="test"\G
            

            (and it still works).

            elenst Elena Stepanova added a comment - Inconsistencies are reproducible easily, except for this one: And now COUNT(*) doesn't work anymore either. MariaDB [information_schema]> select count(*) from tables where table_comment like "Unknown storage engine %"\G It's not "anymore", this particular COUNT didn't work before. The one that worked was different: MariaDB [information_schema]> select count (*) from tables where table_schema= "test" \G (and it still works).

            That's what I meant, after changing the WHERE condition COUNT result doesn't match with number of rows returned by SELECT * with same WHERE condition anymore ...

            hholzgra Hartmut Holzgraefe added a comment - That's what I meant, after changing the WHERE condition COUNT result doesn't match with number of rows returned by SELECT * with same WHERE condition anymore ...
            hholzgra Hartmut Holzgraefe added a comment - - edited

            Tracked it down a little more, results change depending on actual columns being queries,
            e.g. having CHECK_TIME or UPDATE_TIME in the field list the rows for tables
            with unknown engine show up just fine:

            MariaDB [information_schema]> select TABLE_SCHEMA, TABLE_NAME from tables where table_comment="Unknown storage engine 'BLACKHOLE'";
            Empty set (0.01 sec)
             
            MariaDB [information_schema]> select TABLE_SCHEMA, TABLE_NAME, CHECK_TIME from tables where table_comment="Unknown storage engine 'BLACKHOLE'";+--------------+------------+------------+
            | TABLE_SCHEMA | TABLE_NAME | CHECK_TIME |
            +--------------+------------+------------+
            | test         | t1         | NULL       |
            +--------------+------------+------------+
            1 row in set, 1 warning (0.01 sec)
             
            MariaDB [information_schema]> select TABLE_SCHEMA, TABLE_NAME, UPDATE_TIME from tables where table_comment="Unknown storage engine 'BLACKHOLE'";
            +--------------+------------+-------------+
            | TABLE_SCHEMA | TABLE_NAME | UPDATE_TIME |
            +--------------+------------+-------------+
            | test         | t1         | NULL        |
            +--------------+------------+-------------+
            1 row in set, 1 warning (0.01 sec)
            

            hholzgra Hartmut Holzgraefe added a comment - - edited Tracked it down a little more, results change depending on actual columns being queries, e.g. having CHECK_TIME or UPDATE_TIME in the field list the rows for tables with unknown engine show up just fine: MariaDB [information_schema]> select TABLE_SCHEMA, TABLE_NAME from tables where table_comment="Unknown storage engine 'BLACKHOLE'"; Empty set (0.01 sec)   MariaDB [information_schema]> select TABLE_SCHEMA, TABLE_NAME, CHECK_TIME from tables where table_comment="Unknown storage engine 'BLACKHOLE'";+--------------+------------+------------+ | TABLE_SCHEMA | TABLE_NAME | CHECK_TIME | +--------------+------------+------------+ | test | t1 | NULL | +--------------+------------+------------+ 1 row in set, 1 warning (0.01 sec)   MariaDB [information_schema]> select TABLE_SCHEMA, TABLE_NAME, UPDATE_TIME from tables where table_comment="Unknown storage engine 'BLACKHOLE'"; +--------------+------------+-------------+ | TABLE_SCHEMA | TABLE_NAME | UPDATE_TIME | +--------------+------------+-------------+ | test | t1 | NULL | +--------------+------------+-------------+ 1 row in set, 1 warning (0.01 sec)
            hholzgra Hartmut Holzgraefe added a comment - - edited

            If any of these columns is used in the query, either as result field or as part of the WHERE condition, the result correctly includes tables for which the engine plugin is not loaded (implicit use by SELECT * also counts):

            • AUTO_INCREMENT
            • AVG_ROW_LENGTH
            • CHECKSUM
            • CHECK_TIME
            • CREATE_OPTIONS
            • CREATE_TIME
            • DATA_FREE
            • DATA_LENGTH
            • INDEX_LENGTH
            • MAX_DATA_LENGTH
            • ROW_FORMAT
            • TABLE_ROWS
            • UPDATE_TIME

            If only these columns are used these tables are somehow ignored:

            • ENGINE
            • TABLE_CATALOG
            • TABLE_COLLATION
            • TABLE_COMMENT
            • TABLE_NAME
            • TABLE_SCHEMA
            • TABLE_TYPE
            • VERSION
            hholzgra Hartmut Holzgraefe added a comment - - edited If any of these columns is used in the query, either as result field or as part of the WHERE condition, the result correctly includes tables for which the engine plugin is not loaded (implicit use by SELECT * also counts): AUTO_INCREMENT AVG_ROW_LENGTH CHECKSUM CHECK_TIME CREATE_OPTIONS CREATE_TIME DATA_FREE DATA_LENGTH INDEX_LENGTH MAX_DATA_LENGTH ROW_FORMAT TABLE_ROWS UPDATE_TIME If only these columns are used these tables are somehow ignored: ENGINE TABLE_CATALOG TABLE_COLLATION TABLE_COMMENT TABLE_NAME TABLE_SCHEMA TABLE_TYPE VERSION

            More 'fun': when uninstalling the ARCHIVE engine plugin the ARCHIVE tables are not listed in I_S.TABLES at all, no matter what columns are used.

            So my "check INFORMATION_SCHEMA for tables with unknown engines, then issue appropriate INSTALL SONAME commands for these" plan for MDEV-11942 works out for BLACKHOLE, but not for ARCHIVE (and maybe others).

            hholzgra Hartmut Holzgraefe added a comment - More 'fun': when uninstalling the ARCHIVE engine plugin the ARCHIVE tables are not listed in I_S.TABLES at all, no matter what columns are used. So my "check INFORMATION_SCHEMA for tables with unknown engines, then issue appropriate INSTALL SONAME commands for these" plan for MDEV-11942 works out for BLACKHOLE, but not for ARCHIVE (and maybe others).

            For BLACKHOLE I understand things a tiny little bit better now: BLACKHOLE tables will only appear in I_S.TABLES result when the plugin isn't loaded if one of the I_S.TABLES columns marked with open_table=OPEN_FULL_TABLE in ST_FIELD_INFO tables_fields_info[] in sql/sql_show.cc is touched by the query, either in the WHERE condition or the result field list

            Why I_S.TABLES behaves differently on ARCHIVE than on BLACKHOLE when both plugins are not loaded is still a mystery to me though ...

            hholzgra Hartmut Holzgraefe added a comment - For BLACKHOLE I understand things a tiny little bit better now: BLACKHOLE tables will only appear in I_S.TABLES result when the plugin isn't loaded if one of the I_S.TABLES columns marked with open_table=OPEN_FULL_TABLE in ST_FIELD_INFO tables_fields_info[] in sql/sql_show.cc is touched by the query, either in the WHERE condition or the result field list Why I_S.TABLES behaves differently on ARCHIVE than on BLACKHOLE when both plugins are not loaded is still a mystery to me though ...

            I've now fixed the inconsistent behavior, that dependent on what columns were selected. Almost, if you only select the table name, the table isn't opened, so it's engine isn't known, no warning. If the table is opened, though, and the engine is not loaded, there will be a warning.

            serg Sergei Golubchik added a comment - I've now fixed the inconsistent behavior, that dependent on what columns were selected. Almost, if you only select the table name, the table isn't opened, so it's engine isn't known, no warning. If the table is opened, though, and the engine is not loaded, there will be a warning.

            People

              serg Sergei Golubchik
              hholzgra Hartmut Holzgraefe
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.