Commit graph

75035 commits

Author SHA1 Message Date
Sergei Petrunia
ed027d65f1 MDEV-33747: Optimization of (SELECT) IN (SELECT ...) executes subquery at prepare stage
Make IN->EXISTS rewrite not to compute constant left expression if it
has a subquery in it.
2024-03-26 12:45:36 +03:00
Marko Mäkelä
17573166c4 MDEV-22742 fixup: Remove a suppression 2024-03-26 10:47:50 +02:00
Daniele Sciascia
e0c8165487 MDEV-33509 Failed to apply write set with flags=(rollback|pa_unsafe)
Fix function `remove_fragment()` in wsrep_schema so that no error is
raised if the fragment to be removed is not found in the
wsrep_streaming_log table. This is necessary to handle the case where
streaming transaction in idle state is BF aborted. This may result in
the case where the rollbacker thread successfully removes the
transaction's fragments, followed by the applier's attempt to remove
the same fragments. Causing the node to leave the cluster after
reporting a "Failed to apply write set" error.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-03-26 05:56:37 +01:00
Vladislav Vaintroub
af85e2ba19 MTR, Windows - remove --verbose-restart output on buildbot run
MTR buildbot output suggest that buildbot can lose some stdout information
by overwriting it with stderr, which is captured separately

