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

SHOW EXPLAIN: ref returned by SHOW EXPLAIN is different from the normal EXPLAIN ('const' vs empty string)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 10.0.0
    • Component/s: None
    • Labels:
      None

      Description

      EXPLAIN SELECT SLEEP(0.5) FROM t1 WHERE a=1;
      id      1
      select_type     SIMPLE
      table   t1
      type    ref
      possible_keys   a
      key     a
      key_len 5
      ref     const
      rows    1
      Extra   Using index
      SELECT SLEEP(0.5) FROM t1 WHERE a=1;
      
      SHOW EXPLAIN FOR 2;
      id      1
      select_type     SIMPLE
      table   t1
      type    ref
      possible_keys   a
      key     a
      key_len 5
      ref
      rows    1
      Extra   Using index
      Warnings:
      Level   Note
      Code    1003
      Message SELECT SLEEP(0.5) FROM t1 WHERE a=1
      

      bzr version-info

      revision-id: psergey@askmonty.org-20120524182239-gq6jtnnovydnthtl
      date: 2012-05-24 22:22:39 +0400
      revno: 3405
      

      Reproducible with the default optimizer_switch as well as with all OFF values.
      Reproducible with MyISAM, Aria, InnoDB.

      Test case:

      CREATE TABLE t1 (a INT, KEY(a));
      INSERT INTO t1 VALUES
      (3),(1),(5),(1);
      
      --connect (con1,localhost,root,,)
      let $con_id = `SELECT CONNECTION_ID()`;
      
      EXPLAIN SELECT SLEEP(0.5) FROM t1 WHERE a=1;
      --send
      SELECT SLEEP(0.5) FROM t1 WHERE a=1;
      
      --connection default
      let $run = 100;
      while ($run)
      {
        --error 0,ER_ERROR_WHEN_EXECUTING_COMMAND
        --eval SHOW EXPLAIN FOR $con_id
        --dec $run
        if (!$mysql_errno)
        {
          let $run = 0;
        }
      }
      
      --connection con1
      --reap
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              psergey Sergei Petrunia added a comment -

              Fixed. Added comment about create_ref_for_key().

              Show
              psergey Sergei Petrunia added a comment - Fixed. Added comment about create_ref_for_key().

                People

                • Assignee:
                  psergey Sergei Petrunia
                  Reporter:
                  elenst Elena Stepanova
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 3 hours
                    3h