Commit graph

176861 commits

Author SHA1 Message Date
Vicențiu Ciorbaru
aa59ecec89 Merge branch '10.0' into 10.1 2018-06-12 18:55:27 +03:00
Vicențiu Ciorbaru
170bec36c0 Merge branch '5.5' into 10.0 2018-06-12 17:59:31 +03:00
Andrei Elkin
7bbe324fc1 MDEV-13577 slave_parallel_mode=optimistic should not report the mode's
specific temporary errors

The optimistic parallel slave's worker thread could face a run-time error due to
the algorithm's specifics which allows for conflicts like the reported
"Can't find record in 'table'".
A typical stack is like

{noformat}
#0  handler::print_error (this=0x61c00008f8a0, error=149, errflag=0) at handler.cc:3650
#1  0x0000555555e95361 in write_record (thd=thd@entry=0x62a0000a2208, table=table@entry=0x61f00008ce88, info=info@entry=0x7fffdee356d0) at sql_insert.cc:1944
#2  0x0000555555ea7767 in mysql_insert (thd=thd@entry=0x62a0000a2208, table_list=0x61b00012ada0, fields=..., values_list=..., update_fields=..., update_values=..., duplic=<optimized out>, ignore=<optimized out>) at sql_insert.cc:1039
#3  0x0000555555efda90 in mysql_execute_command (thd=thd@entry=0x62a0000a2208) at sql_parse.cc:3927
#4  0x0000555555f0cc50 in mysql_parse (thd=0x62a0000a2208, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at sql_parse.cc:7449
#5  0x00005555566d4444 in Query_log_event::do_apply_event (this=0x61200005b9c8, rgi=<optimized out>, query_arg=<optimized out>, q_len_arg=<optimized out>) at log_event.cc:4508
#6  0x00005555566d639e in Query_log_event::do_apply_event (this=<optimized out>, rgi=<optimized out>) at log_event.cc:4185
#7  0x0000555555d738cf in Log_event::apply_event (rgi=0x61d0001ea080, this=0x61200005b9c8) at log_event.h:1343
#8  apply_event_and_update_pos_apply (ev=ev@entry=0x61200005b9c8, thd=thd@entry=0x62a0000a2208, rgi=rgi@entry=0x61d0001ea080, reason=<optimized out>) at slave.cc:3479
#9  0x0000555555d8596b in apply_event_and_update_pos_for_parallel (ev=ev@entry=0x61200005b9c8, thd=thd@entry=0x62a0000a2208, rgi=rgi@entry=0x61d0001ea080) at slave.cc:3623
#10 0x00005555562aca83 in rpt_handle_event (qev=qev@entry=0x6190000fa088, rpt=rpt@entry=0x62200002bd68) at rpl_parallel.cc:50
#11 0x00005555562bd04e in handle_rpl_parallel_thread (arg=arg@entry=0x62200002bd68) at rpl_parallel.cc:1258
{noformat}

Here {{handler::print_error}} computes whether to error log the
current error when --log-warnings > 1. The decision flag is consulted
bu {{my_message_sql()}} which can be eventually called.
In the bug case the decision is to log.
However in the optimistic mode slave applier case any conflict is
attempted to resolve with rollback and retry to success. Hence the
logging is at least extraneous.

The case is fixed with adding a new flag {{ME_LOG_AS_WARN}} which
{{handler::print_error}} may propagate further on through {{my_error}}
when the error comes from an optimistically running slave worker thread.

The new flag effectively requests the warning level for the errlog record,
while the thread's DA records the actual error (which is regarded as temporary one
by the parallel slave error handler).
2018-06-12 15:29:16 +03:00
Alexey Botchkov
6b8d34fe0d MDEV-14668 ADD PRIMARY KEY IF NOT EXISTS on composite key.
Check the name of the primary key to be 'PRIMARY'. Than
differs it from any implicit primary keys created by an engine.
2018-06-12 12:36:51 +04:00
Marko Mäkelä
0ad9c3a016 MDEV-16456 InnoDB error "returned OS error 71" complains about wrong path
When attempting to rename a table to a non-existing database,
InnoDB would misleadingly report "OS error 71" when in fact the
error code is InnoDB's own (OS_FILE_NOT_FOUND), and not report
both pathnames. Errors on rename could occur due to reasons
connected to either pathname.

