Commit graph

66565 commits

Author SHA1 Message Date
Igor Babaev
7d201d7b30 Fixed mdev-14879 Lost rows for query using recursive CTE
with recursive reference in subquery

If a recursive CTE uses a subquery with recursive reference then
the virtual function reset() must be called after each iteration
performed at the execution of the CTE.
2018-01-09 09:29:16 -08:00
Sachin Setiya
73cf630ffc Fix Compile Error while using Flag '-DUSE_ARIA_FOR_TMP_TABLES:BOOL=OFF' 2018-01-07 00:33:17 +05:30
Igor Babaev
0de565a564 Fixed mdev-14852 Fails to reopen temp table within standard CTE
If the specification of a CTE contains a reference to a temporary table
then THD::open_temporary_table() must be called for this reference for
any occurrence of the CTE in the query. By mistake this was done only
for the first occurrences of CTEs.
The patch fixes this problem in With_element::clone_parsed_spec().
It also moves there the call of check_dependencies_in_with_clauses()
to its proper place before the call of check_table_access().
Additionally the patch optimizes the number of calls of the
function check_dependencies_in_with_clauses().
2018-01-05 08:30:02 -08:00
Monty
5e0b13d173 Fixed wrong arguments to printf and related functions
Other things, mainly to get
create_mysqld_error_find_printf_error tool to work:

- Added protection to not include mysqld_error.h twice
- Include "unireg.h" instead of "mysqld_error.h" in server
- Added protection if ER_XX messages are already defined
- Removed wrong calls to my_error(ER_OUTOFMEMORY) as
  my_malloc() and my_alloc will do this automatically
- Added missing %s to ER_DUP_QUERY_NAME
- Removed old and wrong calls to my_strerror() when using
  MY_ERROR_ON_RENAME (wrong merge)
- Fixed deadlock error message from Galera. Before the extra
  information given to ER_LOCK_DEADLOCK was missing because
  ER_LOCK_DEADLOCK doesn't provide any extra information.

I kept #ifdef mysqld_error_find_printf_error_used in sql_acl.h
to make it easy to do this kind of check again in the future
2018-01-04 16:24:09 +02:00
Sergei Petrunia
c584a496d7 Fix out-of-date comments. 2018-01-04 14:04:52 +03:00
Marko Mäkelä
af0ba43838 Do not misspell "fall through" 2018-01-03 22:22:17 +02:00
Marko Mäkelä
fcde91114d Merge 10.1 into 10.2 2018-01-03 20:42:09 +02:00
Marko Mäkelä
1e89c86dd7 Merge 10.0 into 10.1 2018-01-03 20:41:34 +02:00
Marko Mäkelä
8ac1982fcc Merge 5.5 into 10.0 2018-01-03 20:40:41 +02:00
Marko Mäkelä
84c9c8b2e9 Silence some -Wimplicit-fallthrough by proper spelling 2018-01-03 15:01:17 +02:00
Marko Mäkelä
d361401bc2 Merge 10.1 into 10.2, with some MDEV-14799 fixups
trx_undo_page_report_modify(): For SPATIAL INDEX, keep logging
updated off-page columns twice, so that
the minimum bounding rectangle (MBR) will be logged.
Avoiding the redundant logging would require larger changes
to the undo log format.

row_build_index_entry_low(): Handle SPATIAL_UNKNOWN more robustly,
by refusing to purge the record from the spatial index.
We can get this code when processing old undo log from 10.2.10 or
10.2.11 (the releases affected by MDEV-14799, which was a regression
from MDEV-14051).
2018-01-03 11:56:24 +02:00
Marko Mäkelä
016caa3d20 Merge 10.0 into 10.1 2018-01-02 21:57:22 +02:00
Marko Mäkelä
51e4650ed0 Merge 5.5 into 10.0 2018-01-02 21:52:46 +02:00
Monty
7e882a60bf Ensure that table->vcol_set is properly restored if used
Code in QUICK_RANGE_SELECT::init_ror_merged_scan() could theoretically
have caused crashes if this was ever called from an update or delete

