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

Trace replay produces "Impossible WHERE noticed after reading const tables"

    XMLWordPrintable

Details

    • Can result in unexpected behaviour
    • Q2/2026 Server Maintenance

    Description

      Run this testcase by mtr:

      CREATE TABLE t1 (a INT, b INT, KEY(a)) engine=myisam;
      INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
      analyze table t1;
      set optimizer_record_context=1;
      EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 1;
      select context into dumpfile
          "../../tmp/dump1.sql" from information_schema.optimizer_context;
      drop table t1;
      -- source "$MYSQLTEST_VARDIR/tmp/dump1.sql"
      drop table t1;
      

      The output will be:

      EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 1;
      EXPLAIN
      {
        "query_block": {
          "select_id": 1,
          "cost": 0.002024411,
          "nested_loop": [
            {
              "table": {
                "table_name": "t1",
                "access_type": "ref",
                "possible_keys": ["a"],
                "key": "a",
                "key_length": "5",
                "used_key_parts": ["a"],
                "ref": ["const"],
                "loops": 1,
                "rows": 1,
                "cost": 0.002024411,
                "filtered": 100
              }
            }
          ]
        }
      }
      select context into dumpfile
      "../../tmp/dump1.sql" from information_schema.optimizer_context;
      

      ...

      EXPLAIN FORMAT=JSON SELECT * FROM t1 WHERE a = 1;
      EXPLAIN
      {
        "query_block": {
          "select_id": 1,
          "table": {
            "message": "Impossible WHERE noticed after reading const tables"
          }
        }
      }
      

      EXPLAIN outputs do not match.

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.