summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
authorunknown <dlenev@brandersnatch.localdomain>2004-03-31 21:25:55 +0400
committerunknown <dlenev@brandersnatch.localdomain>2004-03-31 21:25:55 +0400
commitd2906f0ed07bc06161d749d03ffa8acb7c09c785 (patch)
tree526682a26c471951e15c895db2723ad065b5690c /sql/item.h
parentf6a8ec5f925ec7d37d2858c5799b7a91a95accca (diff)
downloadmariadb-git-d2906f0ed07bc06161d749d03ffa8acb7c09c785.tar.gz
Fix for Bug #3307 "FLUSH TABLES sometimes breaks prepared statement
table resolution". Added members to Item_ident for storing original db, table and field names since those that set later from Field have shorter life-time than required by prep. stmt. So we need to restore original names in Item_ident::cleanup(). Also now using special construnctor for creation of Item_field from Field object that ensures that table and field name have big enough life-time. "Fix" for bug #2050 "10 to 1 performance drop with server 4.1.1" Clean ups in implementation of caching of field number in table. Added caching of table in which field is found in find_field_in_tables(). sql/item.cc: Added members to Item_ident for storing original db, table and field names since those that set later from Field have shorter life-time than required by prep. stmt. So we need to restore original names in Item_ident::cleanup(). Added Item_ident::cached_table for caching table there we found our field. Added special constructor for creation of Item_field from Field object that ensures that table and field name have big enough life-time. sql/item.h: Added members to Item_ident for storing original db, table and field names since those that set later from Field have shorter life-time than required by prep. stmt. So we need to restore original names in Item_ident::cleanup(). Changed type of Item_ident::cached_field_index from int to uint (and so NO_CACHED_FIELD_INDEX is UINT_MAX now) because we want to save one comparison in find_field_in_table(). Added Item_ident::cached_table for caching table there we found our field. Added special constructor for creation of Item_field from Field object that ensures that table and field name have big enough life-time. sql/mysql_priv.h: Changed type of cached_field_index_ptr from int* to uint* (and so NO_CACHED_FIELD_INDEX is UINT_MAX now) because we want to save one comparison in find_field_in_table(). sql/sql_acl.cc: Changed type of find_field_in_table() paremeter to make it faster. sql/sql_base.cc: find_field_in_table(): small optimization and soime clean ups in caching of field index. find_field_in_tables(): added aggresive caching of table in which field is found in Item_ident::cached_table. insert_fields(): using special construnctor for creation of Item_field from Field object that ensures that table and field name have big enough life-time.
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/sql/item.h b/sql/item.h
index fccdd7f0732..faee51af97e 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -253,10 +253,20 @@ public:
virtual Item_num* neg()= 0;
};
+#define NO_CACHED_FIELD_INDEX ((uint)(-1))
class st_select_lex;
class Item_ident :public Item
{
+ /*
+ We have to store initial values of db_name, table_name and field_name
+ to be able to restore them during cleanup() because they can be
+ updated during fix_fields() to values from Field object and life-time
+ of those is shorter than life-time of Item_field.
+ */
+ const char *orig_db_name;
+ const char *orig_table_name;
+ const char *orig_field_name;
Item **changed_during_fix_field;
public:
const char *db_name;
@@ -264,9 +274,16 @@ public:
const char *field_name;
/*
Cached value of index for this field in table->field array, used by prep.
- stmts for speeding up their re-execution, -1 if index value is not known.
+ stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX
+ if index value is not known.
+ */
+ uint cached_field_index;
+ /*
+ Cached pointer to table which contains this field, used for the same reason
+ by prep. stmt. too in case then we have not-fully qualified field.
+ 0 - means no cached value.
*/
- int cached_field_index;
+ TABLE_LIST *cached_table;
st_select_lex *depended_from;
Item_ident(const char *db_name_par,const char *table_name_par,
const char *field_name_par);
@@ -298,6 +315,11 @@ public:
{ collation.set(DERIVATION_IMPLICIT); }
// Constructor need to process subselect with temporary tables (see Item)
Item_field(THD *thd, Item_field *item);
+ /*
+ Constructor used inside setup_wild(), ensures that field and table
+ names will live as long as Item_field (important in prep. stmt.)
+ */
+ Item_field(THD *thd, Field *field);
Item_field(Field *field);
enum Type type() const { return FIELD_ITEM; }
bool eq(const Item *item, bool binary_cmp) const;