This also found a bug in the vcol/range.result. file.
2018-01-01 14:44:20 +02:00
Monty
08ff39dca2 Write location of core when doing core dump 2018-01-01 14:12:18 +02:00
Monty
322c637c1c Fixed compiler warnings about possible uninitialized variables 2018-01-01 14:10:22 +02:00
Varun Gupta
a118c20c81 MDEV-10844: EXPLAIN FORMAT=JSON doesn't show order direction for filesort
Currently explain format=json does not show the order direction of fields used during filesort.
This patch would remove this limitation
2017-12-30 10:18:22 +05:30
Sergey Vojtovich
f5c479565d MDEV-11071 - Assertion `thd->transaction.stmt.is_empty()' failed in
Locked_tables_list::unlock_locked_tables

Similarly to regular DROP TABLE, don't leave locked tables mode if CREATE OR
REPLACE dropped temporary table but failed to cerate new one.

The problem is that there's no track of which temporary table was "locked" by
LOCK TABLES.
2017-12-29 11:40:23 +04:00
Vicențiu Ciorbaru
6c4cf79d94 MDEV-13683: crash in Item_window_func::update_used_tables
Window definitions are resolved during fix fields. Updating used tables
for window functions must be done after all window functions have had a
chance to be resolved.

There was an additional problem with the implementation: expressions that
contained window functions never updated the expression's used tables.
To fix both these issues, make sure to call "update_used_tables" on all
items that contain window functions after we have passed through all
items.
2017-12-28 20:04:23 +02:00
Vicențiu Ciorbaru
9aeb5d01d6 Merge remote-tracking branch 'origin/10.1' into bb-10.2-vicentiu 2017-12-28 19:27:00 +02:00
Igor Babaev
bbb8c9d773 Fixed the bug MDEV-14755 Crash when executing prepared statement
for a query that uses CTE

The first reference to a CTE in the processed query uses the unit
built by the parser for the CTE specification. This unit is
considered as the specification of the derived table created for
the first reference of the CTE. This requires some transformation of
the original query tree: the unit of the specification must be moved
to a new position as a slave of the select where the first reference
to the CTE occurs. The transformation is performed by the function
st_select_lex_node::move_as_slave(). There was an obvious bug in this
function. As a result of this bug in many cases the moved unit turned
out to be lost in the query tree. This could cause different problems.
In particular the prepared statements for queries that used CTEs could
miss cleanup for some selects that was performed at the end of the
preparation/execution of the PSs. If such cleanup is not done for a PS
the next execution of the PS causes an assertion abort or a crash.
2017-12-27 10:37:13 -08:00
Vicențiu Ciorbaru
d1c2cd30b7 Merge remote-tracking branch '10.0' into 10.1 2017-12-27 17:50:39 +02:00
Oleksandr Byelkin
462808f3b6 MDEV-10657: incorrect result returned with binary protocol (prepared statements)
If translation table present when we materialize the derived table then
change it to point to the materialized table.

Added debug info to see really what happens with what derived.
2017-12-27 16:01:37 +01:00
Alexander Barkov
02b7dc7bec MDEV-14249 Wrong character set info of Query_log_event and the query in Query_log_event constructed by different charsets cause error when slave apply the event. 2017-12-27 12:30:05 +04:00
Sergei Golubchik
5377242fff MDEV-14026 ALTER TABLE ... DELAY_KEY_WRITE=1 creates table copy for partitioned MyISAM table with DATA DIRECTORY/INDEX DIRECTORY options
set data_file_name and index_file_name in HA_CREATE_INFO
before calling check_if_incompatible_data()
2017-12-25 15:18:21 +01:00
Sergei Golubchik
6d8b1bd620 cleanup: ha_partition::update_create_info 2017-12-25 15:18:21 +01:00
Sachin Setiya
2fe6186124 MDEV-10715 Galera: Replicate MariaDB GTID to other nodes in the cluster
Problem:- Gtid are not transferred in Galera Cluster.

Solution:- We need to transfer gtid in the case on either when cluster is
slave/master in async replication. In normal Gtid replication gtid are generated on
recieving node itself and it is always on sync with other nodes. Because galera keeps
node in sync , So all nodes get same no of event groups. So the issue arises when
say galera is slave in async replication.
A
|    (Async replication)
D <-> E <-> F  {Galera replication}
So what should happen is that all node should apply the master gtid but this does
node happen, becuase node E, F does not recieve gtid from D in write set , So what E(or F)
does is that it applies wsrep_gtid_domain_id, D server-id , E gtid next seq no. This
generated gtid does not always work when say A has different domain id.

So In this commit, on galera node when we see that this event is recieved from master
we simply write Gtid_Log_Event in write_set and send it to other nodes.
2017-12-25 13:57:42 +05:30
Alexey Botchkov
f0f3b6549a MDEV-13970 crash in Item_func_json_extract::read_json.
Item_func_json_extract::val_int fixed.
        It wasn't tested yet as it's called in exotic cases only.
2017-12-25 08:10:48 +04:00
Monty
6e7ca6b0b2 MDEV-13719 Assertion `bit < (map)->n_bits' failed in bitmap_is_set
Problem was that MAX_SLAVE_ERROR didn't cover all possible errors.
2017-12-23 14:53:12 +02:00
Vicențiu Ciorbaru
985d2d393c Merge remote-tracking branch 'origin/10.1' into 10.2 2017-12-22 12:23:39 +02:00
Alexander Barkov
a76a2522ec MDEV-14426 Assertion in Diagnostics_area::set_error_status when using a bad datetime with PS and SP 2017-12-22 08:23:33 +04:00
Sergei Petrunia
9c28fd7a33 Merge branch '10.2' into bb-10.2-mariarocks 2017-12-21 23:34:49 +03:00
Vicențiu Ciorbaru
24efee9100 Follow up to MDEV-12366: FLUSH privileges can break hierarchy of roles
A suggestion to make role propagation simpler from serg@mariadb.org.