os_file_handle_rename_error(): New function, to report errors in
renaming files.
2018-06-12 09:54:31 +03:00
Alexander Barkov
26be507242 MDEV-12060 Crash in EXECUTE IMMEDIATE with an expression returning a GRANT command
Backporting (partially) the fix for MDEV-14603.
2018-06-12 10:41:25 +04:00
Alexander Barkov
5227198908 MDEV-16190 Server crashes in Item_null_result::field_type on SELECT with time field, ROLLUP and HAVING
virtual Item_null_result::get_date() was not overridden.
It used the inherited Item::get_date(), which tests field_type(),
which in case of Item_null_result calls result_field->field_type(),
and result_field is not really always set (e.g. it's not set in the
test case from the bug report).

Overriding Item_null::get_date() like it's done for other val_xxx() methods.
This make the code more symmetric across data types.

In the new reduction, get_date() immediately returns NULL without entering
into any data type specific code.
2018-06-11 16:29:22 +04:00
Sergei Golubchik
ca733d03c8 MDEV-15729 Server crashes in Field::make_field upon HANDLER READ executed with PS protocol
update table->pos_in_table_list during prepare,
just like it's done in normal execution.

otherwise it'll be a dangling pointer
2018-06-11 09:57:54 +02:00
Sergei Golubchik
6da8192174 mysqltest: Allow HANDLER READ in --ps-protocol tests
adjust tests
2018-06-11 09:57:54 +02:00
Sergei Golubchik
e7ca377cb7 MDEV-16342 SHOW ENGINES: MyISAM description is useless
rewrite tautological engine descriptions
2018-06-11 09:57:54 +02:00
Vicențiu Ciorbaru
24d7cbe1e0 Ensure TokuDB compiles both on Linux and OS X
On OS X, (u)int64_t is defined as (unsigned) long long int while on 74
bit Linux it is defined as (unsigned) long int.

Ensure the type matches when doing printf on all systems.
2018-06-11 00:18:12 +03:00
Vicențiu Ciorbaru
e5a3d24b87 Followup for make TokuDB compile with GCC-8
Missed printfs from: 21246066b2
2018-06-10 21:45:05 +03:00
Vicențiu Ciorbaru
719ed09e5e Update test results post-merge 2018-06-10 18:25:11 +03:00
Vicențiu Ciorbaru
3ead951180 Merge branch '5.5' into 10.0 2018-06-10 17:16:27 +03:00
Rutuja Surve
1d43f71c7b MDEV-15021: mysqldump --tables --routines generates non importable dump file
The order of outputting stored procedures is important. Stored
procedures must be available on view creation, for views which make use
of them. Make sure to print them before outputting tables.
2018-06-10 16:50:36 +03:00
Teodor Mircea Ionita
953d70f960 MDEV-15778: Remove packed attr from omt_ and subtree_ classes
Undo the revert that happened by mystake in commit 7fca4b50ff.
2018-06-10 16:39:30 +03:00
Vicențiu Ciorbaru
21246066b2 Make TokuDB compile with GCC-8
GCC-8 introduced multiple warnings and increased the level of
strictness.

* -Wshadow will warn if a local variable shadows a typedef.
* GCC will also warn when memsetting a non-trivial type.
  In this case a non-trivial type can not have a custom constructor.
  For all intents and purposes, the class is trivially-copyable.
* GCC will also warn if you use too many paranthesses which are not
necessary
2018-06-10 15:56:30 +03:00
Vicențiu Ciorbaru
7fca4b50ff Revert "MDEV-15778: Remove packed attr from omt_ and subtree_ classes"
This reverts commit 1735fa340a.
2018-06-10 15:20:43 +03:00
Teodor Mircea Ionita
d39629f01e MDEV-16075: Workaround to run MTR test suite for make test
Assign all tests added via MY_ADD_TEST to a bogus default_ignore target,
so that they are not ran by default when doing bare make test. Add default
test named MTR that calls mysql-test-run suite, which is now the single
test run by make test.

