summaryrefslogtreecommitdiff
path: root/sql/table.h
diff options
context:
space:
mode:
authormhansson/martin@linux-st28.site <>2007-01-29 15:07:11 +0100
committermhansson/martin@linux-st28.site <>2007-01-29 15:07:11 +0100
commit6d7a6097426ae90ee99aa4b5a65085057ba95204 (patch)
tree095a56104c6851c2cc0302f9706e589365bf5539 /sql/table.h
parent8a3592d4e2c621aa9bac7886a32a0c9a5159d00f (diff)
downloadmariadb-git-6d7a6097426ae90ee99aa4b5a65085057ba95204.tar.gz
BUG#20604: FORCE INDEX uses keys disabled by ALTER TABLE
The function that checks whether we can use keys for aggregates, find_key_for_maxmin(), assumes that keys disabled by ALTER TABLE ... DISABLE KEYS are not in the set table->keys_in_use_for_query. I.E., if a key is in this set, the optimizer assumes it is free to use it. The bug is that keys disabled with ALTER TABLE ... DISABLE KEYS still appear in table->keys_in_use_for_query When the TABLE object has been initialized with setup_tables(). Before setup_tables is called, however, keys that are disabled in the aforementioned way are not included in TABLE::keys_in_use_for_query. The provided patch changes the code that updates keys_is_use_for_query so that it assumes that keys_is_use_for_query already takes into account all disabled keys, and generally all keys that should be used by the query.
Diffstat (limited to 'sql/table.h')
-rw-r--r--sql/table.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/sql/table.h b/sql/table.h
index 82083d79570..3c9f2cac164 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -158,7 +158,12 @@ typedef struct st_table_share
LEX_STRING path; /* Path to .frm file (from datadir) */
LEX_STRING normalized_path; /* unpack_filename(path) */
LEX_STRING connect_string;
- key_map keys_in_use; /* Keys in use for table */
+
+ /*
+ Set of keys in use, implemented as a Bitmap.
+ Excludes keys disabled by ALTER TABLE ... DISABLE KEYS.
+ */
+ key_map keys_in_use;
key_map keys_for_keyread;
ha_rows min_rows, max_rows; /* create information */
ulong avg_row_length; /* create information */
@@ -313,7 +318,21 @@ struct st_table {
byte *write_row_record; /* Used as optimisation in
THD::write_row */
byte *insert_values; /* used by INSERT ... UPDATE */
- key_map quick_keys, used_keys, keys_in_use_for_query, merge_keys;
+ key_map quick_keys, used_keys;
+
+ /*
+ A set of keys that can be used in the query that references this
+ table
+
+ All indexes disabled on the table's TABLE_SHARE (see TABLE::s) will be
+ subtracted from this set upon instantiation. Thus for any TABLE t it holds
+ that t.keys_in_use_for_query is a subset of t.s.keys_in_use. Generally we
+ must not introduce any new keys here (see setup_tables).
+
+ The set is implemented as a bitmap.
+ */
+ key_map keys_in_use_for_query;
+ key_map merge_keys;
KEY *key_info; /* data of keys in database */
Field *next_number_field; /* Set if next_number is activated */