Commit graph

198518 commits

Author SHA1 Message Date
Trevor Gross
17a32c3bbc MDEV-30389 Ensure correct dlen during encryption
This patch ensures that all direct and indirect calls to
encryption_crypt provide a `dlen` value correctly initialized to the
destination buffer length, allowing encryption plugins to verify
available space. It also adds assertions to verify related invariants.

Signed-off-by: Trevor Gross <tmgross@umich.edu>
2023-07-02 12:17:08 +02:00
Marko Mäkelä
1fe4bcbe05 Merge 10.11 into 11.0 2023-06-28 09:19:19 +03:00
Yuchen Pei
5ef27d271d
MDEV-31463 Spider should check connection before setting lock wait timeout
When setting the server lockwait timeout, spider should do some basic
checks first, like whether the remote server is still reachable. So
instead of directly calling spider_db_mbase::exec_query(), it should
call spider_db_query().

The reset of the lock wait timeout does not need to do such checks,
because they happen after the successfully setting the lock wait
timeout, implying the checks have been passed already.
2023-06-28 12:14:33 +10:00
Marko Mäkelä
71a1a28a49 Merge 10.10 into 10.11 2023-06-27 17:45:06 +03:00
Marko Mäkelä
135e976696 Merge 10.9 into 10.10 2023-06-27 17:43:31 +03:00
Marko Mäkelä
eb6b521f1b Merge 10.6 into 10.9 2023-06-27 13:48:46 +03:00
Marko Mäkelä
694ce0d08e Merge 10.5 into 10.6 2023-06-27 13:03:32 +03:00
Marko Mäkelä
84dbd0253d MDEV-31487: Recovery or backup failure after innodb_undo_log_truncate=ON
recv_sys_t::parse(): For undo tablespace truncation mini-transactions,
remember the start_lsn instead of the end LSN. This is what we expect
after commit 461402a564 (MDEV-30479).
2023-06-27 09:12:38 +03:00
Marko Mäkelä
493083833b Merge 10.5 into 10.6 2023-06-26 17:11:38 +03:00
Marko Mäkelä
aeeca7111b MDEV-22570 fixup: GCC 13 -Wpessimizing-move 2023-06-26 16:40:36 +03:00
Rucha Deodhar
14275b4715 MDEV-28915: mysql_upgrade fails due to old_mode="", with "Cannot load from
mysql.proc. The table is probably corrupted"

Analysis: When mysql_upgrade runs statements for upgrade, characterset is
converted to utf8mb4 because server starts with old_mode that interprets
utf8 to utf8mb4, but mysql.proc table has "utf8mb3" as hardcoded, so
it crashes with corrupted table.

Fix: Changed Table_check_intact::check() definition to allow both
utf8mb3 and utf8mb4 by checking prefix and changing the upgrade scripts
to explicitly use utf8mb3
2023-06-26 15:10:30 +05:30
Monty
6daccd4e48 Moved test from group_min_max.test to group_min_max_not_embedded.test 2023-06-25 16:26:28 +03:00
Monty
40b9b980da Removed wrongly placed test from group_min_max.test
This is mainly done to be able to push to 11.0
The test is moved in 10.6 to another file, which will add back the test.
2023-06-25 16:22:02 +03:00
Michael Widenius
3c7fd3c89b MDEV-23106 Unable to recognize/import partitioned tables from physical MySQL databases
MDEV-29253 Detect incompatible MySQL partition scheme and either convert
them or report to user and in error log.

This task is about converting in place MySQL 5.6 and 5.7 partition tables
to MariaDB as part of mariadb-upgrade.

- Update TABLE_SHARE::init_from_binary_frm_image() to be able to read
  MySQL frm files with partitions.
- Create .par file, if it do not exists, on open of partitioned table.

Executing mariadb-upgrade will create all the missing .par files.
The MySQL .frm file will be changed to MariaDB format after next
ALTER TABLE.

Other changes:
- If we are using stored mysql_version to distingush between MySQL and
  MariaDB  .frm file information, do not upgrade mysql_version in the
  .frm file as part of CHECK TABLE .. FOR UPGRADE as this would cause
  problems next time we parse the .frm file.
2023-06-25 16:15:08 +03:00
Monty
d671fec431 Fixed some errors & warnings when running mariadb-upgrade on MySQL instance
- Moved view checks after privilege tables are fixed. This is to avoid
  warnings about wrongly defined mysql.proc when checking views.
- Don't use stat tables before they have been fixed.
- Don't run mysql_fix_view() if 'FOR MYSQL' is used if the view is
  already a MariaDB view.