In consequence, modified unit/suite.pm to exclude the MTR test and run the
real ctests flagged for default_ignore target, thus no circular
loop.
2018-06-10 10:14:31 +03:00
Teodor Mircea Ionita
0e6d6354bf Also ignore macOS .DS_Store Finder junk. 2018-06-10 10:13:32 +03:00
Teodor Mircea Ionita
814a284f22 Ignore .cbp QtCreator && CodeBlocks project files 2018-06-10 10:13:32 +03:00
Teodor Mircea Ionita
7053e26e18 MDEV-15778: Fix TokuDB build issues on macOS 10.13.4
Several issues were encountered and fixed as explained bellow:

* missing link to dbug lib;
* user proper fprintf format specifier;
* ZERO_COND_INITIALIZER was using wrong toku_cond_t struct
  initializer for first member of type pthread_cond_t and
  not considering the TOKU_PTHREAD_DEBUG case which has
  one extra struct member of type pfs_key_t;
* Remove likely(!opt_debug_sync_timeout), argument is
  declared extern and not available to Toku;
* pthread_mutex_timedlock() is not available in pthreads
  for Mac, as it's not part of the POSIX pthreads spec.
  The encompassing event_t::wait(ms) methods are unused,
  thus have been removed;
2018-06-10 10:12:34 +03:00
Teodor Mircea Ionita
8f82c48443 MDEV-15778: Restore file permissions lost in merge
Permissions were probably due to a file copy in:
15f7f5c6bb Merge branch 'merge-tokudb-5.6' into 10.0
2018-06-10 10:12:34 +03:00
Teodor Mircea Ionita
1735fa340a MDEV-15778: Remove packed attr from omt_ and subtree_ classes
This is happening because they are declared as packed
and clang has -Waddress-of-packed-member when passing the
address of a packed member, a legit concern on different
architectures. The easiest way to get rid of the errors is to
remove the packed attribute from said structs.
2018-06-10 09:54:00 +03:00
Teodor Mircea Ionita
b8e267c0c5 MDEV-15778: Manually backport TokuDB macOS fixes from 10.0
Fix build on macOS 10.13:

39dceaae60 MDEV-10983: TokuDB does not compile on OS X 10.12
Make use of a different function to get the current tid.
Additionally, librt doesn't exist on OS X. Use System library instead.

 storage/tokudb/PerconaFT/cmake_modules/TokuFeatureDetection.cmake | 4 +++-
 storage/tokudb/PerconaFT/portability/portability.cc               | 9 ++++++++-
 storage/tokudb/PerconaFT/portability/tests/test-xid.cc            | 9 ++++++++-
 storage/tokudb/PerconaFT/portability/toku_config.h.in             | 1 +
 4 files changed, 20 insertions(+), 3 deletions(-)
2018-06-10 09:54:00 +03:00
Varun Gupta
c17468d4ab MDEV-16191: Analyze format=json gives incorrect value for r_limit inside a dependent
subquery when ORDER BY is present

Currently for setting r_limit we divide with the number of iterations we invoke the dependent subquery.
This is not needed for the case of limit. For varying limits we produce the output that the limit varies with
execution.
Also there is a type for filtered , we forgot to multiply by 100 as it is represented as a percent.
2018-06-09 19:04:51 +05:30
Varun Gupta
cd33280b68 MDEV-16374: Filtered shows 0 for materilization scan for a semi join, which makes optimizer always picks
materialization scan over materialization lookup

For non-mergeable semi-joins we don't store the estimates of the IN subquery in table->file->stats.records.
In the function TABLE_LIST::fetch_number_of_rows, we store the number of rows in the tables
(estimates in case of derived table/views).
Currently we don't store the estimates for non-mergeable semi-joins, which leads to a problem of selecting
materialization scan over materialization lookup.
Fixed this by storing these estimated appropriately
2018-06-09 11:40:28 +05:30
Vladislav Vaintroub
15155ecd34 fix typo 2018-06-08 20:42:39 +01:00
Vladislav Vaintroub
5bfd562a00 MDEV-16445 mysql_upgrade_service should add skip-slave-start to server start parameters 2018-06-08 20:42:25 +01:00
Vladislav Vaintroub
141bc58ac9 MDEV-16430: mysql_upgrade_service does not write log file.
Fixed  CreateFile() for the log file
- TRUNCATE_EXISTING does not create a new file, use CREATE_ALWAYS
- Make log file handle inheritable
2018-06-08 19:52:30 +01:00
Chris Calender
d9b159a202 MDEV-15789 - mysqlslap use incorrect table def
The bug arises when one uses --auto-generate-sql-guid-primary (and
--auto-generate-sql-secondary-indexes) with mysqlslap and also have
sql_mode=STRICT_TRANS_TABLE.

