Commit graph

63970 commits

Author SHA1 Message Date
Sergei Golubchik
3d4beee1a9 remove double-counting
rnd_pos_by_record calls ha_rnd_pos, which does the counting
2018-06-28 13:36:51 +02:00
Sergey Vojtovich
bf4244d1a0 MDEV-8540 - Crash on server shutdown since 10.0.16
Only close stdin if it was open initinally. Otherwise we may close file
descriptor which is reused for different puprose (specifically for binlog
index file in case of this bug).
2018-06-27 17:06:00 +04:00
Andrei Elkin
28e1f1453f MDEV-15242 Poor RBR update performance with partitioned tables
Observed and described
partitioned engine execution time difference
between master and slave was caused by excessive invocation
of base_engine::rnd_init which was done also for partitions
uninvolved into Rows-event operation.
The bug's slave slowdown therefore scales with the number of partitions.

Fixed with applying an upstream patch.

References:
----------
https://bugs.mysql.com/bug.php?id=73648
Bug#25687813 REPLICATION REGRESSION WITH RBR AND PARTITIONED TABLES
2018-06-25 16:45:00 +03:00
Igor Babaev
364a20fe0b MDEV-16507 SIGSEGV when use_stat_tables = preferably and
optimizer_use_condition_selectivity = 4

It does not makes sense to try to read statistics for temporary tables
because it's not collected.
2018-06-23 19:36:26 -07:00
Varun Gupta
5f2a67a6c3 MDEV-15247: Crash when SET NAMES 'utf8' is set
In this case we are accessing incorrect memory when we have mergeable semi-joins.
In the case when we have mergeable semi joins parent select will have a table count
of all the tables in that select plus all the tables involved in the IN-subquery.
But this table count does not include the "sjm table" (only includes the inner and outer tables)
denotes as <subquery#> in explain.
2018-06-20 02:36:00 +05:30
Alexander Barkov
c450f7d8d5 Merge remote-tracking branch 'origin/5.5' into 10.0 2018-06-19 14:03:41 +04:00
Alexander Barkov
15b92915ed MDEV-15834 The code in TABLE_SHARE::init_from_binary_frm_image() is not safe 2018-06-19 13:02:02 +04:00
Sergei Golubchik
3661d98822 fix SHOW PROCESSLIST for --embedded
make it return the same Info values as for the standalone server.

This fixes plugins.processlist for --embedded
2018-06-13 20:31:40 +02:00
Sergei Golubchik
51254da52c MDEV-15359 Thread stay in "cleaning up" status after finishing
make thd_get_error_context_description() to show not just
thd->proc_info, but exactly the same thread state that SHOW PROCESSLIST
shows.
2018-06-13 20:26:51 +02:00
Vicențiu Ciorbaru
170bec36c0 Merge branch '5.5' into 10.0 2018-06-12 17:59:31 +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
Igor Babaev
147744d455 MDEV-16235 Server crashes in my_utf8_uni or in my_strtod_int upon
SELECT .. LIMIT 0 (new variant)

This is another attempt to fix the problem of mdev-14515.
2018-06-11 08:52:49 -07: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
Vicențiu Ciorbaru
3ead951180 Merge branch '5.5' into 10.0 2018-06-10 17:16:27 +03:00
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
Oleksandr Byelkin
75b4eb5cc9 Catch of OOM situation. 2018-06-06 15:27:57 +02: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
Monty
a816aa066e Fixed ASAN heap-use-after-free handler::ha_index_or_rnd_end
MDEV-16123 ASAN heap-use-after-free handler::ha_index_or_rnd_end
MDEV-13828 Segmentation fault on RENAME TABLE

Problem was that destructor called methods for closed table.
Fixed by removing code in destructor.
2018-05-23 11:26:49 +03:00
Monty
908676dfd9 MDEV-15308 Assertion `ha_alter_info->alter_info->drop_list.elements
Problem was that handle_if_exists_options() didn't correct
alter_info->flags when things was removed from the list.
2018-05-22 23:08:26 +03:00
Monty
da71c1bad7 MDEV-16229 Replication aborts with ER_VIEW_SELECT_TMPTABLE after half-failed RENAME
Problem was that detection of temporary tables was all wrong for
RENAME TABLE.
(Temporary tables where opened by top level call to
open_temporary_tables(), which can't detect if a temporary table
was renamed to something and then reused).

Fixed by adding proper parsing of rename list to check against
the current name of a table at each rename stage.
Also change do_rename_temporary() to check against the current
state of temporary tables, not according to the state of start
of RENAME TABLE.
2018-05-22 23:05:48 +03:00
Monty
2f3779d31c Fixes for Aria transaction handling with lock tables
MDEV-10130 Assertion `share->in_trans == 0' failed in storage/maria/ma_close.c
MDEV-10378 Assertion `trn' failed in virtual int ha_maria::start_stmt

The problem was that maria_handler->trn was not properly reset
at commit/rollback and ha_maria::exernal_lock() could get confused
because.

There was some old code in ha_maria::implicit_commit() that tried
to take care of this, but it was not bullet proof.

Fixed by adding list of all tables that is part of the maria transaction to
TRN.

A nice side effect was of the fix is that loops in
ha_maria::implict_commit() got to be much simpler.

Other things:
- Fixed a bug in mysql_admin_table() where argument open_for_modify
  was wrongly reset for the next table in the chain
- rollback admin command also in case of fatal error.
- Split _ma_set_trn_for_table() to three version to simplify code
  and debugging.
- Several new asserts to detect the original problem (that file was
  not properly removed from trn before calling ma_close())
2018-05-22 23:05:48 +03:00
Igor Babaev
6a04c2a1aa MDEV-16235 Server crashes in my_utf8_uni or in my_strtod_int
upon SELECT .. LIMIT 0

The code must differentiate between a SELECT with contradictory
WHERE/HAVING and one with LIMIT 0.
Also for the latter printed 'Zero limit' instead of 'Impossible where'
in the EXPLAIN output.
2018-05-22 12:09:05 -07:00
Sergei Golubchik
c1b5d2801e Merge branch '5.5' into 10.0 2018-05-19 15:38:34 +02:00
Sergei Golubchik
cf5226174b MDEV-11129 CREATE OR REPLACE TABLE t1 AS SELECT spfunc() crashes if spfunc() references t1
fix a typo that broke the main.view test

followup for ef295c31e3
2018-05-19 15:34:17 +02:00
Sergei Golubchik
1b2078b4d8 MDEV-15318 CREATE .. SELECT VALUES produces invalid table structure
When Item_insert_value needs a dummy field,
use zero-length Field_string, not Field_null.
The latter isn't compatible with CREATE ... SELECT.
2018-05-17 11:32:13 +02:00
Monty
ef295c31e3 MDEV-11129 CREATE OR REPLACE TABLE t1 AS SELECT spfunc() crashes if spfunc() references t1
Fixed by extending unique_table() with a flag to not allow usage of
the replaced table.

I also cleaned up find_dup_table() to not use goto next.
I also added more comments to the code in find_dup_table()
2018-05-16 21:51:46 +03:00
Monty
b050df4fd3 MDEV-14943 Alter table ORDER BY bug
Problem was that if copy_data_between_tables() didn't do proper
clean up in case of failures:
- copy object was not properly freed
- end_bulk_insert() was not called
- mysql_trans_prepare_alter_copy_data() set THD->transaction.on to
  false which was not properly restored

The last part caused a crash in Aria as Aria depends on that THD
is correct.

Other things:
- Reset info->switched_transactional after usage (safety)
- Reset bulk_insert_single_undo (safety)
2018-05-15 13:12:35 +03:00
Sergei Golubchik
34045af03f MDEV-15216 Assertion `! is_set() || m_can_overwrite_status' failed in Diagnostics_area::set_error_status upon operation inside XA
don't implicitly commit or rollback in mysql_admin_table()
unless the statement has CF_IMPLICIT_COMMIT_END flag.
2018-05-08 10:48:13 +02:00
Sergei Golubchik
42fac32413 Merge branch '5.5' into 10.0 2018-05-01 11:47:43 +02:00
Sergei Golubchik
fab383aac0 Use after free in authentication 2018-05-01 00:30:17 +02:00
Sergei Golubchik
c4499a0391 Merge branch '5.5' into 10.0 2018-04-29 00:38:10 +02:00
Sergei Golubchik
619afb151b MDEV-15456 Server crashes upon adding or dropping a partition in ALTER under LOCK TABLE after ER_SAME_NAME_PARTITION
followup for bcb36ee21e

move reopening before trans_commit_stmt(thd);
2018-04-26 14:08:03 +02:00
Monty
e86c0a5f2a Increase number of max table_open_cache instances
This is a backport of MDEV-11429 from 10.1
2018-04-26 14:21:36 +03:00
Igor Babaev
eb057dce20 MDEV-15035 Wrong results when calling a stored procedure
multiple times with different arguments.

If the ON expression of an outer join is an OR formula with one
of the disjunct being a constant formula then the expression
cannot be null-rejected if the constant formula is true. Otherwise
it can be null-rejected and if so the outer join can be converted
into inner join. This optimization was added in the patch for
mdev-4817. Yet the code had a defect: if the query was used in
a stored procedure with parameters and the constant item contained
some of them then the value of this constant item depended on the
values of the parameters. With some parameters it may be true,
for others not. The validity of conversion to inner join is checked
only once and it happens only for the first call of procedure.
So if the  parameters in the first call allowed the conversion it
was done and next calls used the transformed query though there
could be calls whose parameters made the conversion invalid.

Fixed by cheking whether the constant disjunct in the ON expression
originally contained an SP parameter. If so the expression is not
considered as null-rejected. For this check a new item's attribute
was intruduced: Item::with_param. It is calculated for each item
by fix fields() functions.
Also moved the call of optimize_constant_subqueries() in
JOIN::optimize after the call of simplify_joins(). The reason
for this is that after the optimization introduced by the patch
for mdev-4817 simplify_joins() can use the results of execution
of non-expensive constant subqueries and this is not valid.
2018-04-25 09:22:06 -07:00
Oleksandr Byelkin
adaa891ae7 MDEV-13699: Assertion `!new_field->field_name.str || strlen(new_field->field_name.str) == new_field->field_name.length' failed in create_tmp_table on 2nd execution of PS with semijoin
The problem was that SJ (semi-join) used secondary list (array) of subquery select list. The items there was prepared once then cleaned up (but not really freed from memory because it was made in statement memory).
Original list was not prepared after first execution because select was removed by conversion to SJ.
The solution is to use original list but prepare it first.
2018-04-25 08:47:43 +02:00
Sergei Golubchik
f2433b8dd3 MDEV-10824 - Crash in CREATE OR REPLACE TABLE t1 AS SELECT spfunc()
followup for a3c980b381

same change in Locked_tables_list::unlink_from_list(), otherwise
thd->locked_tables_list will keep pointers to a free'd TABLE if
prelocked under lock tables.

This fixes a crash in main.create_or_replace on debug Win builds
after bcb36ee21e
2018-04-21 13:13:19 +02:00
Sergei Golubchik
587568b72a Merge branch '5.5' into 10.0 2018-04-20 14:33:24 +02:00
Sergei Golubchik
bcb36ee21e MDEV-15456 Server crashes upon adding or dropping a partition in ALTER under LOCK TABLE after ER_SAME_NAME_PARTITION
ALTER TABLE ... ADD PARTITION modifies the open TABLE structure,
and sets table->need_reopen=1 to reset these modifications
in case of an error.

But under LOCK TABLES the table isn't get reopened, despite need_reopen.

Fixed by reopening need_reopen tables under LOCK TABLE.
2018-04-20 10:24:44 +02:00
Sergei Golubchik
1a019d0801 Merge branch 'mysql/5.5' into 5.5 2018-04-19 22:31:26 +02:00
Sergei Golubchik
4f5dd1d40e ASAN error in main.statistics_index_crash-7362
one cannot do keyread on spatial indexes.
2018-04-17 10:13:20 +02:00
Igor Babaev
5e61e1716e MDEV-14515 ifnull result depends on number of rows in joined table
Any expensive WHERE condition for a table-less query with
implicit aggregation was lost. As a result the used aggregate
functions were calculated over a non-empty set of rows even
in the case when the condition was false.
2018-04-16 16:59:19 -07:00
Alexey Botchkov
3eb2a265ea MDEV-14185 CREATE TEMPORARY TABLE AS SELECT causes error 1290 with read_only and InnoDB.
condition fixed.
2018-04-08 09:05:00 +04:00
Alexey Botchkov
d6f3a0064b MDEV-14185 CREATE TEMPORARY TABLE AS SELECT causes error 1290 with read_only and InnoDB.
handler::ha_create_handler_files shouldn't call the
mark_trx_read_write() for the temporary table.
2018-04-07 21:51:15 +04:00
Ian Gilfillan
8901155780 Update contributors 2018-04-05 14:23:18 +04:00
Alexander Barkov
6beb08c7b6 MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way 2018-04-04 09:12:44 +04:00
Vicențiu Ciorbaru
6a72b9096a Merge branch '5.5' into 10.0 2018-04-03 18:08:30 +03:00
Alexander Barkov
606e21867c MDEV-15630 uuid() function evaluates at wrong time in query 2018-04-03 16:28:52 +04:00