Commit graph

66124 commits

Author SHA1 Message Date
Vicențiu Ciorbaru
effbd52b8c MDEV-10879: Window Functions final ordering of result set
Window functions now force an ordering to the result set if none is
specified through order by. The ordering that will be returned is the final ordering
that is used during window function computation. For multiple window functions,
it should generally be the most specific sort ordering for the final
window function in the select list.
2017-07-05 17:18:01 +03:00
Vicențiu Ciorbaru
4f93c732d5 MDEV-13189: Window functions crash when using INTERVAL
Interval function makes use of Item_row. Item_row did not correctly mark
with_window_func flag according to its arguments. Fix it by making
Item_row aware of this flag.
2017-07-05 15:40:25 +03:00
Lixun Peng
007d3ed905 MDEV-12067 flashback does not correcly revert update/replace statements
Problem
-------
For one-statement contains multiple row events, Flashback didn't reverse the
sequence of row events inside one-statement.

Solution
--------
Using a new array 'events_in_stmt' to store the row events of one-statement,
when parsed the last one event, then print from the last one to the first one.

In the same time, fixed another bug, without -vv will not insert the table_map
into print_event_info->m_table_map, then change_to_flashback_event() will not
execute because of Table_map_log_event is empty.
2017-07-03 14:48:07 +08:00
Monty
92f1837a27 Fixed compilation warnings (while testing 32 bit builds) 2017-07-01 14:26:42 +03:00
Monty
2e9b55f763 MDEV-13226 Server crashes when tmpdir runs out of space
There was a missing test in CTE handling if creating a temporary table
failed (in this case as a result of out of space). This caused a table
handler to be used even if it was not allocated.
2017-07-01 14:26:42 +03:00
Monty
dd8474b1dc Added tmp_disk_table_size to limit size of Aria temp tables in tmpdir
- Added variable tmp_disk_table_size
- Added variable tmp_memory_table_size as an alias for tmp_table_size
- Changed internal variable tmp_table_size to tmp_memory_table_size
- create_info.data_file_length is now set with tmp_disk_table_size
- Fixed that Aria doesn't reset max_data_file_length for internal tables
- Added status flag if table is full so that we can detect this on next insert.
  This ensures that the table is always 'correct', but we get the error one
  row after the row that grow the table too big.
- Removed some mutex lock for internal temporary tables
2017-06-30 22:31:37 +03:00
Monty
9f484b63f1 Clean up replication check in open_temporary_table() 2017-06-30 22:31:37 +03:00
Igor Babaev
9f0c1c0cf6 Fixed the bug mdev-13193.
When an equality that can be pushed into a materialized derived
table / view is extracted from multiple equalities and their
operands are cloned then if they have some pointers to Item_equal
objects those pointers must be set to NULL in the clones. Anyway
they are not valid in the pushed predicates.
2017-06-29 20:50:26 -07:00
Igor Babaev
13221b1eb2 Fixed a failure of the test case for the bug mdev-13107 in --ps-protocol.
The fix was in the call the open_normal_and_derived_tables() from
the function mysql_test_select() and it was similar to those from
the patch for mdev-13107.

Added explicit PREPARE statements that failed in --ps-protocol.
2017-06-28 22:40:27 -07:00
Igor Babaev
e608023947 Fixed the bug mdev-13107 and some similar unreported bugs.
The problems were in the code of sql_show.cc. There the tables
could be opened in such a way that mysql_derived_init() never
worked for CTE tables. As a result they were not marked as
derived and mysql_handle_derived() were not called for derived
tables used in their specifications.
2017-06-28 11:39:33 -07:00
Vicențiu Ciorbaru
31ba0fa48d MDEV-12851: Case with window functions query crashes server
The "is null" function performs one operation which no other Item_func
does, which is to update used tables during fix_length_and_dec().

This however can not be performed before window functions have had a
chance to resolve their order by and partition by definitions, which
happens after the initial setup_fields call. Consequently, do not call
Item_func_isnull update_used_tables during fix_length_and_dec().

There was another issue detected once the crash was resolved.
Because window functions did not implement is_null() method, we would
end up returning bad results for "is null" and "is not null" functions.
Implemented is_null() method for Item_windowfunc.
2017-06-28 19:21:31 +03:00
Vicențiu Ciorbaru
23edc7c88f MDEV-13186: main.win failure post MDEV-12336
During statement preparation st_order::item gets set to a value in
ref_ptr_array. During statement execution we were overriding that value,
causing subsequent checks for window functions to return true.

Whenever we do any setting from ref_ptr_array, make sure to always
store the value in all_fields as well.

For function items containing window functions, as MDEV-12336 has
discovered, we don't need to create a separate Item_direct_ref or
Item_aggregate_ref as they will be computed directly from the top-level
item once the window function argument columns are computed.
2017-06-28 15:23:36 +03:00
Vicențiu Ciorbaru
9003869390 Simplify IO_CACHE by removing current_pos and end_pos as self-references
These self references were previously used to avoid having to check the
IO_CACHE's type. However, a benchmark shows that on x86 5930k stock,
the type comparison is marginally faster than the double pointer dereference.
For 40 billion my_b_tell calls, the difference is .1 seconds in favor of performing the
type check. (Basically there is no measurable difference)