This is bad, since stdout contains information about failing test.
So, this is an attempt to minimize the damage by excluding most frequent
stderr messages - those about restart.
2024-03-18 22:28:16 +01:00
Vladislav Vaintroub
5abf0fea51 mtr - synchronize output between different threads on Windows.
An attempt to fix lost output sometimes seen on buildbot.
2024-03-18 22:03:21 +01:00
mariadb-DebarunBanerjee
d912a6369c MDEV-31154 Fatal InnoDB error or assertion `!is_v' failure upon multi-update with indexed virtual column
MDEV-33558 Fatal error InnoDB: Clustered record field for column x not found

This is issue is about row ID filtering used with index on virtual
column(s). We hit debug assert and crash while building the record
template in Innodb. The primary reason is that we try to force the code
path to use the ICP path. With ICP, we don't support index with virtual
column and we validate it while index condition is pushed.

Simplify the code for building template to handle both ICP and Row ID
filtering by skipping virtual columns.
2024-03-15 19:29:46 +05:30
Thirunarayanan Balathandayuthapani
f5df4482e0 MDEV-33214 Table is getting rebuild with ALTER TABLE ADD COLUMN
Problem:
======
- InnoDB fail to do instant operation while adding the variable
length column. Problem is that InnoDB wrongly assumes that
variable character length can never part of externally stored
page.

Solution:
========
instant_alter_column_possible(): Variable length
character field can be stored as externally stored page.
2024-03-15 14:04:59 +05:30
Kristian Nielsen
ef7abc881c MDEV-10793: MDEV-33292: main.kill_processlist-6619 fails sporadically in buildbot
There were several races in the main.kill_processlist-6619 testcase:

 - Lingering connections from a previous test case could be visible in SHOW
   PROCESSLIST and cause .result diff.
 - A sync point "dispatch_command_end" was ineffective, as it was consumed at
   the end of the SET DEBUG command itself.
 - The signal from sync point "before_execute_sql_command" could override an
   earlier signal, causing DEBUG_SYNC timeout and test failure.
 - The final SHOW PROCESSLIST could occasionally see a connection in state
   "Busy" instead of the expected "Sleep".

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-03-14 22:48:12 +01:00
Monty
ae063e4ff5 Fixed random failure in main.kill_processlist-6619
The problem was that SHOW PROCESSLIST was done before the command of
the default connection was cleared.

Reviewer: Sergei Golubchik <serg@mariadb.org>
2024-03-14 21:02:29 +01:00
Dmitry Shulga
d7758debae MDEV-33218: Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed in st_select_lex::fix_prepare_information
In case there is a view that queried from a stored routine or
a prepared statement and this temporary table is dropped between
executions of SP/PS, then it leads to hitting an assertion
at the SELECT_LEX::fix_prepare_information. The fired assertion
 was added by the commit 85f2e4f8e8
(MDEV-32466: Potential memory leak on executing of create view statement).
Firing of this assertion means memory leaking on execution of SP/PS.
Moreover, if the added assert be commented out, different result sets
can be produced by the statement SELECT * FROM the hidden table.

Both hitting the assertion and different result sets have the same root
cause. This cause is usage of temporary table's metadata after the table
itself has been dropped. To fix the issue, reload the cache of stored
routines. To do it  cache of stored routines is reset at the end of
execution of the function dispatch_command(). Next time any stored routine
be called it will be loaded from the table mysql.proc. This happens inside
the method Sp_handler::sp_cache_routine where loading of a stored routine
is performed in case it missed in cache. Loading is performed unconditionally
while previously it was controlled by the parameter lookup_only. By that
reason the signature of the method Sroutine_hash_entry::sp_cache_routine
was changed by removing unused parameter lookup_only.

Clearing of sp caches affects the test main.lock_sync since it forces
opening and locking the table mysql.proc but the test assumes that each
statement locks its tables once during its execution. To keep this invariant
the debug sync points with names "before_lock_tables_takes_lock" and
"after_lock_tables_takes_lock" are not activated on handling the table
mysql.proc
2024-03-14 15:43:03 +07:00
Kristian Nielsen
0a6f46965a MDEV-33475: --gtid-ignore-duplicate can double-apply event in case of parallel replication retry
When rolling back and retrying a transaction in parallel replication, don't
release the domain ownership (for --gtid-ignore-duplicates) as part of the
rollback. Otherwise another master connection could grab the ownership and
double-apply the transaction in parallel with the retry.

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-03-13 16:59:10 +01:00
Dmitry Shulga
428a673152 MDEV-33549: Incorrect handling of UPDATE in PS mode in case a table's colum declared as NOT NULL
UPDATE statement that is run in PS mode and uses positional parameter
handles columns declared with the clause DEFAULT NULL incorrectly in
case the clause DEFAULT is passed as actual value for the positional
parameter of the prepared statement. Similar issue happens in case
an expression specified in the DEFAULT clause of table's column definition.

The reason for incorrect processing of columns declared as DEFAULT NULL
is that setting of null flag for a field being updated was missed
in implementation of the method Item_param::assign_default().
The reason for incorrect handling of an expression in DEFAULT clause is
also missed saving of a field inside implementation of the method
Item_param::assign_default().
2024-03-12 16:13:49 +07:00
Thirunarayanan Balathandayuthapani
738da4918d MDEV-32346 Assertion failure sym_node->table != NULL in pars_retrieve_table_def on UPDATE
- During update operation, InnoDB should avoid the initializing
the FTS_DOC_ID of foreign table if the foreign table is discarded
2024-03-06 14:04:49 +05:30
Thirunarayanan Balathandayuthapani
8532dd82f1 MDEV-13765 encryption.encrypt_and_grep failed in buildbot with wrong result
- Adjust the test case to check whether all tablespaces
are encrypted by comparing it with existing table count.
2024-03-06 11:57:09 +05:30
Alexey Botchkov
b93252a303 MDEV-32454 JSON test has problem in view protocol.
Few Item_func_json_xxx::fix_length_and_dec() functions fixed.
2024-03-02 14:58:57 +04:00
Thirunarayanan Balathandayuthapani
57cc8605eb MDEV-19044 Alter table corrupts while applying the modification log
Problem:
========
- InnoDB reads the length of the variable length field wrongly
while applying the modification log of instant table.

Solution:
========
rec_init_offsets_comp_ordinary(): For the temporary instant
file record, InnoDB should read the length of the variable length
field from the record itself.
2024-02-27 12:59:46 +05:30
Kristian Nielsen
c73c6aea63 MDEV-33426: Aria temptables wrong thread-specific memory accounting in slave thread
Aria temporary tables account allocated memory as specific to the current
THD. But this fails for slave threads, where the temporary tables need to be
detached from any specific THD.

Introduce a new flag to mark temporary tables in replication as "global",
and use that inside Aria to not account memory allocations as thread
specific for such tables.

Based on original suggestion by Monty.

Reviewed-by: Monty <monty@mariadb.org>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-02-16 12:48:30 +01:00
Oleksandr Byelkin
ae709b64e2 fix view protocol in MDEV-29179 2024-02-13 09:24:32 +01:00
Marko Mäkelä
ca88eac835 MDEV-30528 CREATE FULLTEXT INDEX assertion failure WITH SYSTEM VERSIONING
ha_innobase::check_if_supported_inplace_alter(): Require ALGORITHM=COPY
when creating a FULLTEXT INDEX on a versioned table.

row_merge_buf_add(), row_merge_read_clustered_index(): Remove the parameter
or local variable history_fts that had been added in the attempt to fix
MDEV-25004.

Reviewed by: Thirunarayanan Balathandayuthapani
Tested by: Matthias Leich
2024-02-12 16:52:55 +01:00
Rex
36f51d9748 MDEV-29179 Condition pushdown from HAVING into WHERE is not shown in optimizer trace
JOIN::optimize_inner(), Condition pushdown from HAVING into WHERE
	  not shown in optimizer trace.
2024-02-11 22:21:32 +01:00
Oleksandr Byelkin
d816a5ca32 fix test 2024-02-09 10:26:46 +01:00
Dmitry Shulga
e48bd474a2 MDEV-15703: Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
This patch fixes the issue with passing the DEFAULT or IGNORE values to
positional parameters for some kind of SQL statements to be executed
as prepared statements.

The main idea of the patch is to associate an actual value being passed
by the USING clause with the positional parameter represented by
the Item_param class. Such association must be performed on execution of
UPDATE statement in PS/SP mode. Other corner cases that results in
server crash is on handling CREATE TABLE when positional parameter
placed after the DEFAULT clause or CALL statement and passing either
the value DEFAULT or IGNORE as an actual value for the positional parameter.
This case is fixed by checking whether an error is set in diagnostics
area at the function pack_vcols() on return from the function pack_expression()
2024-02-08 09:21:54 +01:00
Marko Mäkelä
85db534731 MDEV-33400 Adaptive hash index corruption after DISCARD TABLESPACE
row_discard_tablespace(): Do not invoke dict_index_t::clear_instant_alter()
because that would corrupt any adaptive hash index entries in the table.

row_import_for_mysql(): Invoke dict_index_t::clear_instant_alter()
after detaching any adaptive hash index entries.
2024-02-08 09:17:47 +01:00
Oleksandr Byelkin
8adc759988 Merge branch '10.4' into mariadb-10.4.33 2024-02-06 15:58:12 +01:00
Otto Kekäläinen
3812e1c958 Fix commit 179424db: No test file or result files should be executable
In commit 179424db the file lowercase_table2.result was made executable
for no known reason, most likely just a mistake. Test result files
definitely should not be executable.

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.
2024-02-05 09:18:20 +01:00
Igor Babaev
05314ed0d4 MDEV-31305 Crash caused by query with aggregation over materialized derived
This bug was fixed by the patch for bug MDEV-30706.
Only a test case is added in this commit.
2024-01-31 23:50:41 -08: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
Denis Protivensky
f4ee7c110c MDEV-22232 Fix test after changing behavior of ALTER DROP FOREIGN KEY
Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-01-30 15:47:47 +01:00
Monty
57ffcd686f MDEV-21472: ALTER TABLE ... ANALYZE PARTITION ... with EITS reads and locks all rows
This was fixed in 10.2 in 2020 but merging the code to 10.3 caused the
bug to come back.
2024-01-30 09:19:01 +02: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
Jan Lindström
f8fa3c55c6 MDEV-33173 : Galera test case galera_sr_kill_slave_before_apply unstable
Add wait_condition to make sure tables are created before next
operations.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-01-30 00:28:33 +01:00
Jan Lindström
ddb27a29b1 MDEV-33172 : Galera test case galera_mdl_race unstable
Add wait_condition between debug sync SIGNAL points and other
expected state conditions and refactor actual sync point for
easier to use in test case.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-01-30 00:27:37 +01:00
Jan Lindström
5b4456b38a MDEV-33036 : Galera test case galera_3nodes.galera_ist_gcache_rollover has warning
Correct used configuration and force server restarts before test
case. Add wait condition instead of sleep to verify that
all expected nodes are back to cluster.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-01-30 00:26:13 +01:00
Jan Lindström
49fa5f6b5f MDEV-33138 : Galera test case MW-336 unstable
Add more inserts before wsrep_slave_threads is set to 1 and
add wait_condition to wait all of them are replicated before
wait_condition about number of wsrep_slave_threads.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-01-30 00:22:42 +01:00
Jan Lindström
736e429320 MDEV-32635: galera_shutdown_nonprim: mysql_shutdown failed
Add wait_condition after cluster membership change

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-01-30 00:22:23 +01:00
Brandon Nesterenko
e4f221a5f2 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-29 15:17:57 -07:00
Jan Lindström
c768ac6208 MDEV-25731 : Assertion `mode_ == m_local' failed in wsrep::client_state::streaming_params()
Problem was that if wsrep_load_data_splitting was used
streaming replication (SR) parameters were set
for MyISAM table. Galera does not currently support SR for
MyISAM.

