Commit graph

195851 commits

Author SHA1 Message Date
Sergei Golubchik
01f6abd1d4 Merge branch '10.4' into 10.5 2024-01-31 17:32:53 +01:00
Sergei Golubchik
46e3a7658b funcs_1.innodb_views times out in --ps 2024-01-31 17:07:46 +01:00
Sergei Golubchik
e5147c8140 regression introduced by MDEV-14448 2024-01-31 15:32:37 +01:00
Sergei Golubchik
d1744ee7a2 MDEV-33343 spider.mdev_28739_simple fails in buildbot
test disabled, until fixed
2024-01-31 15:32:37 +01:00
Oleksandr Byelkin
908c9cf90c workaround for MDEV-33218 2024-01-30 17:00:15 +01:00
Brandon Nesterenko
c75905cacb MDEV-33327: rpl_seconds_behind_master_spike Sensitive to IO Thread Stop Position
rpl.rpl_seconds_behind_master_spike uses the DEBUG_SYNC mechanism to
count how many format descriptor events (FDEs) have been executed,
to attempt to pause on a specific relay log FDE after executing
transactions. However, depending on when the IO thread is stopped,
it can send an extra FDE before sending the transactions, forcing
the test to pause before executing any transactions, resulting in a
table not existing, that is attempted to be read for COUNT.

This patch fixes this by no longer counting FDEs, but rather by
programmatically waiting until the SQL thread has executed the
transaction and then automatically activating the DEBUG_SYNC point
to trigger at the next relay log FDE.
2024-01-30 06:58:44 +01:00
Brandon Nesterenko
112eb14f7e MDEV-27850: rpl_seconds_behind_master_spike debug_sync fix
A debug_sync signal could remain for the SQL thread that should have begun
a wait_for upon seeing a GTID event, but would instead see the old signal
and continue on without waiting. This broke an "idle" condition in
SHOW SLAVE STATUS
which should have automatically negated Seconds_Behind_Master. Instead,
because the SQL thread had already processed the GTID event, it set
sql_thread_caught_up to false, and thereby calculated the value of
Seconds_behind_master, when the test expected 0.

This patch fixes this by resetting the debug_sync state before creating a
new transaction which sends a GTID event to the replica
2024-01-26 11:43:34 -07:00
Vladislav Vaintroub
e96a05948b update C/C 2024-01-26 10:48:54 +01:00
Vladislav Vaintroub
b62f25c650 MDEV-26579 fixup 2024-01-26 00:15:13 +01:00
Vladislav Vaintroub
0f59810b99 MDEV-26579 Support minor MSI in Windows installer.
With this patch, 4-component MSI version can be used, e.g by setting
TINY_VERSION variable in CMake, or by adding a string, e.g
MYSQL_VERSION_EXTRA=-2
which sets TINY_VERSION to 2, and also changes the package name.

The 4-component MSI versions do not support MSI major upgrades, only minor
ones, i.e do not reinstall components, just update existing ones based
on versioning rules.

To support these rules, add DefaultVersion for the files that won't
otherwise be versioned - headers, static and import libraries,
pdbs, text - xml, python and perl scripts Also silence WiX warning
that MSI won't store hashes for those files anymore.
2024-01-26 00:15:13 +01:00
Yuchen Pei
1070575a89
MDEV-33191 spider: fix dbton_id when iterating over links
There are two array fields in spider_share with similar names:

share->use_sql_dbton_ids that maps from i to the i-th dbton used by
share. Thus it should be used only when i iterates over all distinct
dbtons used by share.

share->sql_dbton_ids that maps from i to the dbton used by the i-th
link of the share. Thus it should be used only when i iterates over
all links of a share.

We correct instances where share->sql_dbton_ids should be used instead
of share->use_sql_dbton_ids.
2024-01-25 12:33:52 +11:00
Alexander Barkov
97fcafb9ec MDEV-32837 long unique does not work like unique key when using replace
write_record() when performing REPLACE has an optimization:
- if the unique violation happened in the last unique key, then do UPDATE
- otherwise, do DELETE+INSERT

This patch changes the way of detecting if this optimization
can be applied if the table has long (hash based) unique
(i.e. UNIQUE..USING HASH) constraints.

