Commit graph

45600 commits

Author SHA1 Message Date
Eugene Kosov
cf40393471 Merge 5.5 into 10.1 2019-06-20 12:26:01 +03:00
Igor Babaev
167da05f55 MDEV-19790 Wrong result for query with outer join and IS NOT TRUE predicate
in where clause

The classes Item_func_isnottrue and Item_func_isnotfalse inherited the
implementation of the eval_not_null_tables method from the Item_func
class. As a result the not_null_tables_cache was set incorrectly for
the objects of these classes. It led to improper conversion of outer
joins to inner joins when the where clause of the processed query
contained IS NOT TRUE or IS NOT FALSE predicates. The coverted query
in many cases produced a wrong result set.
2019-06-17 14:23:10 -07:00
Oleksandr Byelkin
5b65d61d93 Merge branch '5.5' into 10.1 2019-06-12 22:54:46 +02:00
Igor Babaev
6db2ebbb2a MDEV-19580 Unrelated JOINs corrupt usage of 'WHERE function() IN (subquery)'
Handling of top level conjuncts in WHERE whose used_tables() contained
RAND_TABLE_BIT in the function make_join_select() was incorrect.
As a result if such a conjunct referred to fields non of which belonged
to the last joined table  it was pushed twice. (This could be seen
for a test case from subselect.test whose output was changed after this
patch had been applied. In 10.1 when running EXPLAIN FORMAT=JSON for
the query from this test case we clearly see that one of the conjuncts
is pushed twice.) This fact by itself was not good. Besides, if such a
conjunct was pushed to a table that was the result of materialization
of a semi-join the query could return a wrong result set. In particular
we could watch it for queries with semi-join subqueries whose left parts
used stored functions without "deterministic' specifier.
2019-06-09 11:11:20 -07:00
Alexander Barkov
b003b0c934 MDEV-19675 Wrong charset is chosen when opening a pre-4.1 table 2019-06-03 12:42:36 +04:00
Sergei Golubchik
6660c072ad MDEV-19491 update query stopped working after mariadb upgrade 10.2.23 -> 10.2.24
as well as

MDEV-19500 Update with join stopped worked if there is a call to a procedure in a trigger
MDEV-19521 Update Table Fails with Trigger and Stored Function
MDEV-19497 Replication stops because table not found
MDEV-19527 UPDATE + JOIN + TRIGGERS = table doesn't exists error

Reimplement the fix for (5d510fdbf0)

MDEV-18507 can't update temporary table when joined with table with triggers on read-only

instead of calling open_tables() twice, put multi-update
prepare code inside open_tables() loop.

