diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2021-02-25 19:59:51 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2021-03-04 22:50:00 +0530 |
commit | f691d9865becfd242ba44cc632034433336af1e7 (patch) | |
tree | 8d30254398f114e7b61d3ecfbcb328e45ec3b946 /sql/handler.h | |
parent | 71d30d01aa1426183526f9bdbc6d2a718fac75ac (diff) | |
download | mariadb-git-f691d9865becfd242ba44cc632034433336af1e7.tar.gz |
MDEV-7317: Make an index ignorable to the optimizer
This feature adds the functionality of ignorability for indexes.
Indexes are not ignored be default.
To control index ignorability explicitly for a new index,
use IGNORE or NOT IGNORE as part of the index definition for
CREATE TABLE, CREATE INDEX, or ALTER TABLE.
Primary keys (explicit or implicit) cannot be made ignorable.
The table INFORMATION_SCHEMA.STATISTICS get a new column named IGNORED that
would store whether an index needs to be ignored or not.
Diffstat (limited to 'sql/handler.h')
-rw-r--r-- | sql/handler.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sql/handler.h b/sql/handler.h index 777a6b455ef..f9b63dd7564 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -781,6 +781,12 @@ typedef bool Log_func(THD*, TABLE*, bool, const uchar*, const uchar*); */ #define ALTER_COLUMN_INDEX_LENGTH (1ULL << 60) + +/** + Means that the ignorability of an index is changed. +*/ +#define ALTER_INDEX_IGNORABILITY (1ULL << 61) + /* Flags set in partition_flags when altering partitions */ @@ -2353,6 +2359,26 @@ struct Table_specification_st: public HA_CREATE_INFO, /** + Structure describing changes to an index to be caused by ALTER TABLE. +*/ + +struct KEY_PAIR +{ + /** + Pointer to KEY object describing old version of index in + TABLE::key_info array for TABLE instance representing old + version of table. + */ + KEY *old_key; + /** + Pointer to KEY object describing new version of index in + Alter_inplace_info::key_info_buffer array. + */ + KEY *new_key; +}; + + +/** In-place alter handler context. This is a superclass intended to be subclassed by individual handlers @@ -2451,6 +2477,11 @@ public: */ uint *index_add_buffer; + KEY_PAIR *index_altered_ignorability_buffer; + + /** Size of index_altered_ignorability_buffer array. */ + uint index_altered_ignorability_count; + /** Old and new index names. Used for index rename. */ @@ -2559,6 +2590,18 @@ public: */ void report_unsupported_error(const char *not_supported, const char *try_instead) const; + void add_altered_index_ignorability(KEY *old_key, KEY *new_key) + { + KEY_PAIR *key_pair= index_altered_ignorability_buffer + + index_altered_ignorability_count++; + key_pair->old_key= old_key; + key_pair->new_key= new_key; + DBUG_PRINT("info", ("index had ignorability altered: %i to %i", + old_key->is_ignored, + new_key->is_ignored)); + } + + }; @@ -2575,6 +2618,7 @@ typedef struct st_key_create_information directly by the user (set by the parser). */ bool check_for_duplicate_indexes; + bool is_ignored; } KEY_CREATE_INFO; |