Instead of gathering the leaf roles in an array, which for very wide
graphs could potentially mean a big part of the whole roles schema, keep
the previous logic. When finally merging a role, set its counter
to something positive.

This will effectively mean that a role has been merged, thus a random pass
through roles hash that touches a previously merged role won't cause the problem
described in MDEV-12366 any more, as propagate_role_grants_action will stop
attempting to merge from that role.
2017-12-21 18:10:00 +02:00
Oleksandr Byelkin
eb14042383 MDEV-14613: Assertion `fixed == 0' failed in Item_func::fix_fields
fix_fields calls fixed.
2017-12-20 16:52:02 +01:00
Vicențiu Ciorbaru
e3d89652e5 Merge branch '10.0' into 10.1 2017-12-20 13:30:05 +02:00
Vicențiu Ciorbaru
042f763268 Merge remote-tracking branch '5.5' into 10.0 2017-12-20 12:51:57 +02:00
Varun Gupta
924db8b4ed MDEV-12350: Heap corruption, overrun buffer, ASAN errors, server crash in my_fill_8bit / filesort
In the function make_sortkey a tmp buffer was defined and in the absence of
param->tmp_buffer, tmp buffer used the sort_keys buffer. sort_keys buffer
has a length defined in sort_field->length, while param->tmp_buffer is
stored in param->rec_length. Make sure to use the appropriate length
based on which buffer we are using otherwise we'll overflow.

Also added a type cast to size_t during the calculation of the sort keys
buffer size to avoid an oveflow if the buffer size exceeds 32 bits.
2017-12-20 11:50:22 +02:00
Alexander Barkov
cb121a047b An after-fix for MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())
Fixing an additional failure discovered after a merge to 10.2
2017-12-20 13:49:27 +04:00
Alexander Barkov
c58df0cdd4 MDEV-14031 Password policy causes replication failure 2017-12-20 12:14:49 +04:00
sjaakola
64e1dda0a0 MW-416 DDL replication moved after acl checking
galera_events test shows a regression with the original fix for MW-416
Reason was that Events::drop_event() can be called also from inside event
execution, and there we have a speacial treatment for event, which executes
"DROP EVENT" statement, and runs TOI replication inside the event processing body.
This resulted in executing WSREP_TO_ISOLATION two times for such DROP EVENT statement.
Fix is to call WSREP_TO_ISOLATION_BEGIN only in Events::drop_event()
2017-12-19 19:46:33 +01:00
sjaakola
1a8da003f6 MW-416
Changed return code for replicatio error to TRUE.
This is aligned with native mysql convention to return TRUE (defined to 1) or FALSE (defined to 0) from a bool function.
This is wrong, but follows the mysql conventiosn, at least...
2017-12-19 19:46:33 +01:00
Simon J Mudd
cfa18e4ae1 MDEV-14639: Fix unexpected end of line at 'Normal shutdown' 2017-12-19 19:30:06 +04:00
Sergey Vojtovich
2cd3169113 MDEV-14265 - RPMLint warning: shared-lib-calls-exit
find_type_or_exit() client helper did exit(1) on error, exit(1) moved to
clients.

mysql_read_default_options() did exit(1) on error, error is passed through and
handled now.

my_str_malloc_default() did exit(1) on error, replaced my_str_ allocator
functions with normal my_malloc()/my_realloc()/my_free().

sql_connect.cc did many exit(1) on hash initialisation failure. Removed error
check since my_hash_init() never fails.

my_malloc() did exit(1) on error. Replaced with abort().

my_load_defaults() did exit(1) on error, replaced with return 2.

my_load_defaults() still does exit(0) when invoked with --print-defaults.
2017-12-19 19:10:54 +04:00
Marko Mäkelä
8d70097c21 Merge 10.1 to 10.2
Follow-up fix to MDEV-14008: Let Field_double::val_uint() silently
return 0 on error
2017-12-19 16:48:28 +02:00
Jan Lindström
252e690c85 Fix galera.view test case crash.
WSREP_TO_ISOLATION_BEGIN() call must be after view name is back
on tables list.
2017-12-19 16:13:35 +02:00
Vicențiu Ciorbaru
be758322e2 MDEV-12366: FLUSH PRIVILEGES can break hierarchy of roles
Whenever we call merge_role_privileges on a role, we make use of
the role->counter variable to check if all it's children have had their
privileges merged. Only if all children have had their privileges merged,
do we update the privileges on parent. This is done to prevent extra work.
The same idea is employed during flush privileges. You only begin merging
from "leaf" roles. The recursive calls will merge their parents at some point.
A problem arises when we try to "re-merge" a parent. Take the following graph:

{noformat}
     A (0)  ----  C (2) ---- D (2)  ---- USER
                 /          /
     B (0)  ----/          /
                          /
     E (0) --------------/
{noformat}

In parentheses we have the "counter" value right before we start to iterate
through the roles hash and propagate values. It represents the number of roles
granted to the current role. The order in which we iterate through the roles
hash is alphabetical.

* First merge A, which leads to decreasing the counter for C to 1. Since C is
not 0, we don't proceed with merging into C.

* Second we merge B, which leads to decreasing the counter for C to 0. Now
we proceed with merging into C. This leads to reducing the counter for D to 1
as part of C merge process.

* Third as we iterate through the hash, we see that C has counter 0, thus we
start the merge process *again*. This leads to reducing the counter for
D to 0! We then attempt to merge D.

* Fourth we start merging E. When E sees D as it's parent (according to the code)
it attempts to reduce D's counter, which leads to overflow. Now D's counter is
a very large number, thus E's privileges are not forwarded to D yet.

To correct this behavior we must make sure to only start merging from initial
leaf nodes.
2017-12-19 12:33:25 +02:00
Vicențiu Ciorbaru
2fced9e7b6 MDEV-13655: Set role does not properly grant privileges.
When granting a role to another role, DB privileges get propagated. If
the grantee had no previous DB privileges, an extra ACL_DB entry is created to
house those "indirectly received" privileges. If, afterwards, DB
privileges are granted to the grantee directly, we must make sure to not
create a duplicate ACL_DB entry.
2017-12-19 12:33:25 +02:00
Galina Shalygina
079c359971 MDEV-14629: failing assertion when a user-defined variable is defined by the recursive CTE
During the user-defined variable defined by the recursive CTE handling procedure
check_dependencies_in_with_clauses that checks dependencies between the tables
that are defined in the CTE and find recursive definitions wasn't called.
2017-12-19 11:49:40 +02:00
Marko Mäkelä
09c5bbf471 Merge 10.0 into 10.1 2017-12-18 20:05:50 +02:00
Nirbhay Choubey
682c3bfd25 MDEV-10442: "Address already in use" on restart
SST processes should inherit mysqld's process group.
2017-12-18 16:57:54 +01:00