1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-24 19:42:23 +03:00
Commit Graph

26 Commits

Author SHA1 Message Date
a977054ee0 Merge branch '10.3' into 10.4 2023-01-28 18:22:55 +01:00
f18c2b6c8a MDEV-15178: Filesort::make_sortorder: Assertion `pos->field != __null |
(Initial patch by Varun Gupta. Amended and added comments).

When the query has both
1. Aggregate functions that require sorting data by group, and
2. Window functions

we need to use two temporary tables. The first temp.table will hold the
join output.  Then it is passed to filesort(). Reading it in sorted
order allows to compute the aggregate functions.

Then, we need to write their values into the second temp. table. Then,
Window Function computation step can pass that to filesort() and read
them in the order it needs.

Failure to create the second temp. table would cause an assertion
failure: window function could would not find where to get the values
of the aggregate functions.
2023-01-23 18:22:21 +02:00
18795f5512 Merge 10.3 into 10.4 2022-09-13 16:36:38 +03:00
f1544424de MDEV-29446 Change SHOW CREATE TABLE to display default collation 2022-09-12 22:10:39 +04:00
a70a1cf3f4 Merge branch '10.3' into 10.4 2022-05-08 23:03:08 +02:00
6f741eb6e4 Merge branch '10.2' into 10.3 2022-05-07 11:48:15 +02:00
624cb9735e Update test results after fix for MDEV-19398 2022-05-06 10:34:27 +03:00
f5ff7d09c7 Merge 10.3 into 10.4 2022-02-25 13:00:48 +02:00
00b70bbb51 Merge 10.2 into 10.3 2022-02-25 10:43:38 +02:00
647e952315 MDEV-15208: server crashed, when using ORDER BY with window function and UNION
(Edits by SergeiP: fix encryption.tempfiles_encrypted, re-word comment)

Global ORDER BY clause of a UNION may not refer to 1) aggregate functions
or 2) window functions.  setup_order() checked for #1 but not for #2.
2022-02-22 06:38:40 +03:00
b4477ae73c Merge branch '10.3' into 10.4 2022-02-10 20:39:13 +01:00
a36fc80aeb Merge branch '10.2' into 10.3 2022-02-10 20:23:56 +01:00
5c89386fdb MDEV-17785: Window functions not working in ONLY_FULL_GROUP_BY mode
(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.
2022-02-07 21:43:42 +03:00
7841a7eb09 Merge branch '10.3' into 10.4 2021-07-31 22:59:58 +02:00
b30f26e3fe Record tempfiles_encrypted test failure 2021-07-22 09:19:18 +02:00
6190a02f35 Merge branch '10.2' into 10.3 2021-07-21 20:11:07 +02:00
d3e4fae797 Merge 10.3 into 10.4 2021-06-21 12:38:25 +03:00
c9a85fb1b1 Merge 10.2 into 10.3 2021-06-21 09:07:40 +03:00
c872125a66 MDEV-25630: Crash with window function in left expr of IN subquery
* Make Item_in_optimizer::fix_fields inherit the with_window_func
  attribute of the subquery's left expression (the subquery itself
  cannot have window functions that are aggregated in this select)

* Make Item_cache_wrapper::Item_cache_wrapper() inherit
  with_window_func attribute of the item it is caching.
2021-06-09 15:52:13 +03:00
a26e7a3726 Merge 10.3 into 10.4 2021-03-08 09:39:54 +02:00
e9b8b76f47 Merge branch '10.2' into 10.3 2021-03-04 16:04:30 +02:00
5da6ffe227 MDEV-25032: Window functions without column references get removed from ORDER BY
row_number() over () window function can be used without any column in the OVER
clause. Additionally, the item doesn't reference any tables, as it's not
effectively referencing any table. Rather it is specifically built based
on the end temporary table used for window function computation.

This caused remove_const function to wrongly drop it from the ORDER
list. Effectively, we shouldn't be dropping any window function from the
ORDER clause, so adjust remove_const to account for that.

Reviewed by: Sergei Petrunia sergey@mariadb.com
2021-03-04 15:37:47 +02:00
7b2bb67113 Merge 10.3 into 10.4 2020-10-29 13:38:38 +02:00
a8de8f261d Merge 10.2 into 10.3 2020-10-28 10:01:50 +02:00
b94e8e4b25 MDEV-23867: insert... select crash in compute_window_func
There are 2 issues here:

Issue #1: memory allocation.
An IO_CACHE that uses encryption uses a larger buffer (it needs space for the encrypted data,
decrypted data, IO_CACHE_CRYPT struct to describe encryption parameters etc).

Issue #2: IO_CACHE::seek_not_done
When IO_CACHE objects are cloned, they still share the file descriptor.
This means, operation on one IO_CACHE may change the file read position
which will confuse other IO_CACHEs using it.

The fix of these issues would be:
Allocate the buffer to also include the extra size needed for encryption.
Perform seek again after one IO_CACHE reads the file.
2020-10-23 22:36:47 +05:30
0a5668f512 MDEV-22556: Incorrect result for window function when using encrypt-tmp-files=ON
The issue here is that end_of_file for encrypted temporary IO_CACHE (used by filesort) is updated
using lseek.
Encryption adds storage overhead and hides it from the caller by recalculating offsets and lengths.
Two different IO_CACHE cannot possibly modify the same file
because the encryption key is randomly generated and stored in the IO_CACHE.
So when the tempfiles are encrypted DO NOT use lseek to change end_of_file.

Further observations about updating end_of_file using lseek
1) The end_of_file update is only used for binlog index files
2) The whole point is to update file length when the file was modified via a different file descriptor.
3) The temporary IO_CACHE files can never be modified via a different file descriptor.
4) For encrypted temporary IO_CACHE, end_of_file should not be updated with lseek
2020-05-17 15:26:18 +05:30