Add a test for a MDL backoff-and-retry loop inside open_tables()
across multi-update prepare code.
2019-06-01 09:43:40 +02:00
Sergei Golubchik
1d4ac3d4d3 cleanup 2019-06-01 09:43:40 +02:00
Igor Babaev
cbb90f77cd MDEV-18479 Complement
This patch complements the patch that fixes bug MDEV-18479.
This patch takes care of possible overflow when calculating the
estimated number of rows in a materialized derived table / view.
2019-05-28 23:26:36 -07:00
Igor Babaev
eb09580b67 MDEV-19588 Wrong results from query, using left join.
This bug could happen when queries with nested outer joins were
executed employing join buffers. At such an execution if the method
JOIN_CACHE::join_records() is called when a join buffer has become
full no 'first_unmatched' field should be cleaned up in the JOIN_TAB
structure to which the join cache with this buffer is attached.
2019-05-28 14:53:08 -07:00
Marko Mäkelä
bf8fe324d2 Merge 5.5 into 10.1 2019-05-28 11:25:45 +03:00
Igor Babaev
0955462d0a MDEV-18479 Assertion `join->best_read < double(1.79769313486231570815e+308L)'
or server crashes in JOIN::fix_all_splittings_in_plan after EXPLAIN

This patch resolves the problem of overflowing when performing
calculations to estimate the cost of an evaluated query execution plan.
The overflowing in a non-debug build could cause different kind of
problems uncluding crashes of the server.
2019-05-27 19:08:23 -07:00
Igor Babaev
e57bb1f76c MDEV-19258 RIGHT JOIN hangs in MariaDB
This patch corrects the patch for the bug 10006. The latter incorrectly
calculates the attribute TABLE_LIST::dep_tables for inner tables
of outer joins that are to be converted into inner joins.
As a result after the patch some valid join orders were not evaluated
and the optimizer could choose an execution plan that was far from
being optimal.
2019-05-23 21:54:17 -07:00
Robert Bindar
aad4e5637d Stale files cause intermittent failure when ordering is unfortunate
Running trigger_null-8605 drop_bad_db_type tests in this order was
failing due to unremoved temporary files created in trigger_null-8605
2019-05-22 16:01:39 +04:00
Varun Gupta
6dbc2ab8b3 MDEV-17752: Plan changes from hash_index_merge to index_merge with new optimizer defaults
The code in best_access_path function, when it does not find a key suitable for ref access
and join_cache_level is set to a value so that hash_join is possible we build a hash key.
Later in the function we compare the cost of ref access with table scan (or index scan
or quick selects). No need to do this when we have got the hash key.
2019-05-21 23:29:13 +05:30
Igor Babaev
2c9844a438 MDEV-18896 Crash in convert_join_subqueries_to_semijoins : Correction
This patch complements the original patch for MDEV-18896 that prevents
conversions to semi-joins in tableless selects used in INSERT statements
in post-5.5 versions of the server.
The test case was corrected as well to ensure that potential conversion
to jtbm semi-joins is also checked (the problem was that one of
the preceeding testcases in subselect_sj.test did not restore the
state of the optimizer switch leaving the 'materialization' in the state
'off' and so blocking this check).
Noticed an inconsistency in the state of select_lex::table_list used
in INSERT statements and left a comment about this.
2019-05-19 11:44:34 -07:00
Varun Gupta
70a5fb49a7 Fixed the case when statistics were not getting read because
we had the statistics tables in the FROM list of the select.
The statistics for tables are not read in such cases, so we need
to check this case separately.
2019-05-16 14:15:59 +05:30
Varun Gupta
6ab9d1627a MDEV-19407: Assertion `field->table->stats_is_read' failed in is_eits_usable
Statistics were not read for a table when we had a CREATE TABLE query.
Enforce reading statistics for commands CREATE TABLE, SET and DO.
2019-05-16 08:33:06 +05:30
Robert Bindar
a941e58fb8 MDEV-788 mysqlimport should support the ability to disable foreign keys 2019-05-15 18:45:58 +04:00
Oleksandr Byelkin
b85aa20065 Merge branch '5.5' into 10.1 2019-05-02 17:23:36 +02:00
Varun Gupta
ca94ce2a58 MDEV-19352: Server crash in alloc_histograms_for_table_share upon query from information schema
To read histograms for a table, we should check if the allocation of statistics was done or not,
if not done we should not try to read histograms for such a table.
2019-05-02 01:02:56 +05:30
Aleksey Midenkov
aba9115426 MDEV-19349 mysql_install_db: segfault at tmp_file_prefix check 2019-05-01 10:15:29 +02:00
Oleksandr Byelkin
5b035c8456 MDEV-14572: Assertion `! is_set()' failed in Diagnostics_area::set_eof_status upon EXPLAIN UPDATE in PS
Restore EXPAIN flag in SELECT_LEX before execution multi-update by flag in LEX
(the same but in other way made before INSERT/DELETE/SELECT)

Without it, mysql_update() didn't know that there will be EXPLAIN result set and was sending OK at the end of the update, which conflicted with the EOF sent later by EXPLAIN.
2019-04-30 11:38:41 +02:00
Alexander Barkov
ba9f8776c2 Tests for MDEV-19359 ASAN heap-use-after-free in copy_if_not_alloced / make_sortkey
The patch for MDEV-18738 fixed this problem. Adding tests only.
2019-04-30 11:10:53 +04:00
Alexander Barkov
5fb6444a37 MDEV-18738 ASAN heap-use-after-free in copy_if_not_alloced / copy_fields
copy_if_not_alloced() did not handle situations when
"from" is a constant string pointing to a substring of "to",
so this code part freed "to" but then tried to copy its old (already freed)
content to a new buffer:

  if (to->realloc(from_length))
    return from;
  if ((to->str_length=MY_MIN(from->str_length,from_length)))
    memcpy(to->Ptr,from->Ptr,to->str_length);

Adding a new code piece that catches such constant substrings
and propery reallocs "to" to preserve its important part referenced
by "from".
2019-04-30 10:53:59 +04:00
Alexander Barkov
021c7216c0 Tests for MDEV-11895 NO_ZERO_DATE affects timestamp values without any warnings
This problem was earlier fixed, possibly by f8a800bec8
and is not repeatable in 10.1-10.4 any more. Adding tests only.
2019-04-29 10:36:57 +04:00
Vladislav Vaintroub
e8778f1c7c MDEV-19265 Server should throw warning if event is created and event_scheduler = OFF 2019-04-28 12:49:59 +02:00
Vladislav Vaintroub
7590861779 MDEV-19276 during connect, write error log warning for ER_DBACCESS_DENIED_ERROR,
if log_warnings > 1.

This makes ER_DBACCESS_DENIED_ERROR handling the same as we do for other
"access denied"
2019-04-28 12:49:59 +02:00
Vladislav Vaintroub
e116f11f0a MDEV-18131 MariaDB does not verify IP addresses from subject alternative
names

Added a call to X509_check_ip_asc() in case server_hostname represents
an IP address.
2019-04-28 12:49:59 +02:00
Sergei Golubchik
d88dfd8732 MDEV-19350 Server crashes in delete_tree_element / ... / Item_func_group_concat::repack_tree
Item_func_group_concat stores values in `tree`, which is often, but not
always the same as `&tree_base`.
2019-04-27 19:38:39 +02:00
Sergei Golubchik
3fe38574fb gis2 fails in embedded
move privilege specific part of gis2.test to gis_notembedded.test
and the rest to gis.test
2019-04-27 11:28:50 +02:00
Varun Gupta
0d5aabd632 MDEV-19334: bool is_eits_usable(Field*): Assertion `field->table->stats_is_read' failed.
Fixed the assert by making sure that not to use EITS if the column statistics was not allocated.
2019-04-27 14:27:02 +05:30
Alexander Barkov
f239fd5034 MDEV-11015 Assertion failed: precision > 0 in decimal_bin_size upon SELECT with DISTINCT, CAST and other functions
Item_func_min_max::fix_length_and_dec() erroneously set max_length
to UINT32_MAX.

Merge notes:
In 10.3 this problem had been fixed earlier.
During merge to 10.3, do a "null merge" in item_func.cc
2019-04-27 08:44:29 +04:00
Sergei Golubchik
2ce52790ff Merge branch '5.5' into 10.1 2019-04-26 14:02:37 +02:00
Sergei Golubchik
da0e00e710 Bug#28986737: RENAMING AND REPLACING MYSQL.USER TABLE CAN LEAD TO A SERVER CRASH 2019-04-25 21:43:31 +02:00
Marko Mäkelä
1cd31bc132 Bug#28573894 ALTER PARTITIONED TABLE ADD AUTO_INCREMENT DIFF RESULT DEPENDING ON ALGORITHM
For partitioned table, ensure that the AUTO_INCREMENT values will
be assigned from the same sequence. This is based on the following
change in MySQL 5.6.44:

commit aaba359c13d9200747a609730dafafc3b63cd4d6
Author: Rahul Malik <rahul.m.malik@oracle.com>
Date:   Mon Feb 4 13:31:41 2019 +0530

    Bug#28573894 ALTER PARTITIONED TABLE ADD AUTO_INCREMENT DIFF RESULT DEPENDING ON ALGORITHM

    Problem:
    When a partition table is in-place altered to add an auto-increment column,
    then its values are starting over for each partition.

    Analysis:
    In the case of in-place alter, InnoDB is creating a new sequence object
    for each partition. It is default initialized. So auto-increment columns
    start over for each partition.

    Fix:
    Assign old sequence of the partition to the sequence of next partition
    so it won't start over.

    RB#21148
    Reviewed by Bin Su <bin.x.su@oracle.com>
2019-04-25 14:12:45 +03:00
Alexander Barkov
bb17094be4 MDEV-18452 ASAN unknown-crash in Field::set_default upon SET bit_column = DEFAULT
Field_bit for BIT(20) uses 2 full bytes in the record,
with additional 4 uneven bits in the "null bit area".

Field::set_default() called from Field_bit::set_default() erroneously
copied 3 bytes instead of 2 bytes from the record with default values.

Changing Field::set_default() to copy pack_length_in_rec() bytes
instead of pack_length() bytes.
2019-04-25 11:48:43 +04:00
Sergei Golubchik
979cad2291 MDEV-9531 GROUP_CONCAT with ORDER BY inside takes a lot of memory while it's executed
group concat tree is allocated in a memroot, so the only way to free
memory is to copy a part of the tree into a new memroot.

track the accumilated length of the result, and when it crosses
the threshold  - copy the result into a new tree, free the old one.
2019-04-24 16:06:54 +02:00
Sergei Golubchik
d3b2228fd8 cleanup: cosmetic fixes 2019-04-24 16:06:54 +02:00
Sergei Golubchik
ed866e9301 MDEV-19182 mysqldump not always handling SHOW CREATE TRIGGER failures correctly
only use SHOW TRIGGERS on old (< 5.1.21) servers, otherwise
always use SHOW CREATE TRIGGER and don't fallback.
2019-04-24 16:06:54 +02:00
Sergei Golubchik
3885099563 tests for AddGeometryColumn and DropGeometryColumn 2019-04-24 16:06:54 +02:00
Sergei Golubchik
2be3ab9776 MDEV-15907 ASAN heap-use-after-free in strnmov / .. / fill_effective_table_privileges on concurrent GRANT and CREATE VIEW
rename a test file.

Closes #1253
2019-04-24 11:15:38 +02:00
Robert Bindar
e52a4ab693 MDEV-15907 ASAN heap-use-after-free
This patch fixes an invalid read in fill_effective_table_privileges
triggered by a grant_version increase between a PREPARE for a
statement creating a view from I_S and EXECUTE.
A tmp table was created and free'd while preparing the statement,
TABLE_LIST::table_name was set to point to the tmp table
TABLE_SHARE::table_name which no longer existed after preparing was
done.
The grant version increase made fill_effective_table_privileges
called during EXECUTE to try fetch the updated grant info and
this is where the dangling table name was used.
2019-04-24 11:15:38 +02:00
Sergei Golubchik
5d510fdbf0 MDEV-18507 can't update temporary table when joined with table with triggers on read-only
triggers are opened and tables used in triggers are prelocked in
open_tables(). But multi-update can detect what tables will actually
be updated only later, after all main tables are opened.

Meaning, if a table is used in multi-update, but is not actually updated,
its on-update treggers will be opened and tables will be prelocked,
even if it's unnecessary. This can cause more tables to be
write-locked than needed, causing read_only errors, privilege errors
and lock waits.

Fix: don't open/prelock triggers unless table->updating is true.
In multi-update after setting table->updating=true, do a second
open_tables() for newly added tables, if any.
2019-04-24 11:15:38 +02:00
Sergei Golubchik
5057d46375 bugfix: multi-update checked privileges on views incorrectly
it always required UPDATE privilege on views, not being able to detect
when a views was not actually updated in multi-update.

fix: instead of marking all tables as "updating" by default,
only set "updating" on tables that will actually be updated
by multi-update. And mark the view "updating" if any of the
view's tables is.
2019-04-24 11:15:38 +02:00
Sergei Golubchik
822071ca5b MDEV-18241 Downgrade from 10.4 to 10.3 crashes
privilege tables can never be views or temporary tables,
don't even try to open them, if they are.
2019-04-24 11:15:38 +02:00
Sergei Golubchik
66099b8f2d cleanup 2019-04-24 11:15:38 +02:00
Igor Babaev
279a907fd0 MDEV-17605 Statistics for InnoDB table is wrong if persistent statistics is used
The command SHOW INDEXES ignored setting of the system variable
use_stat_tables to the value of 'preferably' and and showed statistical
data received from the engine. Similarly queries over the table
STATISTICS from INFORMATION_SCHEMA ignored this setting. It happened
because the function fill_schema_table_by_open() did not read any data
from statistical tables.
2019-04-22 17:11:07 -07:00
Alexey Botchkov
a4f7d85932 MDEV-18920 Prepared statements with st_convexhull hang and eat 100% cpu.
In the case of error when object shapes are half-collected we need
to set the NULL at the vertice's list.
2019-04-22 23:28:44 +04:00
Alexander Barkov
279b50b4eb MDEV-14041 Server crashes in String::length on queries with functions and ROLLUP 2019-04-22 14:01:58 +04:00
Alexander Barkov
f4b2740018 MDEV-17299 Assertion `maybe_null' failed in make_sortkey 2019-04-19 21:04:44 +04:00