Commit graph

184202 commits

Author SHA1 Message Date
Sergei Golubchik
6f40d5c8d6 Item_func_like::walk() was ignoring escape_item
in particular, it caused escape_item->is_expensive() property
to be lost instead of being properly propagated up.
2020-12-19 11:44:42 +01:00
Sergei Golubchik
59211ab7b9 MDEV-24346 valgrind error in main.precedence
Part II.

It's still possible to bypass Item_func_like::escape
initialization in Item_func_like::fix_fields().

This requires ESCAPE argument being a cacheable subquery
that uses tables and is inside a derived table which
is used in multi-update.

Instead of implementing a complex or expensive fix for
this particular ridiculously artificial case, let's simply disallow it.
2020-12-19 11:44:42 +01:00
Sergei Golubchik
a587ded283 MDEV-24346 valgrind error in main.precedence
in queries like

  create view v1 as select 2 like 1 escape (3 in (select 0 union select 1));
  select 2 union select * from v1;

Item_func_like::escape was left uninitialized, because
Item_in_optimizer is const_during_execution()
but not actually const_item() during execution.

It's not, because const subquery evaluation was disabled for derived.
Practically it only needs to be disabled for multi-update
that runs fix_fields() before all tables are locked.
2020-12-19 11:44:42 +01:00
Sergei Golubchik
5785de72ac Item_func_like calls escape_item->fix_fields() twice
this happens if Item_func_like is copied (get_copy()).
after one copy gets fixed, the other tries to fix escape item again.
2020-12-19 11:44:42 +01:00
Jan Lindström
d1e9a4c15c MDEV-23065 : Crash after setting wsrep_on to ON dynamically and reconnect
At end_connection make sure we have wsrep before trying to free
connection assigned to it.
2020-12-19 09:43:13 +02:00
Alice Sherepa
4e43e2f92d MDEV-22008 rpl.rpl_semi_sync fails in bb, MDEV-24418 reenable binlog_truncate_innodb and binlog_spurious_ddl_errors, rpl_parallel_retry fails in bb 2020-12-18 19:31:51 +01:00
Olivier Bertrand
24c18ce892 - Fix json parser (void objects not recognized) modified: json.cpp 2020-12-18 18:59:52 +01:00
Nikita Malyavin
83d2e0841e MDEV-24041 Generated column DELETE with FOREIGN KEY crash InnoDB
row_upd_clust_step() calls row_upd_del_mark_clust_rec() which would
allocate some memory in row_ins_foreign_fill_virtual(). Then,
row_upd_store_row() would access the allocated memory, but only after
potentially freeing that memory by invoking mem_heap_empty(),
leading to ASAN heap-use-after-free diagnostics.

row_ins_foreign_fill_virtual(): Use a more appropriate memory heap with a
longer lifetime.
2020-12-18 20:17:45 +10:00
Igor Babaev
25d6f634b8 MDEV-20751 Permission Issue With Nested CTEs
Due to this bug the server reported bogus messages about lack of SELECT
privileges for base tables used in the specifications of CTE tables.
It happened only if such a CTE were referred to at least twice.
For any non-recursive reference to CTE that is not primary the
specification of the CTE is cloned. The function check_table_access() is
called for such reference. The function checks privileges of the tables
referenced in the specification. As no name resolution was performed for
CTE references whose definitions occurred outside the specification before
the call of check_table_access() that was supposed to check the access
rights of the underlying tables these references were considered
as references to base tables rather than references to CTEs. Yet for CTEs
as well as for derived tables no privileges are needed and thus cannot
be granted.
The patch ensures proper name resolution of all references to CTEs before
any acl checks.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2020-12-17 13:44:06 -08:00
Olivier Bertrand
a786741000 - Fix crash with JsonContains UDF + BSON development 2020-12-17 13:58:13 +01:00
sjaakola
2cb5fb6019 MDEV-24327 wsrep XID checkpointing order with log_slave_updates=OFF
If log_slave_updates==OFF, wsrep applier threads used to be configured
with option: thd->variables.option_bits&= ~(OPTION_BIN_LOG);
(i.e. like sql_log_bin=ON). And this was regardless of log-bin configuration.

With this, having configuration of: --log-bin && --log-slave-updates=OFF,
local threads used binlogging, but applier threads did not. And further:
local threads went through binlog group commit, while applier threads did
direct commits. This resulted in situation, where applier threads entered
earlier in wsrep XID checkpointing, and could sync their wsrep XID out of order.
Later local thread commit would see that higher seqno was already checkpointed,
and fire an assert because of this.

As a fix, applier threads are now forced to enable binlogging regardless of
log-slave-updates configuration.

This PR comes with new mtr test: galera.MDEV-24327, which causes a scenario
where applier transaction is applied and committed while earlier local transaction
is parked before commit order monitor enter. A buggy mariadb versoin would fail
for assertion because of wsrep XID checkpoint order violation.

Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
2020-12-17 10:07:34 +02:00
Igor Babaev
a244be7044 MDEV-23406 Signal 8 in maria_create after recursive cte query
This bug could cause a crash when executing queries that used mutually
recursive CTEs with system variable big_tables set to 1. It happened due
to several bugs in the code that handled recursive table references
referred mutually recursive CTEs. For each recursive table reference a
temporary table is created that contains all rows generated for the
corresponding recursive CTE table on the previous step of recursion.
This temporary table should be created in the same way as the temporary
table created for a regular materialized derived table using the
method select_union::create_result_table(). In this case when the
temporary table is created it uses the select_union::TMP_TABLE_PARAM
structure as the parameter for the table construction. However the
code created the temporary table using just the function create_tmp_table()
and passed pointers to certain fields of the TMP_TABLE_PARAM structure
used for accumulation of rows of the recursive CTE table as parameters
for update. This was a mistake because now different temporary tables
cannot share some TMP_TABLE_PARAM fields in a general case. Besides,
depending on how mutually recursive CTE tables were defined and which
of them were referred in the executed query the select_union object
allocated for a recursive table reference could be allocated again after
the the temporary table had been created. In this case the TMP_TABLE_PARAM
object associated with the temporary table created for the recursive
table reference contained unassigned fields needed for execution when
Aria engine is employed as the engine for temporary tables.
This patch ensures that
- select_union object is created only once for any recursive table
  reference
- any temporary table created for recursive CTEs uses its own
  TMP_TABLE_PARAM structure
The patch also fixes a problem caused by incomplete cleanup of join tables
associated with recursive table references.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2020-12-16 09:13:24 -08:00
Vlad Lesin
719da2c4cc MDEV-22810 mariabackup does not honor open_files_limit from option during backup prepare
open_files_limit option was processed only for --backup, but not for
--prepare.
2020-12-16 10:23:41 +03:00
Daniel Black
aebb111269 MDEV-21958: postfix - result of range_mrr_icp 2020-12-16 10:26:29 +11:00
Daniel Black
2c4761ccc1 MDEV-24172: innodb stats table last_update is TIMESTAMP
The last_updated column of innodb_table_stats and innodb_index_stats
hasn't been DATA_FIXBINARY for many years.

Innodb represents TIMESTAMP as INT of length 4. Let's test it with this
and stop hiding the result in mysql_upgrade test.

Reviewer: Marko
2020-12-16 08:18:19 +11:00
Stepan Patryshev
dc62a67ed3 MDEV-24414 Update and enable galera.galera_defaults 2020-12-15 18:05:59 +02:00
Sergei Petrunia
066212d16c MDEV-21958: Query having many NOT-IN clauses running forever
Basic variant of the fix: do not consider conditions in form

  unique_key NOT IN (c1,c2...)

to be sargable. If there are only a few constants, the condition
is not selective. If there are a lot constants, the overhead of
processing such a huge range list is not worth it.

(Backport to 10.2)
2020-12-15 14:38:30 +03:00
Olivier Bertrand
ceacffbb3b - Fix pretty=2 Tabjson bug on INSERT.
Occuring when inserting more than one line in one statement.
  modified:   storage/connect/json.cpp

- Fix a wrong if statement
  modified:   storage/connect/tabjson.cpp

- Continue BSON implementation
  modified:   storage/connect/bson.cpp
  modified:   storage/connect/bson.h
  modified:   storage/connect/filamtxt.cpp
  modified:   storage/connect/filamtxt.h
  modified:   storage/connect/tabbson.cpp
  modified:   storage/connect/tabbson.h

- No need anymore
  deleted:    storage/connect/mysql-test/connect/r/bson.result
  deleted:    storage/connect/mysql-test/connect/t/bson.test
