Commit graph

197993 commits

Author SHA1 Message Date
Ian Gilfillan
061ea3f639 Update 11.0 HELP 2023-02-13 18:01:25 +11:00
Daniel Black
9656356b55 MDEV-30203 Move mysql symlinks to different package
For both Deb and RPM, create mariadb-client-compat and
mariadb-server-compat containing the mysql links to the mariadb
named executables/scripts.

The mariadb-client-core mysqlcheck was moved to mariadb-client-compat.

The symlinks in MYSQL_ADD_EXECUTABLE is tagged as a
{Client,Server}Symlinks component and placed in
the symlinks packages.

Man pages are restructured be installed into compat package
if that matches the executable.

Columnstore has a workaround as it doesn't use the cmake/plugin.cmake.

Scripts likewise have compatibility symlinks are in
the {server,client}-compat packages.

Co-author: Andrew Hutchings <andrew@linuxjedi.co.uk>

Closes #2390
2023-02-12 12:15:22 +01:00
Daniel Black
36ea5dffe7 resolve-stack-dump was moved from server to client (RPM)
like where the man page and Debian package put it.
2023-02-12 12:15:22 +01:00
Sergei Golubchik
c6f0814468 more changes to man page handling
* move them from ManPagesX component to X (works better for plugins),
  but keep ManPagesDevelopment as C/C is using it
* move backup manpages to Backup
* move plugin manpages (s3, rocksdb) to plugins
2023-02-12 12:15:22 +01:00
Sergei Golubchik
738d4604b7 cmake: rename backup component to Backup
for consistency
2023-02-12 12:15:22 +01:00
Sergei Golubchik
951b7ab57b cmake: simplify handling of man pages
and remove unused function INSTALL_MANPAGE
2023-02-12 12:15:21 +01:00
Sergei Golubchik
f6c5b57eb3 man pages: mariadb* are primary pages, mysql* are generated 2023-02-12 12:15:21 +01:00
Vicențiu Ciorbaru
c7fba948e1 Fix RPL tests post DEBUG_SYNC change
The tests expect the SIGNAL to not be cleared. Thus set NO_CLEAR_EVENT
within DBUG_EXECUTE_IF
2023-02-10 14:44:45 +02:00
Marko Mäkelä
dbab3e8d90 Merge 10.6 into 10.8 2023-02-10 13:43:53 +02:00
Sergei Petrunia
a7666952e0 MDEV-30569: Assertion ...ha_table_flags() in Duplicate_weedout_picker::check_qep
DuplicateWeedout semi-join optimization requires that the tables in
the parent subquery provide rowids that can be compared across table
scans. Most engines support this, federated is the only exception.

DuplicateWeedout is the default catch-all semi-join strategy, which
must be always available. If it is not available for some edge case,
it's better to disable semi-join conversion altogether.

This is what was done in the fix for MDEV-30395. However that fix
has put the check before the view processing, so it didn't detect
federated tables inside mergeable VIEWs.

This patch moves the check to be done at a later phase, when mergeable
views are already merged.
2023-02-10 13:35:32 +02:00
Sergei Petrunia
d661696636 MDEV-30568: Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost
In get_range_limit_read_cost(), handle the case where range_rows=0.
2023-02-10 13:35:31 +02:00
Sergei Petrunia
cc81ea1cc4 MDEV-30529: Assertion `rnd_records <= s->found_records' failed in best_access_path
best_access_path() has an assertion:

   DBUG_ASSERT(rnd_records <= s->found_records);

make it rounding-safe.
2023-02-10 13:35:31 +02:00
Sergei Petrunia
5faf2ac01b MDEV-30525: Assertion `ranges > 0' fails in IO_AND_CPU_COST handler::keyread_time
Make get_best_group_min_max() exit early if the table has
table->records()=0. Attempting to compute loose scan over 0
groups eventually causes an assert when trying to get the
cost of reading 0 ranges.
2023-02-10 13:35:31 +02:00
Monty
00704aff98 Fixed bug in extended key handling when there is no primary key
Extended keys works by first checking if the engine supports extended
keys.
If yes, it extends secondary key with primary key components and mark the
secondary keys as HA_EXT_NOSAME (unique).
If we later notice that there where no primary key, the extended key
information for secondary keys in share->key_info is reset. However the
key_info->flag HA_EXT_NOSAME was not reset!

