Commit graph

117 commits

Author SHA1 Message Date
Oleg Smirnov
405613ebb5 MDEV-34490 get_copy() and build_clone() may return an instance of an ancestor class instead of a copy/clone
The `Item` class methods `get_copy()`, `build_clone()`, and `clone_item()`
face an issue where they may be defined in a descendant class
(e.g., `Item_func`) but not in a further descendant (e.g., `Item_func_child`).
This can lead to scenarios where `build_clone()`, when operating on an
instance of `Item_func_child` with a pointer to the base class (`Item`),
returns an instance of `Item_func` instead of `Item_func_child`.

Since this limitation cannot be resolved at compile time, this commit
introduces runtime type checks for the copy/clone operations.
A debug assertion will now trigger in case of a type mismatch.

`get_copy()`, `build_clone()`, and `clone_item()` are no more virtual,
but virtual `do_get_copy()`, `do_build_clone()`, and `do_clone_item()`
are added to the protected section of the class `Item`.

Additionally, const qualifiers have been added to certain methods
to enhance code reliability.

Reviewer: Oleksandr Byelkin <sanja@mariadb.com>
2024-07-15 18:25:57 +07:00
Dave Gosselin
db0c28eff8 MDEV-33746 Supply missing override markings
Find and fix missing virtual override markings.  Updates cmake
maintainer flags to include -Wsuggest-override and
-Winconsistent-missing-override.
2024-06-20 11:32:13 -04:00
Marko Mäkelä
50a11f396a Merge 10.4 into 10.5 2020-08-01 14:42:51 +03:00
Marko Mäkelä
9216114ce7 Merge 10.3 into 10.4 2020-07-31 18:09:08 +03:00
Marko Mäkelä
66ec3a770f Merge 10.2 into 10.3 2020-07-31 13:51:28 +03:00
Dan Solodko
459b87f6b4 MDEV-9911: NTILE must return an error when parameter is not stable 2020-07-28 06:35:32 +02:00
Marko Mäkelä
e67daa5653 Merge 10.4 into 10.5 2020-07-15 14:51:22 +03:00
Marko Mäkelä
9936cfd531 Merge 10.3 into 10.4 2020-07-15 10:17:15 +03:00
Marko Mäkelä
8a0944080c Merge 10.2 into 10.3 2020-07-14 22:59:19 +03:00
Varun Gupta
253aa7bbc4 MDEV-12059: Assertion `precision > 0' failed with a window function or window aggregate function
Pass the unsigned flag from the Item_sum to the window function
2020-07-07 17:30:53 +05:30
Alexander Barkov
33b839b2e7 MDEV-20280 PERCENTILE_DISC() rejects temporal and string input 2020-06-01 14:30:21 +04:00
Marko Mäkelä
8cc15c036d Merge 10.4 into 10.5 2019-12-27 21:17:16 +02:00
Alexander Barkov
4c57ab34d4 Merge remote-tracking branch 'origin/10.3' into 10.4 2019-12-25 13:33:28 +04:00
Alexander Barkov
ee9a19fb05 MDEV-21392 Cleanup redundant overriding in Item_sum_num 2019-12-25 12:23:24 +04:00
Marko Mäkelä
c221bcdce7 Merge 10.3 into 10.4 2019-08-16 10:51:20 +03:00
Alexander Barkov
6073049a36 MDEV-20353 Add separate type handlers for unsigned integer data types 2019-08-15 21:53:24 +04:00
Alexander Barkov
841294cfaa MDEV-20351 Window function BIT_OR() OVER (..) return a wrong data type 2019-08-15 10:32:42 +04:00
Alexander Barkov
c1599821a5 Merge remote-tracking branch 'origin/10.4' into 10.5 2019-08-13 23:49:10 +04:00
Alexander Barkov
95cdc1ca5f Merge commit '43882e764d6867c6855b1ff057758a3f08b25c55' into 10.4 2019-08-13 11:42:31 +04:00
Alexander Barkov
2dac123515 A cleanup for MDEV-20273 Add class Item_sum_min_max - removing duplicate code
Reusing the MIN()/MAX() fix_length_and_dec() related code for window functions
- FIRST_VALUE()
- LAST_VALUE()
- NTH_VALUE()
- LEAD()
- LAG
2019-08-09 09:00:17 +04:00
Alexander Barkov
d70dac2079 MDEV-20278 PERCENTILE_DISC() returns a wrong data type 2019-08-07 21:01:22 +04:00
Alexander Barkov
e978efd96b MDEV-20273 Add class Item_sum_min_max 2019-08-07 14:13:44 +04:00
Alexander Barkov
e6ff3f9d1c MDEV-20052 Add a MEM_ROOT pointer argument to Type_handler::make_xxx_field() 2019-07-12 06:58:51 +04:00
Marko Mäkelä
2fd82471ab Merge 10.3 into 10.4 2019-06-12 08:37:27 +03:00
Marko Mäkelä
b42dbdbccd Merge 10.2 into 10.3 2019-06-11 13:00:18 +03:00
Varun Gupta
7906bee67b MDEV-18015: Assertion `global_status_var.global_memory_used == 0' failed when using UDF , window functions and views
Adding destructor for Group_bound_tracker to free Cached_item_str.
The Cached_item for window functions are allocated on THD:mem_root
but the Cached_item_str has value of type string which is allocated on
the heap, so we need to call free() for it
2019-06-04 23:23:10 +05:30
Alexander Barkov
1b4bb3b5bb MDEV-19124 Assertion `0' failed in Item::val_native 2019-04-02 09:13:16 +04:00
Alexander Barkov
3e1f3d3e2f A cleanup in Item_sum: removing dead code 2019-03-28 07:52:14 +04:00
Marko Mäkelä
d88c136b9f Merge 10.3 into 10.4 2018-10-17 19:11:42 +03:00
Varun Gupta
97a37edc97 MDEV-17137: Syntax errors with VIEW using MEDIAN
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
2018-10-16 08:11:26 -07:00
Alexander Barkov
ad8e02ac45 MDEV-17317 Add THD* parameter into Item::get_date() and stricter data type control to "fuzzydate" 2018-09-28 14:01:17 +04:00
Marko Mäkelä
7830fb7f45 Merge 10.2 into 10.3 2018-08-28 12:22:56 +03:00
zhzhzoo
2a361ebe1b MDEV-15204: lag/lead function order list mandatory 2018-08-25 18:47:14 +03:00
Oleksandr Byelkin
083279f783 Merge commit '6b8802e8dd5467556a024d807a1df23940b00895' into bb-10.3-fix_len_dec 2018-06-19 14:51:50 +02:00
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
Marko Mäkelä
b006d2ead4 Merge bb-10.2-ext into 10.3 2018-02-15 10:22:03 +02:00
Alexander Barkov
95d075a0e5 MDEV-15293 CAST(AS TIME) returns bad results for LAST_VALUE(),NAME_CONST(),SP variable 2018-02-13 20:37:31 +04:00
Michael Widenius
166056f744 Remove not used mem_root argument from build_clone(), get_copy() and get_item_copy()
TODO:
- Make get_thd_memroot() inline
  - To do this, we need to reduce dependence of include files, especially
    so that sql_class.h is not depending in item.h
2017-11-23 09:49:45 +02:00
Varun Gupta
ab5503c8c5 Updates the tests for the percentile functions 2017-11-01 23:17:15 +05:30
Varun Gupta
40887913ff Update the error messages involving percentile functions 2017-11-01 23:17:15 +05:30
Varun Gupta
b5c104d00a Changes made according to the review given, mostly fixing coding style errors 2017-11-01 23:16:59 +05:30
Vicențiu Ciorbaru
24e219b179 Remove has_error as a member from Item_sum and use THD::is_error() instead
Additionally, allow a query with window functions to be killed by the user during
its execution.
2017-11-01 23:13:02 +05:30
Varun Gupta
f8e135c7df made changes according to the review, mostly removing unused code and fixing code to follow the coding conventions 2017-11-01 23:13:02 +05:30
Varun Gupta
03ed22326a Added the error
1)ER_ARGUMENT_OUT_OF_RANGE: This error is thrown if the argument of the percentile function is not in the range [0,1]
  2)ER_ARGUMENT_NOT_CONSTANT: This error is thrown if the argument of the percnetile function is not constant in the
    entire partition of the window function
2017-11-01 23:13:01 +05:30
Varun Gupta
96565ac311 Added the function setting_handler_for_percentile_function() for the percentile_disc function that would
set the type of the result field for percentile_disc. Percentile_cont would habe double precision result type
2017-11-01 23:13:01 +05:30
Varun Gupta
eb2187a24f Val_str function added for the percentile_disc function, as it can have result type as STRING_RESULT 2017-11-01 23:13:01 +05:30
Varun Gupta
275ce39f05 Percentile class implemented, most of the functions have the same functionalite as the percentile cont class 2017-11-01 23:13:01 +05:30
Varun Gupta
01d2b6e9d9 Implemented the implementation of percentile functions using Item_cache instead of Cache_Item 2017-11-01 23:13:01 +05:30
Varun Gupta
ba9fbc6a83 implementation of add() function added to the Item_sum_percentile_disc class 2017-11-01 23:13:01 +05:30
Varun Gupta
31f1541f1e Setting handler to have the return type as that of the element by which we are ordering the partition 2017-11-01 23:13:01 +05:30