summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorunknown <bell@laptop.sanja.is.com.ua>2003-08-19 20:14:35 +0300
committerunknown <bell@laptop.sanja.is.com.ua>2003-08-19 20:14:35 +0300
commit6d0a048701e07e69dea899fc1a6caa8f5d6b435d (patch)
tree095650183fd0ccdaa33b61c73f3a08954efac80b /sql/sql_base.cc
parent3808546d8a67d62420f9111998d94e44050ac313 (diff)
parent513917a53f87ce43dea98838a7d4e6196b9ea82b (diff)
downloadmariadb-git-6d0a048701e07e69dea899fc1a6caa8f5d6b435d.tar.gz
merge
mysql-test/r/subselect.result: Auto merged mysql-test/t/subselect.test: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.h: Auto merged
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index f33533d9eb7..dc6e791c4be 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1355,6 +1355,7 @@ int open_tables(THD *thd,TABLE_LIST *start)
int result=0;
DBUG_ENTER("open_tables");
+ thd->current_tablenr= 0;
restart:
thd->proc_info="Opening tables";
for (tables=start ; tables ; tables=tables->next)
@@ -1473,6 +1474,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
DBUG_ENTER("open_ltable");
thd->proc_info="Opening table";
+ thd->current_tablenr= 0;
while (!(table=open_table(thd,table_list->db,
table_list->real_name,table_list->alias,
&refresh)) && refresh) ;
@@ -2141,6 +2143,7 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
{
+ table_map not_null_tables= 0;
DBUG_ENTER("setup_conds");
thd->set_query_id=1;
@@ -2150,6 +2153,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
thd->where="where clause";
if ((*conds)->fix_fields(thd, tables, conds) || (*conds)->check_cols(1))
DBUG_RETURN(1);
+ not_null_tables= (*conds)->not_null_tables();
}
/* Check if we are using outer joins */
@@ -2164,9 +2168,15 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
DBUG_RETURN(1);
thd->lex.current_select->cond_count++;
- /* If it's a normal join, add the ON/USING expression to the WHERE */
- if (!table->outer_join)
+ /*
+ If it's a normal join or a LEFT JOIN which can be optimized away
+ add the ON/USING expression to the WHERE
+ */
+ if (!table->outer_join ||
+ ((table->table->map & not_null_tables) &&
+ !(specialflag & SPECIAL_NO_NEW_FUNC)))
{
+ table->outer_join= 0;
if (!(*conds=and_conds(*conds, table->on_expr)))
DBUG_RETURN(1);
table->on_expr=0;