diff options
-rw-r--r-- | mysql-test/r/select.result | 13 | ||||
-rw-r--r-- | mysql-test/t/select.test | 8 | ||||
-rw-r--r-- | sql/sql_select.cc | 8 | ||||
-rw-r--r-- | vio/vio.c | 3 |
4 files changed, 30 insertions, 2 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index fdcc7f9cdea..a921d75f20a 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3468,3 +3468,16 @@ a a a 2 2 2 3 3 3 drop table t1; +drop table if exists t1,t2; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)) TYPE=MyISAM; +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) TYPE=MyISAM; +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +aa id t2_id id +2 8299 2517 2517 +3 8301 2518 2518 +4 8302 2519 2519 +5 8303 2520 2520 +6 8304 2521 2521 +drop table if exists t1,t2; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 15d44bcd672..d9b75fca362 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1795,5 +1795,11 @@ select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); # natural join select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; - drop table t1; +drop table if exists t1,t2; +CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)) TYPE=MyISAM; +INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); +CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) TYPE=MyISAM; +INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); +select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; +drop table if exists t1,t2; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index eaa291f4d90..80b1ceb0538 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -923,7 +923,13 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, JOIN_TAB *end_table= &join.join_tab[join.tables]; for (; table < end_table ; table++) { - if (table->select_cond) + /* + table->keyuse is set in the case there was an original WHERE clause + on the table that was optimized away. + table->on_expr tells us that it was a LEFT JOIN and there will be + at least one row generated from the table. + */ + if (table->select_cond || (table->keyuse && !table->on_expr)) { /* We have to sort all rows */ select_limit= HA_POS_ERROR; diff --git a/vio/vio.c b/vio/vio.c index bed380c6cd9..d822651cca6 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -98,6 +98,9 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) vio->sd); #if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) #if !defined(NO_FCNTL_NONBLOCK) +#if defined(__FreeBSD__) + fcntl(sd, F_SETFL, vio->fcntl_mode); /* Yahoo! FreeBSD patch */ +#endif vio->fcntl_mode = fcntl(sd, F_GETFL); #elif defined(HAVE_SYS_IOCTL_H) /* hpux */ /* Non blocking sockets doesn't work good on HPUX 11.0 */ |