Commit 5d1b299f authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/dlenev/src/mysql-4.1-868

parents b15eba88 e3b11b1d
...@@ -840,7 +840,7 @@ a t1.a in (select t2.a from t2) ...@@ -840,7 +840,7 @@ a t1.a in (select t2.a from t2)
explain SELECT t1.a, t1.a in (select t2.a from t2) FROM t1; explain SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
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 index NULL PRIMARY 4 NULL 4 Using index 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 Using index
2 DEPENDENT SUBQUERY t2 index_in a a 5 func 2 Using index 2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 Using index
CREATE TABLE t3 (a int(11) default '0'); CREATE TABLE t3 (a int(11) default '0');
INSERT INTO t3 VALUES (1),(2),(3); INSERT INTO t3 VALUES (1),(2),(3);
SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1; SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
...@@ -1253,7 +1253,7 @@ a ...@@ -1253,7 +1253,7 @@ a
explain select * from t2 where t2.a in (select a from t1); explain select * from t2 where t2.a in (select a from t1);
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 t2 index NULL PRIMARY 4 NULL 4 Using where; Using index 1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 simple_in PRIMARY PRIMARY 4 func 1 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 Using index
select * from t2 where t2.a in (select a from t1 where t1.b <> 30); select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a a
2 2
...@@ -1261,7 +1261,7 @@ a ...@@ -1261,7 +1261,7 @@ a
explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
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 t2 index NULL PRIMARY 4 NULL 4 Using where; Using index 1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 simple_in PRIMARY PRIMARY 4 func 1 Using index; Using where 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 Using index; Using where
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a a
2 2
...@@ -1286,7 +1286,7 @@ a ...@@ -1286,7 +1286,7 @@ a
explain select * from t2 where t2.a in (select a from t1); explain select * from t2 where t2.a in (select a from t1);
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 t2 index NULL a 5 NULL 4 Using where; Using index 1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 index_in a a 5 func 1001 Using index 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 Using index
select * from t2 where t2.a in (select a from t1 where t1.b <> 30); select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a a
2 2
...@@ -1294,7 +1294,7 @@ a ...@@ -1294,7 +1294,7 @@ a
explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
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 t2 index NULL a 5 NULL 4 Using where; Using index 1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 index_in a a 5 func 1001 Using index; Using where 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 Using index; Using where
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a a
2 2
...@@ -1317,7 +1317,7 @@ a ...@@ -1317,7 +1317,7 @@ a
explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30); explain select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
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 t2 index NULL a 5 NULL 4 Using where; Using index 1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 index_in a a 5 func 1001 Using index; Using where 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 Using index; Using where
drop table t1, t2, t3; drop table t1, t2, t3;
create table t1 (a int, b int); create table t1 (a int, b int);
create table t2 (a int, b int); create table t2 (a int, b int);
...@@ -1405,9 +1405,9 @@ a3 1 ...@@ -1405,9 +1405,9 @@ a3 1
explain select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; explain select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
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 index NULL s1 6 NULL 3 Using index 1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_in s1 s1 6 func 2 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
explain select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; explain select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
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 index NULL s1 6 NULL 3 Using index 1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
2 DEPENDENT SUBQUERY t2 index_in s1 s1 6 func 1 Using index; Using where 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 1 Using index; Using where
drop table t1,t2; drop table t1,t2;
...@@ -123,9 +123,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -123,9 +123,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 0 const row not found 1 PRIMARY t1 system PRIMARY NULL NULL NULL 0 const row not found
1 PRIMARY t2 ALL DDOCTYPEID_IDX NULL NULL NULL 9 Using where 1 PRIMARY t2 ALL DDOCTYPEID_IDX NULL NULL NULL 9 Using where
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 32 test.t2.DOCTYPEID 1 1 PRIMARY t4 eq_ref PRIMARY PRIMARY 32 test.t2.DOCTYPEID 1
2 DEPENDENT SUBQUERY t3 simple_in PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where 2 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
3 DEPENDENT SUBQUERY t3 simple_in PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where 3 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
4 DEPENDENT SUBQUERY t3 simple_in PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where 4 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
5 DEPENDENT SUBQUERY t3 simple_in PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where 5 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
6 DEPENDENT SUBQUERY t3 simple_in PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 32 func 1 Using index; Using where 6 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 32 func 1 Using index; Using where
drop table t1, t2, t3, t4; drop table t1, t2, t3, t4;
...@@ -773,7 +773,7 @@ int subselect_union_engine::prepare() ...@@ -773,7 +773,7 @@ int subselect_union_engine::prepare()
return unit->prepare(thd, result, 0); return unit->prepare(thd, result, 0);
} }
int subselect_simplein_engine::prepare() int subselect_uniquesubquery_engine::prepare()
{ {
//this never should be called //this never should be called
DBUG_ASSERT(0); DBUG_ASSERT(0);
...@@ -860,7 +860,7 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row) ...@@ -860,7 +860,7 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row)
} }
} }
void subselect_simplein_engine::fix_length_and_dec(Item_cache **row) void subselect_uniquesubquery_engine::fix_length_and_dec(Item_cache **row)
{ {
//this never should be called //this never should be called
DBUG_ASSERT(0); DBUG_ASSERT(0);
...@@ -919,9 +919,9 @@ int subselect_union_engine::exec() ...@@ -919,9 +919,9 @@ int subselect_union_engine::exec()
return res; return res;
} }
int subselect_simplein_engine::exec() int subselect_uniquesubquery_engine::exec()
{ {
DBUG_ENTER("subselect_simplein_engine::exec"); DBUG_ENTER("subselect_uniquesubquery_engine::exec");
int error; int error;
TABLE *table= tab->table; TABLE *table= tab->table;
if ((tab->ref.key_err= (*tab->ref.key_copy)->copy())) if ((tab->ref.key_err= (*tab->ref.key_copy)->copy()))
...@@ -949,9 +949,9 @@ int subselect_simplein_engine::exec() ...@@ -949,9 +949,9 @@ int subselect_simplein_engine::exec()
DBUG_RETURN(end_exec(table) || (error != 0)); DBUG_RETURN(end_exec(table) || (error != 0));
} }
int subselect_simplein_engine::end_exec(TABLE *table) int subselect_uniquesubquery_engine::end_exec(TABLE *table)
{ {
DBUG_ENTER("subselect_simplein_engine::end_exec"); DBUG_ENTER("subselect_uniquesubquery_engine::end_exec");
int error=0, tmp; int error=0, tmp;
if ((tmp= table->file->extra(HA_EXTRA_NO_CACHE))) if ((tmp= table->file->extra(HA_EXTRA_NO_CACHE)))
{ {
...@@ -968,9 +968,9 @@ int subselect_simplein_engine::end_exec(TABLE *table) ...@@ -968,9 +968,9 @@ int subselect_simplein_engine::end_exec(TABLE *table)
DBUG_RETURN(error != 0); DBUG_RETURN(error != 0);
} }
int subselect_indexin_engine::exec() int subselect_indexsubquery_engine::exec()
{ {
DBUG_ENTER("subselect_indexin_engine::exec"); DBUG_ENTER("subselect_indexsubselect_engine::exec");
int error; int error;
bool null_finding= 0; bool null_finding= 0;
TABLE *table= tab->table; TABLE *table= tab->table;
...@@ -1075,7 +1075,7 @@ void subselect_union_engine::exclude() ...@@ -1075,7 +1075,7 @@ void subselect_union_engine::exclude()
unit->exclude_level(); unit->exclude_level();
} }
void subselect_simplein_engine::exclude() void subselect_uniquesubquery_engine::exclude()
{ {
//this never should be called //this never should be called
DBUG_ASSERT(0); DBUG_ASSERT(0);
......
...@@ -183,8 +183,8 @@ public: ...@@ -183,8 +183,8 @@ public:
void fix_length_and_dec(); void fix_length_and_dec();
friend class select_exists_subselect; friend class select_exists_subselect;
friend class subselect_simplein_engine; friend class subselect_uniquesubquery_engine;
friend class subselect_indexin_engine; friend class subselect_indexsubquery_engine;
}; };
/* IN subselect */ /* IN subselect */
...@@ -227,7 +227,7 @@ public: ...@@ -227,7 +227,7 @@ public:
friend class Item_ref_null_helper; friend class Item_ref_null_helper;
friend class Item_is_not_null_test; friend class Item_is_not_null_test;
friend class subselect_indexin_engine; friend class subselect_indexsubquery_engine;
}; };
/* ALL/ANY/SOME subselect */ /* ALL/ANY/SOME subselect */
...@@ -313,14 +313,14 @@ public: ...@@ -313,14 +313,14 @@ public:
}; };
struct st_join_table; struct st_join_table;
class subselect_simplein_engine: public subselect_engine class subselect_uniquesubquery_engine: public subselect_engine
{ {
protected: protected:
st_join_table *tab; st_join_table *tab;
Item *cond; Item *cond;
public: public:
subselect_simplein_engine(THD *thd, st_join_table *tab_arg, subselect_uniquesubquery_engine(THD *thd, st_join_table *tab_arg,
Item_subselect *subs, Item *where) Item_subselect *subs, Item *where)
:subselect_engine(thd, subs, 0), tab(tab_arg), cond(where) :subselect_engine(thd, subs, 0), tab(tab_arg), cond(where)
{} {}
...@@ -335,14 +335,14 @@ public: ...@@ -335,14 +335,14 @@ public:
static int end_exec(TABLE *table); static int end_exec(TABLE *table);
}; };
class subselect_indexin_engine: public subselect_simplein_engine class subselect_indexsubquery_engine: public subselect_uniquesubquery_engine
{ {
bool check_null; bool check_null;
public: public:
subselect_indexin_engine(THD *thd, st_join_table *tab_arg, subselect_indexsubquery_engine(THD *thd, st_join_table *tab_arg,
Item_subselect *subs, Item *where, Item_subselect *subs, Item *where,
bool chk_null) bool chk_null)
:subselect_simplein_engine(thd, tab_arg, subs, where), :subselect_uniquesubquery_engine(thd, tab_arg, subs, where),
check_null(chk_null) check_null(chk_null)
{} {}
int exec(); int exec();
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
"MAYBE_REF","ALL","range","index","fulltext", "MAYBE_REF","ALL","range","index","fulltext",
"ref_or_null","simple_in","index_in" "ref_or_null","unique_subquery","index_subquery"
}; };
static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array); static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array);
...@@ -773,10 +773,11 @@ JOIN::optimize() ...@@ -773,10 +773,11 @@ JOIN::optimize()
{ {
if (test_in_subselect(&where)) if (test_in_subselect(&where))
{ {
join_tab[0].type= JT_SIMPLE_IN; join_tab[0].type= JT_UNIQUE_SUBQUERY;
error= 0; error= 0;
DBUG_RETURN(unit->item-> DBUG_RETURN(unit->item->
change_engine(new subselect_simplein_engine(thd, change_engine(new
subselect_uniquesubquery_engine(thd,
join_tab, join_tab,
unit->item, unit->item,
where))); where)));
...@@ -787,10 +788,11 @@ JOIN::optimize() ...@@ -787,10 +788,11 @@ JOIN::optimize()
{ {
if (test_in_subselect(&where)) if (test_in_subselect(&where))
{ {
join_tab[0].type= JT_INDEX_IN; join_tab[0].type= JT_INDEX_SUBQUERY;
error= 0; error= 0;
DBUG_RETURN(unit->item-> DBUG_RETURN(unit->item->
change_engine(new subselect_indexin_engine(thd, change_engine(new
subselect_indexsubquery_engine(thd,
join_tab, join_tab,
unit->item, unit->item,
where, where,
...@@ -803,7 +805,7 @@ JOIN::optimize() ...@@ -803,7 +805,7 @@ JOIN::optimize()
((Item_func *) having)->functype() == ((Item_func *) having)->functype() ==
Item_func::ISNOTNULLTEST_FUNC) Item_func::ISNOTNULLTEST_FUNC)
{ {
join_tab[0].type= JT_INDEX_IN; join_tab[0].type= JT_INDEX_SUBQUERY;
error= 0; error= 0;
if ((conds= remove_additional_cond(conds))) if ((conds= remove_additional_cond(conds)))
...@@ -812,7 +814,7 @@ JOIN::optimize() ...@@ -812,7 +814,7 @@ JOIN::optimize()
join_tab->info= "Using index"; join_tab->info= "Using index";
DBUG_RETURN(unit->item-> DBUG_RETURN(unit->item->
change_engine(new subselect_indexin_engine(thd, change_engine(new subselect_indexsubquery_engine(thd,
join_tab, join_tab,
unit->item, unit->item,
conds, conds,
......
...@@ -76,7 +76,7 @@ typedef struct st_join_cache { ...@@ -76,7 +76,7 @@ typedef struct st_join_cache {
enum join_type { JT_UNKNOWN,JT_SYSTEM,JT_CONST,JT_EQ_REF,JT_REF,JT_MAYBE_REF, enum join_type { JT_UNKNOWN,JT_SYSTEM,JT_CONST,JT_EQ_REF,JT_REF,JT_MAYBE_REF,
JT_ALL, JT_RANGE, JT_NEXT, JT_FT, JT_REF_OR_NULL, JT_ALL, JT_RANGE, JT_NEXT, JT_FT, JT_REF_OR_NULL,
JT_SIMPLE_IN, JT_INDEX_IN}; JT_UNIQUE_SUBQUERY, JT_INDEX_SUBQUERY};
class JOIN; class JOIN;
......
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