summaryrefslogtreecommitdiff
path: root/client/mysql.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.11 into 11.0Marko Mäkelä2023-02-161-0/+3
|\
| * Merge branch '10.9' into 10.10Oleksandr Byelkin2023-01-311-0/+3
| |\
| | * Merge branch '10.8' into 10.9Oleksandr Byelkin2023-01-311-0/+3
| | |\
| | | * Merge branch '10.7' into 10.8Oleksandr Byelkin2023-01-311-0/+3
| | | |\
| | | | * Merge branch '10.5' into 10.6Oleksandr Byelkin2023-01-311-0/+3
| | | | |\
| | | | | * Merge branch '10.4' into 10.5Oleksandr Byelkin2023-01-271-0/+3
| | | | | |\
| | | | | | * Merge branch '10.3' into 10.4Oleksandr Byelkin2023-01-261-0/+3
| | | | | | |\
| | | | | | | * Add my_afree after my_alloca in early return caseEric Herman2023-01-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code already had a call to `my_afree` in the normal return case, but failed to do so in the early return case.
* | | | | | | | MDEV-30327 Client crashes in print_last_query_costMonty2023-02-101-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed by calling init_pager() before tee_fprintf()
* | | | | | | | Changing all cost calculation to be given in millisecondsMonty2023-02-021-6/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it easier to compare different costs and also allows the optimizer to optimizer different storage engines more reliably. - Added tests/check_costs.pl, a tool to verify optimizer cost calculations. - Most engine costs has been found with this program. All steps to calculate the new costs are documented in Docs/optimizer_costs.txt - User optimizer_cost variables are given in microseconds (as individual costs can be very small). Internally they are stored in ms. - Changed DISK_READ_COST (was DISK_SEEK_BASE_COST) from a hard disk cost (9 ms) to common SSD cost (400MB/sec). - Removed cost calculations for hard disks (rotation etc). - Changed the following handler functions to return IO_AND_CPU_COST. This makes it easy to apply different cost modifiers in ha_..time() functions for io and cpu costs. - scan_time() - rnd_pos_time() & rnd_pos_call_time() - keyread_time() - Enhanched keyread_time() to calculate the full cost of reading of a set of keys with a given number of ranges and optional number of blocks that need to be accessed. - Removed read_time() as keyread_time() + rnd_pos_time() can do the same thing and more. - Tuned cost for: heap, myisam, Aria, InnoDB, archive and MyRocks. Used heap table costs for json_table. The rest are using default engine costs. - Added the following new optimizer variables: - optimizer_disk_read_ratio - optimizer_disk_read_cost - optimizer_key_lookup_cost - optimizer_row_lookup_cost - optimizer_row_next_find_cost - optimizer_scan_cost - Moved all engine specific cost to OPTIMIZER_COSTS structure. - Changed costs to use 'records_out' instead of 'records_read' when recalculating costs. - Split optimizer_costs.h to optimizer_costs.h and optimizer_defaults.h. This allows one to change costs without having to compile a lot of files. - Updated costs for filter lookup. - Use a better cost estimate in best_extension_by_limited_search() for the sorting cost. - Fixed previous issues with 'filtered' explain column as we are now using 'records_out' (min rows seen for table) to calculate filtering. This greatly simplifies the filtering code in JOIN_TAB::save_explain_data(). This change caused a lot of queries to be optimized differently than before, which exposed different issues in the optimizer that needs to be fixed. These fixes are in the following commits. To not have to change the same test case over and over again, the changes in the test cases are done in a single commit after all the critical change sets are done. InnoDB changes: - Updated InnoDB to not divide big range cost with 2. - Added cost for InnoDB (innobase_update_optimizer_costs()). - Don't mark clustered primary key with HA_KEYREAD_ONLY. This will prevent that the optimizer is trying to use index-only scans on the clustered key. - Disabled ha_innobase::scan_time() and ha_innobase::read_time() and ha_innobase::rnd_pos_time() as the default engine cost functions now works good for InnoDB. Other things: - Added --show-query-costs (\Q) option to mysql.cc to show the query cost after each query (good when working with query costs). - Extended my_getopt with GET_ADJUSTED_VALUE which allows one to adjust the value that user is given. This is used to change cost from microseconds (user input) to milliseconds (what the server is internally using). - Added include/my_tracker.h ; Useful include file to quickly test costs of a function. - Use handler::set_table() in all places instead of 'table= arg'. - Added SHOW_OPTIMIZER_COSTS to sys variables. These are input and shown in microseconds for the user but stored as milliseconds. This is to make the numbers easier to read for the user (less pre-zeros). Implemented in 'Sys_var_optimizer_cost' class. - In test_quick_select() do not use index scans if 'no_keyread' is set for the table. This is what we do in other places of the server. - Added THD parameter to Unique::get_use_cost() and check_index_intersect_extension() and similar functions to be able to provide costs to called functions. - Changed 'records' to 'rows' in optimizer_trace. - Write more information to optimizer_trace. - Added INDEX_BLOCK_FILL_FACTOR_MUL (4) and INDEX_BLOCK_FILL_FACTOR_DIV (3) to calculate usage space of keys in b-trees. (Before we used numeric constants). - Removed code that assumed that b-trees has similar costs as binary trees. Replaced with engine calls that returns the cost. - Added Bitmap::find_first_bit() - Added timings to join_cache for ANALYZE table (patch by Sergei Petrunia). - Added records_init and records_after_filter to POSITION to remember more of what best_access_patch() calculates. - table_after_join_selectivity() changed to recalculate 'records_out' based on the new fields from best_access_patch() Bug fixes: - Some queries did not update last_query_cost (was 0). Fixed by moving setting thd->...last_query_cost in JOIN::optimize(). - Write '0' as number of rows for const tables with a matching row. Some internals: - Engine cost are stored in OPTIMIZER_COSTS structure. When a handlerton is created, we also created a new cost variable for the handlerton. We also create a new variable if the user changes a optimizer cost for a not yet loaded handlerton either with command line arguments or with SET @@global.engine.optimizer_cost_variable=xx. - There are 3 global OPTIMIZER_COSTS variables: default_optimizer_costs The default costs + changes from the command line without an engine specifier. heap_optimizer_costs Heap table costs, used for temporary tables tmp_table_optimizer_costs The cost for the default on disk internal temporary table (MyISAM or Aria) - The engine cost for a table is stored in table_share. To speed up accesses the handler has a pointer to this. The cost is copied to the table on first access. If one wants to change the cost one must first update the global engine cost and then do a FLUSH TABLES. This was done to be able to access the costs for an open table without any locks. - When a handlerton is created, the cost are updated the following way: See sql/keycaches.cc for details: - Use 'default_optimizer_costs' as a base - Call hton->update_optimizer_costs() to override with the engines default costs. - Override the costs that the user has specified for the engine. - One handler open, copy the engine cost from handlerton to TABLE_SHARE. - Call handler::update_optimizer_costs() to allow the engine to update cost for this particular table. - There are two costs stored in THD. These are copied to the handler when the table is used in a query: - optimizer_where_cost - optimizer_scan_setup_cost - Simply code in best_access_path() by storing all cost result in a structure. (Idea/Suggestion by Igor)
* | | | | | | | MDEV-26548: replace .mysql_history with .mariadb_historyDaniel Black2023-01-241-13/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fall back to using .mysql_history if .mariadb_history isn't present and .mysql_history is present. Also replace the use of MYSQL_HISTFILE as an environment variable with MARIADB_HISTFILE and fall back to using MYSQL_HISTFILE if MARIADB_HISTFILE isn't present.
* | | | | | | | MDEV-30153 ad hoc client versions are confusingSergei Golubchik2023-01-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | try to make them less confusing for users. Hopefully, if the version string will be changed like - mariadb Ver 15.1 Distrib 10.11.2-MariaDB for Linux (x86_64) + mariadb from 10.11.2-MariaDB, client 15.1 for Linux (x86_64) users will be less inclined to reply "15.1" to the question "what mariadb version are you using?"
* | | | | | | | unify client/tool version stringSergei Golubchik2023-01-191-2/+2
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | it should now always be /path/to/exe Ver <tool version> Distrib <server version> for <OS> (<ARCH>) in all tools and clients
* | | | | | | Merge branch '10.9' into 10.10Oleksandr Byelkin2022-08-101-1/+1
|\ \ \ \ \ \ \ | |/ / / / / /
| * | | | | | Merge branch '10.8' into 10.9mariadb-10.9.2Oleksandr Byelkin2022-08-101-1/+1
| |\ \ \ \ \ \ | | |/ / / / /
| | * | | | | Merge branch '10.7' into 10.8mariadb-10.8.4Oleksandr Byelkin2022-08-101-1/+1
| | |\ \ \ \ \ | | | |/ / / /
| | | * | | | Merge branch '10.5' into 10.6Oleksandr Byelkin2022-08-101-1/+1
| | | |\ \ \ \ | | | | |/ / /
| | | | * | | Merge branch '10.4' into 10.5mariadb-10.5.17Oleksandr Byelkin2022-08-101-1/+1
| | | | |\ \ \ | | | | | |/ /
| | | | | * | Merge branch '10.3' into bb-10.4-releasemariadb-10.4.26Oleksandr Byelkin2022-08-101-1/+1
| | | | | |\ \ | | | | | | |/
| | | | | | * Fix typos in the codebase.fluesvamp2022-08-091-1/+1
| | | | | | |
* | | | | | | don't use ssl for windows named pipes - it doesn't workSergei Golubchik2022-07-281-1/+1
|/ / / / / /
* | | | | | Merge 10.8 into 10.9Marko Mäkelä2022-07-281-9/+8
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge 10.7 into 10.8Marko Mäkelä2022-07-281-4/+4
| |\ \ \ \ \ | | |/ / / /
| | * | | | Merge 10.5 into 10.6Marko Mäkelä2022-07-271-4/+4
| | |\ \ \ \ | | | |/ / /
| | | * | | Merge 10.4 into 10.5Marko Mäkelä2022-07-271-4/+4
| | | |\ \ \ | | | | |/ /
| | | | * | Merge branch '10.3' into 10.4Oleksandr Byelkin2022-07-271-4/+4
| | | | |\ \ | | | | | |/
| | | | | * MDEV-28197 Linux mariadb-client build does not accept Unicode charactersSergei Golubchik2022-07-101-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apparently newer libedit is readline-compatible enough to be detected as a readline, with USE_NEW_READLINE_INTERFACE defined and USE_LIBEDIT_INTERFACE not defined. Let's set the locale unconditionally, independently from the readline/libedit variant. It's already happening anyway now, unless one specifies --default-character-set explicitly.
| * | | | | Merge 10.7 into 10.8Marko Mäkelä2022-07-011-5/+4
| |\ \ \ \ \ | | |/ / / /
| | * | | | Merge 10.5 into 10.6Marko Mäkelä2022-07-011-5/+4
| | |\ \ \ \ | | | |/ / /
| | | * | | Merge 10.4 into 10.5Marko Mäkelä2022-07-011-5/+4
| | | |\ \ \ | | | | |/ /
| | | | * | Merge 10.3 into 10.4Marko Mäkelä2022-07-011-5/+4
| | | | |\ \ | | | | | |/
| | | | | * Fix most clang-15 -Wunused-but-set-variableMarko Mäkelä2022-07-011-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, refactor trx_i_s_common_fill_table() to remove dead code. Warnings about yynerrs in Bison-generated yyparse() will remain for now.
* | | | | | Merge 10.8 into 10.9Marko Mäkelä2022-06-071-0/+10
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge 10.7 into 10.8Marko Mäkelä2022-06-061-0/+10
| |\ \ \ \ \ | | |/ / / /
| | * | | | Merge 10.5 into 10.6Marko Mäkelä2022-06-021-0/+10
| | |\ \ \ \ | | | |/ / /
| | | * | | Merge 10.4 into 10.5Marko Mäkelä2022-06-021-0/+10
| | | |\ \ \ | | | | |/ /
| | | | * | Merge 10.3 into 10.4Marko Mäkelä2022-06-021-0/+10
| | | | |\ \ | | | | | |/
| | | | | * Add option --enable-cleartext-plugin to the MariaDB clientTing Nian2022-05-261-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For compatibility reasons, add the option to the MariaDB client without any functional changes besides simply accepting the option and emitting a warning that it is obsolete. In MySQL this security related option is compulsory in certain use cases. When users switch to MariaDB, this client command that used to work starts failing without a sensible error message. In worst case users resort to re-installing the mysql client from MySQL. In MariaDB the option is obsolete and should simply be ignored. Users however don't have any opportunity to learn that unless the client program tells them so. Before: mysql --enable-cleartext-plugin ... mysql: unknown option '--enable-cleartext-plugin' (program terminates) After: mysql --enable-cleartext-plugin ... WARNING: option '--enable-cleartext-plugin' is obsolete. (program executes) All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
* | | | | | MDEV-27743 Remove Lex::charsetAlexander Barkov2022-03-221-1/+4
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch also fixes: MDEV-27690 Crash on `CHARACTER SET csname COLLATE DEFAULT` in column definition MDEV-27853 Wrong data type on column `COLLATE DEFAULT` and table `COLLATE some_non_default_collation` MDEV-28067 Multiple conflicting column COLLATE clauses are not rejected MDEV-28118 Wrong collation of `CAST(.. AS CHAR COLLATE DEFAULT)` MDEV-28119 Wrong column collation on MODIFY + CONVERT
* | | | | Merge branch 'preview-10.8-MDEV-26713-Windows-i18-support' into 10.8bb-10.8-wladVladislav Vaintroub2022-01-181-33/+156
|\ \ \ \ \ | |/ / / / |/| | | |
| * | | | MDEV-26713 allow users with non-UTF8 passwords to login after upgrade.preview-10.8-MDEV-26713-windows-i18-supportVladislav Vaintroub2021-12-151-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Translate username, password and database from UTF8 into desired charset, if non-auto default-character-set was used, on Windows10 1903 This change is implemented only in the command line client, and mainly to allow users with non-UTF8 passwords to login. The user is supposed to use the same charset that was used during setting password (usually, console CP if used in CLI) Add a test to document the behavior.
| * | | | MDEV-26713 set console codepage to what user set in --default-character-setVladislav Vaintroub2021-12-151-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If someone on whatever reasons uses --default-character-set=cp850, this will avoid incorrect display, and inserting incorrect data. Adjusting console codepage sometimes also needs to happen with --default-charset=auto, on older Windows. This is because autodetection is not always exact. For example, console codepage on US editions of Windows is 437. Client autodetects it as cp850, a rather loose approximation, given 46 code point differences. We change the console codepage to cp850, so that there is no discrepancy. That fix is currently Windows-only, and serves people who used combination of chcp to achieve WYSIWYG effect (although, this would mostly likely used with utf8 in the past) Now, --default-character-set would be a replacement for that. Fix fs_character_set() detection of current codepage.
| * | | | MDEV-27090 Windows client - ReadConsoleA does not work correctly with UTF8 ↵Vladislav Vaintroub2021-12-151-33/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | codepage Corresponding Windows bug https://github.com/microsoft/terminal/issues/4551 Use ReadConsoleW instead and convert to console's input codepage, to workaround. Also, disable VT sequences in the console output, as we do not knows what type of data comes with SELECT, we do not want VT escapes there. Remove my_cgets()
| * | | | Revert "MDEV-26713 Windows - improve utf8 support for command line tools"st-10.8-wladVladislav Vaintroub2021-11-191-101/+25
| | | | | | | | | | | | | | | | | | | | This reverts commit several commits pushed by mistake.
| * | | | MDEV-26713 Windows - improve utf8 support for command line toolsVladislav Vaintroub2021-11-181-25/+101
| | | | |
* | | | | Merge 10.5 into 10.6Marko Mäkelä2022-01-041-8/+3
|\ \ \ \ \ | |/ / / / |/| / / / | |/ / /
| * | | Merge branch 10.4 into 10.5st-10.5-juliusJulius Goryavsky2021-12-261-8/+3
| |\ \ \ | | |/ /
| | * | Merge branch 10.3 into 10.4Julius Goryavsky2021-12-251-8/+3
| | |\ \ | | | |/
| | | * Merge branch 10.2 into 10.3Julius Goryavsky2021-12-231-8/+3
| | | |\
| | | | * MDEV-27191 MariaDB client - "system" command does not work on WindowsVladislav Vaintroub2021-12-071-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | - define USE_POPEN, like it is done elsewhere. - use Notepad as default editor on Windows for the "edit" command.