This causes some strange things to happen:
- Tables that have no primary key or secondary index that contained the
  primary key would be wrongly optimized as the secondary key could be
  thought to be unique when it was not and not unique when it was.
- The problem was not shown in EXPLAIN because of a bug in
  create_ref_for_key() that caused EQ_REF to be displayed by EXPLAIN as REF
  when extended keys where used and the secondary key contained the primary
  key.

This is fixed with:
- Removed wrong test in make_join_select() which did not detect that key
  where unique when a secondary key contains the primary.
- Moved initialization of extended keys from create_key_infos() to
  init_from_binary_frm_image() after we know if there is a usable primary
  key or not. One disadvantage with this approach is that
  key_info->key_parts may have not used slots (for keys we thought could
  be extended but could not). Fixed by adding a check for unused key_parts
  to copy_keys_from_share().

Other things:
- Simplified copying of first key part in create_key_infos().
- Added a lot of code comments in code that I had to check as part of
  finding the issue.
- Fixed some indentation.
- Replaced a couple of looks using references to pointers in C
  context where the reference does not give any benefit.
- Updated Aria and Maria to not assume the all key_info->rec_per_key
  are in one memory block (this could happen when using dervived
  tables with many keys).
- Fixed a bug where key_info->rec_per_key where not allocated
- Optimized TABLE::add_tmp_key() to only call alloc() once.
  (No logic changes)

Test case changes:
- innodb_mysql.test changed index as an index the optimizer thought
  was unique, was not. (Table had no primary key)

TODO:
- Move code that checks for partial or too long keys to the primary loop
  earlier that initally decides if we should add extended key fields.
  This is needed to ensure that HA_EXT_NOSAME is not set for partial or
  too long keys. It will also shorten the current code notable.
2023-02-10 13:35:31 +02:00
Marko Mäkelä
6aec87544c Merge 10.5 into 10.6 2023-02-10 13:03:01 +02:00
Monty
fe1f4ca8ce MDEV-30486 Table is not eliminated in bb-11.0
Some tables where not eliminated when they could have been.
This was caused because HA_KEYREAD_ONLY is not set anymore for InnoDB
clustered index and the elimination code was depending on
field->part_of_key_not_clustered which was not set if HA_KEYREAD_ONLY
is not present.

Fixed by moving out field->part_of_key and
field->part_of_key_not_clustered from under HA_KEYREAD_ONLY (which
they should never have been part of).

Other things:
- Fixed a bug in make_join_select() that caused range to be used when
  there where elminiated or constant tables present (Caused wrong
  change of plans in join_outer_innodb.test). This also affected
  show_explain.test and subselct_sj_mat.test where wrong 'range's where
  replaced with index scans.

Reviewer: Sergei Petrunia <sergey@mariadb.com>
2023-02-10 12:59:37 +02:00
Monty
01c82173dd Removed /2 of InnoDB ref_per_key[] estimates
The original code was there to favor index search over table scan.
This is not needed anymore as the cost calculations for table scans
and index lookups are now more exact.
2023-02-10 12:59:36 +02:00
Sergei Petrunia
87507bbb4f Optimizer Trace: make plan_prefix not show const/eliminated tables 2023-02-10 12:59:36 +02:00
Sergei Golubchik
2010cfab2a remove GET_ADJUST_VALUE
avoid contaminating my_getopt with sysvar implementation details.
adjust variable values after my_getopt, like it's done for others.
this fixes --help to show correct values.
2023-02-10 12:59:36 +02:00
Sergei Golubchik
d10b3b0169 remove SHOW_OPTIMIZER_COST
avoid contaminating SHOW code with sysvar implementation details.
And no hard-coded factor either.
2023-02-10 12:59:36 +02:00
Sergei Golubchik
affab99c2f remove Feature_into_old_syntax
it doesn't provide any information we'll use.
No matter what the value is, we don't remove the non-standard
syntax unless we have to
2023-02-10 12:59:36 +02:00
Sergei Golubchik
7e465aeb3a typos in comments, etc 2023-02-10 12:59:36 +02:00
Monty
5e5988dbb8 Selectivity: apply found_constraint heuristic only to post-join #rows.
matching_candidates_in_table() computes the number of rows one
gets from the current table after applying the WHERE clause on
just this table

