[MDEV-11103] Wrong result (missing rows) on query from a view with WHERE .. ANY, condition_pushdown_for_derived=on Created: 2016-10-21  Updated: 2016-11-17  Resolved: 2016-11-17

Status: Closed
Project: MariaDB Server
Component/s: Optimizer, Views
Affects Version/s: 10.2
Fix Version/s: 10.2.3

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: regression-10.2

Sprint: 10.2.4-3

 Description   

CREATE TABLE t1 (i INT);
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2);
SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );

Actual result, 10.2 82b974a1b6

MariaDB [test]> SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
Empty set (0.00 sec)

Expected result

MariaDB [test]> SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
+------+
| i    |
+------+
|    1 |
|    2 |
+------+
2 rows in set (0.00 sec)



 Comments   
Comment by Oleksandr Byelkin [ 2016-11-16 ]

Some how condition (not((t1.i <= 3))) was pushed in the view which made view have no records.

{
  "query_block": {
    "select_id": 1,
    "r_loops": 1,
    "r_total_time_ms": 0.0577,
    "table": {
      "table_name": "<derived3>",
      "access_type": "ALL",
      "r_loops": 1,
      "rows": 2,
      "r_rows": 0,
      "r_total_time_ms": 2.3e-4,
      "filtered": 100,
      "r_filtered": 100,
      "attached_condition": "<nop>((v1.i <= 3))",
      "materialized": {
        "query_block": {
          "select_id": 3,
          "r_loops": 1,
          "r_total_time_ms": 0.0244,
          "table": {
            "table_name": "t1",
            "access_type": "ALL",
            "r_loops": 1,
            "rows": 2,
            "r_rows": 2,
            "r_total_time_ms": 0.0048,
            "filtered": 100,
            "r_filtered": 0,
            "attached_condition": "(not((t1.i <= 3)))"
          }
        }
      }
    }
  }
}

Comment by Igor Babaev [ 2016-11-17 ]

The fix for this bug was pushed into the 10.2 tree.

Generated at Thu Feb 08 07:47:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.