Commit graph

497 commits

Author SHA1 Message Date
Sergey Vojtovich
30ddf96113 Fixed ya main.flush_read_lock sporadic failure
Use different signal names, so that subsequent WAIT_FOR is not awaken by
previous signal.
2019-05-14 23:51:10 +04:00
Oleksandr Byelkin
29a0f5acf3 MDEV-19277: Add status variable that gets incremented if connection is aborted prior to authentication
MDEV-19282: Log more specific warning with log_warnings=2 if connection is aborted prior to authentication
2019-05-14 16:38:13 +02:00
Varun Gupta
41779561ec Fixed myisam_mrr for 32 bit systems 2019-05-13 22:41:28 +05:30
Sergey Vojtovich
7a6c36b547 Fixed main.flush_read_lock sporadic failure
With MDEV-19384 fixed FTWRL releases HANDLER locks early, which allows
concurrent threads to go. Test case may get stuck on FTWRL waiting for
LOCK TABLES.
2019-05-13 20:23:44 +04:00
Varun Gupta
6a365e0bf2 MDEV-13628: ORed condition in pushed index condition is not removed from the WHERE
So to push index condition for each join tab we have calculate the index condition that can be pushed and then
remove this index condition from the original condition. This is done through the function make_cond_remainder.
The problem is the function make_cond_remainder does not remove index condition when there is an OR operator.

Fixed this by making the function make_cond_remainder to keep in mind of the OR operator.
Also updated results for multiple test files which were incorrectly updated by the commit e0c1b3f242

code which was supposed to remove the condition present in the index
condition was not getting executed when the condition had OR operator, with AND the pushed
index condition was getting removed from where.

This problem affects all versions starting from 5.5 but this is a performance improvement, so fixing it in 10.4
2019-05-11 20:50:12 +05:30
Daniel Black
d2fa5f8cfc MDEV-8553: Impossible where for a!=a, a<a, a>a
For a table column `a`, the above expressions logically
equate to false in all cases.

With this patch the optimizer knows about this and queries
like:

SELECT * FROM t1 WHERE a!=a

no longer need to evaluate a!=a for every row.

The same applies if the expression was `a<a`, or `a>a`

An `EXPLAIN SELECT COOUNT(*) FROM t1 WHERE a<a` will show:

id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1      SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE

Similarly `NOT (a!=a)` is always true.

EXPLAIN SELECT COUNT(*) FROM t1 WHERE not (a!=a);
id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1      SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
2019-05-10 14:05:36 +04:00
Vladislav Vaintroub
ad36d38024 MDEV-19235 MariaDB Server compiled for 128 Indexes crashes at startup
With MAX_INDEXIES=64(default), key_map=Bitmap<64> is just a wrapper around
ulonglong and thus "trivial" (can be bzero-ed, or memcpy-ed, and stays
valid still)

With MAX_INDEXES=128, key_map = Bitmap<128> is not a "trivial" type
anymore. The implementation uses MY_BITMAP, and MY_BITMAP contains pointers
which make Bitmap invalid, when it is memcpy-ed/bzero-ed.

The problem in 10.4 is that there are many new key_map members, inside TABLE
or KEY, and those are often memcopied and bzeroed

The fix makes Bitmap "trivial", by inlining most of MY_BITMAP functionality.
pointers/heap allocations are not used anymore.
2019-05-09 18:58:16 +02:00
Igor Babaev
fd386e39cd MDEV-18689 Simple query with extra brackets stopped working
Parenthesis around table names and derived tables should be allowed
in FROM clauses and some other context as it was in earlier versions.

Returned test queries that used such parenthesis in 10.3 to their
original form. Adjusted test results accordingly.
2019-05-06 11:14:39 -07:00
Monty
b8259e4b59 MDEV-19384 Deadlock in FTWRL
The deadlock happened between FTWRL under open HANDLER, LOCK TABLE and
DROP DATABASE

Fixed by reverting the previous fix for handler open in
lock_global_read_lock()

Fixed the original (wrong) test case in flush_read_lock.test to be
repeatable.
2019-05-06 14:56:31 +03:00
Marko Mäkelä
d3dcec5d65 Merge 10.3 into 10.4 2019-05-05 15:06:44 +03:00
Marko Mäkelä
b132b8895e Merge 10.3 into 10.4 2019-05-05 10:23:14 +03:00
Varun Gupta
ca098107a2 MDEV-18117: Crash with Explain extended when using limit rows examined
No need to set SELECT_LEX:explicit_limit when we have a limit clause
that sets only the EXAMINED ROWS
2019-05-03 09:46:00 +05:30
Varun Gupta
879878e43d MDEV-18943: Group Concat with limit not working with views
Adjusted the Item_func_group_concat::print function to take into account
limit if present with GROUP_CONCAT
2019-05-03 08:50:40 +05:30
Marko Mäkelä
158247d3bd Merge 10.2 into 10.3 2019-05-02 21:43:24 +03:00
Monty
0cc7c6085e Enable mysqlcheck and flush_read_lock tests
- Updated results
- Run mysqlcheck without --user-stat-tables=PREFERABLY to keep results
  consistent
- Don't allow one to run analyze table under FTWRL as analyze table
  nowadays has to update status tables.
2019-05-02 16:11:32 +03:00
Aleksey Midenkov
d46ffaf6af MDEV-17655 Inconsistent grant-name usage between grant-statement and privilege tables
Closes #1044
2019-05-02 11:40:06 +02:00
Varun Gupta
0fd5ecb03c Adjust the result for join_cache.test 2019-05-02 10:12:35 +05:30
Igor Babaev
2b7e080fae MDEV-19363 Assertion `select_lex' failed in LEX::pop_select
This patch corrects the patch for MDEV-19324. The latter did not
work properly in the cases when the transformation
  (SELECT ... ORDER BY ...) LIMIT ... =>
   SELECT ... ORDER BY ... LIMIT ...
was applied to the operands of a set operation.
2019-05-01 18:20:06 -07:00
Varun Gupta
cb9fa1a08b MDEV-9959: A serious MariaDB server performance bug
If a derived table has SELECT DISTINCT, provide index statistics for it so that the join optimizer in the
upper select knows that ref access to the table will produce one row.
2019-04-30 21:07:25 +05:30
Alexander Barkov
8c8bee0a56 MDEV-10307 CAST(11068046444225730969 AS SIGNED) does not return a warning 2019-04-30 15:51:49 +04:00
Alexander Barkov
589dc00d94 Test for MDEV-11874 "Data too long for column" instead of "Invalid default value for" upon ALTER in strict mode
This problem was earlier fixed by the patch for:
    MDEV-16421 Make system tables crash safe

Adding tests only.
2019-04-29 09:25:42 +04:00
Marko Mäkelä
4d59f45260 Merge 10.2 into 10.3 2019-04-27 20:41:31 +03:00
Igor Babaev
5dee4a99d9 MDEV-19324 Wrong results from query, using brackets with ORDER BY ..LIMIT
If a select query was of the form (SELECT ... ORDER BY ...) LIMIT ...
then in most cases it returned incorrect result. It happened because
SELECT ... ORDER BY ... was wrapped into a select with materialized
derived table:
  SELECT ... ORDER BY ... =>
  SELECT * FROM (SELECT ... ORDER BY ...) dt.
Yet for any materialized derived table ORDER BY without LIMIT is ignored.
This patch resolves the problem by the conversion
  (SELECT ... ORDER BY ...) LIMIT ... =>
  SELECT ... ORDER BY ... LIMIT ...
at the parser stage.

Similarly
  ((SELECT ... UNION ...) ORDER BY ...) LIMIT ...
is converted to
  (SELECT ... UNION ...) ORDER BY ... LIMIT ...
This conversion optimizes execution of the query because the result of
(SELECT ... UNION ...) ORDER BY ... is not materialized into a temporary
table anymore.
2019-04-26 17:56:26 -07:00
Marko Mäkelä
e6bdf77e4b Merge 10.3 into 10.4
In is_eits_usable(), we disable an assertion that fails due to
MDEV-19334.
2019-04-25 16:05:20 +03:00
Marko Mäkelä
acf6f92aa9 Merge 10.2 into 10.3 2019-04-25 09:05:52 +03:00
Alexander Barkov
ca7fbcea6c MDEV-19317 TEXT column accepts too long literals as a default value
Adding new virtual methods in Field:
- make_empty_rec_store_default_value()
- make_empty_rec_reset()

This simplifies the logic for every Field type,
and makes the code more friendly to pluggable data types.
2019-04-25 08:26:08 +04:00
Galina Shalygina
a765b19e5c MDEV-19245: Impossible WHERE should be noticed earlier after HAVING pushdown
The bug appears because not all conditions are found to be knowingly
true or false in WHERE after HAVING pushdown optimization.
Impossible WHERE can be found much earlier compared with how it is done now.

To fix it and_new_conditions_to_optimized_cond() is changed.
2019-04-22 16:19:55 +03:00
Alexander Barkov
765ae6e821 MDEV-19239 ERROR 1300 (HY000): Invalid utf8 character string in 10.3.13-MariaDB
A sequence of <digits>e<mbhead><mbtail>, e.g.:

  SELECT 123eXYzzz FROM t1;

was not scanned correctly (where XY is a multi-byte character).

The multi-byte head byte X was appended to 123e separately from
the multi-byte tail byte Y, so a pointer to "Yzzz" was passed
into scan_ident_start(), which failed on a bad multi-byte sequence.

After this change, scan_ident_start() gets a pointer to "XYzzz",
so it correctly sees the whole multi-byte character.
2019-04-21 12:07:30 +04:00
Igor Babaev
a65d3b2c16 MDEV-19255 Server crash in st_join_table::save_explain_data or assertion
`sel->quick' failure in JOIN::make_range_rowid_filters upon query
           with rowid_filter=ON

Index ranges can be defined using conditions with inexpensive subqueries.
Such a subquery is evaluated when some representation of a possible range
sequence is built. After the evaluation the JOIN structure of the subsquery is distroyed.
Any attempt to build the above representation may fail because the
function that checks whether a subquery is inexpensive in some cases uses
the join structure of the subquery.
When a range rowid filter is built by a range sequence constructed out of
a range condition that uses an inexpensive subquery the representation of
the the sequence is built twice. Building the second representation fails
due to the described problem with the execution of Item_subselect::is_expensive().
The function was corrected to return the result of the last its invocation
if the Item_subselect object has been already evaluated.
2019-04-19 16:18:48 -07:00
Alexander Barkov
f4019f5b35 Backporting from 10.4 to 10.3: MDEV-17325 NULL-ability problems with LEAST() in combination with NO_ZERO_DATE and NO_ZERO_IN_DATE
This also fixes:
MDEV-17299 Assertion `maybe_null' failed in make_sortkey

Note, during merge of the 10.1 version of MDEV-17299,
please use the 10.3 version of the code (i.e. null merge the 10.1 version).
2019-04-20 00:11:50 +04:00
Monty
38f390f549 MDEV-19224 Assertion `marked_for_read()' failed
Problem was that wrong key_info variable was used, which caused UNIQUE
key to be used as a covering key
2019-04-19 13:22:01 +03:00
Monty
c07e346ca6 MDEV-19252 Problem with DBUG_ASSERT_AS_PRINTF and marked_for_write()
Problem was that DBUG_FIX_WRITE_SET was not enabled when using
DBUG_ASSERT_AS_PRINTF
2019-04-19 13:20:15 +03:00
Igor Babaev
59ed5f3aa4 MDEV-19164 Assertion `fixed' failed in Item_func_inet_aton::val_int
When pushing a condition from HAVING into WHERE the function
st_select_lex::pushdown_from_having_into_where() transforms column
references in the pushed condition then performs cleanup of
items of the condition and finally calls fix_fields() for the condition
items. The cleanup is performed by a call of the method walk() with
cleanup_processor as the first parameter. Unfortunately this sequence
of calls does not work if the condition contains cached items, because
fix_fields() cannot go through Item_cache items and this leaves
underlying items unfixed.
The solution of this problem used in this patch is just does not allow
to process Item_cache objects when performing cleanup of the pushed
condition. In order to let the traversal procedure walk() not to process
Item_cache objects the third parameter of the used call of walk()
is set to a fictitious pointer (void *) 1. And Item_cache::walk() is
changed to prevent any action when it gets such value as the third
parameter.
2019-04-17 21:37:29 -07:00
Oleksandr Byelkin
f202f3dfe6 MDEV-19263: Server crashes in mysql_handle_single_derived upon 2nd execution of PS
Fix case of prelocking placeholder
2019-04-16 23:21:04 +02:00
Igor Babaev
645f77a6bc MDEV-19195 Active Record unit test fails with MariaDB 10.4.3
Currently usage of range rowid filters can be combined only with
ref access and single index range access. So if the optimizer has
chosen some other quick select method to access a joined table
then no range rowid filter can be used for this table.
2019-04-16 16:51:21 +02:00
Oleksandr Byelkin
eb056f8726 MDEV-17362: SIGSEGV in JOIN::optimize_inner or Assertion `fixed == 0' failed in Item_equal::fix_fields, server crashes after 2nd execution of PS
Move reinitialisation of pushdown variables for every query, because it used now not only for derived tables.
2019-04-16 09:25:43 +02:00
Kentoku SHIBA
3e89e0f2ba
MDEV-16543 Replicating to spider is fragile without retries (#1272)
add changes of test results
2019-04-13 05:54:30 +09:00
Marko Mäkelä
7896503686 Merge 10.3 into 10.4 2019-04-12 12:45:06 +03:00
Eugene Kosov
4dc10ec68d MDEV-19236 Improve error message for ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_COLUMN_TYPE
remove a sometimes misleading word INPLACE from error message
2019-04-12 12:28:09 +03:00
Marko Mäkelä
d8303c3ee7 Merge 10.3 into 10.4 2019-04-08 08:22:34 +03:00
Marko Mäkelä
cc492bfd4f Merge 10.2 into 10.3 2019-04-07 11:49:50 +03:00
Igor Babaev
18bf0bf496 MDEV-18956 Assertion `sel->quick' failed in JOIN::make_range_rowid_filters
If SUBS_IN_TO_EXISTS strategy has been chosen for a subquery then
additional conditions are injected into WHERE/ON/HAVING of this subquery
and it may happen that test_quick_select() invoked from
JOIN::make_range_rowid_filters() discovers impossible range. This
must be checked.
2019-04-05 23:14:05 -07:00
Galina Shalygina
a2e477ffd0 MDEV-19186: Assertion `field->table == table' failed in create_tmp_table
Temporary table is defined with the view field in HAVING.
Item_direct_view_ref for this field is dropped and that causes error.

To fix it Item_direct_view_ref::remove_item_direct_ref() is added.
2019-04-06 00:04:52 +03:00
Galina Shalygina
694d1a50bd MDEV-19185: Pushdown constant function defined with subquery
The bug occurs because of the wrong pushdown of constant function
defined with subquery from HAVING into WHERE. Subqueries can't be
pushed into WHERE.

To fix it with_subquery() call is added to check if the function contains
subquery.
2019-04-05 22:55:20 +03:00
Alexander Barkov
c84dde148f MDEV-19184 Crash in IS_IPV6(_ucs2 0x0031) 2019-04-05 16:29:13 +04:00
Igor Babaev
d2013e7328 MDEV-18982 Partition pruning with column list causes syntax error in 10.4
A syntax error was reported for any INSERT statement with explicit
partition selection it if i used a column list.
Fixed by saving the parsing place before parsing the clause for explicit
partition selection and restoring it when the clause has been parsed.
2019-04-04 16:36:26 -07:00
Marko Mäkelä
d5a2bc6a0f Merge 10.2 into 10.3 2019-04-04 19:41:12 +03:00
Galina Shalygina
ae15f91f22 MDEV-18769 Assertion `fixed == 1' failed in Item_cond_or::val_int
This bug is caused by pushdown from HAVING into WHERE.
    It appears because condition that is pushed wasn't fixed.

    It is also discovered that condition pushdown from HAVING into
    WHERE is done wrong. There is no need to build clones for some
    conditions that can be pushed. They can be simply moved from HAVING
    into WHERE without cloning.
    build_pushable_cond_for_having_pushdown(),
    remove_pushed_top_conjuncts_for_having() methods are changed.

    It is found that there is no transformation made for fields of
    pushed condition.
    field_transformer_for_having_pushdown transformer is added.

    New tests are added. Some comments are changed.
2019-04-04 18:06:56 +03:00
Sergey Vojtovich
914bb5387f Removed redundant partitioning check
This check was introduced in 602a222 and then became redundant in ad1553e,
where we attempt to open a table even for non-copy algorithms.

Added missing test case from 602a222.

Part of MDEV-17805 - Remove InnoDB cache for temporary tables.
2019-04-03 16:47:27 +04:00
Sergey Vojtovich
1dac55cf0e Removed redundant SE lock for tmp tables
CREATE TEMPORARY TABLE locks SE plugin 6 times. 5 of these locks are
released by the end of the statement. And only 1 acquired by
init_from_binary_frm_image() / plugin_lock() remains.

The lock removed in this patch was clearly redundant.

Part of MDEV-17805 - Remove InnoDB cache for temporary tables.
2019-04-03 16:47:25 +04:00