- Added 'FOR UPGRADE' as an option for 'REPAIR VIEW' to be able to
  detect if the REPAIR command comes from mariadb_upgrade. In this
  case we get a warning, instead of an error, if a definer of a view
  does not exists.
2023-06-25 16:15:08 +03:00
Vicentiu Ciorbaru
324d8a6036 Fix segfault in find_files if db is NULL and path does not exist or can't be read
In this case, one would end up calling my_error(ER_BAD_DB_ERROR, ...)
with a null ptr for DB, which caused a NULL ptr dereference.
2023-06-25 16:15:08 +03:00
Vicentiu Ciorbaru
38fe266ea9 Fix gcc warning for wsrep_plug 2023-06-25 16:15:08 +03:00
Vicentiu Ciorbaru
f20d556f19 Fix use of uninitialized variable
The original code generated a warning in gcc 13.1
2023-06-25 16:15:08 +03:00
Monty
ecd8a52252 Renamed 'mysql' -> 'mariadb' in mtr 2023-06-25 16:15:08 +03:00
Monty
ccc48b40e3 Fixed window warning 2023-06-25 15:38:20 +03:00
Brandon Nesterenko
c2d44ecb90 MDEV-29894: Calling a function from a different database in a slave side trigger crashes
When opening and locking tables, if triggers will be invoked in a
separate database, thd->set_db() is invoked, thus freeeing the memory
and headers which thd->db had previously pointed to. In row based
replication, the event execution logic initializes thd->db to point
to the database which the event targets, which is owned by the
corresponding table share (introduced in d9898c9 for MDEV-7409).
The problem then, is that during the table opening and locking
process for a row event, memory which belongs to the table share
would be freed, which is not valid.

This patch replaces the thd->reset_db() calls to thd->set_db(),
which copies-by-value, rather than by reference. Then when the
memory is freed, our copy of memory is freed, rather than memory
which belongs to a table share.

Notes:
  1. The call to change thd->db now happens on a higher-level, in
Rows_log_event::do_apply_event() rather than ::do_exec_row(), in the
call stack. This is because do_exec_row() is called within a loop,
and each invocation would redundantly set and unset the db to the
same value.
  2. thd->set_db() is only used if triggers are to be invoked, as
there is no vulnerability in the non-trigger case, and copying
memory would be an unnecessary inefficiency.