When using this option, mysqlslap should create a column with varchar(36),
but it appears to create it as a varchar(32) only. Then if one has
sql_mode=STRICT_TRANS_TABLES, it throws an error, like:

  mysqlslap: Cannot run query INSERT INTO t1 VALUES (...)
  ERROR : Data too long for column 'id' at row 1

Upstream bug report: BUG#80329.
2018-06-07 17:21:14 +04:00
Marko Mäkelä
3627dd7f6a MDEV-16416 Crash on IMPORT TABLESPACE of a ROW_FORMAT=COMPRESSED table
fil_iterate(): Invoke fil_encrypt_buf() correctly when
a ROW_FORMAT=COMPRESSED table with a physical page size of
innodb_page_size is being imported. Also, validate the page checksum
before decryption, and reduce the scope of some variables.

AbstractCallback::operator()(): Remove the parameter 'offset'.
The check for it in FetchIndexRootPages::operator() was basically
redundant and dead code since the previous refactoring.
2018-06-07 10:34:32 +03:00
Oleksandr Byelkin
75b4eb5cc9 Catch of OOM situation. 2018-06-06 15:27:57 +02:00
Marko Mäkelä
1d4e1d3263 Merge 10.0 to 10.1 2018-06-06 11:04:17 +03:00
Vladislav Vaintroub
72b6d01848 MDEV-10246 ssl-* config file options have no effect without mysql_ssl_set()
Partially revert 4ef7497996
that caused regression.

Any ssl- option must imply use_ssl=1, even if mysql_set_ssl() was not
used.
2018-06-05 22:13:19 +01:00
Marko Mäkelä
55abcfa7b7 MDEV-16124 fil_rename_tablespace() times out and crashes server during table-rebuilding ALTER TABLE
InnoDB insisted on closing the file handle before renaming a file.
Renaming a file should never be a problem on POSIX systems. Also on
Windows it should work if the file was opened in FILE_SHARE_DELETE
mode.

fil_space_t::stop_ios: Remove. We no longer need to stop file access
during rename operations.

fil_mutex_enter_and_prepare_for_io(): Remove the wait for stop_ios.