Fix is to ignore wsrep_load_data_splitting setting (with
warning) if table is not InnoDB table.

This is 10.4-10.5 case of fix.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-01-29 06:34:46 +01:00
Jan Lindström
daaa16a47f MDEV-25089 : Assertion `error.len > 0' failed in galera::ReplicatorSMM::handle_apply_error()
Problem is that Galera starts TOI (total order isolation) i.e.
it sends query to all nodes. Later it is discovered that
used engine or other feature is not supported by Galera.
Because TOI is executed parallelly in all nodes appliers
could execute given TOI and ignore the error and
start inconsistency voting causing node to leave from
cluster or we might have a crash as reported.

For example SEQUENCE engine does not support GEOMETRY data
type causing either inconsistency between nodes (because
some errors are ignored on applier) or crash.

Fixed my adding new function wsrep_check_support to check
can Galera support provided CREATE TABLE/SEQUENCE before TOI is
started and if not clear error message is provided to
the user.

Currently, not supported cases:

* CREATE TABLE ... AS SELECT when streaming replication is used
* CREATE TABLE ... WITH SYSTEM VERSIONING AS SELECT
* CREATE TABLE ... ENGINE=SEQUENCE
* CREATE SEQUENCE ... ENGINE!=InnoDB
* ALTER TABLE t ... ENGINE!=InnoDB where table t is SEQUENCE

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-01-29 06:34:46 +01:00
Jan Lindström
3228c08fa8 MDEV-22063 : Assertion `0' failed in wsrep::transaction::before_rollback
Problem was that REPLACE was using consistency check that started
TOI and we tried to rollback it.