Reviewed By:
============
Andrei Elkin <andrei.elkin@mariadb.com>
2023-06-21 12:51:01 -06:00
Monty
3d617fdc7f MDEV-31375 Assertion `dbl_records <= s->records' failed with optimizer_use_condition_selectivity=1
The reason for the crash wad that 'best splitting' optimization
predicted less rows to be found than what opt_range did.
This code in apply_selectivity_for_table(), when using use_cond_selectivity=1,
was not prepared for this case which caused an assert in debug builds.
Production builds is not affected.

The fix is to choose the smaller of the two row counts. It will have a
minimum on costs when using use_cond_selectivity=1 and should not cause
any problems in production.
2023-06-21 15:44:25 +03:00
Monty
d3c81804ba MDEV-31494 Server crashes in ha_partition::index_blocks / get_key_scans_params
MDEV-31445 Server crashes in ha_partition::index_blocks / cost_for_index_read

The crash happened in the case where partition pruning finds 0
partitions.
2023-06-21 15:43:46 +03:00
Sergei Petrunia
0b61f4e0e4 Fix comment 2023-06-20 12:58:39 +03:00
Meng-Hsiu Chiang
774dee9abc Fix compiler warnings
-Wdeprecated-declarations:
  Replace deprecated xmlXPathInit() with xmlInitParser()[1]

-Wmaybe-uninitialized:
  `fil1` was initialized to 0 in commit 0138220 to fix compiler
  warnings, but `fil2` was missed.

ref:
[1]: https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-xpath.html#xmlXPathInit
2023-06-19 10:27:46 +01:00
Monty
f25a74c0b0 Fixed typo on opt_range.cc: SEL_ARG::number_of_eq_groups()
It could cause wrong range estimation for GROUP BY queries that are
using 'WHERE index_part >= constant'.
(The function was trying to check for 'index_part = constant')

Reporter: Yuty Chaikou
2023-06-18 12:11:18 +03:00
Thirunarayanan Balathandayuthapani
bd076d4dff MDEV-31442 page_cleaner thread aborts while releasing the tablespace
- InnoDB shouldn't acquire the tablespace when it is being stopped
or closed
2023-06-16 14:58:48 +05:30
Sergei Petrunia
f7e9ac0d88 MDEV-31449: Assertion s->table->opt_range_condition_rows <= s->found_records
Fix a typo in make_join_statistics(): when updating statistics for
derived table, set s->table->... not "table->..."
2023-06-15 11:27:31 +03:00
Sergei Petrunia
0e2e70c4c1 MDEV-31479: Inconsistency between MRR and SQL layer costs can cause poor query plan
(Same as
TODO-3938: best_access_path shows negative costs for mrr=on)

best_access_path() assumes that quick select cost includes
(quick->rows/TIME_FOR_COMPARE) as a cost of checking the attached
part of the WHERE condition.

It calls adjust_quick_cost() to subtract addition from quick's cost.

The problem was that DS-MRR cost formula didn't include this cost.
For very large tables, adjust_quick_cost() would produce a negative
cost which would cause assert in debug build or bad query plan choice
in release builds.

Approved-by: Monty <monty@mariadb.org>
2023-06-14 13:56:33 +03:00
Monty
e1a631fecc Fixed wrong assignment in calculate_block_sizes() for MEM_ROOT
The effect was that that ROOT_FLAG_THREAD_SPECIFIC was cleared and
the memory allocated by memroot would be contributed the the system,
not to the thread.

This exposed a bug in how "show explain for ..." allocated data.
- The thread that did provide the explain allocated data in the
  "show explain" threads mem_root, which is marked as THREAD_SPECIFIC.
- Fixed by allocating the explain data in a temporary explain_mem_root
  which is not THREAD_SPECIFIC.

Other things:
- Added extra checks when using update_malloc_size()
- Do not call update_malloc_size() for memory not registered with
  update_malloc_size(). This avoid some wrong 'memory not freed' reports.
- Added a checking of 'thd->killed' to ensure that
  main.truncate_notembedded.test still works.

Reported by: Yury Chaikou
2023-06-14 00:39:14 +03:00
Monty
c4cf5e17ac Fixed main.mysqld-help and connect.drop-open-error tests 2023-06-14 00:39:14 +03:00
Monty
3eab2275d0 Added option sql_error_warnings to sql_error_log plugin 2023-06-12 14:57:21 +03:00
Monty
582d0cf5b0 Added not_as_root.inc to some test scripts that fails if run as root 2023-06-10 11:14:15 +03:00
Thirunarayanan Balathandayuthapani
841e905f20 MDEV-31442 page_cleaner thread aborts while releasing the tablespace
After further I/O on a tablespace has been stopped
(for example due to DROP TABLE or an operation that
rebuilds a table), page cleaner thread tries to
flush the pending writes for the tablespace and
releases the tablespace reference even though it was not
acquired.

fil_space_t::flush(): Don't release the tablespace when it is
being stopped and closed

Thanks to Marko Mäkelä for suggesting this patch.
2023-06-09 18:15:33 +05:30
Tuukka Pasanen
8171f9da87 MDEV-31423: Make sure that datadir is available with SySV-init script
Commit fixes Debian SySV-init script fail:
  /etc/init.d/mariadb: line 90: [: : integer expression expected
which happens if datadir is not changed in configuration which
makes it invisible when printing MariaDB config defaults.

Commit makes sure that there is some value if nothing else if in hand
use default /usr/lib/mysql or fail with correct error message if
directory is not present
2023-06-09 10:22:34 +10:00
Monty
c70f35f00b Disable flush_logs_not_windows.test of run as root (causes failure) 2023-06-08 17:15:16 +03:00
Monty
29ec07a5b1 Update BUILD scripts
- Remove -Wimplicit-fallthrough=2 for gcc versions < 6
- Don't do git submodule update one fresh git clones
  This fixes an issue when using git 1.0 that gives
  errors on empty submodule directories
2023-06-08 17:08:38 +03:00
Thirunarayanan Balathandayuthapani
bf0a54df34 MDEV-31416 ASAN errors in dict_v_col_t::detach upon adding key to virtual column
- InnoDB throws ASAN error while adding the index on virtual column
of system versioned table. InnoDB wrongly assumes that virtual
column collation type changes, creates new column with different
character set. This leads to failure while detaching the column
from indexes.
2023-06-08 16:34:45 +05:30
Marko Mäkelä
5fb2c031f7 Merge 10.11 into 11.0 2023-06-08 13:49:48 +03:00
Marko Mäkelä
cb9d97ef38 MariaDB 11.0.2 release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEF39AEP5WyjM2MAMF8WVvJMdM0dgFAmR/ci8ACgkQ8WVvJMdM
 0dgAyBAAyZDiB+MrekSjH7acxhQuRNEzs3LbUZSQceGXETYtWrI+xiBx6TsqnGfa
 AaXFKha12TIgTRNVko9E6DwgT5AR0XgUAStas/NniP7UEnteyqgX3//8t6aqVbrP
 hcw88QufqkZwLGRpnFGGOU10sbeZqLzN5Yj2WZEQj//alff/AJ11foJqkj4VX8P6
 O6ILjsD1KSkcFqgmEmB0zDzm60yuzfeyhUnHNiYP79gKjqSiY4U+pIZiwqvVf9lb
 tlRbjYt7hQDatiK8NNnl+AlLSJyEFJ/gKVYvH/Mg7WQNJxqyLSJUxMRpBskj1tZ3
 uksMg3iy3EsCP2jlDIyP6xmNy6I+ako1S9kOgHkFy2ggohyUPEw5+TorRFrCUTrn
 BJqwG0VrZ6hynE5DGBhWzRbHB1R00AS4uQ4gFlryQ4h1EhVnx6JnkRz5WFNsOf1v
 +PyGCnjYE0UYDtG07K5DVSTkfKcnG4TUvn2tzcFIi5be1Xb4tEA9n0ZaN2Tenkjv
 QgnzX8lbNBJf00HC6wzip/rESDDL7FMr7GEfUemMVdZTdU+wiKEqW2zIyEUmDzTp
 jpX2NAa7/aWqZOHGD2Pvuctb6fbIbWESIiO92A9mbtbyUJDB/BZHQahiazTCsOQ2
 1b7XcndLfl+cyExqHqCtHfdajOAjgjXW4AV2EdLatWMLGBWzE0I=
 =06BQ
 -----END PGP SIGNATURE-----

Merge mariadb-11.0.2 into 11.0
2023-06-08 11:35:36 +03:00
Marko Mäkelä
56bcb2b5c6 MariaDB 10.11.4 release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEF39AEP5WyjM2MAMF8WVvJMdM0dgFAmSAdPoACgkQ8WVvJMdM
 0dhX6g//WFQ0jMtd5get3IFkaUggulfaz0z5HWifxBFxTQWDlebgq8t1TLNKP+iX
 9PXPN+QOyGKeDqo5UdOgsl/A0pm1pKq99J3m7tPgJ/creRkRrQgDTW+ZaTRXbZsn
 hC6Nz6XHwKCX0fuwme/k/sCqxTh1ePRnnHtkQBRShyRgnessnY2jB9wRDNPl3nPT
 Bd27Y2deuW3VRzDtSg7j244mGozXDlMFZN21g5nHLlRvqa3NBxKrhDDyZj+kQKBG
 urbYzf0UNjKncegqYplUw61MglMrKOsBKXCoyu/YMrpBxaNpnoZVfQ3q4hmW/KjG
 Z+9cVyzrsB/WkF+FyO6i6rZ9imWBn/EJ/p8fvpBseTPsorEQ5yKh/4SMpgp3OOUM
 K6IFae8tuSHg/8brE1Ywt/Ib8WbZ0pwr9vdFRohoBlRTs84XGdYHyzxVTRXHXmKR
 ED3JMMmLyOlKcYCQIBg52IVAUq2BwsHfZjUu2sUQ8DVCFOy0gS+OeK93XKq0nLyl
 qz54bfokuLCDw1EIS5n9lXJT6yD5cSZXOBiv4l5aUj7KirrTIKHoNd3OXPzuIBE9
 C+2MJu3+Cw1eLElAR1C+zebqzQvh6Ii1nUd3Mgi9P5mKUy57WCtynP9II5Ft/0Yd
 Nb1BTNqDsqPSiwt/q+CimbhXi6N51SLuJBDYe5PMAAzY83nj578=
 =FXKK
 -----END PGP SIGNATURE-----

Merge mariadb-10.11.4 into 10.11
2023-06-08 11:23:45 +03:00
Marko Mäkelä
5d7b957eb0 Merge 10.10 into 10.11 2023-06-08 11:23:08 +03:00
Marko Mäkelä
47c9a61d96 MariaDB 10.10.5 release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEF39AEP5WyjM2MAMF8WVvJMdM0dgFAmSAdK8ACgkQ8WVvJMdM
 0djVHA/+OFBiJlc0XIPSJAzxvsjVeh9ufjRCEaugj3SQv9oAI5C/teegVRjxl+6E
 BZWZUpGHzr+p5w50M9P3oThqMriawyJne48cAcuNa6rWG7OAOqCLD0VAc/QL6lF5
 diRutRv8DoRC3iHTIKQlFOR18pQDbcczgBtgznI/bmtf5SIFKd1mrq0z+iA5wQ++
 0/VPqcIixumGCFsjaBxzafOz4wD4oYed3HCuVs143ZHqP99HGmsZxVbT7ASd5r2K
 9OPsov/G3kVtJSXoxJcnNflZNFNkH5Ek2z5fEZAR/HFYvypNksT6GY2Y9GbwPoGe
 TqXTUXy3VwZ4+7498y50P0Y3UikOQWDUSCHyrU96e5JN1/fRDPvpz7C52EXFVUfC
 eCNhnIeTL1qVIK6cn1JQO++Odn8Suyt92gq1T8K8yRjaWWoZa/ElY2PxgjpqIbqo
 A01EDUrPu4O79XLfXjOWp6TaM/pYSk4mHtPhso+GNKsM2rMPuYtb5RbdA1dYwFAM
 aP5bOALzQUygNN6a0G+wQoclQRKbDHFaCzByh1L3cIJ6+5Pvk4mP+xPtbgt06jhG
 9tmA8hwWdqP5AI5xf27wYrn0AS2i7NsunVjKC12851JLsn1Y0dm6KQ/dhTys+Bxc
 VCbw3Y3Yanqhbyx6XfoyfcQ5Ctnwvz4dNYTI2YeVG6FDYCYrwWk=
 =MKqT
 -----END PGP SIGNATURE-----

Merge mariadb-10.10.5 into 10.10
2023-06-08 11:22:20 +03:00
Marko Mäkelä
e704a13b32 Merge 10.9 into 10.10 2023-06-08 11:22:12 +03:00
Sergei Petrunia
b3074128a6 MDEV-31380 post-fix: fix group_min_max.test with embedded and view-protocol
embedded doesn't have optimizer trace,
view-protocol doesn't work with long column names.
2023-06-08 11:14:50 +03:00
Marko Mäkelä
5b37d58306 MariaDB 10.9.7 release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEF39AEP5WyjM2MAMF8WVvJMdM0dgFAmSAdGQACgkQ8WVvJMdM
 0dgc7RAA2jb1EOHUe0j0yOtVenln2OlsdKjSGDDZeKI5oPku6VfzbEdJcduTiqOo
 Sywkcp5+mixHpfH233E8/OVNVB4N5BUiCVYs7FJUqP194TXXnp6W4Kprc5B5I96p
 +Zrk3b3VEip2Y7GaxHmqi9l0ItTvTC6QoPp+QtMuKxQrnkr9LO4WRPI4zc7C6+c2
 k4xkVPqKyH7K5wDqT/FZCKTLa6Tx2ewpN+OkNKIuX/eJZ7AYrmww1j/yLAvjxvfd
 hy42H9AGSsYVJfWoCNBYBBejGjVunn2qcRcYscZlSuEDRuCJfXPLChxrvVgauwK7
 56mGGWMQZ8jAKz85ZgPZjxrddBftgyJckCloUjYwzPAYxjg3LYYU6SiAeV30rN2w
 1hSct8r9Ca0ljdhGPJ3eT4OZ1OwdceiTE21A4y/zLX8ZwvAt64wquU7eyw7W/vuK
 /g/EqL7Uxc48GlpjPK5feZkAA3GP4K7rVjsYri8zFIhXIjTSnz/Oatp/QKh8CNFo
 YeId5MYNHEupsI7d6z3OX4SEksoqokTsLQiBsIse3WUXxTtbC+cHlfAAIWQEkLIv
 PE45o/3alseQIv0gcVkmPTLR+k1pgxLHhwLvVKVzKgw1ppMwy9y9HgxhvjbWxhoS
 p9SXoz+PJpiLlSkTP+FVI3ypUYBruMPWYykcQ5+AbBMNITcgJM4=
 =F3h+
 -----END PGP SIGNATURE-----

Merge mariadb-10.9.7 into 10.9
2023-06-08 10:46:52 +03:00
Marko Mäkelä
223c2c5b9d Merge 10.6 into 10.9 2023-06-08 10:46:19 +03:00
Marko Mäkelä
80585c9d6f Merge 10.5 into 10.6 2023-06-08 10:42:56 +03:00
Marko Mäkelä
d3eefbaa55 MDEV-31355 fixup: Adjust one more test
The test gcol.gcol_purge would reliably hang on 10.6 on a
Microsoft Windows builder without this adjustment.
A similar adjustment was applied in
commit 3e40f9a7f3
to the tests innodb.dml_purge and innodb.instant_alter_purge.
2023-06-08 10:40:48 +03:00
Marko Mäkelä
21031b24fc Suppress an occasional buffer pool warning 2023-06-08 09:38:03 +03:00