The function had a "found_counstraint heuristic" which reduced the
number of rows after WHERE check by 25% if there were comparisons
between key parts in table T and previous tables, like WHERE
T.keyXpartY= func(prev_table.cols)

Note that such comparisons can only be checked when the row of
table T is joined with rows of the previous tables. It is wrong
to apply the selectivity before the join operation.

Fixed by moving the 'found_constraint' code to a separate function
and only reducing the #rows in 'records_out'.

Renamed matching_candidates_in_table() to apply_selectivity_for_table() as
the function now either applies selectivity on the rows (depending
on the value of thd->variables.optimizer_use_condition_selectivity)
or uses the selectivity from the available range conditions.
2023-02-10 12:59:36 +02:00
Monty
33af691f23 Updated comments in best_access_path() 2023-02-10 12:59:36 +02:00
Monty
0eca91ab75 MDEV-30080 Wrong result with LEFT JOINs involving constant tables
The reason things fails in 10.5 and above is that test_quick_select()
returns -1 (impossible range) for empty tables if there are any
conditions attached.

This didn't happen in 10.4 as the cost for a range was more than for
a table scan with 0 rows and get_key_scan_params() did not create any
range plans and thus did not mark the range as impossible.

The code that checked the 'impossible range' conditions did not take
into account all cases of LEFT JOIN usage.

Adding an extra check if the table is used with an ON condition in case
of 'impossible range' fixes the issue.
2023-02-10 12:59:36 +02:00
Monty
3316a54db3 Code cleanups and add some caching of functions to speed up things
Detailed description:
- Added more function comments and fixed types in some old comments
- Removed an outdated comment
- Cleaned up some functions in records.cc
  - Replaced "while" with "if"
  - Reused error code
  - Made functions similar
- Added caching of pfs_batch_update()
- Simplified some rowid_filter code
  - Only call build_range_rowid_filter() if rowid filter will be used
  - Replaced tab->is_rowid_filter_built with need_to_build_rowid_filter.
    We only have to test need_to_build_rowid_filter to know if we have
    to build the filter. Old code needed two tests
  - Added function 'clear_range_rowid_filter' to disable rowid filter.
    Made things simpler as we can now clear all rowid filter variables
    in one place.
- Removed some 'if' in sub_select()
2023-02-10 12:59:36 +02:00
Monty
65da564530 MDEV-30360 Assertion `cond_selectivity <= 1.000000001' failed in ...
The problem was that make_join_select() called test_quick_select() outside
of best_access_path(). This could use indexes that where not taken into
account before and this caused changes to selectivity and 'records_out'.

Fixed by updating records_out if test_quick_select() was called.
2023-02-10 12:59:24 +02:00
Monty
0a7d291756 MDEV-30328 Assertion `avg_io_cost != 0.0 || index_cost.io + row_cost.io == 0' failed in Cost_estimate::total_cost()
The assert was there to check that engines reports sensible numbers for IO.
However this does not work in case of optimizer_disk_read_ratio=0.

