summaryrefslogtreecommitdiff
path: root/sql/item_windowfunc.cc
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-23479: Add a THD* argument to Item_func_or_sum::fix_length_and_dec()Rucha Deodhar2022-03-301-3/+3
| | | | | Fix: Added THD *thd argument in Item_func_or_sum::fix_length_and_dec() and in fix_length_and_dec() for all derived classes of Item_func_or_sum.
* Merge branch '10.5 into 10.6mariadb-10.6.7Sergei Golubchik2022-02-101-0/+2
|\
| * Merge branch '10.4' into 10.5mariadb-10.5.15Sergei Golubchik2022-02-101-0/+2
| |\
| | * Merge branch '10.3' into 10.4mariadb-10.4.24Sergei Golubchik2022-02-101-0/+2
| | |\
| | | * Merge branch '10.2' into 10.3mariadb-10.3.34Sergei Golubchik2022-02-101-0/+2
| | | |\
| | | | * MDEV-17785: Window functions not working in ONLY_FULL_GROUP_BY modeSergei Petrunia2022-02-071-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Backport Varun Gupta's patch + edit the commit comment) Name resolution code produced errors for valid queries with window functions (but not for queries which used aggregate functions as window functions). Name resolution code worked incorrectly, because window function objects had is_window_func_sum_expr()=false. This was so, because mark_as_window_func_sum_expr() was only called for aggregate functions used as window functions. The fix is to call it for any window function.
| | | | * MDEV-15180: server crashed with NTH_VALUE()Varun Gupta2020-08-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | Reduce usage of strlen()Monty2021-05-191-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes: - To detect automatic strlen() I removed the methods in String that uses 'const char *' without a length: - String::append(const char*) - Binary_string(const char *str) - String(const char *str, CHARSET_INFO *cs) - append_for_single_quote(const char *) All usage of append(const char*) is changed to either use String::append(char), String::append(const char*, size_t length) or String::append(LEX_CSTRING) - Added STRING_WITH_LEN() around constant string arguments to String::append() - Added overflow argument to escape_string_for_mysql() and escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow. This was needed as most usage of the above functions never tested the result for -1 and would have given wrong results or crashes in case of overflows. - Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING. Changed all Item_func::func_name()'s to func_name_cstring()'s. The old Item_func_or_sum::func_name() is now an inline function that returns func_name_cstring().str. - Changed Item::mode_name() and Item::func_name_ext() to return LEX_CSTRING. - Changed for some functions the name argument from const char * to to const LEX_CSTRING &: - Item::Item_func_fix_attributes() - Item::check_type_...() - Type_std_attributes::agg_item_collations() - Type_std_attributes::agg_item_set_converter() - Type_std_attributes::agg_arg_charsets...() - Type_handler_hybrid_field_type::aggregate_for_result() - Type_handler_geometry::check_type_geom_or_binary() - Type_handler::Item_func_or_sum_illegal_param() - Predicant_to_list_comparator::add_value_skip_null() - Predicant_to_list_comparator::add_value() - cmp_item_row::prepare_comparators() - cmp_item_row::aggregate_row_elements_for_comparison() - Cursor_ref::print_func() - Removes String_space() as it was only used in one cases and that could be simplified to not use String_space(), thanks to the fixed my_vsnprintf(). - Added some const LEX_CSTRING's for common strings: - NULL_clex_str, DATA_clex_str, INDEX_clex_str. - Changed primary_key_name to a LEX_CSTRING - Renamed String::set_quick() to String::set_buffer_if_not_allocated() to clarify what the function really does. - Rename of protocol function: bool store(const char *from, CHARSET_INFO *cs) to bool store_string_or_null(const char *from, CHARSET_INFO *cs). This was done to both clarify the difference between this 'store' function and also to make it easier to find unoptimal usage of store() calls. - Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*) - Changed some 'const char*' arrays to instead be of type LEX_CSTRING. - class Item_func_units now used LEX_CSTRING for name. Other things: - Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character in the prompt would cause some part of the prompt to be duplicated. - Fixed a lot of instances where the length of the argument to append is known or easily obtain but was not used. - Removed some not needed 'virtual' definition for functions that was inherited from the parent. I added override to these. - Fixed Ordered_key::print() to preallocate needed buffer. Old code could case memory overruns. - Simplified some loops when adding char * to a String with delimiters.
* | | | | Split item->flags into base_flags and with_flagsMonty2021-05-191-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was done to simplify copying of with_* flags Other things: - Changed Flags to C++ enums, which enables gdb to print out bit values for the flags. This also enables compiler errors if one tries to manipulate a non existing bit in a variable. - Added set_maybe_null() as a shortcut as setting the MAYBE_NULL flags was used in a LOT of places. - Renamed PARAM flag to SP_VAR to ensure it's not confused with persistent statement parameters.
* | | | | Change bitfields in Item to an uint16Michael Widenius2021-05-191-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reason for the change is that neither clang or gcc can do efficient code when several bit fields are change at the same time or when copying one or more bits between identical bit fields. Updated bits explicitely with & and | is MUCH more efficient than what current compilers can do.
* | | | | Revert MDEV-14517 Cleanup for Item::with_subselectMichael Widenius2021-05-191-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added back variable 'with_subquery' to Item class as a bit field. This made the code shorter, faster (removed some virtual methods, less code to create an initialized item etc) and made many Item's 7 bytes smaller. This is the last set of my patches the decreases the size of Item. Some examples from gdb: sizeof(Item): 144 -> 120 sizeof(Item_func) 208 -> 184 sizeof(Item_sum_max) 368 -> 344
* | | | | Revert MDEV-16592 "Change Item::with_sum_func to a virtual method"Michael Widenius2021-05-191-0/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added back variable 'with_sum_func' to Item class as a bit field. This made the code shorter, faster (removed some virtual methods, less code to create an initialized item etc) and made many Item's 7 bytes smaller. The code is also easier to understand as 'with_sum_func' is threated as any other Item variable when creating or copying items.
* | | | Merge 10.4 into 10.5Marko Mäkelä2020-08-011-4/+2
|\ \ \ \ | |/ / /
| * | | Merge 10.3 into 10.4Marko Mäkelä2020-07-311-4/+2
| |\ \ \ | | |/ /
| | * | Merge 10.2 into 10.3Marko Mäkelä2020-07-311-4/+2
| | |\ \ | | | |/
| | | * MDEV-18916: crash in Window_spec::print_partition() with decimalsVarun Gupta2020-07-271-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | Merge 10.4 into 10.5Marko Mäkelä2020-07-021-2/+2
|\ \ \ \ | |/ / /
| * | | Merge 10.3 into 10.4Marko Mäkelä2020-07-021-2/+2
| |\ \ \ | | |/ /
| | * | Merge 10.2 into 10.3Marko Mäkelä2020-07-021-2/+2
| | |\ \ | | | |/
| | | * MDEV-22984: Throw an error when arguments to window functions are window ↵Varun Gupta2020-06-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | functions Window function is not allowed as arguments to window functions according to the standard.
* | | | MDEV-20280 PERCENTILE_DISC() rejects temporal and string inputAlexander Barkov2020-06-011-7/+0
| | | |
* | | | Merge remote-tracking branch 'origin/10.4' into 10.5Alexander Barkov2019-08-131-30/+35
|\ \ \ \ | |/ / /
| * | | Merge commit '43882e764d6867c6855b1ff057758a3f08b25c55' into 10.4Alexander Barkov2019-08-131-30/+35
| |\ \ \ | | |/ /
| | * | A cleanup for `MDEV-20273 Add class Item_sum_min_max` - removing duplicate codeAlexander Barkov2019-08-091-27/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reusing the MIN()/MAX() fix_length_and_dec() related code for window functions - FIRST_VALUE() - LAST_VALUE() - NTH_VALUE() - LEAD() - LAG
| | * | MDEV-20272 PERCENTILE_DISC() crashes on a temporal type inputAlexander Barkov2019-08-071-10/+23
| | | |
| | * | MDEV-20278 PERCENTILE_DISC() returns a wrong data typeAlexander Barkov2019-08-071-2/+10
| | | |
* | | | MDEV-20052 Add a MEM_ROOT pointer argument to Type_handler::make_xxx_field()Alexander Barkov2019-07-121-1/+2
|/ / /
* | | MDEV-19124 Assertion `0' failed in Item::val_nativeAlexander Barkov2019-04-021-0/+8
| | |
* | | Merge 10.3 into 10.4Marko Mäkelä2018-10-171-0/+17
|\ \ \ | |/ /
| * | MDEV-17137: Syntax errors with VIEW using MEDIANVarun Gupta2018-10-161-0/+17
| | | | | | | | | | | | | | | | | | | | | The syntax error happened because we had not implemented a different print for percentile functions. The syntax is a bit different when we use percentile functions as window functions in comparision to normal window functions. Implemented a seperate print function for percentile functions
* | | MDEV-17317 Add THD* parameter into Item::get_date() and stricter data type ↵Alexander Barkov2018-09-281-2/+2
| | | | | | | | | | | | control to "fuzzydate"
* | | MDEV-16910 Add class VDecAlexander Barkov2018-08-071-5/+3
| | | | | | | | | | | | | | | Adding classes VDec and VDec2_lazy, according to the task description. This patch removes around 250 duplicate code lines.
* | | Merge remote-tracking branch 'origin/10.3' into 10.4Alexander Barkov2018-07-031-6/+8
|\ \ \ | |/ /
| * | MDEV-16489 when lead() returns null on a datetime field, the result is ↵Alexander Barkov2018-06-201-1/+1
| | | | | | | | | | | | treated as the literal string '[NULL]'
| * | Merge commit '6b8802e8dd5467556a024d807a1df23940b00895' into bb-10.3-fix_len_decbb-10.3-fix_len_decOleksandr Byelkin2018-06-191-2/+4
| |\ \ | | |/
| | * MDEV-11071: Assertion `thd->transaction.stmt.is_empty()' failed in ↵Oleksandr Byelkin2018-06-151-2/+4
| | | | | | | | | | | | | | | | | | Locked_tables_list::unlock_locked_table fix_length_and_dec now return result (error/OK)
| * | Merge 10.2 into 10.3Marko Mäkelä2018-06-181-3/+3
| |\ \ | | |/
| | * MDEV-15870 Using aggregate and window function in unexpected places can ↵Alexander Barkov2018-06-131-3/+3
| | | | | | | | | | | | crash the server
* | | MDEV-16592 Change Item::with_sum_func from a member to a virtual methodAlexander Barkov2018-06-271-1/+0
|/ /
* | MDEV-16385 ROW SP variable is allowed in unexpected contextAlexander Barkov2018-06-051-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem described in the bug report happened because the code did not test check_cols(1) after fix_fields() in a few places. Additionally, fix_fields() could be called multiple times for SP variables, because they are all fixed at a early stage in append_for_log(). Solution: 1. Adding a few helper methods - fix_fields_if_needed() - fix_fields_if_needed_for_scalar() - fix_fields_if_needed_for_bool() - fix_fields_if_needed_for_order_by() and using it in many cases instead of fix_fields() where the "fixed" status is not definitely known to be "false". 2. Adding DBUG_ASSERT(!fixed) into Item_splocal*::fix_fields() to catch double execution. 3. Adding tests. As a good side effect, the patch removes a lot of duplicate code (~60 lines): if (!item->fixed && item->fix_fields(..) && item->check_cols(1)) return true;
* | Merge bb-10.2-ext into 10.3Marko Mäkelä2018-02-151-0/+16
|\ \
| * | MDEV-15293 CAST(AS TIME) returns bad results for ↵Alexander Barkov2018-02-131-0/+11
| | | | | | | | | | | | LAST_VALUE(),NAME_CONST(),SP variable
| * | Merge remote-tracking branch 'origin/10.2' into bb-10.2-extAlexander Barkov2018-02-081-0/+5
| |\ \ | | |/
| | * fix Item_window_func::print() not to crash before fix_fields()Sergei Golubchik2018-02-061-0/+5
| | | | | | | | | | | | | | | | | | | | | 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
* | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-11-301-2/+2
|\ \ \ | |/ /
| * | MDEV-14517 Cleanup for Item::with_subselect and Item::has_subquery()Alexander Barkov2017-11-281-2/+2
| | |
* | | Updates the tests for the percentile functionsVarun Gupta2017-11-011-4/+4
| | |
* | | Date-time fields are disabled currently for the result type of percentile ↵Varun Gupta2017-11-011-3/+2
| | | | | | | | | | | | function
* | | Tests added for percentile and median functionsVarun Gupta2017-11-011-1/+1
| | |
* | | Added fix_fields for percentile function to check the type of argument and ↵Varun Gupta2017-11-011-11/+43
| | | | | | | | | | | | to ensure that only numeric arguments are allowed