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

LP:825075 - Wrong result with multipart key + MIN/MAX loose scan and OR expression in WHERE

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.3.9
    • Fix Version/s: 5.5.30, 5.3.13, 5.2.15
    • Component/s: None
    • Labels:

      Description

      The following test case produces wrong result:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 ( a int, b varchar(1), KEY (b,a));
      INSERT INTO t1 VALUES (0,NULL),(9,NULL),(8,'c'),(4,'d'),(7,'d'),(NULL,'f'),(7,'f'),(8,'g'),(NULL,'j');
      
      SELECT a , b FROM t1 WHERE a IS NULL OR b = 'z' ;
      SELECT max(a) , b FROM t1 WHERE a IS NULL OR b = 'z' GROUP BY b; 
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              timour Timour Katchaounov added a comment -

              The bug manifests itself with the above example in MariaDB 5.3.

              In MariaDB 5.5, MySQL 5.5, and MySQL 5.6 the bug cannot be reproduced directly by the above example because the cost of loose scan is higher than that of index scan.
              However, if one changes the cost in GDB, loose scan is chosen, which produces wrong result. So the final test case for 5.5 and above must be designed to trigger loose scan.

              Show
              timour Timour Katchaounov added a comment - The bug manifests itself with the above example in MariaDB 5.3. In MariaDB 5.5, MySQL 5.5, and MySQL 5.6 the bug cannot be reproduced directly by the above example because the cost of loose scan is higher than that of index scan. However, if one changes the cost in GDB, loose scan is chosen, which produces wrong result. So the final test case for 5.5 and above must be designed to trigger loose scan.
              Hide
              timour Timour Katchaounov added a comment -

              There is a patch, the patch has been reviewed by Sergey. The review requires more analysis and possibly a more generic solution.

              Show
              timour Timour Katchaounov added a comment - There is a patch, the patch has been reviewed by Sergey. The review requires more analysis and possibly a more generic solution.
              Hide
              timour Timour Katchaounov added a comment -

              The wrong result is present in MariaDB 5.3 and on, and in MySQL 5.5/5.6 (older versions should be affected too).
              In addition MySQL crashes by calling EXPLAIN on the query after executing it or doing a show create table (in 5.5.), or 'create table t2 like t1' (in 5.6). MariaDB works fine, just the wrong result is a problem.
              The MySQL crash was filed as http://bugs.mysql.com/?id=68179, let's see if they'll hide it.

              Show
              timour Timour Katchaounov added a comment - The wrong result is present in MariaDB 5.3 and on, and in MySQL 5.5/5.6 (older versions should be affected too). In addition MySQL crashes by calling EXPLAIN on the query after executing it or doing a show create table (in 5.5.), or 'create table t2 like t1' (in 5.6). MariaDB works fine, just the wrong result is a problem. The MySQL crash was filed as http://bugs.mysql.com/?id=68179 , let's see if they'll hide it.
              Hide
              psergey Sergei Petrunia added a comment -

              They did: "You do not have access to bug #68179."

              Show
              psergey Sergei Petrunia added a comment - They did: "You do not have access to bug #68179."
              Hide
              timour Timour Katchaounov added a comment -

              pushed to 5.3

              Show
              timour Timour Katchaounov added a comment - pushed to 5.3

                People

                • Assignee:
                  timour Timour Katchaounov
                  Reporter:
                  philipstoev Philip Stoev
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 1 week, 30 minutes
                    1w 30m
                    Remaining:
                    Time Spent - 3 days, 3 hours Remaining Estimate - 1 day, 5 hours, 30 minutes
                    1d 5h 30m
                    Logged:
                    Time Spent - 3 days, 3 hours Remaining Estimate - 1 day, 5 hours, 30 minutes
                    3d 3h