Fixed by removing the assert.
2023-02-10 12:58:50 +02:00
Monty
1a13dbff01 MDEV-30327 Client crashes in print_last_query_cost
Fixed by calling init_pager() before tee_fprintf()
2023-02-10 12:58:50 +02:00
Monty
8d4bccf338 MDEV-30313 Sporadic assertion `cond_selectivity <= 1.0' failure in get_range_limit_read_cost
The bug was related to floating point rounding. Fixed the assert to take
that into account.
2023-02-10 12:58:50 +02:00
Monty
5de734da6b Added sys.optimizer_switch_on() and sys.optimizer_switch_off()
These are helpful tools to quickly see what optimizer switch options
are on or off.  The different options are displayed alphabetically
2023-02-10 12:58:50 +02:00
Monty
356a860155 Changed 'check_costs' so that --init-query can be used to override setup_engine() 2023-02-10 12:58:50 +02:00
Monty
02b7735b82 MDEV-30310 Assertion failure in best_access_path upon IN exceeding IN_PREDICATE_CONVERSION_THRESHOLD, derived_with_keys=off
The bug was some old code that, without any explanation, reset
PART_KEY_FLAG from fields in temporary tables. This caused
join_tab->key_dependent to not be updated properly, which caused
an assert.
2023-02-10 12:58:50 +02:00
Monty
4be0bfad98 Simplified code in generate_derived_keys() and when using pos_in_tables
Added comments that not used keys of derivied tables will be deleted.
Added some comments about checking if pos_in_table_list is 0.

Other things:
- Added a marker (DBTYPE_IN_PREDICATE) in TABLE_LIST->derived_type
  to indicate that the table was generated from IN (list). This is
  useful for debugging and can later be used by explain if needed.
- Removed a not needed test of table->pos_in_table_list as it should
  always be valid at this point in time.
2023-02-10 12:58:50 +02:00
Monty
9a4110aa57 MDEV-30256 Wrong result (missing rows) upon join with empty table
The problem was an assignment in test_quick_select() that flagged empty
tables with "Impossible where". This test was however wrong as it
didn't work correctly for left join.

Removed the test, but added checking of empty tables in DELETE and UPDATE
to get similar EXPLAIN as before.

The new tests is a bit more strict (better) than before as it catches all
cases of empty tables in single table DELETE/UPDATE.
2023-02-10 12:58:50 +02:00
Monty
e3f56254a8 MDEV-30098 Server crashes in ha_myisam::index_read_map with index_merge_sort_intersection=on
Fixes also
MDEV-30104 Server crashes in handler_rowid_filter_check upon ANALYZE TABLE

cancel_pushed_rowid_filter() didn't inform the handler that rowid_filter
was canceled.
2023-02-10 12:58:50 +02:00
Monty
76d2a77d52 MDEV-30088 Assertion `cond_selectivity <= 1.0' failed in get_range_limit_read_cost
Fixed cost calculation for MERGE tables with 0 tables
2023-02-10 12:58:50 +02:00
Monty
3fa99f0c0e Change cost for REF to take into account cost for 1 extra key read_next
The main difference in code path between EQ_REF and REF is that for
REF we have to do an extra read_next on the index to check that there
is no more matching rows.

Before this patch we added a preference of EQ_REF by ensuring that REF
would always estimate to find at least 2 rows.

This patch adds the cost of the extra key read_next to REF access and
removes the code that limited REF to at least 2 rows. For some queries
this can have a big effect as the total estimated rows will be halved
for each REF table with 1 rows.

multi_range cost calculations are also changed to take into account
the difference between EQ_REF and REF.

The effect of the patch to the test suite:
- About 80 test case changed
- Almost all changes where for EXPLAIN where estimated rows for REF
  where changed from 2 to 1.
- A few test cases using explain extended had a change of 'filtered'.
  This is because of the estimated rows are now closer to the
  calculated selectivity.
- A very few test had a change of table order.
  This is because the change of estimated rows from 2 to 1 or the small
  cost change for REF
  (main.subselect_sj_jcl6, main.group_by, main.dervied_cond_pushdown,
  main.distinct, main.join_nested, main.order_by, main.join_cache)
- No key statistics and the estimated rows are now smaller which cased
  estimated filtering to be lower.
  (main.subselect_sj_mat)
- The number of total rows are halved.
  (main.derived_cond_pushdown)
- Plans with 1 row changed to use RANGE instead of REF.
  (main.group_min_max)
- ALL changed to REF
  (main.key_diff)
- Key changed from ref + index_only to PRIMARY key for InnoDB, as
  OPTIMIZER_ROW_LOOKUP_COST + OPTIMIZER_ROW_NEXT_FIND_COST is smaller than
  OPTIMIZER_KEY_LOOKUP_COST + OPTIMIZER_KEY_NEXT_FIND_COST.
  (main.join_outer_innodb)
- Cost changes printouts
  (main.opt_trace*)
- Result order change
  (innodb_gis.rtree)
2023-02-10 12:58:50 +02:00
Denis Protivensky
4d09050ca7 MDEV-29281 Report events from provider (add node eviction event)
Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
2023-02-10 11:30:46 +01:00
Jan Lindström
6a5af66ddf Update wsrep-lib submodule 2023-02-10 11:30:46 +01:00
Marko Mäkelä
c41c79650a Merge 10.4 into 10.5 2023-02-10 12:02:11 +02:00
Sergei Golubchik
4fa2747a63 MDEV-29582 post-review fixes
don't include my_progname in the error message, my_error starts from it
automatically, resulting in, like

/usr/bin/mysqladmin: Notice: /usr/bin/mysqladmin is deprecated and will be removed in a future release, use command 'mariadb-admin'

and remove "Notice" so that the problem description would directly
follow the executable name.