Do not use wsrep_before_rollback and wsrep_after_rollback if
we are runing consistency check because no writeset keys are
in that case added. Do not allow consistency check usage
if table storage for target table is not InnoDB, instead
give warning. REPLACE|SELECT INTO ... SELECT will use
now TOI if table storage for target table is not InnoDB
to maintain consistency between galera nodes.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-01-29 06:34:46 +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
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
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
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
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
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
Oleksandr Byelkin
f807a9f874 MDEV-31523 Using two temporary tables in OPTIMIZE TABLE lead to crash
Fixed typo in mysql_admin_table which cused call of
close_unused_temporary_table_instances alwas for the first table
instead of the current table.

Added ASSERT that close_unused_temporary_table_instances should not
remove all instances of user created temporary table.
2024-01-11 11:21:32 +01:00
Alexander Barkov
9322ef03e3 MDEV-32645 CAST(AS UNSIGNED) fails with --view-protocol
Item_float::neg() did not preserve the "presentation" from "this".
So
  CAST(-1e0 AS UNSIGNED)  -- cast from double to unsigned
changes its meaning to:
  CAST(-1 AS UNSIGNED)  -- cast signed to undigned

Fixing Item_float::neg() to construct the new value for
Item_float::presentation as follows:
- if the old value starts with minus, then the minus is truncated:
  '-2e0' -> '2e0'
- otherwise, minus sign followed by its old value:
  '1e0'  -> '-1e0'
2024-01-09 11:44:05 +04:00
Yuchen Pei
ca276a0f3f
MDEV-33169 Reset sequence used fields after check in alter sequence
The bitmap is temporarily flipped to ~0 for the sake of checking all
fields. It needs to be restored because it will be reused in second
and subsequent ps execution.
2024-01-09 09:50:54 +11:00
Sergei Golubchik
ac0ce44519 ./mtr --skip-not-found should skip combinations too
With the result like

encryption.innochecksum 'debug'   [ skipped ] combination not found

instead of

*** ERROR: Could not run encryption.innochecksum with 'debug' combination(s)
2024-01-08 13:57:51 +01:00