diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-05-23 10:32:21 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-05-23 10:32:21 +0300 |
commit | 826f9d4f7e99973cafe7654697d7c50b8b64b76b (patch) | |
tree | 8e41c3a90d40c21c37fcbd0658afe7d349865540 /sql/sql_statistics.cc | |
parent | e5d71e0b3d3ebd4e69526002720f93d62a3fd641 (diff) | |
parent | 31fe70290c54c44231aed881f5138924f32e47c5 (diff) | |
download | mariadb-git-826f9d4f7e99973cafe7654697d7c50b8b64b76b.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'sql/sql_statistics.cc')
-rw-r--r-- | sql/sql_statistics.cc | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index e4cc00f45ba..5c8d85c2cc1 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file @@ -2229,6 +2229,9 @@ inline bool statistics_for_command_is_needed(THD *thd) case SQLCOM_DELETE_MULTI: case SQLCOM_REPLACE: case SQLCOM_REPLACE_SELECT: + case SQLCOM_CREATE_TABLE: + case SQLCOM_SET_OPTION: + case SQLCOM_DO: break; default: return FALSE; @@ -3369,12 +3372,13 @@ int read_statistics_for_tables_if_needed(THD *thd, TABLE_LIST *tables) if (table_share->stats_cb.stats_is_read) tl->table->stats_is_read= TRUE; if (thd->variables.optimizer_use_condition_selectivity > 3 && - table_share && !table_share->stats_cb.histograms_are_read) + table_share && table_share->stats_cb.stats_can_be_read && + !table_share->stats_cb.histograms_are_read) { (void) read_histograms_for_table(thd, tl->table, stat_tables); table_share->stats_cb.histograms_are_read= TRUE; } - if (table_share->stats_cb.stats_is_read) + if (table_share->stats_cb.histograms_are_read) tl->table->histograms_are_read= TRUE; } } @@ -4144,6 +4148,14 @@ bool is_stat_table(const LEX_CSTRING *db, LEX_CSTRING *table) bool is_eits_usable(Field *field) { + Column_statistics* col_stats= field->read_stats; + + // check if column_statistics was allocated for this field + if (!col_stats) + return false; + + DBUG_ASSERT(field->table->stats_is_read); + /* (1): checks if we have EITS statistics for a particular column (2): Don't use EITS for GEOMETRY columns @@ -4151,12 +4163,9 @@ bool is_eits_usable(Field *field) partition list of a table. We assume the selecticivity for such columns would be handled during partition pruning. */ -#if 0 /* Work around MDEV-19334 */ - DBUG_ASSERT(field->table->stats_is_read); -#endif - Column_statistics* col_stats= field->read_stats; - return col_stats && !col_stats->no_stat_values_provided() && //(1) - field->type() != MYSQL_TYPE_GEOMETRY && //(2) + + return !col_stats->no_stat_values_provided() && //(1) + field->type() != MYSQL_TYPE_GEOMETRY && //(2) #ifdef WITH_PARTITION_STORAGE_ENGINE (!field->table->part_info || !field->table->part_info->field_in_partition_expr(field)) && //(3) |