Commit graph

67691 commits

Author SHA1 Message Date
Marko Mäkelä
89698cef72 MDEV-10570: Fix -Wmaybe-uninitialized
Rows_log_event::change_to_flashback_event(): Reduce the scope
of the variable swap_buff2, and do not duplicate conditions.

GCC 9.3.0 flagged the -Wmaybe-uninitialized when compiling the
10.5 branch using cmake -DWITH_ASAN=ON -DCMAKE_CXX_FLAGS=-O2
2020-03-17 10:35:56 +02:00
Marko Mäkelä
9f858f38c0 Fix clang 10 warnings
_ma_fetch_keypage(): Correct an assertion that used to always hold.
Thanks to clang -Wint-in-bool-context for flagging this.

double_to_datetime_with_warn(): Suppress -Wimplicit-int-float-conversion
by adding a cast. LONGLONG_MAX converted to double will actually be
LONGLONG_MAX+1.
2020-03-13 08:37:22 +02:00
Marko Mäkelä
47382a2f8c Fix GCC 10 -Wclass-memaccess 2020-03-13 07:53:41 +02:00
Marko Mäkelä
32904dc5fa Merge 10.1 into 10.2 2020-03-13 07:20:36 +02:00
Sergei Petrunia
b30446c85d Fix compile warning:
It was:
implicit conversion from 'ha_rows' (aka 'unsigned long long') to 'double'
changes value from 18446744073709551615 to 18446744073709551616

Follow what JOIN::get_examined_rows() does for similar code.
2020-03-11 13:46:57 +03:00
Jan Lindström
2bf4e574ad MDEV-21758 : Events switched randomly to SLAVESIDE_DISABLED
Change events only on Galera environment where idea is that
event is enabled only on one node of the cluster and nodes
are identified by server_id.
2020-03-09 12:19:11 +02:00
seppo
4618c974e4
MDEV-21723 Async slave thread BF abort and replaying fixes (#1448)
If async replication slave thread conflicts with cluster replication,
then the async slave transaction should be BF aborted, and depending on the
state of async slave transaction execution, potentially also replayed.
There were problems in such BF abort implementation and the replaying was not
started.
This pull request contains fixes which make sure that if async slave thread is
marked to abort and replay, it will complete carry out the rollback and
release all locks and resources before starting the replaying. After replaying,
async slave transactions is treated as successful, so the slave thread will
continue as usual, handling next replication event.

There is also new mtr test: galera.galera_slave_replay, which stresses both a
certification failure for async slave thread and a successful BF abort
followed by replaying.
2020-02-23 10:29:42 +02:00
Alexey Botchkov
f6663bfbd3 MDEV-17941 ALTER USER IF EXISTS does not work, although documentation says it should.
Mistake in syntax definition fixed - should be ALTER USER IF EXISTS,
not ALTER IF EXISTS USER.
2020-02-11 00:19:37 +04:00
Oleksandr Byelkin
594282a534 Merge branch '10.1' into 10.2 2020-02-10 14:31:39 +01:00
Oleksandr Byelkin
716161ea03 Merge branch '5.5' into 10.1 2020-02-10 14:18:00 +01:00
Vladislav Vaintroub
b08579aa28 MDEV-16308 : protocol messed up sporadically
Context involves semicolon batching, and the error starts 10.2
No reproducible examples were made yet, but TCP trace suggests
multiple packets that are "squeezed" together (e.g overlong OK packet
that has a trailer which is belongs to another packet)

Remove thd->get_stmt_da()->set_skip_flush() when processing a batch.
skip_flush stems from the COM_MULTI code, which was checked in during
10.2 (and is never used)

The fix is confirmed to work, when evaluated by bug reporter (one of them)

We never reproduced it locally, with multiple tries
thus the root cause analysis is still missing.
2020-02-10 12:44:53 +01:00
Oleksandr Byelkin
a241d41195 MDEV-18027: Running out of file descriptors and eventual crash
For automatic number of opened files limit take into account number of table instances for table cache
2020-02-05 15:34:02 +01:00
Marko Mäkelä
256994ef74 MDEV-21586: Fix a warning for converting my_bool to bool 2020-01-31 11:33:07 +02:00
Marko Mäkelä
2daf3b14fe Merge 10.1 into 10.2 2020-01-31 10:53:56 +02:00
Vladislav Vaintroub
f37a56de3c MDEV-21586 Server does not start if lc_messages setting was not english.
Fixed a bug introduced in  MDEV-11345, server did not start if
non-english error messages were set in startup parameters.

Added lc_messages=de_DE option into an existing test case.
2020-01-30 18:43:50 +01:00
Anel Husakovic
4932ec871f Clean the comment for table_f_c unt parameter
Deleted with commit: c70a9fa1e3
2020-01-29 12:50:17 +01:00
Sujatha
d89bb88674 MDEV-20923:UBSAN: member access within address … which does not point to an object of type 'xid_count_per_binlog'
Problem:
-------
Accessing a member within 'xid_count_per_binlog' structure results in
following error when 'UBSAN' is enabled.

member access within address 0xXXX which does not point to an object of type
'xid_count_per_binlog'

Analysis:
---------
The problem appears to be that no constructor for 'xid_count_per_binlog' is
being called, and thus the vtable will not be initialized.

Fix:
---
Defined a parameterized constructor for 'xid_count_per_binlog' class.
2020-01-29 16:33:05 +05:30
Oleksandr Byelkin
f2ccfcaca1 Merge branch '10.1' into 10.2 2020-01-24 13:46:49 +01:00
Sujatha
599a06098b MDEV-21490: binlog tests fail with valgrind: Conditional jump or move depends on uninitialised value in sql_ex_info::init
Problem:
=======
P1) Conditional jump or move depends on uninitialised value(s)
    sql_ex_info::init(char const*, char const*, bool) (log_event.cc:3083)