Problem:

The old condition did not take into account that
TABLE_SHARE and TABLE see long uniques differently:
- TABLE_SHARE sees as HA_KEY_ALG_LONG_HASH and HA_NOSAME
- TABLE sees as usual non-unique indexes
So the old condition could erroneously decide that the UPDATE optimization
is possible when there are still some unique hash constraints in the table.

Fix:

- If the current key is a long unique, it now works as follows:

  UPDATE can be done if the current long unique is the last
  long unique, and there are no in-engine (normal) uniques.

- For in-engine uniques nothing changes, it still works as before:

  If the current key is an in-engine (normal) unique:
  UPDATE can be done if it is the last normal unique.
2024-01-24 17:19:54 +04:00
Alexander Barkov
f738cc9876 MDEV-29095 REGEXP_REPLACE treats empty strings different than REPLACE in ORACLE mode
Turning REGEXP_REPLACE into two schema-qualified functions:
- mariadb_schema.regexp_replace()
- oracle_schema.regexp_replace()

Fixing oracle_schema.regexp_replace(subj,pattern,replacement) to treat
NULL in "replacement" as an empty string.

Adding new classes implementing oracle_schema.regexp_replace():
- Item_func_regexp_replace_oracle
- Create_func_regexp_replace_oracle

Adding helper methods:
- String *Item::val_str_null_to_empty(String *to)
- String *Item::val_str_null_to_empty(String *to, bool null_to_empty)

and reusing these methods in both Item_func_replace and
Item_func_regexp_replace.
2024-01-24 10:59:17 +04:00
Daniel Black
3699a7e1a9 macos: Fix CMAKE_OSX_ARCHITECTURES when not set
When CMAKE_OSX_ARCHITECTURES isn't set we end up with
"Packaging as: mariadb-10.4.33-osx10.19-x86_64" on arm64 builders.

Instead of implying 64bit is x86, use CMAKE_SYSTEM_PROCESSOR to form
the filename.
2024-01-24 10:01:15 +11:00
Vicențiu Ciorbaru
7c2f082222
Improve READLINE_V5 detection
More in depth check to cover all used readline functions.
2024-01-23 18:38:22 +02:00
Sergei Golubchik
a7ee3bc58b MDEV-29954 Unique hash key on column prefix is computed incorrectly
use the original, not the truncated, field in the long unique prefix,
that is, in the hash(left(field, length)) expression.

because MyISAM CHECK/REPAIR in compute_vcols() moves table->field
but not prefix fields from keyparts.

Also, implement Field_string::cmp_prefix() for prefix comparison
of CHAR columns to work.
2024-01-23 15:40:42 +01:00
Sergei Golubchik
14d00fdb15 cleanup: MY_STRNNCOLLSP_NCHARS_EMULATE_TRIMMED_TRAILING_SPACES
no need to use it when both arguments have the same length
2024-01-23 15:40:42 +01:00
Sergei Golubchik
8bb464899f cleanup: unused and undefined methods 2024-01-23 15:40:42 +01:00
Sergei Golubchik
dcb814c44e MDEV-11628 mysql.slow_log reports incorrect start time
use thd->start_time for the "start_time" column of the slow_log table.
"current_time" here refers to the current_time() function return value
not to the actual *current* time.

also fixes
MDEV-33267 User with minimal permissions can intentionally corrupt mysql.slow_log table
2024-01-23 15:40:42 +01:00
Sergei Golubchik
db9fad1562 cleanup: main.log_tables test 2024-01-23 15:40:42 +01:00
Sergei Golubchik
2bc940f7c9 disable perfschema in mtr bootstrap
should fix numerous failures of main.bootstrap tets
2024-01-23 15:40:42 +01:00
Vicențiu Ciorbaru
27459b413d
MDEV-14448: Ctrl-C should not exit client
Undo any Windows behaviour changes.
2024-01-23 16:25:58 +02:00
Alexander Barkov
81d01855fe MDEV-28651 quote(NULL) returns incorrect result in view ('NU' instead of 'NULL')
Item_func_quote did not calculate its max_length correctly for nullable
arguments.

Fix:

In case if the argument is nullable, reserve at least 4 characters
so the string "NULL" fits.
2024-01-23 13:22:58 +04:00
Daniel Black
5ce6a352b6 MDEV-33290: Disable ColumnStore based on boost version
MCOL-5611 supporting with Boost-1.80, the version "next_prime"
disappears from https://github.com/boostorg/unordered/blob/boost-1.79.0/include/boost/unordered/detail/implementation.hpp
makes it the currenly highest supported versions.

Lets check this version.

While CMake-3.19+ supports version ranges in package determinations this
isn't supported for Boost in Cmake-3.28. So we check for the 1.80 and
don't compile ColumnStore.
2024-01-23 15:20:25 +11:00
Dmitry Shulga
13e49b783f sql_test.cc compile fix 2024-01-23 11:02:51 +11:00
Rex
117388225c MDEV-33165 Incorrect result interceptor passed to mysql_explain_union()
Statements affect by this bug are all SQL statements that
1) prefixed with "EXPLAIN"
2) have a lower level join structure created for a union subquery.

A bug in select_describe() passed an incorrect "result" object to
mysql_explain_union(), resulting in unpredictable behaviour and
out of context calls.

Reviewed by: Oleksandr Byelkin, sanja@mariadb.com
2024-01-23 08:57:15 +13:00
Oleksandr Byelkin
15bd7e0b89 "New" version of CC (in fact no changes) 2024-01-22 19:44:04 +01:00
Oleksandr Byelkin
a9172b8a43 Update minizip files for connect enginbe from last zlib 1.3. 2024-01-22 19:44:04 +01:00
Brandon Nesterenko
01ca57ec16 MDEV-32168: Postpush fix for rpl_domain_id_filter_master_crash
While a replica may be reading events from the
primary, the primary is killed. Left to its own
devices, the IO thread may or may not stop in
error, depending on what it is doing when its
connection to the primary is killed (e.g. a
failed read results in an error, whereas if the
IO thread is idly waiting for events when the
connection dies, it will enter into a reconnect
loop and reconnect). MDEV-32168 changed the test
to always wait for the reconnect, thus breaking
the error case, as the IO thread would be stopped
at a time of expecting it to be running.

The fix is to manually stop/start the IO thread
to ensure it is in a consistent state.

Note that rpl_domain_id_filter_master_crash.test
will need additional changes after fixing MDEV-33268

Reviewed By:
============
Kristian Nielsen <knielsen@knielsen-hq.org>
2024-01-22 07:30:52 -07:00
Brandon Nesterenko
207c85783b MDEV-33283: Binlog Checksum is Zeroed by Zlib if Part of Event Data is Empty
An existing binlog checksum can be overridden to 0 if writing a NULL
payload when using Zlib for the computation. That is, calling into
Zlib's crc32 with empty data initializes an incremental CRC
computation to 0.

This patch changes the Log_event_writer::write_data() to exit
immediately if there is nothing to write, thereby bypassing the
checksum computation. This follows the pattern of
Log_event_writer::encrypt_and_write(), which also exits immediately
if there is no data to write.

Reviewed By:
============
Andrei Elkin <andrei.elkin@mariadb.com>
2024-01-22 07:15:42 -07:00
Vicențiu Ciorbaru
3cd8875145
MDEV-14448: Ctrl-C should not exit the client
This patch introduces the following behaviour for Linux while
maintaining old behaviour for Windows:

Ctrl + C (sigint) clears the current buffer and redraws the prompt.
Ctrl-C no longer exits the client if no query is running.
Ctrl-C kills the current running query if there is one. If there is an
error communicating with the server while trying to issue a KILL QUERY,
the client exits. This is in line with the past behaviour of Ctrl-C.
On Linux Ctrl-D can be used to close the client.
On Windows Ctrl-C and Ctrl-BREAK still exits the client if no query is running.
Windows can also exit the client via \q<enter> or exit<enter>.

== Implementation details ==
The Linux implementation has two corner cases, based on which library is
used: libreadline or libedit, both are handled in code to achieve the
same user experience.

Additional code is taken from MySQL, ensuring there is identical
behaviour on Windows, to MySQL's mysql client implementation for other
CTRL- related signals.