To prevent bugs from copying the structure using the equals(=) operator,
and having to do the bookkeeping manually, remove these "convenience"
variables.
2017-06-28 15:23:36 +03:00
Igor Babaev
02655a91cf Fixed the bug mdev-13166.
This patch corrects the fix for mdev-12845.
2017-06-26 12:16:04 -07:00
Sergey Vojtovich
6d0aed42c5 MDEV-12070 - Introduce thd_query_safe() from MySQL 5.7
Merged relevant part of MySQL revision:
565d20b44f
2017-06-26 16:11:22 +04:00
Sergey Vojtovich
dd710e7552 MDEV-12882 - Assertion failed in MDL_context::upgrade_shared_lock
Relaxed assertion (in MySQL it was removed).
For "LOCK TABLES t1 WRITE CONCURRENT, t1 READ" upgrade lock to weakest
existing suitable lock, which is MDL_SHARED_NO_READ_WRITE.
2017-06-26 16:11:22 +04:00
Igor Babaev
9f3622191d Fixed the bug mdev-12845.
This patch fills in a serious flaw in the
code that supports condition pushdown into
materialized views / derived tables.

If a predicate happened to contain a reference
to a mergeable view / derived table and it does
not depended directly on the target materialized
view / derived table then the predicate was not
considered as a subject to pusdown to this view
/ derived table.
2017-06-22 22:06:03 -07:00
Oleksandr Byelkin
064d1a480c MDEV-12579: Incorrect arguments to mysqld_stmt_execute when using LOBs
Parameters can be MYSQL_TYPE_VARCHAR for long data load.
2017-06-22 15:28:57 +02:00
Vicențiu Ciorbaru
0992be927e MDEV-13068 Crash in Item::split_sum_func2 with INSERT SELECT using window functions
When running setup fields during the final step of insert using select
the final setup_fields does not have any sum functions. Our current
condition for calling split_sum_func however would attempt to use an empty
NULL sum_func_list, if the item contained a window function.

The solution is to not perform another split_sum_func for the item
containing a window function if we do not actually have a sum_func_list.
2017-06-20 13:38:35 +03:00
Marko Mäkelä
c73fa2d75f Merge 10.1 into 10.2
This will also change the minimum and maximum value of
innodb_log_file_size to 1MiB and 512GiB, respectively.
2017-06-19 16:46:34 +03:00
Igor Babaev
cf4a6abea1 Fixed the bug mdev-13064.
This is another attempt to fix the bug mdev-12992.
This patch introduces st_select_lex::context_analysis_place for
the place in SELECT where context analysis is currently performed.
It's similar to st_select_lex::parsing_place, but it is used at
the preparation stage.
2017-06-16 09:50:57 -07:00
Sergey Vojtovich
056bab0880 MDEV-12620 - set lock_wait_timeout = 1;flush tables with read lock;
lock not released after timeout

Release GRL if FLUSH TABLES phase failed.
2017-06-16 15:47:46 +04:00
Marko Mäkelä
e5980bf1b1 Remove the unnecessary method handlerton::release_temporary_latches()
The sole purpose of handlerton::release_temporary_latches and its wrapper
function was to release the InnoDB adaptive hash index latch
(btr_search_latch).

When the btr_search_latch was split into an array of latches
in MySQL 5.7.8 as part of the Oracle Bug#20985298 fix, the "caching"
of the latch across storage engine API calls was removed. As part of that,
the function trx_search_latch_release_if_reserved() was changed to an
assertion and the function trx_reserve_search_latch_if_not_reserved()
was removed, and handlerton::release_temporary_latches() practically
became a no-op.

Note: MDEV-12121 replaced the function
trx_search_latch_release_if_reserved()
with the more appropriately named macro trx_assert_no_search_latch().
2017-06-16 12:37:00 +03:00
Oleksandr Byelkin
91ae1258ee MDEV-12471: BULK Command
BULK execution moved to a new command.
2017-06-14 12:02:54 +02:00
Igor Babaev
7a12894de1 Fixed the bug mdev12992.
When the SELECT query from a trigger that used a subquery
in its SELECT list was prepared the counter select_n_having_items
was incremented in the constructor Item::Item(THD *thd).
As a result each invocation of the trigger required more and more
memory for the ref_pointer_array for this SELECT.
Made sure that the counter st_select_lex::select_n_having_items
would be incremented only at the first execution of such trigger.
2017-06-10 16:39:39 -07:00
Marko Mäkelä
2d8fdfbde5 Merge 10.1 into 10.2
Replace have_innodb_zip.inc with innodb_page_size_small.inc.
2017-06-08 12:45:08 +03:00
Marko Mäkelä
30df297c2f Merge 10.0 into 10.1
Rewrite the test encryption.innodb-checksum-algorithm not to
require any restarts or re-bootstrapping, and to cover all
innodb_page_size combinations.

