diff options
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sql/field.cc b/sql/field.cc index 1887a87f044..c4cf5a8b152 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9902,3 +9902,27 @@ void Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, set_warning(level, code, cuted_increment)) make_truncated_value_warning(thd, level, str, ts_type, field_name); } + + +/* + @brief + Return possible keys for a field + + @details + Return bit map of keys over this field which can be used by the range + optimizer. For a field of a generic table such keys are all keys that starts + from this field. For a field of a materialized derived table/view such keys + are all keys in which this field takes a part. This is less restrictive as + keys for a materialized derived table/view are generated on the fly from + present fields, thus the case when a field for the beginning of a key is + absent is impossible. + + @return map of possible keys +*/ + +key_map Field::get_possible_keys() +{ + DBUG_ASSERT(table->pos_in_table_list); + return (table->pos_in_table_list->is_materialized_derived() ? + part_of_key : key_start); +} |