fil_rename_tablespace(): Remove the retry logic; do not close the
file handle. Remove the unused fault injection that was added along
with the DATA DIRECTORY functionality (MySQL WL#5980).

os_file_create_simple_func(), os_file_create_func(),
os_file_create_simple_no_error_handling_func(): Include FILE_SHARE_DELETE
in the share_mode. (We will still prevent multiple InnoDB instances
from using the same files by not setting FILE_SHARE_WRITE.)
2018-06-05 18:16:12 +03:00
Marko Mäkelä
3b7da8a44c MDEV-15824 innodb_defragment=ON trumps innodb_optimize_fulltext_only=ON in OPTIMIZE TABLE
ha_innobase::optimize(): If both innodb_defragment and
innodb_optimize_fulltext_only are at their default settings (OFF),
fall back to ALTER TABLE. Else process one or both options.
2018-06-05 11:39:47 +03:00
Marko Mäkelä
f6376bfd1c Add FLUSH TABLES to avoid corruption of MyISAM system tables 2018-06-05 11:39:47 +03:00
Marko Mäkelä
41cbe92bf1 Remove dead code that was added in MDEV-5834
ha_innobase::set_partition_owner_stats(): Remove (unused function).

ha_innobase::ha_partition_stats: Remove (the variable is never read).

Remove unused ut_timer functions.
2018-06-05 11:39:47 +03:00
Varun Gupta
5fb2c586f2 MDEV-16225: wrong resultset from query with semijoin=on
For non-semi-join subquery optimization we do a cost based decision between
Materialisation and IN -> EXIST transformation. The issue in this case is that for IN->EXIST transformation
we run JOIN::reoptimize with the IN->EXISt conditions and we come up with a new query plan. But when we compare
the cost with Materialization, we make the decision to chose Materialization so we need to restore the query plan
for Materilization.
The saving and restoring for keyuse array and join_tab keyuse is only done when we have atleast
one element in the keyuse_array , we are now changing to do it even for 0 elements to main the generality.
2018-06-02 11:52:48 +05:30
Vladislav Vaintroub
c1698e8dc5 MDEV-16303 - do not install wsrep.ini on Windows 2018-05-29 16:47:47 +01:00
Marko Mäkelä
6aa50bad39 MDEV-16283 ALTER TABLE...DISCARD TABLESPACE still takes long on a large buffer pool
Also fixes MDEV-14727, MDEV-14491
InnoDB: Error: Waited for 5 secs for hash index ref_count (1) to drop to 0
by replacing the flawed wait logic in dict_index_remove_from_cache_low().

On DISCARD TABLESPACE, there is no need to drop the adaptive hash index.
We must drop it on IMPORT TABLESPACE, and eventually on DROP TABLE or
DROP INDEX. As long as the dict_index_t object remains in the cache
and the table remains inaccessible, the adaptive hash index entries
to orphaned pages would not do any harm. They would be dropped when
buffer pool pages are reused for something else.

btr_search_drop_page_hash_when_freed(), buf_LRU_drop_page_hash_batch():
Remove the parameter zip_size, and pass 0 to buf_page_get_gen().

buf_page_get_gen(): Ignore zip_size if mode==BUF_PEEK_IF_IN_POOL.

buf_LRU_drop_page_hash_for_tablespace(): Drop the adaptive hash index
even if the tablespace is inaccessible.

buf_LRU_drop_page_hash_for_tablespace(): New global function, to drop
the adaptive hash index.

buf_LRU_flush_or_remove_pages(), fil_delete_tablespace():
Remove the parameter drop_ahi.

dict_index_remove_from_cache_low(): Actively drop the adaptive hash index
if entries exist. This should prevent InnoDB hangs on DROP TABLE or
DROP INDEX.

row_import_for_mysql(): Drop any adaptive hash index entries for the table.

row_drop_table_for_mysql(): Drop any adaptive hash index for the table,
except if the table resides in the system tablespace. (DISCARD TABLESPACE
does not apply to the system tablespace, and we do no want to drop the
adaptive hash index for other tables than the one that is being dropped.)

row_truncate_table_for_mysql(): Drop any adaptive hash index entries for
the table, except if the table resides in the system tablespace.
2018-05-29 14:00:20 +03:00
Marko Mäkelä
b7985a45a6 Fix type mismatch 2018-05-29 08:55:07 +03:00
Marko Mäkelä
35a9c90fff MDEV-14589 InnoDB should not lock a delete-marked record
When the transaction isolation level is SERIALIZABLE, or when
a locking read is performed in the REPEATABLE READ isolation level,
InnoDB must lock delete-marked records in order to prevent another
transaction from inserting something.

However, at READ UNCOMMITTED or READ COMMITTED isolation level or
when the parameter innodb_locks_unsafe_for_binlog is set, the
repeatability of the reads does not matter, and there is no need
to lock any records.

row_search_for_mysql(): Skip locks on delete-marked committed records
upfront, instead of invoking row_unlock_for_mysql() afterwards.
The unlocking never worked for secondary index records.
2018-05-29 08:54:33 +03:00
Monty
d8da920264 MDEV-10679 Crash in performance schema and partitioning with discovery
Crash happened because in discover, table->work_part_info was not properly
reset before execution.
Fixed by resetting before calling execute alter table, create table or
mysql_create_frm_image.
2018-05-26 12:49:25 +03:00
Monty
199517f501 Avoid warnings in String::copy when copying string on itself (ok to do) 2018-05-26 12:49:25 +03:00
Monty
5a16fe0e6f Fixed compiler warnings
When merging this with 10.2 and later, one can just use the 10.2 or later code
2018-05-26 12:49:25 +03:00
Monty
29dbb23fb7 MDEV-16093 Memory leak with triggers
Problem was that blob memory allocated in Table_trigger_list was not
properly freed
2018-05-26 12:49:25 +03:00
Sergei Golubchik
9e22cae1cf embedded use-after-free ASAN error
Close MYSQL (and destroy THD) in the same thread where it was used,
because THD embeds MDL_context, that owns some LF_PINS, that remember
a pointer to my_thread_var->stack_ends_here.
2018-05-25 18:24:06 +02:00
Marko Mäkelä
bfed1bfe28 Add a missing dependency to a test 2018-05-24 11:55:27 +03:00