Commit f675536a authored by unknown's avatar unknown

Merge 5.1->5.2

parents 30370ee2 ee06e4d6
...@@ -263,7 +263,7 @@ WHERE t1.f1 GROUP BY t1.f1)); ...@@ -263,7 +263,7 @@ WHERE t1.f1 GROUP BY t1.f1));
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort 2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort
2 SUBQUERY t1 fulltext f1 f1 0 1 Using where 2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
PREPARE stmt FROM PREPARE stmt FROM
'EXPLAIN SELECT 1 FROM t1 'EXPLAIN SELECT 1 FROM t1
WHERE 1 > ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a WHERE 1 > ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a
...@@ -273,12 +273,12 @@ EXECUTE stmt; ...@@ -273,12 +273,12 @@ EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort 2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort
2 SUBQUERY t1 fulltext f1 f1 0 1 Using where 2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
EXECUTE stmt; EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort 2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort
2 SUBQUERY t1 fulltext f1 f1 0 1 Using where 2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
PREPARE stmt FROM PREPARE stmt FROM
'EXPLAIN SELECT 1 FROM t1 'EXPLAIN SELECT 1 FROM t1
...@@ -289,12 +289,12 @@ EXECUTE stmt; ...@@ -289,12 +289,12 @@ EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort 2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort
2 SUBQUERY t1 fulltext f1 f1 0 1 Using where 2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
EXECUTE stmt; EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort 2 SUBQUERY a system NULL NULL NULL NULL 1 Using filesort
2 SUBQUERY t1 fulltext f1 f1 0 1 Using where 2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
DROP TABLE t1; DROP TABLE t1;
End of 5.1 tests. End of 5.1 tests.
...@@ -1378,7 +1378,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1378,7 +1378,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE jt5 index NULL PRIMARY 4 NULL 2 100.00 Using index 1 SIMPLE jt5 index NULL PRIMARY 4 NULL 2 100.00 Using index
1 SIMPLE jt2 index NULL PRIMARY 4 NULL 2 100.00 Using index 1 SIMPLE jt2 index NULL PRIMARY 4 NULL 2 100.00 Using index
Warnings: Warnings:
Note 1003 select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt1` left join (`test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(1) left join `test`.`t1` `jt2` on(1)) on((`test`.`jt6`.`f1` and 1))) on(1) where 1 Note 1003 select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt1` left join (`test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(1) left join `test`.`t1` `jt2` on(1)) on(((`test`.`jt6`.`f1` <> 0) and 1))) on(1) where 1
EXPLAIN EXTENDED SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1 EXPLAIN EXTENDED SELECT STRAIGHT_JOIN jt1.f1 FROM t1 AS jt1
RIGHT JOIN t1 AS jt2 RIGHT JOIN t1 AS jt2
RIGHT JOIN t1 AS jt3 RIGHT JOIN t1 AS jt3
...@@ -1395,7 +1395,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -1395,7 +1395,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE jt2 index NULL PRIMARY 4 NULL 2 100.00 Using index 1 SIMPLE jt2 index NULL PRIMARY 4 NULL 2 100.00 Using index
1 SIMPLE jt1 index NULL PRIMARY 4 NULL 2 100.00 Using index 1 SIMPLE jt1 index NULL PRIMARY 4 NULL 2 100.00 Using index
Warnings: Warnings:
Note 1003 select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(1) left join `test`.`t1` `jt2` on(1)) on((`test`.`jt6`.`f1` and 1)) left join `test`.`t1` `jt1` on(1) where 1 Note 1003 select straight_join `test`.`jt1`.`f1` AS `f1` from `test`.`t1` `jt6` left join (`test`.`t1` `jt3` join `test`.`t1` `jt4` left join `test`.`t1` `jt5` on(1) left join `test`.`t1` `jt2` on(1)) on(((`test`.`jt6`.`f1` <> 0) and 1)) left join `test`.`t1` `jt1` on(1) where 1
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#49600: outer join of two single-row tables with joining attributes # Bug#49600: outer join of two single-row tables with joining attributes
......
...@@ -4,7 +4,7 @@ insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), ...@@ -4,7 +4,7 @@ insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
(10), (11), (12), (13), (14), (15), (16), (17), (18), (19); (10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
explain select * from t1 where not(not(a)); explain select * from t1 where not(not(a));
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index 1 SIMPLE t1 range a a 5 NULL 20 Using where; Using index
select * from t1 where not(not(a)); select * from t1 where not(not(a));
a a
1 1
...@@ -385,7 +385,7 @@ NULL NULL ...@@ -385,7 +385,7 @@ NULL NULL
3 1 3 1
explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a)); explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a));
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 5 NULL 5 100.00 Using where; Using index 1 SIMPLE t1 range a a 5 NULL 4 100.00 Using where; Using index
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,(`test`.`t1`.`a` <> 0) AS `not(not(a))`,((`test`.`t1`.`a` > 2) or `test`.`t1`.`a`) AS `not(a <= 2 and not(a))`,(`test`.`t1`.`a` like '1') AS `not(a not like "1")`,(`test`.`t1`.`a` in (1,2)) AS `not (a not in (1,2))`,(`test`.`t1`.`a` = 2) AS `not(a != 2)` from `test`.`t1` where `test`.`t1`.`a` having `test`.`t1`.`a` Note 1003 select `test`.`t1`.`a` AS `a`,(`test`.`t1`.`a` <> 0) AS `not(not(a))`,((`test`.`t1`.`a` > 2) or `test`.`t1`.`a`) AS `not(a <= 2 and not(a))`,(`test`.`t1`.`a` like '1') AS `not(a not like "1")`,(`test`.`t1`.`a` in (1,2)) AS `not (a not in (1,2))`,(`test`.`t1`.`a` = 2) AS `not(a != 2)` from `test`.`t1` where (`test`.`t1`.`a` <> 0) having (`test`.`t1`.`a` <> 0)
drop table t1; drop table t1;
...@@ -3711,7 +3711,7 @@ CREATE TABLE t1 (c INT); ...@@ -3711,7 +3711,7 @@ CREATE TABLE t1 (c INT);
CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias; CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias;
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`c` AS `view_column` from `t1` having `view_column` latin1 latin1_swedish_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`c` AS `view_column` from `t1` having (`view_column` <> 0) latin1 latin1_swedish_ci
SELECT * FROM v1; SELECT * FROM v1;
view_column view_column
...@@ -3906,6 +3906,23 @@ SELECT * FROM v1; ...@@ -3906,6 +3906,23 @@ SELECT * FROM v1;
a a
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
#
# LP BUG#777809 (a retrograded condition for view ON)
#
CREATE TABLE t1 ( f1 int NOT NULL , f6 int NOT NULL ) ;
INSERT IGNORE INTO t1 VALUES (20, 2);
CREATE TABLE t2 ( f3 int NOT NULL ) ;
INSERT IGNORE INTO t2 VALUES (7);
CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2;
PREPARE prep_stmt FROM 'SELECT t1.f6 FROM t1 RIGHT JOIN v2 ON v2.f3 WHERE t1.f1 != 0';
EXECUTE prep_stmt;
f6
2
EXECUTE prep_stmt;
f6
2
drop view v2;
drop table t1,t2;
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# -- End of 5.1 tests. # -- End of 5.1 tests.
# ----------------------------------------------------------------- # -----------------------------------------------------------------
...@@ -2623,47 +2623,6 @@ create table t1 (a int primary key, b int) engine = innodb; ...@@ -2623,47 +2623,6 @@ create table t1 (a int primary key, b int) engine = innodb;
insert into t1 values (1,1),(2,1); insert into t1 values (1,1),(2,1);
alter ignore table t1 add unique `main` (b); alter ignore table t1 add unique `main` (b);
drop table t1; drop table t1;
#
# Bug#56862 Execution of a query that uses index merge returns a wrong result
#
CREATE TABLE t1 (
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
a int,
b int,
INDEX idx(a))
ENGINE=INNODB;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
SET SESSION sort_buffer_size = 1024*36;
EXPLAIN
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
2 DERIVED t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 3537 Using sort_union(idx,PRIMARY); Using where
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
COUNT(*)
1537
SET SESSION sort_buffer_size = DEFAULT;
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
# #
# Test for bug #39932 "create table fails if column for FK is in different # Test for bug #39932 "create table fails if column for FK is in different
......
...@@ -849,51 +849,6 @@ insert into t1 values (1,1),(2,1); ...@@ -849,51 +849,6 @@ insert into t1 values (1,1),(2,1);
alter ignore table t1 add unique `main` (b); alter ignore table t1 add unique `main` (b);
drop table t1; drop table t1;
--echo #
--echo # Bug#56862 Execution of a query that uses index merge returns a wrong result
--echo #
CREATE TABLE t1 (
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
a int,
b int,
INDEX idx(a))
ENGINE=INNODB;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
SET SESSION sort_buffer_size = 1024*36;
EXPLAIN
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
SET SESSION sort_buffer_size = DEFAULT;
DROP TABLE t1;
--echo End of 5.1 tests --echo End of 5.1 tests
......
...@@ -2410,42 +2410,4 @@ PACK_KEYS=0; ...@@ -2410,42 +2410,4 @@ PACK_KEYS=0;
CREATE INDEX a ON t1 (a); CREATE INDEX a ON t1 (a);
CREATE INDEX c on t1 (c); CREATE INDEX c on t1 (c);
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
a int,
b int,
INDEX idx(a))
ENGINE=INNODB;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
SET SESSION sort_buffer_size = 1024*36;
EXPLAIN
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
2 DERIVED t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 3537 Using sort_union(idx,PRIMARY); Using where
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
COUNT(*)
1537
SET SESSION sort_buffer_size = DEFAULT;
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
...@@ -647,48 +647,4 @@ CREATE INDEX c on t1 (c); ...@@ -647,48 +647,4 @@ CREATE INDEX c on t1 (c);
DROP TABLE t1; DROP TABLE t1;
#
# Bug#56862 Execution of a query that uses index merge returns a wrong result
#
CREATE TABLE t1 (
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
a int,
b int,
INDEX idx(a))
ENGINE=INNODB;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
SET SESSION sort_buffer_size = 1024*36;
EXPLAIN
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
SET SESSION sort_buffer_size = DEFAULT;
DROP TABLE t1;
--echo End of 5.1 tests --echo End of 5.1 tests
...@@ -3953,6 +3953,26 @@ SELECT * FROM v1; ...@@ -3953,6 +3953,26 @@ SELECT * FROM v1;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # LP BUG#777809 (a retrograded condition for view ON)
--echo #
CREATE TABLE t1 ( f1 int NOT NULL , f6 int NOT NULL ) ;
INSERT IGNORE INTO t1 VALUES (20, 2);
CREATE TABLE t2 ( f3 int NOT NULL ) ;
INSERT IGNORE INTO t2 VALUES (7);
CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2;
PREPARE prep_stmt FROM 'SELECT t1.f6 FROM t1 RIGHT JOIN v2 ON v2.f3 WHERE t1.f1 != 0';
EXECUTE prep_stmt;
EXECUTE prep_stmt;
drop view v2;
drop table t1,t2;
--echo # ----------------------------------------------------------------- --echo # -----------------------------------------------------------------
--echo # -- End of 5.1 tests. --echo # -- End of 5.1 tests.
--echo # ----------------------------------------------------------------- --echo # -----------------------------------------------------------------
...@@ -1504,6 +1504,7 @@ bool add_to_list(THD *thd, SQL_I_List<ORDER> &list, Item *group,bool asc); ...@@ -1504,6 +1504,7 @@ bool add_to_list(THD *thd, SQL_I_List<ORDER> &list, Item *group,bool asc);
bool push_new_name_resolution_context(THD *thd, bool push_new_name_resolution_context(THD *thd,
TABLE_LIST *left_op, TABLE_LIST *left_op,
TABLE_LIST *right_op); TABLE_LIST *right_op);
Item *normalize_cond(Item *cond);
void add_join_on(TABLE_LIST *b,Item *expr); void add_join_on(TABLE_LIST *b,Item *expr);
void add_join_natural(TABLE_LIST *a,TABLE_LIST *b,List<String> *using_fields, void add_join_natural(TABLE_LIST *a,TABLE_LIST *b,List<String> *using_fields,
SELECT_LEX *lex); SELECT_LEX *lex);
......
...@@ -271,7 +271,6 @@ class QUICK_SELECT_I ...@@ -271,7 +271,6 @@ class QUICK_SELECT_I
virtual bool reverse_sorted() = 0; virtual bool reverse_sorted() = 0;
virtual bool unique_key_range() { return false; } virtual bool unique_key_range() { return false; }
virtual bool clustered_pk_range() { return false; }
enum { enum {
QS_TYPE_RANGE = 0, QS_TYPE_RANGE = 0,
...@@ -542,8 +541,6 @@ class QUICK_INDEX_MERGE_SELECT : public QUICK_SELECT_I ...@@ -542,8 +541,6 @@ class QUICK_INDEX_MERGE_SELECT : public QUICK_SELECT_I
THD *thd; THD *thd;
int read_keys_and_merge(); int read_keys_and_merge();
bool clustered_pk_range() { return test(pk_quick_select); }
/* used to get rows collected in Unique */ /* used to get rows collected in Unique */
READ_RECORD read_record; READ_RECORD read_record;
}; };
......
...@@ -195,15 +195,6 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, ...@@ -195,15 +195,6 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
if (select && my_b_inited(&select->file)) if (select && my_b_inited(&select->file))
tempfile= &select->file; tempfile= &select->file;
else if (select && select->quick && select->quick->clustered_pk_range())
{
/*
In case of QUICK_INDEX_MERGE_SELECT with clustered pk range we have to
use its own access method(i.e QUICK_INDEX_MERGE_SELECT::get_next()) as
sort file does not contain rowids which satisfy clustered pk range.
*/
tempfile= 0;
}
else else
tempfile= table->sort.io_cache; tempfile= table->sort.io_cache;
if (tempfile && my_b_inited(tempfile) && if (tempfile && my_b_inited(tempfile) &&
......
...@@ -6855,6 +6855,28 @@ push_new_name_resolution_context(THD *thd, ...@@ -6855,6 +6855,28 @@ push_new_name_resolution_context(THD *thd,
} }
/**
Fix condition which contains only field (f turns to f <> 0 )
@param cond The condition to fix
@return fixed condition
*/
Item *normalize_cond(Item *cond)
{
if (cond)
{
Item::Type type= cond->type();
if (type == Item::FIELD_ITEM || type == Item::REF_ITEM)
{
cond= new Item_func_ne(cond, new Item_int(0));
}
}
return cond;
}
/** /**
Add an ON condition to the second operand of a JOIN ... ON. Add an ON condition to the second operand of a JOIN ... ON.
...@@ -6873,6 +6895,7 @@ void add_join_on(TABLE_LIST *b, Item *expr) ...@@ -6873,6 +6895,7 @@ void add_join_on(TABLE_LIST *b, Item *expr)
{ {
if (expr) if (expr)
{ {
expr= normalize_cond(expr);
if (!b->on_expr) if (!b->on_expr)
b->on_expr= expr; b->on_expr= expr;
else else
......
...@@ -9223,7 +9223,7 @@ where_clause: ...@@ -9223,7 +9223,7 @@ where_clause:
expr expr
{ {
SELECT_LEX *select= Select; SELECT_LEX *select= Select;
select->where= $3; select->where= normalize_cond($3);
select->parsing_place= NO_MATTER; select->parsing_place= NO_MATTER;
if ($3) if ($3)
$3->top_level_item(); $3->top_level_item();
...@@ -9239,7 +9239,7 @@ having_clause: ...@@ -9239,7 +9239,7 @@ having_clause:
expr expr
{ {
SELECT_LEX *sel= Select; SELECT_LEX *sel= Select;
sel->having= $3; sel->having= normalize_cond($3);
sel->parsing_place= NO_MATTER; sel->parsing_place= NO_MATTER;
if ($3) if ($3)
$3->top_level_item(); $3->top_level_item();
...@@ -10706,7 +10706,7 @@ wild_and_where: ...@@ -10706,7 +10706,7 @@ wild_and_where:
} }
| WHERE expr | WHERE expr
{ {
Select->where= $2; Select->where= normalize_cond($2);
if ($2) if ($2)
$2->top_level_item(); $2->top_level_item();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment