Commit graph

183759 commits

Author SHA1 Message Date
Marko Mäkelä
d88c136b9f Merge 10.3 into 10.4 2018-10-17 19:11:42 +03:00
Marko Mäkelä
2fa4ed031c MDEV-17483 Insert on delete-marked record can wrongly inherit old values for instantly added column
row_ins_clust_index_entry_low(): Do not call dtuple_t::trim()
before row_ins_clust_index_entry_by_modify(), so that the values
of all columns will be available in row_upd_build_difference_binary().
If applicable, the tuple can be trimmed in btr_cur_optimistic_update()
or btr_cur_pessimistic_update(), which will be called by
row_ins_clust_index_entry_by_modify().
2018-10-17 18:55:46 +03:00
Igor Babaev
c2c1550f57 MDEV-17419 Subquery with group by returns wrong results
Added only test case because the bug was fixed by the patch for mdev-17382.
2018-10-17 04:37:25 -07:00
Igor Babaev
13e217b8c1 MDEV-17027 server crashes in Bitmap<64u>::merge
The function and_new_conditions_to_optimized_cond() incorrectly handled
the WHERE conditions with one multiple equality and one IN subquery predicate
that could be converted into a jtbm semi-join. This could cause crashes.

The fix code was prepared by Galina Shalygina.
2018-10-17 01:28:07 -07:00
Alexander Barkov
6eae037c4c MDEV-17474 Change Unicode collation implementation from "handler" to "inline" style 2018-10-17 06:44:40 +04:00
Eugene Kosov
fee24b1281 MDEV-17313 Data race in ib_counter_t
try fix OSX build
2018-10-16 22:51:45 +04:00
Varun Gupta
97a37edc97 MDEV-17137: Syntax errors with VIEW using MEDIAN
The syntax error happened because we had not implemented a different print for
percentile functions. The syntax is a bit different when we use percentile functions
as window functions in comparision to normal window functions.
Implemented a seperate print function for percentile functions
2018-10-16 08:11:26 -07:00
Alexander Barkov
f7179c4432 MDEV-17460 Move the code from Item_extract::val_int() to a new class Extract_source 2018-10-16 11:14:39 +04:00
Alexander Barkov
1c5fd80a04 Fixing a test failure on 32bit platforms in the new MDEV-17434 code 2018-10-16 06:59:30 +04:00
Alexander Barkov
22e75434e7 MDEV-17434 EXTRACT(DAY FROM negative_time) returns wrong result 2018-10-15 17:46:25 +04:00
Igor Babaev
103b1df510 MDEV-17222 Reproducible server crash in String_list::append_str or
in Field_iterator_table::create_item

When IN predicate is converted to IN subquery we have to ensure that
any item from the select list of the subquery has some name and this name
is unique across the select list.
This was not guaranteed by the code before the patch for MDEV-17222.
If the name of an item of the select list was not set, and this happened
for binary constants, then the server crashed. If the first row in the IN
list contained the same constant in two different positions then the server
returned an error message.
This was fixed by providing all constants in the first row of the IN list
with generated names.
2018-10-14 15:29:08 -07:00
Alexander Barkov
a53b99bf13 MDEV-17417 TIME(99991231235959) returns 838:59:59 instead of 23:59:58 2018-10-14 17:28:55 +04:00
Kristian Nielsen
74387028a0 Merge branch 'gtid_table_garbage_rows' into 10.3 2018-10-13 23:48:43 +02:00
Kristian Nielsen
61bba2a540 Fix build of embedded server 2018-10-13 22:53:12 +02:00
Kristian Nielsen
00164ea4b1 Merge branch 'gtid_table_garbage_rows_10.3' into 10.3 2018-10-13 19:50:53 +02:00
Vladislav Vaintroub
2fd770641e Revert the last change to replication test
disable rpl_mdev382 on Windows, due to unix shell escaping used there.
2018-10-12 20:07:08 +02:00
Vladislav Vaintroub
00c40efcd6 Fix portability issues with rpl test suite. 2018-10-12 16:43:45 +01:00
Alexander Barkov
6120ae4aca Adjusting old tests and adding new tests for "MDEV-8765: mysqldump -use utf8mb4 by default" 2018-10-12 06:34:13 +04:00
Daniel Black
ce643ddac7 MDEV-8765: mysqldump -use utf8mb4 by default
Bump mysqldump to a version greater than that on the 10.3 branch.
2018-10-12 05:16:01 +04:00
Marko Mäkelä
7e869a2767 Merge 10.2 into 10.3 2018-10-11 23:09:10 +03:00
Marko Mäkelä
81a5b6ccd5 MDEV-17433 Allow InnoDB start up with empty ib_logfile0 from mariabackup --prepare
A prepared backup from Mariabackup does not really need to contain any
redo log file, because all log will have been applied to the data files.

