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

"ERROR 1944 (HY000): Failed to open t.test": table and db name are reversed

    XMLWordPrintable

Details

    • Can result in unexpected behaviour

    Description

      In sql/sql_table.cc, both error paths in open_global_temporary_table() pass (table, db) to my_error(ER_GTID_OPEN_TABLE_FAILED). The format string is Failed to open %s.%s and every other caller in the tree uses (db, table), so the rendered output is reversed - the message reads Failed to open t.test where the expected ordering is test.t. Neither call site is reachable on a normal user surface (pseudo_slave_mode is for mysqlbinlog replay, rgi_slave only triggers on a corrupt log feed), but the swap renders mis-ordered identifiers whenever it does fire.

      SET pseudo_slave_mode=1;
      CREATE GLOBAL TEMPORARY TABLE t (c INT) ON COMMIT PRESERVE ROWS;
      SELECT * FROM t;
      

      Leads to:

      MDEV-35915-v13 CS 13.0.0 825771a5746c2522694cc2faa1b670023dd46182 (Debug, Clang 21.1.3-20250923) Build 27/03/2026

      13.0.0-dbg>SELECT * FROM t;
      ERROR 1944 (HY000): Failed to open t.test
      

      Expected: Failed to open test.t.

      Suggested patch:

      --- a/sql/sql_table.cc
      +++ b/sql/sql_table.cc
      @@ -6223,7 +6223,7 @@ my_bool open_global_temporary_table(THD *thd, TABLE_SHARE *source,
         {
           // If we're here, replica was fed with an incorrect log.
           my_error(ER_GTID_OPEN_TABLE_FAILED, MYF(0),
      -             source->table_name.str, source->db.str);
      +             source->db.str, source->table_name.str);
           return TRUE;
         }
       
      @@ -6234,7 +6234,7 @@ my_bool open_global_temporary_table(THD *thd, TABLE_SHARE *source,
                        "Can't open global temporary table under "
                        "slave applier execution mode");
           my_error(ER_GTID_OPEN_TABLE_FAILED, MYF(0),
      -             source->table_name.str, source->db.str);
      +             source->db.str, source->table_name.str);
           return TRUE;
         }
      

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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