summaryrefslogtreecommitdiff
path: root/sql/sql_statistics.cc
Commit message (Collapse)AuthorAgeFilesLines
* cleanup: hide HA_ERR_RECORD_DELETED in ha_rnd_next()Sergei Golubchik2018-05-121-4/+0
| | | | | it's internal storage engine error, don't let it leak into the upper layer.
* Merge branch '10.2' into 10.3Sergei Golubchik2018-05-111-2/+2
|\
| * Merge branch '10.1' into 10.2Sergei Golubchik2018-05-101-2/+2
| |\
| | * ASAN error in is_stat_table()Sergei Golubchik2018-05-051-2/+2
| | | | | | | | | | | | | | | | | | | | | don't memcmp beyond the first argument's end Also: use my_strcasecmp(table_alias_charset), like elsewhere, not memcmp
* | | Merge 10.2 into 10.3Marko Mäkelä2018-04-241-1/+1
|\ \ \ | |/ /
| * | Merge 10.1 into 10.2Marko Mäkelä2018-04-241-1/+1
| |\ \ | | |/
| | * Merge 10.0 into 10.1Marko Mäkelä2018-04-241-1/+1
| | |\
| | | * ASAN error in main.statistics_index_crash-7362Sergei Golubchik2018-04-171-1/+1
| | | | | | | | | | | | | | | | one cannot do keyread on spatial indexes.
* | | | Merge remote-tracking branch '10.2' into 10.3Vicențiu Ciorbaru2018-04-121-6/+16
|\ \ \ \ | |/ / /
| * | | Merge branch '10.1' into 10.2Vicențiu Ciorbaru2018-04-101-7/+16
| |\ \ \ | | |/ /
| | * | Merge branch '10.0' into 10.1Vicențiu Ciorbaru2018-04-071-7/+16
| | |\ \ | | | |/
| | | * MDEV-9744: session optimizer_use_condition_selectivity=5 causing SQL Error ↵Varun Gupta2018-04-021-6/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (1918): Encountered illegal value '' when converting to DECIMAL The issue was that EITS data was allocated but then not read for some reason (one being to avoid a deadlock), then the optimizer was using these bzero'ed buffers as EITS statistics. This should not be allowed, we should use statistcs for a table only when we have successfully loaded/read the stats from the statistical tables.
* | | | Change C_STRING_WITH_LEN to STRING_WITH_LENMonty2018-01-301-47/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This preserves const str for constant strings Other things - A few variables where changed from LEX_STRING to LEX_CSTRING - Incident_log_event::Incident_log_event and record_incident where changed to take LEX_CSTRING* as an argument instead of LEX_STRING
* | | | Changed database, tablename and alias to be LEX_CSTRINGMonty2018-01-301-42/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was done in, among other things: - thd->db and thd->db_length - TABLE_LIST tablename, db, alias and schema_name - Audit plugin database name - lex->db - All db and table names in Alter_table_ctx - st_select_lex db Other things: - Changed a lot of functions to take const LEX_CSTRING* as argument for db, table_name and alias. See init_one_table() as an example. - Changed some function arguments from LEX_CSTRING to const LEX_CSTRING - Changed some lists from LEX_STRING to LEX_CSTRING - threads_mysql.result changed because process list_db wasn't always correctly updated - New append_identifier() function that takes LEX_CSTRING* as arguments - Added new element tmp_buff to Alter_table_ctx to separate temp name handling from temporary space - Ensure we store the length after my_casedn_str() of table/db names - Removed not used version of rename_table_in_stat_tables() - Changed Natural_join_column::table_name and db_name() to never return NULL (used for print) - thd->get_db() now returns db as a printable string (thd->db.str or "")
* | | | Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3Alexander Barkov2017-10-301-10/+10
|\ \ \ \ | | | | | | | | | | | | | | | TODO: enable MDEV-13049 optimization for 10.3
| * \ \ \ Merge remote-tracking branch 'origin/10.2' into bb-10.2-extAlexander Barkov2017-10-181-10/+10
| |\ \ \ \ | | |/ / /
| | * | | Windows : Fix truncation warnings in sql/Vladislav Vaintroub2017-10-101-10/+10
| | | | |
* | | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-10-041-1/+4
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.2 into bb-10.2-extMarko Mäkelä2017-10-031-1/+4
| |\ \ \ \ | | |/ / /
| | * | | Avoid using HA_POS_ERROR constant when passing around values of type double.Sergei Petrunia2017-10-031-1/+4
| | | | | | | | | | | | | | | | | | | | This is error-prone and causes warnings on Windows
* | | | | Give asserts if update_stats() fails.Monty2017-09-081-1/+7
| | | | | | | | | | | | | | | | | | | | This is done to help find where the error is if stat_tables_par.test fails
* | | | | Changed KEY names to use LEX_CSTRINGMichael Widenius2017-08-241-2/+2
| | | | |
* | | | | Enusure that my_global.h is included firstMichael Widenius2017-08-241-1/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added sql/mariadb.h file that should be included first by files in sql directory, if sql_plugin.h is not used (sql_plugin.h adds SHOW variables that must be done before my_global.h is included) - Removed a lot of include my_global.h from include files - Removed include's of some files that my_global.h automatically includes - Removed duplicated include's of my_sys.h - Replaced include my_config.h with my_global.h
* | | | Changing field::field_name and Item::name to LEX_CSTRINGMonty2017-04-231-21/+20
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Benefits of this patch: - Removed a lot of calls to strlen(), especially for field_string - Strings generated by parser are now const strings, less chance of accidently changing a string - Removed a lot of calls with LEX_STRING as parameter (changed to pointer) - More uniform code - Item::name_length was not kept up to date. Now fixed - Several bugs found and fixed (Access to null pointers, access of freed memory, wrong arguments to printf like functions) - Removed a lot of casts from (const char*) to (char*) Changes: - This caused some ABI changes - lex_string_set now uses LEX_CSTRING - Some fucntions are now taking const char* instead of char* - Create_field::change and after changed to LEX_CSTRING - handler::connect_string, comment and engine_name() changed to LEX_CSTRING - Checked printf() related calls to find bugs. Found and fixed several errors in old code. - A lot of changes from LEX_STRING to LEX_CSTRING, especially related to parsing and events. - Some changes from LEX_STRING and LEX_STRING & to LEX_CSTRING* - Some changes for char* to const char* - Added printf argument checking for my_snprintf() - Introduced null_clex_str, star_clex_string, temp_lex_str to simplify code - Added item_empty_name and item_used_name to be able to distingush between items that was given an empty name and items that was not given a name This is used in sql_yacc.yy to know when to give an item a name. - select table_name."*' is not anymore same as table_name.* - removed not used function Item::rename() - Added comparision of item->name_length before some calls to my_strcasecmp() to speed up comparison - Moved Item_sp_variable::make_field() from item.h to item.cc - Some minimal code changes to avoid copying to const char * - Fixed wrong error message in wsrep_mysql_parse() - Fixed wrong code in find_field_in_natural_join() where real_item() was set when it shouldn't - ER_ERROR_ON_RENAME was used with extra arguments. - Removed some (wrong) ER_OUTOFMEMORY, as alloc_root will already give the error. TODO: - Check possible unsafe casts in plugin/auth_examples/qa_auth_interface.c - Change code to not modify LEX_CSTRING for database name (as part of lower_case_table_names)
* | | Merge branch '10.1' into 10.2Sergei Golubchik2017-03-301-1/+1
|\ \ \ | |/ /
| * | Correct FSF addressiangilfillan2017-03-101-1/+1
| | |
* | | cleanup: handler::key_readSergei Golubchik2017-02-131-2/+1
| | | | | | | | | | | | | | | | | | * rename to "keyread" (to avoid conflicts with tokudb), * change from bool to uint and store the keyread index number there * provide a bool accessor to check if keyread is enabled
* | | MDEV-11836 vcol.vcol_keys_myisam fails in buildbot and outsideSergei Golubchik2017-02-131-3/+2
| | | | | | | | | | | | | | | | | | | | | move TABLE::key_read into handler. Because in index merge and DS-MRR there can be many handlers per table, and some of them use key read while others don't. "keyread" is really per handler, not per TABLE property.
* | | Merge branch '10.1' into 10.2Sergei Golubchik2016-12-291-23/+149
|\ \ \ | |/ /
| * | MDEV-10435 crash with bad stat tables.Alexey Botchkov2016-12-091-12/+145
| | | | | | | | | | | | | | | | | | | | | | | | Functions from sql/statistics.cc don't seem to expect stat tables to fail or to have inadequate structure. Table open errors suppressed and some validity checks added. Invalid tables reported to the server log.
| * | MDEV-10957: Assertion failure when dropping a myisam table with ↵Nirbhay Choubey2016-11-021-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | wsrep_replicate_myisam enabled Internal updates to system statistical tables could wrongly trigger an additional total-order replication if wsrep_repli -cate_myisam is enabled. Fixed by adding a check to skip total-order replication for stat tables. Test: galera.galera_var_replicate_myisam_on
| * | Merge branch '10.0-galera' into 10.1Sergei Golubchik2016-11-021-11/+4
| |\ \ | | |/
| | * Fixed bug mdev-11096.Igor Babaev2016-10-261-11/+4
| | | | | | | | | | | | | | | | | | | | | | | | 1. When min/max value is provided the null flag for it must be set to 0 in the bitmap Culumn_statistics::column_stat_nulls. 2. When the calculation of the selectivity of the range condition over a column requires min and max values for the column then we have to check that these values are provided.
* | | MDEV-10957: Assertion failure when dropping a myisam tableNirbhay Choubey2016-12-191-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... with wsrep_replicate_myisam enabled Internal updates to system statistical tables could wrongly trigger an additional total-order replication if wsrep_repli -cate_myisam is enabled. Fixed by adding a check to skip total-order replication for stat tables.
* | | cleanup: avoid Field::field_indexSergei Golubchik2016-12-121-2/+2
| | | | | | | | | | | | prefer x->field over table->field[x->field->field_index]
* | | Merge branch '10.1' into 10.2Sergei Golubchik2016-06-301-0/+9
|\ \ \ | |/ /
| * | Merge branch '10.0' into 10.1Sergei Golubchik2016-06-281-0/+9
| |\ \ | | |/
| | * MDEV-8633: information_schema.index_statistics doesn't deleteJan Lindström2016-06-201-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | item when drop table indexes or drop table; Problem was that table and index statistics is removed from persistent tables but not from memory cache. Added functions to remove table and index statistics from memory cache.
* | | Removed TABLE->sort to make it possible to have multiple active calls toMonty2016-03-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | filesort and init_read_record() for the same table. This will simplify code for WINDOW FUNCTIONS (MDEV-6115) - Filesort_info renamed to SORT_INFO and moved to filesort.h - filesort now returns SORT_INFO - init_read_record() now takes a SORT_INFO parameter. - unique declaration is moved to uniques.h - subselect caching of buffers is now more explicit than before - filesort_buffer is now reusable even if rec_length has changed. - filsort_free_buffers() and free_io_cache() calls are removed - Remove one malloc() when using get_addon_fields() Other things: - Added --debug-assert-on-not-freed-memory option to make it easier to debug some not-freed-memory issues.
* | | MDEV-8715 - Obsolete sql_alloc() in favor of THD::alloc() and thd_alloc()Sergey Vojtovich2015-11-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following left in semi-improved state to keep patch size reasonable: - Field operator new: left thd_alloc(current_thd) - Sql_alloc operator new: left thd_alloc(thd_get_current_thd()) - Item_args constructors: left thd_alloc(thd) - Item_func_interval::fix_length_and_dec(): no THD arg, have to call current_thd - Item_func_dyncol_exists::val_int(): same - Item_dyncol_get::val_str(): same - Item_dyncol_get::val_int(): same - Item_dyncol_get::val_real(): same - Item_dyncol_get::val_decimal(): same - Item_singlerow_subselect::fix_length_and_dec(): same
* | | MDEV-8716 - Obsolete sql_calloc() in favor of THD::calloc() and thd_calloc()Sergey Vojtovich2015-11-261-3/+4
|/ /
* | Merge branch '10.0' into 10.1Sergei Golubchik2015-11-191-10/+132
|\ \ | |/
| * MDEV-7370: Server deadlocks on renaming a table for which persistent ↵Sergei Petrunia2015-11-181-2/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | statistics exists RENAME TABLE code tries to update EITS statistics. It hung, because it used an index on (db_name,table_name) to find the table, and attempted to update these values at the same time. The fix is do what SQL UPDATE statement does when updating index that it's used for scanning: - First, buffer the rowids of rows to be updated, - then make the second pass to actually update the rows Also fixed the call to rename_table_in_stat_tables() in sql_rename.cc to pass the correct new database (before, it passed old db_name so cross- database renames were not handled correctly). Variant #2, with review feedback addressed.
| * MDEV#7383: engine-independent-stats column_stats has limited values for ↵Sergei Petrunia2015-11-091-8/+8
| | | | | | | | | | | | | | | | | | | | max/min values Patch from Daniel Black: - Change the charset of mysql.column_stats.{min_value, max_value} from utf8_bin varchar to varbinary - Adjust the code that saves/reads the data accordingly. - Also provide upgrade statement in mysql_system_tables_fix.sql
* | MDEV-6650 - LINT_INIT emits code in non-debug buildsSergey Vojtovich2015-03-161-1/+1
|/ | | | | Replaced all references to LINT_INIT with UNINIT_VAR and LINT_INIT_STRUCT. Removed LINT_INIT macro.
* MDEV-7362: ANALYZE TABLES crash with table-independent-statistics gatheringVicențiu Ciorbaru2015-01-171-2/+8
| | | | | | | | | | | FULLTEXT indexes do not permit index first lookups. By calling: ha_index_first() with a garbage parameter, random data gets overwritten that causes the table->field array to be corrupted. Subsequently, when the field array is accessed, a segfault occurs. By not allowing index statistics for FULLTEXT indexes, the problem is resolved.
* MDEV-7087 main.stat_tables-enospc fails in buildbot on a valgrind buildSergei Golubchik2014-11-181-0/+2
| | | | | | when reading data into the record buffer, the tail of the VARCHAR (between real and max varchar length) is not written to. initialize the record buffer to avoid writing uninitialized memory to disk.
* Fixed bug mdev-6843.Igor Babaev2014-10-281-1/+6
| | | | | | The function get_column_range_cardinality() returned a wrong result for any column containing only null values.
* MDEV-6738: use_stat_table + histograms crashing optimizerSergey Petrunya2014-10-101-3/+3
| | | | | | - When EITS code calls store_key_image_to_rec(), it should follow its calling convention (which is counter-intuitive)
* MDEV-6442: Assertion `join->best_read < double(...)' failed with ↵Sergey Petrunya2014-10-061-1/+15
| | | | | | | | | | | | | optimizer_use_condition_selectivity >=3 - Fix the crash by making get_column_range_cardinality() to handle the special case where Column_stats objects is an all-zeros object (the question of what is the point of having Field::read_stats point to such object remains a mystery) - Added a few comments. Learning the code still.