Commit graph

14 commits

Author SHA1 Message Date
Varun Gupta
caa474f8e3 MDEV-15180: server crashed with NTH_VALUE()
fix_fields for the arguments of the NTH_VALUE function was updating the same reference,
so for the second argument (or after the first argument) the items were not resolved
to their corresponding field from the view as they were updating the reference to the
first argument.
2020-08-06 18:01:00 +05:30
Varun Gupta
a6410deba9 MDEV-18916: crash in Window_spec::print_partition() with decimals
Removed an unnecessary ifndef which was printing the window name for a named
window only in the case of debug build. The print() for the window function
should behave in the same way on both release and debug builds.
2020-07-27 13:53:33 +05:30
Varun Gupta
4a2e7b5368 MDEV-22984: Throw an error when arguments to window functions are window functions
Window function is not allowed as arguments to window functions according to the standard.
2020-06-30 18:16:01 +05:30
Oleksandr Byelkin
6b8802e8dd MDEV-11071: Assertion `thd->transaction.stmt.is_empty()' failed in Locked_tables_list::unlock_locked_table
fix_length_and_dec now return result (error/OK)
2018-06-15 10:31:30 +02:00
Alexander Barkov
2412c15191 MDEV-15870 Using aggregate and window function in unexpected places can crash the server 2018-06-13 11:56:56 +04:00
Sergei Golubchik
2eb00d1eba fix Item_window_func::print() not to crash before fix_fields()
because dbug_print_item() can be invoked any time in gdb,
also before fix_fields.

this fixes a crash of main.win in debug builds
2018-02-06 14:51:31 +01: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
Vicențiu Ciorbaru
57341852b5 MDEV-11746: Wrong result upon using FIRST_VALUE with a window frame
Reimplement FIRST_VALUE to act as NTH_VALUE with 0 offset. The previous
implementation was flawed when the window frame would remove values.
2017-02-14 07:46:58 +02:00
Igor Babaev
78b5e8d6ca Fixed bug mdev-11745.
Due to this bug many queries that contained a window function
with MIN/MAX aggregation returned wrong results.

Calculation of a MIN/MAX aggregate function uses cache objects
and a comparator object that are created and set up in
Item_sum_hybrid::fix_fields () by a call of Item_sum_hybrid::setup_hybrid().
The latter binds the objects to the first argument of the
MIN/MAX function. Meanwhile window function perform aggregation
over fields of a temporary table. So binding must be done rather to
these fields. The earliest moment when setup the objects used in
MIN/max functions can be done is after all calls of the method
split_sum_func().

This patch introduces this late setup, but only for aggregate
functions used in window functions.
Probably it makes sense to use this late setup for all MIN/MAX
objects.
2017-02-09 19:34:01 -08:00
Igor Babaev
903f34c7a9 Fixed bug mdev-10868.
There was no implementation of the virtual method print()
for the Item_window_func class. As a result for a view
containing window function an invalid view definition could
be written in the frm file. When a query that refers to
this view was executed a syntax error was reported.
2016-09-30 17:40:40 -07:00
Vicențiu Ciorbaru
53cf265b3b Implement LEAD and LAG and NTH_VALUE functions
Refactour out (into a copy for now) the logic of Item_sum_hybrid, to
allow for multiple arguments. It does not contain the comparator
members. The result is the class Item_sum_hybrid_simple.

LEAD and LAG make use of this Item to store previous rows in a chache.
It also helps in specifying the field type. Currently LEAD/LAG do not
support default values.

NTH_VALUE behaves identical to LEAD and LAG, except that the starting
position cursor is placed on the top of the frame instead of the current
row.
2016-09-24 15:12:34 +02:00
Vicențiu Ciorbaru
9a5930bcdf Implement first_value and last_value as window functions
Currently the implementation doesn't support removal, thus the
computation is performed by running over the window frame again.
2016-09-24 15:12:34 +02:00
Vicențiu Ciorbaru
23e8b508a0 MDEV-10059: Compute window functions with same sorting criteria simultaneously
Perform only one table scan for each window function present. We do this
by keeping keeping cursors for each window function frame bound and
running them for each function for every row.
2016-09-09 18:32:35 +03:00
Galina Shalygina
be1d06c8a5 Merge branch '10.2' into 10.2-mdev9864 2016-05-08 23:04:41 +03:00