code: All the following variables are not initialized.
----
  return ((cached_new_format != -1) ? cached_new_format :
    (cached_new_format=(field_term_len > 1 || enclosed_len > 1 ||
    line_term_len > 1 || line_start_len > 1 || escaped_len > 1)));

P2) Conditional jump or move depends on uninitialised value(s)
    Rows_log_event::Rows_log_event(char const*, unsigned
      int, Format_description_log_event const*) (log_event.cc:9571)

Code: Uninitialized values is reported for 'var_header_len' variable.
----
  if (var_header_len < 2 || event_len < static_cast<unsigned
      int>(var_header_len + (post_start - buf)))

P3) Conditional jump or move depends on uninitialised value(s)
    Table_map_log_event::pack_info(Protocol*) (log_event.cc:11553)

code:'m_table_id' is uninitialized.
----
  void Table_map_log_event::pack_info(Protocol *protocol)
  ...
  size_t bytes= my_snprintf(buf, sizeof(buf), "table_id: %lu (%s.%s)",
                              m_table_id, m_dbnam, m_tblnam);

Fix:
===
P1 - Fix)
Initialize cached_new_format,field_term_len, enclosed_len, line_term_len,
line_start_len, escaped_len members in default constructor.

P2 - Fix)
"var_header_len" is initialized by reading the event buffer. In case of an
invalid event the buffer will contain invalid data. Hence added a check to
validate the event data. If event_len is smaller than valid header length
return immediately.

P3 - Fix)
'm_table_id' within Table_map_log_event is initialized by reading data from
the event buffer. Use 'VALIDATE_BYTES_READ' macro to validate the current
state of the buffer. If it is invalid return immediately.
2020-01-24 13:35:03 +05:30
Sergei Golubchik
8eec2d61fc MDEV-21249 MariaDB 10.3.10 When referring to bigint to generate timestamp data in the virtual generated column, the value of the generated column does not change when the time zone changes
FROM_UNIXTIME() depends on @@time_zone, so it's VCOL_SESSION_FUNC
2020-01-21 21:15:10 +01:00
Oleksandr Byelkin
3a1716a7e7 Merge branch '10.1' into 10.2 2020-01-20 16:15:05 +01:00
Julius Goryavsky
578b6ba02a MDEV-19457: sys_vars.wsrep_provider_basic failed in buildbot
If the initialization of the wsrep provider failed, in some
cases the internal variable wrep_inited indicating that the
initialization has already been completed is still set to
"1", which then leads to confusion in the initialization
status. To solve the problem, we should set this variable
to "1" only if the wsrep provider initialization really
completed successfully.

An earlier issue has already been fixed for branch 10.4,
and this patch contains a fix for earlier versions (where
Galera 3.x is used).
2020-01-20 12:14:26 +01:00
Oleksandr Byelkin
f31bf6f094 Merge branch '5.5' into 10.1 2020-01-19 12:22:12 +01:00
Sergei Golubchik
4d1c1b23e1 Bug#29630767 - USE OF UNINITIALIZED VALUE IN LIBMYSQL (CLIENT.CC FUNCTION RUN_PLUGIN_AUTH) 2020-01-18 00:05:16 +01:00
Sergei Petrunia
d595a91bc6 Fix a merge typo 2020-01-17 18:39:00 +03:00
Jan Lindström
c4195305b2 MDEV-17062 : Test failure on galera.MW-336
Add mutex protection while we calculate required slave
thread change and create them. Add error handling.
2020-01-17 12:51:18 +02:00
Sergei Petrunia
b04429434a Merge branch '10.1' into 10.2
# Conflicts:
#	sql/sp_head.cc
#	sql/sql_select.cc
#	sql/sql_trigger.cc
2020-01-17 00:24:17 +03:00
Vicențiu Ciorbaru
409aba3d99 Improve documentation of Unique class
* size represents the size of an element in the Unique class
* full_size is used when the Unique class counts the number of
duplicates stored per element. This requires additional space per Unique
element.
2020-01-16 13:22:39 +02:00
Sergei Petrunia
23041af720 MDEV-21341: Fix UBSAN failures, part 8: fix error in compare_fields_by_table_order
Dont assign Item_field variables to point to Item_string objects (even if we
don't make any dangerous calls for them).
2020-01-15 16:35:59 +03:00
Sergei Petrunia
4635047ca1 MDEV-21341: Fix UBSAN failures, part #5
Item_cond inherits from Item_args but doesn't store its arguments
as function arguments, which means it has zero arguments.
Don't call memcpy in this case.
2020-01-15 16:34:51 +03:00
Sergei Petrunia
5e5ae51b73 MDEV-21341: Fix UBSAN failures: Issue Six
(Variant #2 of the patch, which keeps the sp_head object inside the
MEM_ROOT that sp_head object owns)
(10.3 requires extra work due to sp_package, will commit a separate
patch for it)

sp_head::operator new() and operator delete() were dereferencing sp_head*
pointers to memory that didn't hold a valid sp_head object (it was
not created/already destroyed).
This caused UBSan to crash when looking up type information.

Fixed by providing static sp_head::create() and sp_head::destroy() methods.
2020-01-14 18:15:32 +03:00
Markus Mäkelä
5683c113b8 Use get_ident_len in heartbeat event error messages
The string doesn't appear to be null-terminated when binlog checksums are
enabled. This causes a corrupt binlog name in the error message when a
slave is ahead of the master.
2020-01-13 14:50:02 +02:00
Sujatha
41cde4fe22 MDEV-18514: Assertion `!writer.checksum_len || writer.remains == 0' failed
Analysis:
========
'max_binlog_cache_size' is configured and a huge transaction is executed. When
the transaction specific events size exceeds 'max_binlog_cache_size' the event
cannot be written to the binary log cache and cache write error is raised.
Upon cache write error the statement is rolled back and the transaction cache
should be truncated to a previous statement specific position.  The truncate
operation should reset the cache to earlier valid positions and flush the new
changes. Even though the flush is successful the cache write error is still in
marked state. The truncate code interprets the cache write error as cache flush
failure and returns abruptly without modifying the write cache parameters.
Hence cache is in a invalid state. When a COMMIT statement is executed in this
session it tries to flush the contents of transaction cache to binary log.
Since cache has partial events the cache write operation will report
'writer.remains' assert.

Fix:
===
Binlog truncate function resets the cache to a specified size. As a first step
of truncation, clear the cache write error flag that was raised during earlier
execution. With this new errors that surface during cache truncation can be
clearly identified.
2020-01-09 12:45:05 +05:30
Sujatha
8317f77ccc Merge branch '10.1' into 10.2
MDEV-18046: Assortment of crashes, assertion failures and ASAN errors in mysql_show_binlog_events

Problem:
========
SHOW BINLOG EVENTS FROM <pos> reports following assert when ASAN is enabled.

uint32 binlog_get_uncompress_len(const char*):
  Assertion `(buf[0] & 0xe0) == 0x80' failed