When the user copies a prepared backup to a data directory (overwriting
existing files), it could happen that the data directory already contained
redo log files from the past. mariabackup --copy-back) would delete the
old redo log files, but a user’s own copying script might not do that.
To prevent corruption caused by mixing an old redo log file with data
files from a backup, starting with MDEV-13311, Mariabackup would create
a zero-length ib_logfile0 that would prevent startup.

Actually, there is no need to prevent InnoDB from starting up when a
single zero-length file ib_logfile0 is present. Only if there exist
multiple data files of different lengths, then we should refuse to
start up due to inconsistency. A single zero-length ib_logfile0 should
be treated as if the log files were missing: create new log files
according to the configuration.

open_log_file(): Remove. There is no need to open the log files
at this point, because os_file_get_status() already determined
the size of the file.

innobase_start_or_create_for_mysql(): Move the creation of new
log files a little later, not when finding out that the first log
file does not exist, but after finding out that it does not exist
or it exists as a zero-length file.
2018-10-11 23:00:48 +03:00
Eugene Kosov
be31c18e4a ib_counter_t code simplified without functional changes 2018-10-11 22:55:52 +03:00
Marko Mäkelä
b8944e8972 Fix a sign mismatch 2018-10-11 22:47:42 +03:00
Marko Mäkelä
6319c0b541 MDEV-13564: Replace innodb_unsafe_truncate with innodb_safe_truncate
Rename the 10.2-specific configuration option innodb_unsafe_truncate
to innodb_safe_truncate, and invert its value.

The default (for now) is innodb_safe_truncate=OFF, to avoid
disrupting users with an undo and redo log format change within
a Generally Available (GA) release series.
2018-10-11 15:10:13 +03:00
Eugene Kosov
f9547748a6 MDEV-17313 Data race in ib_counter_t
ib_counter_t: make all reads/writes to m_counter relaxed atomical
2018-10-11 14:40:00 +03:00
Alexander Barkov
4de0d920be MDEV-17411 Wrong WHERE optimization with simple CASE and searched CASE 2018-10-11 13:39:53 +04:00
Marko Mäkelä
30629e196d MDEV-13564: Null-merge 10.2 into 10.3
We keep the MySQL 5.7 backup-incompatible TRUNCATE TABLE
only in MariaDB Server 10.2. In 10.3 and later releases,
only the backup-friendly TRUNCATE will be available.
2018-10-11 08:33:59 +03:00
Marko Mäkelä
ae9d82c9f8 Merge 10.2 into 10.3 2018-10-11 08:22:08 +03:00
Marko Mäkelä
3448ceb02a MDEV-13564: Implement innodb_unsafe_truncate=ON for compatibility
While MariaDB Server 10.2 is not really guaranteed to be compatible
with Percona XtraBackup 2.4 (for example, the MySQL 5.7 undo log format
change that could be present in XtraBackup, but was reverted from
MariaDB in MDEV-12289), we do not want to disrupt users who have
deployed xtrabackup and MariaDB Server 10.2 in their environments.

With this change, MariaDB 10.2 will continue to use the backup-unsafe
TRUNCATE TABLE code, so that neither the undo log nor the redo log
formats will change in an incompatible way.

Undo tablespace truncation will keep using the redo log only. Recovery
or backup with old code will fail to shrink the undo tablespace files,
but the contents will be recovered just fine.

In the MariaDB Server 10.2 series only, we introduce the configuration
parameter innodb_unsafe_truncate and make it ON by default. To allow
MariaDB Backup (mariabackup) to work properly with TRUNCATE TABLE
operations, use loose_innodb_unsafe_truncate=OFF.

MariaDB Server 10.3.10 and later releases will always use the
backup-safe TRUNCATE TABLE, and this parameter will not be
added there.

recv_recovery_rollback_active(): Skip row_mysql_drop_garbage_tables()
unless innodb_unsafe_truncate=OFF. It is too unsafe to drop orphan
tables if RENAME operations are not transactional within InnoDB.

LOG_HEADER_FORMAT_10_3: Replaces LOG_HEADER_FORMAT_CURRENT.

log_init(), log_group_file_header_flush(),
srv_prepare_to_delete_redo_log_files(),
innobase_start_or_create_for_mysql(): Choose the redo log format
and subformat based on the value of innodb_unsafe_truncate.
2018-10-11 08:17:04 +03:00
Marko Mäkelä
07815d9555 Merge 10.1 into 10.2 2018-10-11 08:16:08 +03:00
Marko Mäkelä
940f0c78a4 MDEV-11487: Make row_ins_index_entry_set_vals() static 2018-10-11 08:14:56 +03:00
Sergei Petrunia
8d116d1686 MDEV-17181: rocksdb.allow_to_start_after_corruption fails on current 10.2
The test needs to be run with rocksdb_flush_log_at_trx_commit=1, otherwise
the changes do not survive a crash.
2018-10-10 14:39:57 +03:00
Marko Mäkelä
f545e3cfa9 MDEV-15562: Remove dict_table_t::rollback_instant(unsigned n)
On the rollback of changes to SYS_COLUMNS, MDEV-15562 will
break the assumption that the only instantaneous changes to columns
are the addition to the end of the column list.

The function dict_table_t::rollback_instant(unsigned n)
is inherently incompatible with instantly dropping or reordering
columns.

When a change to SYS_COLUMNS is rolled back, we must simply evict
the affected table definition, at the end of the rollback. We cannot
free the table object immediately, because the current transaction
that is being rolled back may be holding a lock on the table and
its metadata record.

dict_table_remove_from_cache_low(): Replaced
by dict_table_remove_from_cache().

dict_table_remove_from_cache(): Add a third parameter keep=false,
so that the table can be freed by the caller.

trx_lock_t::evicted_tables: List of tables on which trx_t::evict_table()
was invoked.

trx_t::evict_table(): Evict a table definition during rollback.

trx_commit_in_memory(): Empty the trx->lock.evicted_tables list
after the locks were released, by freeing the table objects.

row_undo_ins_remove_clust_rec(), row_undo_mod_clust_low():
Invoke trx_t::evict_table() on the affected table if a change to
SYS_COLUMNS is being rolled back.
2018-10-10 12:47:46 +03:00
Marko Mäkelä
f58a0b3afc MDEV-15562: Simplify FOREIGN KEY error handling on DDL
The error handling for ALTER TABLE…ALGORITHM=COPY as well as
CREATE TABLE used to commit the CREATE TABLE transaction and then
issue DROP TABLE in a separate transaction. This is unnecessarily
breaking atomicity during DDL operations. Let us revise it so
that the DROP TABLE will be executed within the same transaction,
which will finally be rolled back.

FIXME: Introduce an undo log record so that the data file would be
deleted on rollback and no DROP TABLE would be needed at all.

FIXME: Avoid unnecessary access to per-table tablespace during DROP TABLE.
If the .ibd file is going to be deleted anyway, we should not bother
to mark the pages free.

dict_create_add_foreigns_to_dictionary(): Do not commit the transaction.
We want simple rollback in case dict_load_foreigns() would fail.

create_table_info_t::create_table(), row_create_index_for_mysql(),
row_table_add_foreign_constraints(): Before invoking rollback, drop
the table. Rollback would invoke trx_t::evict_table(), and after that
dropping the table would be a no-op.

ha_innobase::create(): Before rollback, drop the table. If the SQL
layer invoked ha_innobase::delete_table() later, it would be a no-op
because the rollback would have invoked trx_t::evict_table().
2018-10-10 12:06:19 +03:00
Marko Mäkelä
cd08173490 MDEV-15562: Add dict_index_t::first_user_field()
dict_index_t::first_user_field(): Return the first data field in
a clustered index, that is, the field after the PRIMARY KEY and
the two system columns DB_TRX_ID, DB_ROLL_PTR.

dtuple_convert_big_rec(): Remove some local variables.
2018-10-10 11:58:24 +03:00
Marko Mäkelä
2a955c7a83 Merge 10.3 into 10.4 2018-10-10 10:36:51 +03:00
Jan Lindström
3c3c4ae225 MDEV-17403: Test failure on galera.galera_enum
Add wait on second node.
2018-10-10 09:17:10 +03:00
Marko Mäkelä
61b32df931 Merge 10.2 into 10.3 2018-10-10 06:45:19 +03:00
Marko Mäkelä
00b6c7d8fc MDEV-16946 innodb.alter_kill failed in buildbot with wrong result
Ensure that no redo log checkpoint occurs in a critical section
of a recovery test.
2018-10-10 06:31:43 +03:00
Marko Mäkelä
2610c26a53 MDEV-16273 innodb.alter_kill fails Unknown storage engine 'InnoDB'
The test is shutting down InnoDB, corrupting a file, and finally
restarting InnoDB. Before the shutdown, the test created the table
and inserted some records. Before MDEV-12288, there would be no access
to the table after server restart, but after MDEV-12288 purge would
reset the transaction identifier after the INSERT, and this would
sometimes happen after the restart.

To make the test deterministic, wait for purge to complete before the
shutdown.
2018-10-10 06:14:14 +03:00
Vladislav Vaintroub
5b0b6660f6 MDEV-17413 - Don't crash in my_malloc_size_cb_func()
if thread specific memory is requested and current_thd is NULL.