2020-12-15 12:28:03 +01:00
Vladislav Vaintroub
ac9c6f53a5 MDEV-24034 Policy CMP0075 is not set during compile
The policy is not set for 10.2
If it is set, CMake would complain about bundled zlib for which the policy
is not set.

Fix:
- Set policy for 10.2 for the top level project.
For 10.3+ it was already set

- Cleanup zlib to remove unneeded stuff. It is an internal static library,
it needs none of PROJECT, library versioning, RC file on Windows.
The name of the library on Unix does not make any difference, since it is
static and compiled in.
2020-12-15 12:27:13 +01:00
Rucha Deodhar
74223c33d1 MDEV-23209: Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())'
failed in Diagnostics_area::set_ok_status on INSERT

Analysis: Error is not returned when strict mode is enabled and value is
truncated because double is outside range.
Fix: Return HA_ERR_AUTOINC_ERANGE if the error was reported when double is
outside range.
2020-12-15 13:00:24 +05:30
Rucha Deodhar
5f4d351d7f MDEV-22422: Assertion `! is_set()' failed in Diagnostics_area::set_eof_status
Analysis: The error is not returned when the statement can't be used.
And so we still go on to search for keywords.
Fix: Return the error state.
2020-12-15 13:00:24 +05:30
Daniel Black
384f107ae5 MDEV-21646: postfix - my_addr_resolve: static Dl_info info
Encountered the linker failure on Debug build in 10.4:

[53/585] Linking CXX executable unittest/sql/mf_iocache-t
FAILED: unittest/sql/mf_iocache-t
: && /usr/bin/c++  -pie -fPIC -fstack-protector --param=ssp-buffer-size=4 -fPIC -g -DENABLED_DEBUG_SYNC -ggdb3 -DSAFE_MUTEX -DSAFEMALLOC -DTRASH_FREED_MEMORY -Wall -Wextra -Wno-format-truncation -Wno-init-self -Wno-nonnull-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wvla -Wwrite-strings -Werror  -Wl,-z,relro,-z,now unittest/sql/CMakeFiles/mf_iocache-t.dir/mf_iocache-t.cc.o unittest/sql/CMakeFiles/mf_iocache-t.dir/__/__/sql/mf_iocache_encr.cc.o  -o unittest/sql/mf_iocache-t  -lpthread  mysys/libmysys.a  unittest/mytap/libmytap.a  mysys_ssl/libmysys_ssl.a  mysys/libmysys.a  dbug/libdbug.a  mysys/libmysys.a  dbug/libdbug.a  -lz  -lm  strings/libstrings.a  -lpthread  -lssl  -lcrypto  -ldl && :
/usr/bin/ld: mysys/libmysys.a(my_addr_resolve.c.o):/home/dan/repos/mariadb-server-10.4/mysys/my_addr_resolve.c:173: multiple definition of `info'; unittest/sql/CMakeFiles/mf_iocache-t.dir/mf_iocache-t.cc.o:/home/dan/repos/mariadb-server-10.4/unittest/sql/mf_iocache-t.cc:99: first defined here

