summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge commit '10.4' into 10.5Oleksandr Byelkin2021-01-061-7/+7
|\
| * Merge branch '10.3' into 10.4bb-10.4-MDEV-23468Oleksandr Byelkin2020-12-251-7/+7
| |\
| | * Merge branch '10.2' into 10.3Oleksandr Byelkin2020-12-231-7/+7
| | |\
| | | * MDEV-4677 GROUP_CONCAT not showing any output with group_concat_max_len >= 4GbSergei Golubchik2020-12-101-7/+7
| | | | | | | | | | | | | | | | | | | | don't allow group_concat_max_len values >= 4Gb (they never worked anyway)
* | | | Merge 10.4 into 10.5Marko Mäkelä2020-11-031-5/+9
|\ \ \ \ | |/ / /
| * | | Merge 10.3 into 10.4Marko Mäkelä2020-11-031-5/+9
| |\ \ \ | | |/ /
| | * | Merge 10.2 into 10.3Marko Mäkelä2020-11-021-5/+9
| | |\ \ | | | |/
| | | * MDEV-22387: Do not violate __attribute__((nonnull))Marko Mäkelä2020-11-021-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This follows up commit commit 94a520ddbe39ae97de1135d98699cf2674e6b77e and commit 7c5519c12d46ead947d341cbdcbb6fbbe4d4fe1b. After these changes, the default test suites on a cmake -DWITH_UBSAN=ON build no longer fail due to passing null pointers as parameters that are declared to never be null, but plenty of other runtime errors remain.
* | | | Merge branch '10.4' into 10.5Oleksandr Byelkin2020-08-041-6/+6
|\ \ \ \ | |/ / /
| * | | Merge branch '10.3' into 10.4Oleksandr Byelkin2020-08-031-6/+6
| |\ \ \ | | |/ /
| | * | Merge branch '10.2' into 10.3Oleksandr Byelkin2020-08-031-6/+6
| | |\ \ | | | |/
| | | * Merge branch '10.1' into 10.2Oleksandr Byelkin2020-08-021-7/+7
| | | |\
| | | | * Code comment spellfixesIan Gilfillan2020-07-221-8/+8
| | | | |
| | | * | MDEV-21082: isnan/isinf compilation errors, isfinite warnings on MacOSVlad Lesin2019-11-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fix consists of three commits backported from 10.3: 1) Cleanup isnan() portability checks (cherry picked from commit 7ffd7fe9627d1f750a3712aebb4503e5ae8aea8e) 2) Cleanup isinf() portability checks Original problem reported by Wlad: re-compilation of 10.3 on top of 10.2 build would cache undefined HAVE_ISINF from 10.2, whereas it is expected to be 1 in 10.3. std::isinf() seem to be available on all supported platforms. (cherry picked from commit bc469a0bdf85400f7a63834f5b7af1a513dcdec9) 3) Use std::isfinite in C++ code This is addition to parent revision fixing build failures. (cherry picked from commit 54999f4e75f42baca484ae436b382ca8817df1dd)
* | | | | Fixed memory leak in item_sum.cc::report_cut_value_error()Monty2020-06-241-3/+6
| | | | | | | | | | | | | | | | | | | | Only affects DBUG builds
* | | | | MDEV-22844 JSON_ARRAYAGG is limited by group_concat_max_len.Alexey Botchkov2020-06-151-19/+34
| | | | | | | | | | | | | | | | | | | | Warning message and function result fixed
* | | | | Merge 10.4 into 10.5Marko Mäkelä2020-06-141-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.3 into 10.4Marko Mäkelä2020-06-131-15/+25
| |\ \ \ \ | | |/ / /
| | * | | MDEV-11563: GROUP_CONCAT(DISTINCT ...) may produce a non-distinct listVarun Gupta2020-06-091-15/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backported from MYSQL Bug #25331425: DISTINCT CLAUSE DOES NOT WORK IN GROUP_CONCAT Issue: ------ The problem occurs when: 1) GROUP_CONCAT (DISTINCT ....) is used in the query. 2) Data size greater than value of system variable: tmp_table_size. The result would contain values that are non-unique. Root cause: ----------- An in-memory structure is used to filter out non-unique values. When the data size exceeds tmp_table_size, the overflow is written to disk as a separate file. The expectation here is that when all such files are merged, the full set of unique values can be obtained. But the Item_func_group_concat::add function is in a bit of hurry. Even as it is adding values to the tree, it wants to decide if a value is unique and write it to the result buffer. This works fine if the configured maximum size is greater than the size of the data. But since tmp_table_size is set to a low value, the size of the tree is smaller and hence requires the creation of multiple copies on disk. Item_func_group_concat currently has no mechanism to merge all the copies on disk and then generate the result. This results in duplicate values. Solution: --------- In case of the DISTINCT clause, don't write to the result buffer immediately. Do the merge and only then put the unique values in the result buffer. This has be done in Item_func_group_concat::val_str. Note regarding result file changes: ----------------------------------- Earlier when a unique value was seen in Item_func_group_concat::add, it was dumped to the output. So result is in the order stored in SE. But with this fix, we wait until all the data is read and the final set of unique values are written to output buffer. So the data appears in the sorted order. This only fixes the cases when we have DISTINCT without ORDER BY clause in GROUP_CONCAT.
* | | | | MDEV-22840: JSON_ARRAYAGG gives wrong results with NULL values and ORDER by ↵Varun Gupta2020-06-121-5/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clause The problem here is similar to the case with DISTINCT, the tree used for ORDER BY needs to also hold the null bytes of the record. This was not done for GROUP_CONCAT as NULLS are rejected by GROUP_CONCAT. Also introduced a comparator function for the order by tree to handle null values with JSON_ARRAYAGG.
* | | | | MDEV-22011: DISTINCT with JSON_ARRAYAGG gives wrong resultsVarun Gupta2020-06-121-6/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For DISTINCT to be handled with JSON_ARRAYAGG, we need to make sure that the Unique tree also holds the NULL bytes of a table record inside the node of the tree. This behaviour for JSON_ARRAYAGG is different from GROUP_CONCAT because in GROUP_CONCAT we just reject NULL values for columns. Also introduced a comparator function for the unique tree to handle null values for distinct inside JSON_ARRAYAGG.
* | | | | MDEV-11563: GROUP_CONCAT(DISTINCT ...) may produce a non-distinct listVarun Gupta2020-06-121-15/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backported from MYSQL Bug #25331425: DISTINCT CLAUSE DOES NOT WORK IN GROUP_CONCAT Issue: ------ The problem occurs when: 1) GROUP_CONCAT (DISTINCT ....) is used in the query. 2) Data size greater than value of system variable: tmp_table_size. The result would contain values that are non-unique. Root cause: ----------- An in-memory structure is used to filter out non-unique values. When the data size exceeds tmp_table_size, the overflow is written to disk as a separate file. The expectation here is that when all such files are merged, the full set of unique values can be obtained. But the Item_func_group_concat::add function is in a bit of hurry. Even as it is adding values to the tree, it wants to decide if a value is unique and write it to the result buffer. This works fine if the configured maximum size is greater than the size of the data. But since tmp_table_size is set to a low value, the size of the tree is smaller and hence requires the creation of multiple copies on disk. Item_func_group_concat currently has no mechanism to merge all the copies on disk and then generate the result. This results in duplicate values. Solution: --------- In case of the DISTINCT clause, don't write to the result buffer immediately. Do the merge and only then put the unique values in the result buffer. This has be done in Item_func_group_concat::val_str. Note regarding result file changes: ----------------------------------- Earlier when a unique value was seen in Item_func_group_concat::add, it was dumped to the output. So result is in the order stored in SE. But with this fix, we wait until all the data is read and the final set of unique values are written to output buffer. So the data appears in the sorted order. This only fixes the cases when we have DISTINCT without ORDER BY clause in GROUP_CONCAT.
* | | | | MDEV-21914 JSON_ARRAYAGG doesn't reject ORDER BY clause, but doesn't work ↵Alexey Botchkov2020-06-041-12/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | either. ORDER BY fixed for JSON_ARRAYAGG.
* | | | | MDEV-22084 Squared brackets missing from JSON_ARRAYAGG when used in a view.Alexey Botchkov2020-06-041-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | Item_func_groupconcat::print() should be fixed to work for the derived classes.
* | | | | MDEV-22640, MDEV-22449, MDEV-21528 JSON_ARRAYAGG crashes with NULL values.Alexey Botchkov2020-06-041-17/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have to include NULL in the result which the GOUP_CONCAT doesn't always do. Also converting should be done into another String instance as these can be same.
* | | | | Merge 10.4 into 10.5Marko Mäkelä2020-05-181-3/+5
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.3 into 10.4Marko Mäkelä2020-05-161-3/+5
| |\ \ \ \ | | |/ / /
| | * | | MDEV-18100: User defined aggregate functions not working correctly when the ↵Varun Gupta2020-05-151-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | schema is changed The issue here was that when the schema was changed the value for the THD::server_status is ored with SERVER_SESSION_STATE_CHANGED. For custom aggregate functions, currently we check if the server_status is equal to SERVER_STATUS_LAST_ROW_SENT then we should terminate the execution of the custom aggregate function as there are no more rows to fetch. So the check should be that if the server status has the bit set for SERVER_STATUS_LAST_ROW_SENT then we should terminate the execution of the custom aggregate function.
* | | | | Merge 10.4 into 10.5Marko Mäkelä2019-12-271-21/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge remote-tracking branch 'origin/10.3' into 10.4Alexander Barkov2019-12-251-21/+1
| |\ \ \ \ | | |/ / /
| | * | | MDEV-21392 Cleanup redundant overriding in Item_sum_numAlexander Barkov2019-12-251-21/+1
| | | | |
* | | | | MDEV-16620 JSON_ARRAYAGG and JSON_OBJECTAGG.Alexey Botchkov2019-10-141-8/+0
| | | | | | | | | | | | | | | | | | | | Ison_objectagg implemented.
* | | | | Merge branch 'MDEV-16620' of https://github.com/markus456/server into bb-10.5-hfAlexey Botchkov2019-10-101-3/+24
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: sql/sql_yacc.yy
| * | | | | MDEV-16620: Add JSON_ARRAYAGG functionMarkus Mäkelä2019-07-041-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The JSON_ARRAYAGG function extends the GROUP_CONCAT function and provides a method of aggregating JSON results. The current implementation supports DISTINCT and LIMIT but not ORDER BY (Oracle supports GROUP BY). Adding GROUP BY support is possible but it requires some extra work as the grouping appears to be done inside a temporary table that complicates matters. Added test cases that covert aggregation of all JSON types and JSON validation for the generated results.
* | | | | | MDEV-19713 Remove big_tables system variableSergei Golubchik2019-09-281-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mark big_tables deprecated, the server can put temp tables on disk as needed avoiding "table full" errors. in case someone would really need to force a tmp table to be created on disk from the start and for testing allow tmp_memory_table_size to be set to 0. fix tests to use that instead (and add a test that it actually works). make sure in-memory TREE size limit is never 0 (it's [ab]using tmp_memory_table_size at the moment) remove few sys_vars.*_basic tests
* | | | | | Merge 10.4 into 10.5Marko Mäkelä2019-09-061-12/+60
|\ \ \ \ \ \ | | |/ / / / | |/| | | |
| * | | | | MDEV-19961 MIN(timestamp_column) returns a wrong result in a GROUP BY queryAlexander Barkov2019-08-191-12/+60
| | | | | |
* | | | | | Revert "MDEV-20342 Turn Field::flags from a member to a method"Alexander Barkov2019-08-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit e86010f909fb6b8c4ffd9d6df92991ac079e67e7. Reverting on Monty's request, as this change makes merging things from 10.5 to 10.2 much harder.
* | | | | | MDEV-20342 Turn Field::flags from a member to a methodAlexander Barkov2019-08-141-1/+1
| | | | | |
* | | | | | Merge remote-tracking branch 'origin/10.4' into 10.5Alexander Barkov2019-08-131-39/+101
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge commit '43882e764d6867c6855b1ff057758a3f08b25c55' into 10.4Alexander Barkov2019-08-131-38/+100
| |\ \ \ \ \ | | | |/ / / | | |/| | |
| | * | | | A cleanup for `MDEV-20273 Add class Item_sum_min_max` - removing duplicate codeAlexander Barkov2019-08-091-1/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reusing the MIN()/MAX() fix_length_and_dec() related code for window functions - FIRST_VALUE() - LAST_VALUE() - NTH_VALUE() - LEAD() - LAG
| | * | | | MDEV-20273 Add class Item_sum_min_maxAlexander Barkov2019-08-071-38/+38
| | | | | |
* | | | | | Merge 10.4 into 10.5Marko Mäkelä2019-08-131-4/+7
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge 10.3 into 10.4Marko Mäkelä2019-07-251-4/+7
| |\ \ \ \ \ | | |/ / / / | | | / / / | | |/ / / | |/| | |
| | * | | Merge 10.2 into 10.3Eugene Kosov2019-07-161-4/+7
| | |\ \ \ | | | |/ /
| | | * | Merge 10.1 into 10.2Eugene Kosov2019-07-091-4/+7
| | | |\ \ | | | | |/
| | | | * MDEV-17857 Assertion `tmp != ((long long) 0x8000000000000000LL)' failed in ↵Alexander Barkov2019-07-051-4/+7
| | | | | | | | | | | | | | | | | | | | TIME_from_longlong_datetime_packed upon SELECT with GROUP BY
* | | | | MDEV-20052 Add a MEM_ROOT pointer argument to Type_handler::make_xxx_field()Alexander Barkov2019-07-121-10/+13
|/ / / /
* | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-06-141-1/+5
|\ \ \ \ | |/ / /