Leave DBUG_ASSERT() in place, to check in DBUG version.
2018-10-09 18:44:10 +01:00
Sergei Petrunia
8b371e4b13 MDEV-16577: rocksdb.issue255 fails in buildbot
Make the testcase stable
2018-10-09 17:01:49 +03:00
Alexander Barkov
5646c43159 MDEV-17216 Assertion `!dt->fraction_remainder(decimals())' failed in Field_temporal_with_date::store_TIME_with_warning
The problem happened because {{Field_xxx::store(longlong nr, bool unsigned_val)}} erroneously passed {{unsigned_flag}} to the {{usec}} parameter of this constructor:
{code:cpp}
Datetime(int *warn, longlong sec, ulong usec, date_conv_mode_t flags)
{code}

1. Changing Time and Datetime constructors to accept data as Sec6 rather than as
longlong/double/my_decimal, so it's not possible to do such mistakes
in the future. Additional good effect of these changes:
- This reduced some amount of similar code (minus ~35 lines).
- The code now does not rely on the fact that "unsigned_flag" is
   not important inside Datetime().
  The constructor always gets all three parts: sign, integer part,
  fractional part. The simple the better.

2. Fixing Field_xxx::store() to use the new Datetime constructor format.
   This change actually fixes the problem.

3. Adding "explicit" keyword to all Sec6 constructors,
to avoid automatic hidden conversion from double/my_decimal to Sec6,
as well as from longlong/ulonglong through double to Sec6.

4. Change#1 caused (as a dependency) changes in a few places
   with code like this:

  bool neg= nr < 0 && !unsigned_val;
  ulonglong value= m_neg ? (ulonglong) -nr : (ulonglong) nr;

These fragments relied on a non-standard behavior with
the operator "minus" applied to the lowest possible negative
signed long long value. This can lead to different results
depending on the platform and compilation flags.
We have fixed such bugs a few times already.
So instead of modifying the old wrong code to a new wrong code,
replacing all such fragments to use Longlong_hybrid,
which correctly handles this special case with -LONGLONG_MIN
in its method abs().
This also reduced the amount of similar code
(1 or 2 new lines instead 3 old lines in all 6 such fragments).

5. Removing ErrConvInteger(longlong nr, bool unsigned_flag= false)
   and adding ErrConvInteger(Longlong_hybrid) instead, to encourage
   use of safe Longlong_hybrid instead of unsafe pairs nr+neg.

6. Removing unused ErrConvInteger from Item_cache_temporal::get_date()
2018-10-09 12:02:35 +04:00
Vladislav Vaintroub
f4cdf90d73 MDEV-17279 Windows : link C runtime dynamically
Changed the build to use /MD flag so that DDL version of C runtime is used.

To make sure MariaDB is always runnable on target system, include
redistributable CRT libraries into installer.

For MSI package, use Microsoft's merge modules.
For ZIP  use "applocal" approach,i.e place redistributable dlls
into the bin directory of the package(via InstallRequiredSystemLibraries
cmake module) The space overhead of libraries in negligible, ~ 3MB unpacked.

There are 2 cases, where we still link C runtime statically

- Upgrade wizard, it uses MFC, and we link statically to avoid
redistribute also whole MFC (for this single application, does not
make much sense).

- MSI installer's custom action dll wixca.dll.Here, we need static link
so that MSI won't fail on a target system that does not have VC++2015
runtime already installed.
2018-10-09 08:42:48 +01:00
Marko Mäkelä
43ee6915fa Merge 10.2 into 10.3 2018-10-09 09:11:30 +03:00
Alexander Barkov
c57bbb2596 MDEV-17400 The result of TIME('42949672965959-01') depends on architecture
- Fixing portabibily problems in sql-common/my_time.c
  (and additionally in sql/sql_time.cc)

- Re-enabling func_time.test
  Now all new chunks added in MDEV-17351 work fine on all platforms.
2018-10-09 07:50:24 +04:00
Andrei Elkin
f517d8c742 MDEV-17346 parallel slave start and stop races to workers disappeared
The bug appears as a slave SQL thread hanging in
rpl_parallel_thread_pool::get_thread() while there are no slave worker
threads to awake it.

The reason of the hang is that at the parallel slave worker pool
activation the being stared SQL thread could read the worker pool size
concurrently with pool deactivation. At reading the SQL thread did not
employ necessary protection from a race.

Fixed with making the SQL thread at the pool activation first
to grab the same lock as potential deactivator also does prior
to access the pool size.
2018-10-08 19:46:34 +03:00
Thirunarayanan Balathandayuthapani
e9d9ca8c44 MDEV-16980 Wrongly set tablename len while opening the
table for purge thread

Problem:
=======
	Purge tries to fetch mdl lock for the whole table even though it tries
to open one of the partition. But table name length was wrongly set to indicate
the partition name too.

Solution:
========
- Table name length should identify the table name only not the partition name.
2018-10-08 21:40:18 +05:30
Thirunarayanan Balathandayuthapani
7d4beb7286 MDEV-16980 Wrongly set tablename len while opening the
table for purge thread

Problem:
=======
	Purge tries to fetch mdl lock for the whole table even though it tries
to open one of the partition. But table name length was wrongly set to indicate
the partition name too.

Solution:
========
- Table name length should identify the table name only not the partition name.
2018-10-08 21:06:42 +05:30
Igor Babaev
8595361768 MDEV-17381 Wrong query result with LATERAL DERIVED optimization
and join_cache_level=6

This bug was fixed by the patch for mdev-17382 applied to 5.5.
2018-10-08 06:55:48 -07:00