summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorSergey Petrunia <psergey@askmonty.org>2009-06-22 15:46:31 +0400
committerSergey Petrunia <psergey@askmonty.org>2009-06-22 15:46:31 +0400
commit9e65634b2337e96445e14ce72b144353f779a4a5 (patch)
treec47fb368bc0d9c63fc609a977ab7a03378aff3d0 /sql/item.cc
parent7a9f45c6d5fc90a18c44e52ddd147e95fdacc264 (diff)
downloadmariadb-git-9e65634b2337e96445e14ce72b144353f779a4a5.tar.gz
MWL#17: Table elimination
- Make elimination check to be able detect cases like t.primary_key_col1=othertbl.col AND t.primary_key_col2=func(t.primary_key_col1). These are needed to handle e.g. the case of func() being a correlated subquery that selects the latest value. - If we've removed a condition with subquery predicate, EXPLAIN [EXTENDED] won't show the subquery anymore sql/item.cc: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item.h: MWL#17: Table elimination - Add tem_field::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_subselect.cc: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. - Added a comment about possible problem in Item_subselect::walk sql/item_subselect.h: MWL#17: Table elimination - Item_subselect got 'eliminated' attribute. It is used only to determine if the subselect should be printed by EXPLAIN. - Item_subselect got List<Item> refers_to - a list of item in the current select that are referred to from within the subselect. - Added Item_*::check_column_usage_processor(). it allows to check which key parts a condition depends on. sql/item_sum.cc: MWL#17: Table elimination sql/sql_lex.cc: MWL#17: Table elimination sql/sql_lex.h: MWL#17: Table elimination sql/sql_select.h: MWL#17: Table elimination
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 010e4cb441a..d317b16a264 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1915,6 +1915,30 @@ void Item_field::reset_field(Field *f)
name= (char*) f->field_name;
}
+bool Item_field::check_column_usage_processor(uchar *arg)
+{
+ Field_processor_info* info=(Field_processor_info*)arg;
+ if (used_tables() & ~info->allowed_tables)
+ return FALSE;
+
+ if (field->table == info->table)
+ {
+ if (!(field->part_of_key.is_set(info->keyno)))
+ return TRUE;
+
+ KEY *key= &field->table->key_info[info->keyno];
+ for (uint part= 0; part < key->key_parts; part++)
+ {
+ if (field->field_index == key->key_part[part].field->field_index)
+ {
+ info->needed_key_parts |= key_part_map(1) << part;
+ break;
+ }
+ }
+ }
+ return FALSE;
+}
+
const char *Item_ident::full_name() const
{
char *tmp;
@@ -3380,7 +3404,7 @@ static void mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
/* store pointer on SELECT_LEX from which item is dependent */
if (mark_item)
mark_item->depended_from= last;
- current->mark_as_dependent(last);
+ current->mark_as_dependent(last, resolved_item);
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
char warn_buff[MYSQL_ERRMSG_SIZE];