Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
The following query:
SELECT * FROM (
SELECT *
FROM t2
LEFT JOIN v1
ON (t2.a = v1.b)
) AS derived
returns the following incorrect result when run the first time as a prepared statement:
a b
6 0
The second run, as well as non-prepared execution, return the correct result:
a b
6 NULL
explain:
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
2 DERIVED t2 system NULL NULL NULL NULL 1
2 DERIVED t1 ALL NULL NULL NULL NULL 0 Using where
optimizer switch:
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on
repeatable on maria-5.3. Not repeatable on maria-5.2, mysql-5.5
bzr version-info:
revision-id: <email address hidden>
date: 2011-10-13 13:44:50 +0200
build-date: 2011-10-14 13:08:11 +0300
revno: 3233
branch-nick: maria-5.3
test case:
CREATE TABLE t2 (a int NOT NULL);
INSERT INTO t2 VALUES (6);
CREATE TABLE t1 (b int NOT NULL);
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
PREPARE st1 FROM '
SELECT * FROM (
SELECT *
FROM t2
LEFT JOIN v1
ON (t2.a = v1.b)
) AS derived
';
EXECUTE st1;
EXECUTE st1;