make the check to work when the executable is in the PATH
(so, invoked simply like 'mysql' and thus readlink cannot find it)

fix the check in mysql_install_db and mysql_secure_installation to not
print the warning if the intermediate path contains "mysql" substring

add this message also to
* mysql_waitpid
* mysql_convert_table_format
* mysql_find_rows
* mysql_setpermissions
* mysqlaccess
* mysqld_multi
* mysqld_safe
* mysqldumpslow
* mysqlhotcopy
* mysql_ldb

Closes #2273
2023-02-10 10:45:25 +01:00
Daniel Black
b30b040b73 MDEV-29582 deprecate mysql* names
Eventually mysql symlinks will go away, as MariaDB and MySQL keep
diverging and we do not want to make it impossible to install
MariaDB and MySQL side-by-side when users want it.

It also useful if people start using MariaDB tools with MariaDB.

If the exe doesn't begine with "mariadb" or is a symlink,
print a warning to use the resolved name.

In my_readlink, add check on my_thread_var as its used by comp_err
and other build utils that also use my_init.
2023-02-10 10:45:25 +01:00
Daniel Black
cacea31687 MDEV-30621: Türkiye is the correct current country naming
As requested to the UN the country formerly known as Turkey is
to be refered to as Türkiye.

Reviewer: Alexander Barkov
2023-02-10 17:07:38 +11:00
Daniel Black
483ddb5684 MDEV-30621: Türkiye is the correct current country naming
As requested to the UN the country formerly known as Turkey is
to be refered to as Türkiye.
2023-02-10 08:44:14 +11:00
Brandon Nesterenko
eecd4f1459 MDEV-30608: rpl.rpl_delayed_parallel_slave_sbm sometimes fails with Seconds_Behind_Master should not have used second transaction timestamp
One of the constraints added in the MDEV-29639 patch, is that only
the first event after idling should update last_master_timestamp;
and as long as the replica has more events to execute, the variable
should not be updated. The corresponding test,
rpl_delayed_parallel_slave_sbm.test, aims to verify this; however,
if the IO thread takes too long to queue events, the SQL thread can
appear to catch up too fast.

This fix ensures that the relay log has been fully written before
executing the events.

Note that the underlying cause of this test failure needs to be
addressed as a bug-fix, this is a temporary fix to stop test
failures. To track work on the bug-fix for the underlying issue,
please see MDEV-30619.
2023-02-09 13:02:14 -07:00
Igor Babaev
c63768425b MDEV-30586 DELETE with aggregation in subquery of WHERE returns bogus error
The parser code for single-table DELETE missed the call of the function
LEX::check_main_unit_semantics(). As a result the the field nested level
of SELECT_LEX structures remained set 0 for all non-top level selects.
This could lead to different kind of problems. In particular this did not
allow to determine properly the selects where set functions had to be
aggregated when they were used in inner subqueries.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2023-02-09 08:59:23 -08:00
Vicențiu Ciorbaru
08c852026d Apply clang-tidy to remove empty constructors / destructors
This patch is the result of running
run-clang-tidy -fix -header-filter=.* -checks='-*,modernize-use-equals-default' .

Code style changes have been done on top. The result of this change
leads to the following improvements:

1. Binary size reduction.
* For a -DBUILD_CONFIG=mysql_release build, the binary size is reduced by
  ~400kb.
* A raw -DCMAKE_BUILD_TYPE=Release reduces the binary size by ~1.4kb.

2. Compiler can better understand the intent of the code, thus it leads
   to more optimization possibilities. Additionally it enabled detecting
   unused variables that had an empty default constructor but not marked
   so explicitly.

   Particular change required following this patch in sql/opt_range.cc

   result_keys, an unused template class Bitmap now correctly issues
   unused variable warnings.

   Setting Bitmap template class constructor to default allows the compiler
   to identify that there are no side-effects when instantiating the class.
   Previously the compiler could not issue the warning as it assumed Bitmap
   class (being a template) would not be performing a NO-OP for its default
   constructor. This prevented the "unused variable warning".
2023-02-09 16:09:08 +02:00
Vladislav Vaintroub
8dab661416 MDEV-30624 HeidiSQL 12.3 2023-02-09 11:28:55 +01:00
Vladislav Vaintroub
aa028e02c3 Update Windows time zone mappings using latest CLDR data 2023-02-09 09:15:08 +01:00