Test innodb.101_compatibility with all innodb_page_size combinations.
2017-06-06 10:59:54 +03:00
Sachin Setiya
da61107fc8 MDEV-9544 FLUSH [RELAY] LOGS does not rotate logs for a named slave
Problem:- In the case of multisource replication/named slave
when we run "FLUSH LOGS" , it does not flush logs.

Solution:- A new function Master_info_index->flush_all_relay_logs()
is created which will rotate relay logs for all named slave.
This will be called in reload_acl_and_cache function when
connection_name.length == 0
2017-06-05 13:11:10 +05:30
Sergei Golubchik
5e0038b376 cleanup: remove Regexp_processor_pcre::m_subpatterns_needed
it's unused now.
2017-05-29 21:07:54 +02:00
Sergei Golubchik
2372bfaa7b MDEV-12942 REGEXP_INSTR returns 1 when using brackets
always use full m_SubStrVec length in pcre_exec, we don't know
how many subexpressions user's regexp will have
2017-05-29 21:07:54 +02:00
Marko Mäkelä
c2ef0bb6ce Merge 5.5 into 10.0 2017-05-29 13:15:36 +03:00
Igor Babaev
af4421e82d Fixed the bug mdev-12931.
This corrects the patch for mdev-10006.
The current code supports only those semi-join nests that are placed at
the join top level. So such nests cannot depend on other tables or nests.
2017-05-29 00:27:14 -07:00
Varun Gupta
e4d10e09cf MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff'
was corrupted, server crashes in opt_sum_query

Extended keys feature disabled if the length of extended key is longer than MAX_KEY_LEN
2017-05-28 00:40:36 +05:30
Marko Mäkelä
8c81f24d1b Merge 10.1 into 10.2 2017-05-26 22:45:46 +03:00
Sergei Golubchik
f42e08f951 Merge branch '10.0-galera' into 10.1 2017-05-26 19:21:19 +02:00
Marko Mäkelä
4abc2dd0c7 Merge 10.0 to 10.1 2017-05-26 15:11:23 +03:00
Sergei Golubchik
b430133bb9 MDEV-12844 numerous issues in MASTER_GTID_WAIT() 2017-05-24 11:59:05 +02:00
Sergei Golubchik
ae76ff4524 compiler warning on Win64
cast pointer(64)->long(32)
2017-05-24 11:59:04 +02:00
Sergei Golubchik
7e0c8fc3fb MDEV-12389 ADD CHECK leaves an orphaned .par file 2017-05-24 11:59:04 +02:00
Oleksandr Byelkin
b8405c853f MDEV-11958: LEFT JOIN with stored routine produces incorrect result
Added forgoten method of Item_func_sp to make it correctly work with LEFT/RIGHT JOIN.
Fixed inconsistency with the null table caches.
2017-05-23 11:06:31 +02:00
Vladislav Vaintroub
70630e3c92 Workaround dependency problems (constant rebuilds) in Visual Studio generator 2017-05-23 09:01:36 +00:00
Marko Mäkelä
8f643e2063 Merge 10.1 into 10.2 2017-05-23 11:09:47 +03:00
Marko Mäkelä
b61700c221 Merge 10.0 into 10.1 2017-05-23 08:59:03 +03:00
Marko Mäkelä
70505dd45b Merge 10.1 into 10.2 2017-05-22 09:46:51 +03:00
Marko Mäkelä
65e1399e64 Merge 10.0 into 10.1
Significantly reduce the amount of InnoDB, XtraDB and Mariabackup
code changes by defining pfs_os_file_t as something that is
transparently compatible with os_file_t.
2017-05-20 08:41:20 +03:00
Sergei Golubchik
725e47bfb5 Merge branch '5.5' into 10.0 2017-05-20 00:59:40 +02:00
Sergei Golubchik
7c03edf2fe MDEV-6262 analyze the coverity report on mariadb
uploaded 10.0, analyzed everything with the Impact=High
(and a couple of Medium)
2017-05-19 20:26:56 +02:00
Marko Mäkelä
13a350ac29 Merge 10.0 into 10.1 2017-05-19 12:29:37 +03:00
Igor Babaev
5e9d651108 Fixed the bug mdev-12788.
In some rare cases queries with UNION ALL
using a derived table specified by
a grouping select with a subquery in WHERE and
impossible HAVING detected after constant row
substitution could hang.
The cause was not a proper return from the
function subselect_single_select_engine::exec()
in the case when the subquery was not optimized
beforehand and the optimization performed
in this function requested for a change of the
subquery engine. This was fixed.
Also a change was applied that avoided execution
of a subquery if impossible having was detected
for the main query at the optimization stage.
2017-05-18 23:56:49 -07:00
Vicențiu Ciorbaru
45898c2092 Merge remote-tracking branch 'origin/10.0' into 10.0 2017-05-18 15:45:55 +03:00