Commit graph

45470 commits

Author SHA1 Message Date
Sergei Petrunia
e292ea8751 Make the testcase deterministic 2016-04-08 12:02:43 +02:00
Sergei Petrunia
cb002d3479 Window functions: make "ORDER BY window_func" work
- When window functions are present, JOIN::simple_order should be set
  to FALSE. (Otherwise, the optimizer may attempt to do a "pre-sorting"
  on the first join_tab. Which can work in some cases, but generally
  isn't)

- filesort tries to only read table fields that it requires. Window
  function requires its temp.table field.  In order to pass this info
  to filesort, added an implementation of Item_window_func::
  register_field_in_read_map.
2016-04-08 03:21:25 +03:00
Sergei Petrunia
59e5f5b47e Merge branch '10.2' into bb-10.2-mdev9543
- Make Window Functions errors use the MariaDB's extra error range.
- Fix a trivial bug in check_error_mesg
2016-04-07 00:54:39 +03:00
Sergei Petrunia
306de8a927 MDEV-9877: Window functions: wrong sort criteria is used
" The sort order for the sub-sequence of window functions starting
from the element marked by SORTORDER_CHANGE_FLAG up to the next
element marked by SORTORDER_CHANGE_FLAG must be taken from the
last element of the sub-sequence (not from the first one)."
2016-04-06 23:02:31 +03:00
Sergei Petrunia
2efabf81f1 MDEV-9847: Window functions: crash with big_tables=1
- Move filesort's sort_positions argument into class Filesort.
- Make window function code construct Filesort with sort_positions=true.
2016-04-06 20:34:23 +03:00
Alexander Barkov
00917fae7e MDEV-9874 LOAD XML INFILE does not handle well broken multi-byte characters
- Moving the new my_charlen()-based code handling multi-byte characters
  from READ_INFO::field_field() to a new method READ_INFO::read_mbtail()
- Reusing read_mbtail() in READ_INFO::read_value(), instead of the old
  my_mbcharlen()-based code which did not catch broken byte sequences
2016-04-06 10:31:38 +04:00
Alexander Barkov
d516a2ae0c MDEV-9823 LOAD DATA INFILE silently truncates incomplete byte sequences 2016-04-06 09:13:49 +04:00
Sergei Petrunia
9bd194b1b7 MDEV-9848: Window functions: reuse sorting and/or scanning
- Rename Window_funcs_computation to Window_funcs_computation_step
- Introduce Window_func_sort which invokes filesort and then
  invokes computation of all window functions that use this ordering.
- Expose Window functions' sort operations in EXPLAIN|ANALYZE FORMAT=JSON
2016-04-05 19:10:44 +03:00
Vicențiu Ciorbaru
960b221c0b Convert ntile to work with expressions as parameters. 2016-04-04 22:04:18 +03:00
Vicențiu Ciorbaru
be3902fceb Implement ntile window function.
The current implementation does not allow for a dynamic expression
within the sum function's parameter.
2016-04-04 22:04:18 +03:00
Alexander Barkov
e975cd0ba9 MDEV-9842 LOAD DATA INFILE does not work well with a TEXT column when using sjis 2016-04-02 00:18:58 +04:00
Igor Babaev
2e4bd4407e The implementation of the template bubble_sort assumed
that the call-back comparison function returns a positive
number when arg1 < arg2, and a negative number when arg1 > arg2.
This is not in line with other implementation of sorting
algorithm.
Changed bubble_sort: now a negative result from the comparison
function means that arg1 < arg2, and positive result means
that arg1 > arg2.
Changed accordingly all call-back functions that are used as
parameters in the call of bubble_sort.

Added a test case to check the proper sorting of window functions.
2016-04-01 12:00:54 -07:00
Alexander Barkov
3fc6a8b832 MDEV-9811 LOAD DATA INFILE does not work well with gbk in some cases
MDEV-9824 LOAD DATA does not work with multi-byte strings in LINES TERMINATED BY when IGNORE is specified
2016-03-31 14:22:25 +04:00
Alexander Barkov
1d73005bf3 MDEV-8360 Clean-up CHARSET_INFO: strnncollsp: diff_if_only_endspace_difference
- Removing the "diff_if_only_endspace_difference" argument from
  MY_COLLATION_HANDLER::strnncollsp(), my_strnncollsp_simple(),
  as well as in the function template MY_FUNCTION_NAME(strnncollsp)
  in strcoll.ic

- Removing the "diff_if_only_space_different" from ha_compare_text(),
  hp_rec_key_cmp().

- Adding a new function my_strnncollsp_padspace_bin() and reusing
  it instead of duplicate code pieces in my_strnncollsp_8bit_bin(),
  my_strnncollsp_latin1_de(), my_strnncollsp_tis620(),
  my_strnncollsp_utf8_cs().

- Adding more tests for better coverage of the trailing space handling.

- Removing the unused definition of HA_END_SPACE_ARE_EQUAL
2016-03-31 11:04:48 +04:00
Sergey Vojtovich
282497dd6d MDEV-6720 - enable connection log in mysqltest by default 2016-03-31 10:11:16 +04:00
Sergei Petrunia
2078392cc9 Make EXPLAIN FORMAT=JSON be able to show the key that's used for sorting.
This will be useful for window functions development.
2016-03-30 18:39:10 +03:00
Vicențiu Ciorbaru
de35787a83 Merge branch 'cume_dist' into bb-10.2-mdev9543 2016-03-28 22:52:18 +03:00
Vicențiu Ciorbaru
3544fe0144 Implemented cume_dist function.
Also fixed a bug in row_counts detection, when partition changes.
2016-03-28 22:51:42 +03:00
Sergei Petrunia
4fe6fbbb63 Merge branch 'bb-10.2-mdev9543' of github.com:MariaDB/server into bb-10.2-mdev9543 2016-03-28 22:19:55 +03:00
Sergei Petrunia
2bd4dc38e0 Merge branch '10.2' into bb-10.2-mdev9543 2016-03-28 22:18:38 +03:00
Sergei Petrunia
d146c2cedc MDEV-9787: Window functions: HAVING and GROUP BY
- Hook window function computation into the right location.
- Add a testcase which shows that HAVING is now checked before
  the window function computation step.
2016-03-28 20:53:09 +03:00
Sergei Petrunia
e88758330c Make window functions computation step show up in EXPLAIN FORMAT=JSON output 2016-03-28 18:38:42 +03:00
Sergei Petrunia
44fdb56c97 MDEV-8646: Re-engineer the code for post-join operations
- Make EXPLAIN code use the post-join operations
- Remove Sort_and_group_tracker that was used for that purpose
2016-03-28 12:02:56 +03:00
Sergei Golubchik
02839ef249 more result updates 2016-03-24 09:35:14 +01:00
Igor Babaev
82cb35be11 Changed the base class for Item_window_func from Item_result_field to
Item_func_or_sum.
Implemented method update_used_tables for class Item_findow_func.
Added the flag Item::with_window_func.
Made sure that window functions could be used only in SELECT list
and ORDER BY clause.
Added test cases that checked different illegal placements of
window functions.
2016-03-23 16:09:58 -07:00
Sergei Golubchik
f67a2211ec Merge branch '10.1' into 10.2 2016-03-23 22:36:46 +01:00
Monty
06b4556452 Fixed failures from changing values of thread_stack and thread_cache_size
Added --thread_cache_size=0 to some tests that was depending on not having
a thread cache.
2016-03-23 15:11:30 +02:00
Alexander Barkov
e4435b5ec3 MDEV-9604 crash in Item::save_in_field with empty enum value
1. Fixing Field_time::get_equal_const_item() to pass TIME_FUZZY_DATES
   and TIME_INVALID_DATES to get_time_with_conversion().
   This is needed to make the recursively called Item::get_date() return
   non-NULL values on garbage input. This makes Field_time::get_equal_const_item()
   work consistently with how Item::val_time_packed() works.

2. Fixing Item::get_date() to return TIME'00:00:00' rather than
   DATE'0000-00-00' on empty or garbage input when:
   - TIME_FUZZY_DATES is enabled
   - The caller requested a TIME value (by passing TIME_TIME_ONLY).
   This is needed to avoid conversion of DATE'0000-00-00' to TIME
   in get_time_with_conversion(), which would erroneously try to subtract
   CURRENT_DATE from DATE'0000-00-00' and return TIME'-838:59:59' rather than
   the desired zero value TIME'00:00:00'.

   #1 and #2 fix these type of scripts to return one row with both
   MyISAM and InnoDB, with and without an index on t1.b:

     CREATE TABLE t1 (a ENUM('a'), b TIME, c INT, KEY(b));
     INSERT INTO t1 VALUES ('','00:00:00',0);
     SELECT * FROM t1 WHERE b='';
     SELECT * FROM t1 WHERE a=b;
     SELECT * FROM t1 IGNORE INDEX(b) WHERE b='';
     SELECT * FROM t1 IGNORE INDEX(b) WHERE a=b;

   Additionally, #1 and #2 fix the originally reported in MDEV-9604 crash
   in Item::save_in_field(), because now execution goes through a different
   path, so save_in_field() is called for a Item_time_literal instance
   (which is non-NULL) rather than a Item_cache_str instance (which could
   return NULL without setting null_value).

3. Fixing Field_temporal::get_equal_const_item_datetime() to enable
   equal field propagation for DATETIME and TIMESTAMP in case of
   comparison (e.g. when ANY_SUBST), for symmetry with
   Field_newdate::get_equal_const_item(). This fixes a number of problems
   with empty set returned on comparison to empty/garbage input.
   Now all SELECT queries in this script return one row for MyISAM and InnoDB,
   with and without an index on t1.b:

     CREATE TABLE t1 (a ENUM('a'), b DATETIME, c INT, KEY(b));
     INSERT INTO t1 VALUES ('','0000-00-00 00:00:00',0);
     SELECT * FROM t1 WHERE b='';
     SELECT * FROM t1 WHERE a=b;
     SELECT * FROM t1 IGNORE INDEX(b) WHERE b='';
     SELECT * FROM t1 IGNORE INDEX(b) WHERE a=b;
2016-03-23 08:26:40 +04:00
Monty
fa3edbf40d Increase value of thread_cache_size to 32
Added 5 minute timeout before automaticlally removing threads from thread
cache.

This solves a problem with jemalloc, which is slow with a small
thread cache and also makes thread_cache big enough that most users
doesn't have to touch it
2016-03-22 23:44:52 +02:00
Alexey Botchkov
0a4a78ae8c MDEV-6058 MySQL Bug #11766693: LOG-SLOW-ADMIN-STATEMENTS AND
LOG-SLOW-SLAVE-STATEMENTS NOT DISPLAYED.

        These parameters were moved from the command line options to
        the system variables section. Treatment of the
        opt_log_slow_slave_statements changed to let the
        dynamic change of the variable.
2016-03-22 23:26:39 +04:00
Sergei Golubchik
fd6c588659 Merge branch 'bb-10.1-serg' into 10.1 2016-03-22 19:18:48 +01:00
Igor Babaev
1fc2c63fb1 Manual merge of branch 'bb-10.2-mdev8789' into 10.2 2016-03-21 11:46:03 -07:00
Sergei Golubchik
3b0c7ac1f9 Merge branch '10.0' into 10.1 2016-03-21 13:02:53 +01:00
Sergei Golubchik
98ea806207 Merge branch '5.5' into 10.0 2016-03-21 11:54:45 +01:00
Oleksandr Byelkin
e8af217e16 MDEV-9590: Always print "Engine-independent statistic" warnings and might be filtering columns unintentionally from engines
Do not issue the warning in case we are not going to collect the statistics.
2016-03-21 11:48:04 +01:00
Sergei Golubchik
b9e571882b MDEV-9679 main.delayed fails sporadically
update main.delayed test after 38b89a61
ALTER TABLE ... COMMENT is no longer blocking,
use a different ALTER TABLE variant.
2016-03-21 11:43:19 +01:00
Alexander Barkov
9476854211 MDEV-9369 IN operator with ( num, NULL ) gives inconsistent result
Based on this commit into MySQL-5.7:
> commit 8e51b845aafc8b4cdebd763c8aebda262ac2d4cd
> Author: Guilhem Bichot <guilhem.bichot@oracle.com>
> Date:   Mon Nov 4 15:44:55 2013 +0100
>
>    Bug#13944462 'NULL IN (XX)' RETURNS WRONG RESULTS
2016-03-21 11:21:44 +04:00
Sergei Golubchik
23903255d8 MDEV-9629 Disappearing PRI from Key column after creating a trigger
when creating shadow nullable fields, preserve all
original field flags (because we swap flags
back and forth in not_null_fields_have_null_values())
2016-03-19 19:40:33 +01:00
Oleksandr Byelkin
4fdac6c07e MDEV-9701: CREATE VIEW with GROUP BY or ORDER BY and constant produces invalid definition
Fixed printing integer constant in the ORDER clause (MySQL solution)
Removed workaround for double resolving counter in the ORDER.
2016-03-18 19:22:13 +01:00
Igor Babaev
a74e8d36dd For some window functions an order list must be present. 2016-03-18 10:52:02 -07:00
Oleksandr Byelkin
2f7b6c5751 MDEV-9058: protocol: COM_MULTI command (part 3)
Support of "previuousely used statement ID".
All IDs with highest bit ON reserved for special use.
2016-03-18 18:25:37 +01:00
Alexander Barkov
b25373beb5 MDEV-9653 Assertion `length || !scale' failed in uint my_decimal_length_to_precision(uint, uint, bool)
MDEV-9752 Wrong data type for COALEASCE(?,1) in prepared statements
2016-03-18 17:50:18 +04:00
Sergei Petrunia
13f9535f2d MDEV-9724: Window functions: Frame Exclusion support
Produce a "not supported" error if one attempts to exclude rows
2016-03-18 11:32:38 +03:00
Igor Babaev
a197c6bb68 Prohibit using window functions of some types with
window frames in full accordance with the SQL standard.
2016-03-18 00:33:53 -07:00
Elena Stepanova
96a7e74ed3 Extra space in the result file 2016-03-18 00:28:18 +02:00
Igor Babaev
84c3a20ff9 Fixed bug mdev-9754.
Each window name has to be resolved only once.
2016-03-17 14:13:38 -07:00
Sergei Petrunia
6533bd1b74 Window functions + ORDER BY : first testcase 2016-03-17 21:51:00 +03:00
Sergei Petrunia
ee9297f656 MDEV-9740: Window functions: catch invalid window frame specs
Catch errors in window frame definitions
2016-03-17 16:55:44 +03:00
Igor Babaev
c3ab9712b0 Fixed the bug mdev-9719 concerning execution of prepared statements
with window functions. Added the test case for it.
Also allowed to use aliases for set functions in partition and order lists
that are specified in window functions.
2016-03-16 23:35:28 -07:00
Alexander Barkov
9b53d84d14 MDEV-9656 Assertion `0' failed in Item_sum_field::get_tmp_table_field().
Removing a wrong ASSERT. Item_sum_field now uses the inherited
Item::get_tmp_table_field().
2016-03-16 13:43:06 +04:00