Fix:
===
**Part11: Converted debug assert to error handler code**
2020-01-07 21:29:07 +05:30
Sujatha
cb204e11ea MDEV-18046: Assortment of crashes, assertion failures and ASAN errors in mysql_show_binlog_events
Problem:
========
SHOW BINLOG EVENTS FROM <pos> reports following ASAN error.

AddressSanitizer: heap-buffer-overflow on address
READ of size 1 at 0x60e00009cf71 thread T28
#0 0x55e37e034ae2 in net_field_length

Fix:
===
**Part10: Avoid reading out of buffer**
2020-01-07 18:27:06 +05:30
Sujatha
d05c511d34 MDEV-18046: Assortment of crashes, assertion failures and ASAN errors in mysql_show_binlog_events
Problem:
========
SHOW BINLOG EVENTS FROM <pos> reports following assert when ASAN is enabled.

Query_log_event::Query_log_event(const char*, uint,
    const Format_description_log_event*, Log_event_type):
  Assertion `(pos) + (6) <= (end)' failed

Fix:
===
**Part9: Removed additional DBUG_ASSERT**
2020-01-07 18:27:06 +05:30
Sujatha
bac3353361 MDEV-18046: Assortment of crashes, assertion failures and ASAN errors in mysql_show_binlog_events
Problem:
========
SHOW BINLOG EVENTS FROM <pos> reports following ASAN error

AddressSanitizer: SEGV on unknown address
The signal is caused by a READ memory access.
User_var_log_event::User_var_log_event(char const*, unsigned int,
    Format_description_log_event const*)

Implemented part of upstream patch.
commit: mysql/mysql-server@a3a497ccf7

Fix:
===
**Part8: added checks to avoid reading out of buffer limits**
2020-01-07 18:27:05 +05:30
Sujatha
2187f1c2ca MDEV-18046: Assortment of crashes, assertion failures and ASAN errors in mysql_show_binlog_events
Problem:
========
SHOW BINLOG EVENTS FROM <pos> reports following ASAN error
"heap-buffer-overflow on address" and some times it asserts.

Table_map_log_event::Table_map_log_event(const char*, uint,
    const Format_description_log_event*)
Assertion `m_field_metadata_size <= (m_colcnt * 2)' failed.

Fix:
===
**Part7: Avoid reading out of buffer**


Converted debug assert to error handler code.
2020-01-07 18:27:05 +05:30
Sujatha
d6fa69e4be MDEV-18046: Assortment of crashes, assertion failures and ASAN errors in mysql_show_binlog_events
Problem:
========
SHOW BINLOG EVENTS FROM <pos> reports following ASAN error

AddressSanitizer: heap-buffer-overflow on address 0x60400002acb8
Load_log_event::copy_log_event(char const*, unsigned long, int,
    Format_description_log_event const*)

Fix:
===
**Part6: Moved the event_len validation to the begin of copy_log_event function**
2020-01-07 18:27:05 +05:30
Sujatha
15781283eb MDEV-18046: Assortment of crashes, assertion failures and ASAN errors in mysql_show_binlog_events
Problem:
========
SHOW BINLOG EVENTS FROM <pos> reports following ASAN error

AddressSanitizer: heap-buffer-overflow on address
String::append(char const*, unsigned int)
Query_log_event::pack_info(Protocol*)

Fix:
===
**Part5: Added check to catch buffer overflow**
2020-01-07 18:27:05 +05:30
Sujatha
a42ef10815 MDEV-18046: Assortment of crashes, assertion failures and ASAN errors in mysql_show_binlog_events
Problem:
========
SHOW BINLOG EVENTS FROM <pos> reports following ASAN error