We make Dl_info static as in MDEV-21646 moving it out of the function
was the main goal and having it scope limited by static doesn't affect
the function.
2020-12-15 14:47:16 +11:00
Sergei Golubchik
4fa44c584c MDEV-24331 mysqldump fails with "Got error: 1356" if the database contains a view with a subquery
detect derived tables differently. TABLE_LIST::is_derived()
only works after mysql_derived_init()
2020-12-11 19:35:38 +01:00
Olivier Bertrand
aa10789f47 BSON development 2020-12-11 16:34:50 +01:00
Sergei Golubchik
79fd338e6c MDEV-23942 mariadb-10.5.6/storage/connect/plugutil.cpp:380: bad width ?
cppcheck warnings
2020-12-10 15:25:14 +01:00
Sergei Golubchik
493c7d34cb MDEV-24194 View definition corruption
fix parsing of "1 IS NULL = 2"
2020-12-10 08:45:20 +01:00
Sergei Golubchik
f6e91552f0 MDEV-4677 GROUP_CONCAT not showing any output with group_concat_max_len >= 4Gb
don't allow group_concat_max_len values >= 4Gb
(they never worked anyway)
2020-12-10 08:45:20 +01:00
Sergei Golubchik
e189faf0b3 document that a fulltext parser plugin can replace mysql_add_word callback 2020-12-10 08:45:20 +01:00
Sergei Golubchik
aeb561cf3e tests for YEAR(N) 2020-12-10 08:45:20 +01:00
Sergei Golubchik
ba33d4753e cleanup: type_year test formatting 2020-12-10 08:45:20 +01:00
Sergei Golubchik
589479b3ec MDEV-14836 Assertion `m_status == DA_ERROR' failed in Diagnostics_area::sql_errno upon query from I_S with LIMIT ROWS EXAMINED
Make the test case more robust. We only care that the query returns
no rows and that the server doesn't crash.
2020-12-10 08:45:20 +01:00
Sergei Golubchik
b31912fd35 MDEV-24033: SIGSEGV in __memcmp_avx2_movbe from queue_insert | SIGSEGV in __memcmp_avx2_movbe from native_compare
don't allow too small max_sort_length values
2020-12-10 08:45:20 +01:00
Sergei Golubchik
59bbe873d4 Revert "MDEV-24033: SIGSEGV in __memcmp_avx2_movbe from queue_insert | SIGSEGV in __memcmp_avx2_movbe from native_compare"
This reverts commit 5a0c34e4c2.
but keeps the test case
2020-12-10 08:45:20 +01:00
Aleksey Midenkov
f99abb45c5 MDEV-17573 Assertion in federatedx on multi-update
Cause: shared federatedx_io cannot store table-specific data.

Fix: move current row reference `federatedx_io_mysql::current` to
ha_federatedx.

FederatedX connection (represented by federatedx_io) is stored into
federatedx_txn::txn_list of per-server connections (see
federatedx_txn::acquire()). federatedx_txn object is stored into THD
(see ha_federatedx::external_lock()). When multiple handlers acquire
FederatedX connection they get single federatedx_io instance. Multiple
handlers do their operation via federatedx_io_mysql::mark_position()
and federatedx_io_mysql::fetch_row() in arbitrarty manner. They access
the same federatedx_io_mysql instance and same MYSQL_ROWS *current
pointer, so one handler disrupts the work of the other.

Related to "MDEV-14551 Can't find record in table on multi-table update
with ORDER BY".
2020-12-09 20:15:29 +03:00
Olivier Bertrand
4eeadedc77 - Fix json_bjson (s was erase by Json_Subset)
modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/jsonudf.h

- Fix compile error (Force_Bson was not conditional by BSON_SUPPORT)
  modified:   storage/connect/ha_connect.cc

- Continue Bjson implementation
  modified:   storage/connect/block.h
  modified:   storage/connect/bson.cpp
  modified:   storage/connect/bson.h
  modified:   storage/connect/bsonudf.cpp
  modified:   storage/connect/bsonudf.h
  modified:   storage/connect/plugutil.cpp
  modified:   storage/connect/tabbson.cpp
  modified:   storage/connect/tabjson.cpp

- Typo
  deleted:    storage/connect/Header.h
2020-12-09 00:55:06 +01:00
Igor Babaev
a3f7f2334a MDEV-24019 Assertion is hit for query using recursive CTE with no default DB
When the query using a recursive CTE whose definition contained wildcard
symbols in the recursive part was processed at the prepare stage an
assertion was hit if the query was executed without any default database
set. The failure happened when the function insert_fields() tried to check
column privileges for the temporary table created for a recursive
reference to the CTE. No acl checks are needed for any CTE. That's why this
check should be blocked as well. The patch formulates a stricter condition
at which this check is to be blocked that covers the case when a query
using recursive CTEs is executed with no default database set.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2020-12-08 11:13:36 -08:00
Olivier Bertrand
871532c3b9 - Continue BSON implementation
modified:   storage/connect/bson.cpp
  modified:   storage/connect/bson.h
  modified:   storage/connect/bsonudf.cpp
  modified:   storage/connect/cmgfam.cpp
  modified:   storage/connect/cmgfam.h
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/jmgfam.cpp
  modified:   storage/connect/jmgfam.h
  modified:   storage/connect/jmgoconn.cpp
  modified:   storage/connect/mycat.cc
  modified:   storage/connect/tabbson.cpp
  modified:   storage/connect/tabjson.cpp
2020-12-08 01:15:40 +01:00
Igor Babaev
2db6eb1429 MDEV-22781 CREATE VIEW containing WITH clause Signal 11
For table references to CTEs the field TABLE_LIST::db must be set to
an empty string as it's done for table references to derived tables in
order CTEs to be processed similar to how derived tables are processed.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2020-12-07 09:26:40 -08:00
Anel Husakovic
f924a3bd6c MDEV-24139: CHECK_CLAUSE field in INFORMATION_SCHEMA.CHECK_CONSTRAINTS truncate check constraints expressions
- Reviewed by: daniel@mariadb.org
2020-12-07 09:56:06 +01:00
Anel Husakovic
eb7b14ec9a MDEV-21367: mysqld_safe log don't log to err.log
Introduced with 6b7918d524 in `10.2` just check for helper and handle
it if exist.

Reviewed by: cvicentiu@mariadb.org
2020-12-07 09:56:06 +01:00
Anel Husakovic
a82209ca31 MDEV-24177 && MDEV-24178
- MDEV-24177: main.sp2 test fails: Result length mismatch
- MDEV-24178: main.upgrade_MDEV-19650 test fails: Result length mismatch

Reviewed by: serg@mariadb.com
2020-12-07 09:56:06 +01:00
Olivier Bertrand
c05b1288fd Remove a push warning causing failing assert. Modified storage/connect/filamap.cpp 2020-12-04 23:21:59 +01:00
Igor Babaev
50d7eddc3d MDEV-24314 Unexpected error message when selecting from view that uses
mergeable derived table

Do not check privileges for derived tables/CTEs and their fields.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
2020-12-04 08:53:40 -08:00
Marko Mäkelä
1eb59c307d MDEV-24340 Unique final message of InnoDB during shutdown
innobase_space_shutdown(): Remove. We want this step to be executed
before the message "InnoDB: Shutdown completed; log sequence number "
is output by innodb_shutdown(). It used to be executed after that step.

innodb_shutdown(): Duplicate the code that used to live in
innobase_space_shutdown().

innobase_init_abort(): Merge with innobase_space_shutdown().
2020-12-04 11:46:47 +02:00
Olivier Bertrand
4b6d661c7f Fix failed compile modified storage/connect/ha_connect.cc 2020-12-02 00:35:58 +01:00
Olivier Bertrand
7d439334ff Fix failed compile modified storage/connect/ha_connect.cc and mycat.cc 2020-12-01 20:57:05 +01:00
Olivier Bertrand
4e8af8a664 - Fix memory leak for the JSON table type
(and continue BSON implementatio)
  modified:   storage/connect/bson.cpp
  modified:   storage/connect/bson.h
  modified:   storage/connect/bsonudf.cpp
  modified:   storage/connect/connect.cc
  modified:   storage/connect/global.h
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/mycat.cc
  modified:   storage/connect/plgdbsem.h
  modified:   storage/connect/plugutil.cpp
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabjson.h
  modified:   storage/connect/user_connect.cc

- Desesperatly trying to fix xml.test failure
  modified:   storage/connect/mysql-test/connect/r/xml.result
2020-12-01 19:39:09 +01:00
Alexey Botchkov
178d32f03b MDEV-24318 server_audit doesn't respect filters for PROXY_CONNECT
events.

The log line should be added behind the filters.
2020-12-01 14:13:05 +04:00
Vlad Lesin
e6b3e38d62 MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.

When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.

For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.

During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.

For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.

If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-12-01 08:08:57 +03:00
Monty
828471cbf8 MDEV 15532 Assertion `!log->same_pk' failed in row_log_table_apply_delete
The reason for the failure is that
thd->mdl_context.release_transactional_locks()
was called after commit & rollback even in cases where the current
transaction is still active.

For 10.2, 10.3 and 10.4 the fix is simple:
- Replace all calls to thd->mdl_context.release_transactional_locks() with
  thd->release_transactional_locks(). The thd function will only call
  the mdl_context function if there are no active transactional locks.
  In 10.6 we will better fix where we will change the return value for
  some trans_xxx() functions to indicate if transaction did close the
  transaction or not. This will avoid the need of the indirect call.

Other things:
- trans_xa_commit() and trans_xa_rollback() will automatically
  call release_transactional_locks() if the transaction is closed.
- We can't do that for the other functions as the caller of many of these
  are doing additional work (like close_thread_tables) before calling
  release_transactional_locks().
- Added missing abort_result_set() and missing DBUG_RETURN in
  select_create::send_eof()
- Fixed wrong indentation in injector::transaction::commit()
2020-11-30 22:21:43 +02:00