* The CTRL_CLOSE, CTRL_LOGOFF, CTRL_SHUTDOWN will issue the equivalent
  of CTRL-C and "end" the program. This ensures that the query is killed
  when the client is closed by closing the terminal, logging off the
  user or shutting down the system. The latter two signals are not sent
  for interactive applications, but it handles the case when a user has
  defined a service to use mysql client to issue a command. See
  https://learn.microsoft.com/en-us/windows/console/handlerroutine

This patch is built on top of the initial work done by Anel Husakovic
<anel@mariadb.org>.
Closes #2815
2024-01-22 14:59:48 +02:00
Sisi Huang
7e8e51eb3a MDEV-32990 federatedx time_zone round trips
Modified `federatedx_io_mysql::actual_query` to set the time zone to '+00:00' only upon establishing a new connection instead of with each query execution.
2024-01-22 13:44:53 +11:00
Igor Babaev
e8041c7065 MDEV-33270 Failure to call SP invoking another SP with parameter requiring type conversion
This patch corrects the fix for MDEV-32569. The latter has not taken into
account the fact not each statement uses the SELECT_LEX structure. In
particular CALL statements do not use such structure. However the parameter
passed to the stored procedure used in such a statement may require an
invocation of Type_std_attributes::agg_item_set_converter().

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2024-01-19 08:38:00 -08:00
Thirunarayanan Balathandayuthapani
7573fe8b07 MDEV-32968 InnoDB fails to restore tablespace first page from doublewrite buffer when page is empty
recv_dblwr_t::find_first_page(): Free the allocated memory
to read the first 3 pages from tablespace.

innodb.doublewrite: Added sleep to ensure page cleaner thread
wake up from my_cond_wait
2024-01-19 17:01:36 +05:30
Brad Smith
2ef01d0034 wsrep scripts fixes for working on OpenBSD 2024-01-19 15:45:08 +11:00
Marko Mäkelä
ee1407f74d MDEV-32268: GNU libc posix_fallocate() may be extremely slow
os_file_set_size(): Let us invoke the Linux system call fallocate(2)
directly, because the GNU libc posix_fallocate() implements a fallback
that writes to the file 1 byte every 4096 or fewer bytes. In one
environment, invoking fallocate() directly would lead to 4 times the
file growth rate during ALTER TABLE. Presumably, what happened was
that the NFS server used a smaller allocation block size than 4096 bytes
and therefore created a heavily fragmented sparse file when
posix_fallocate() was used. For example, extending a file by 4 MiB
would create 1,024 file fragments. When the file is actually being
written to with data, it would be "unsparsed".

The built-in EOPNOTSUPP fallback in os_file_set_size() writes a buffer
of 1 MiB of NUL bytes. This was always used on musl libc and other
Linux implementations of posix_fallocate().
2024-01-18 11:00:27 +02:00
Sophist
c95ba183d2 Replace incorrect message mariadb-safe with correct mariadbd-safe 2024-01-18 08:51:17 +11:00
Robin Newhouse
615f4a8c9e MDEV-32587 Allow json exponential notation starting with zero
Modify the NS_ZERO state in the JSON number parser to allow
exponential notation with a zero coefficient (e.g. 0E-4).

The NS_ZERO state transition on 'E' was updated to move to the
NS_EX state rather than returning a syntax error. Similar change
was made for the NS_ZE1 (negative zero) starter state.

This allows accepted number grammar to include cases like:

- 0E4
- -0E-10

which were previously disallowed. Numeric parsing remains
the same for all other states.

Test cases are added to func_json.test to validate parsing for
various exponential numbers starting with zero coefficients.

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.
2024-01-17 19:25:43 +05:30
Oleksandr Byelkin
8e337e016f new WolfSSL v5.6.6-stable 2024-01-17 10:45:05 +01:00
Yuchen Pei
9c059a4f1c
Spider: no need to check for ubsan when running ubsan tests
It's ok to run these tests without ubsan too, and we get some tests
for free.
2024-01-17 10:33:02 +11:00
Alexander Barkov
fa3171df08 MDEV-27666 User variable not parsed as geometry variable in geometry function
Adding GEOMETRY type user variables.
2024-01-16 18:53:23 +04:00
Thirunarayanan Balathandayuthapani
caad34df54 MDEV-32968 InnoDB fails to restore tablespace first page from doublewrite buffer when page is empty
- InnoDB fails to find the space id from the page0 of
the tablespace. In that case, InnoDB can use
doublewrite buffer to recover the page0 and write
into the file.