heap-buffer-overflow within "my_strndup" in Rotate_log_event

my_strndup /mysys/my_malloc.c:254
Rotate_log_event::Rotate_log_event(char const*, unsigned int,
    Format_description_log_event const*)

Fix:
===
**Part4: Improved the check for event_len validation**
2020-01-07 18:27:05 +05:30
Sujatha
5a54e84e5d MDEV-18046: Assortment of crashes, assertion failures and ASAN errors in mysql_show_binlog_events
Problem:
========
SHOW BINLOG EVENTS FROM <pos> reports following crash when ASAN is enabled.

SEGV on unknown address
in inline_mysql_mutex_destroy
in my_bitmap_free
in Update_rows_log_event::~Update_rows_log_event()

Fix:
===
**Part3: Initialize m_cols_ai.bitmap to NULL**
2020-01-07 18:27:05 +05:30
Sujatha
913f405d95 MDEV-18046: Assortment of crashes, assertion failures and ASAN errors in mysql_show_binlog_events
Problem:
========
SHOW BINLOG EVENTS FROM <pos> reports following assert when ASAN is enabled.

Rows_log_event::Rows_log_event(const char*, uint,
    const Format_description_log_event*):
Assertion `var_header_len >= 2'

Implemented part of upstream patch.
commit: mysql/mysql-server@a3a497ccf7

Fix:
===
**Part2: Avoid reading out of buffer limits**
2020-01-07 18:27:05 +05:30
Sujatha
a6dd827a4d MDEV-18046: Assortment of crashes, assertion failures and ASAN errors in mysql_show_binlog_events
Problem:
========
SHOW BINLOG EVENTS FROM <pos> causes a variety of failures, some of which are
listed below. It is not a race condition issue, but there is some
non-determinism in it.

Analysis:
========
"show binlog events from <pos>" code considers the user given position as a
valid event start position. The code starts reading data from this event start
position onwards and tries to map it to a set of known events. Each event has
a specific event structure and asserts have been added to ensure that read
event data satisfies the event specific requirements. When a random position
is supplied to "show binlog events command" the event structure specific
checks will fail and they result in assert.

Fix:
====
The fix is split into different parts. Each part addresses either an ASAN
issue or an assert/crash.

**Part1: Checksum based position validation when checksum is enabled**


Using checksum validate the very first event read at the user specified
position. If there is a checksum mismatch report an appropriate error for the
invalid event.
2020-01-07 18:27:05 +05:30
Oleksandr Byelkin
b35290e19b Merge branch '10.1' into 10.2 2020-01-03 12:40:38 +01:00
Oleksandr Byelkin
4d7f073506 Merge branch '5.5' into 10.1 2020-01-03 10:36:23 +01:00
Varun Gupta
faf2a6e5f0 MDEV-20922: Adding an order by changes the query results
For Item_direct_view_ref , get value from val_* methods
instead of result* family
The val_* methods gets value from the item on which it is referred.
2020-01-02 09:49:13 +05:30
Varun Gupta
359d91aaee MDEV-19680:: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index) || (!(ptr >= table->record[0] && ptr < table->record[0] + table->s->reclength)))' or alike failed upon SELECT with mix of functions from simple view
Set read_set bitmap for view from the JOIN::all_fields list instead of JOIN::fields_list
as split_sum_func would have added items to the all_fields list.
2019-12-26 17:36:32 +05:30
Varun Gupta
891609b571 MDEV-21318: Wrong results with window functions and implicit grouping
The issue here is for degenerate joins we should execute the window
function but it is not getting executed in all the cases.

To get the window function values window function needs to be executed
always. This currently does not happen in few cases
where the join would return 0 or 1 row like
  1) IMPOSSIBLE WHERE
  2) MIN/MAX optimization
  3) EMPTY CONST TABLE

The fix is to make sure that window functions get executed
and the temporary table is setup for the execution of window functions
2019-12-26 15:18:49 +05:30
Alexander Barkov
3dfe1ba3b8 MDEV-21388 Wrong result of DAYNAME()=xxx in combination with condition_pushdown_for_derived=on 2019-12-24 15:05:52 +04:00