- buf_dblwr_t::init_or_load_pages(): Loads only the pages
which are valid.(page lsn >= checkpoint). To do that,
InnoDB has to open the redo log before system
tablespace, read the latest checkpoint information.

recv_dblwr_t::find_first_page():
1) Iterate the doublewrite buffer pages and find the 0th page
2) Read the tablespace flags, space id from the 0th page.
3) Read the 1st, 2nd and 3rd page from tablespace file and
compare the space id with the space id which is stored
in doublewrite buffer.
4) If it matches then we can write into the file.
5) Return space which matches the pages from the file.

SysTablespace::read_lsn_and_check_flags(): Remove the
retry logic for validating the first page. After
restoring the first page from doublewrite buffer,
assign tablespace flags by reading the first page.

recv_recovery_read_max_checkpoint(): Reads the maximum
checkpoint information from log file

recv_recovery_from_checkpoint_start(): Avoid reading
the checkpoint header information from log file

Datafile::validate_first_page(): Throw error in case
of first page validation fails.
2024-01-15 14:08:27 +05:30
Thirunarayanan Balathandayuthapani
653cb195d3 MDEV-26740 Inplace alter rebuild increases file size
PageBulk::init(): Unnecessary reserves the extent before
allocating a page for bulk insert. btr_page_alloc()
capable of handing the extending of tablespace.
2024-01-15 13:04:10 +05:30
Tuukka Pasanen
ee30491e50 MDEV-32111: Debian Sid/Trixie will not have libncurses 5 anymore
Upstream Debian Sid which will become Debian Trixie (13)
have dropped NCurses version 5 and changed dev package name just
libncurses-dev
2024-01-14 13:27:10 +11:00
Oleg Smirnov
48e4962c44 MDEV-29298 INSERT ... SELECT Does not produce an optimizer trace
Add INSERT ... SELECT to the list of commands that can be traced

Approved by Sergei Petrunia (sergey@mariadb.com)
2024-01-13 11:44:55 +07:00
Kristian Nielsen
5b0a4159ef Fix test failures on s390x in test following main.column_compression_rpl
The problem is the test is skipped after sourcing include/master-slave.inc.
This leaves the slave threads running after the test is skipped, causing a
following test to fail during rpl setup.

Also rename have_normal_bzip.inc to the more appropriate _zlib.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-01-12 17:22:08 +01:00
Anel Husakovic
8a763c014e MDEV-32235: mysql_json cannot be used on newly created table
- Closes PR #2839
- Usage of `Column_definition_fix_attributes()` suggested by Alexandar
  Barkov - thanks bar, that is better than hook in server code
  (reverted 22f3ebe4bf)
  - This method is called after parsing the data type:
    * in `CREATE/ALTER TABLE`
    * in SP: return data type, parameter data type, variable data type
  - We want to disallow all these use cases of MYSQL_JSON.

- Reviewer: bar@mariadb.com
            cvicentiu@mariadb.org
2024-01-12 19:13:28 +04:00
Anel Husakovic
8b5c1d5afa Revert "MDEV-32235: mysql_json cannot be used on newly created table"
This reverts commit 22f3ebe4bf.
2024-01-12 18:52:12 +04:00
Anel Husakovic
22f3ebe4bf MDEV-32235: mysql_json cannot be used on newly created table
Closes PR #2839
Reviewer: cvicentiu@mariadb.org
2024-01-11 16:07:01 +01:00
Anel Husakovic
9a5f85dcbe MDEV-32790: Output result in show create table for mysql_json type should be longtext
- We don't test `json` MySQL tables from `std_data` since the error `ER_TABLE_NEEDS_REBUILD
` is invoked. However MDEV-32235 will override this test after merge,
but leave it to show behavior and historical changes.

- Closes PR #2833
Reviewer: <cvicentiu@mariadb.org>
          <serg@mariadb.com>
2024-01-11 14:44:33 +01:00