summaryrefslogtreecommitdiff
path: root/sql/sql_window.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2021-07-09 18:56:34 -0700
committerIgor Babaev <igor@askmonty.org>2021-07-20 11:26:33 -0700
commit4c387945f0f8d5df84ae987c4a4bba7675815c72 (patch)
tree80a8974201ebb4e9addc5ead9562b096c1b15918 /sql/sql_window.cc
parent872422dcbbe3681a794935fb2cae422d9d5f4108 (diff)
downloadmariadb-git-4c387945f0f8d5df84ae987c4a4bba7675815c72.tar.gz
MDEV-25565 Crash on 2-nd execution of SP/PS for query calculating window functions
from view A crash of the server happened when executing a stored procedure whose the only query calculated window functions over a mergeable view specified as a select from non-mergeable view. The crash could be reproduced if the window specifications of the window functions were identical and both contained PARTITION lists and ORDER BY lists. A crash also happened on the second execution of the prepared statement created for such query. If to use derived tables or CTE instead of views the problem still manifests itself crashing the server. When optimizing the window specifications of a window function the server can substitute the partition lists and the order lists for the corresponding lists from another window specification in the case when the lists are identical. This substitution is not permanent and should be rolled back before the second execution. It was not done and this ultimately led to a crash when resolving the column names at the second execution of SP/PS.
Diffstat (limited to 'sql/sql_window.cc')
-rw-r--r--sql/sql_window.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index 612c6e692fe..3ef751bc5b9 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -479,9 +479,15 @@ int compare_window_funcs_by_window_specs(Item_window_func *win_func1,
Let's use only one of the lists.
*/
if (!win_spec1->name() && win_spec2->name())
+ {
+ win_spec1->save_partition_list= win_spec1->partition_list;
win_spec1->partition_list= win_spec2->partition_list;
+ }
else
+ {
+ win_spec2->save_partition_list= win_spec2->partition_list;
win_spec2->partition_list= win_spec1->partition_list;
+ }
cmp= compare_order_lists(win_spec1->order_list,
win_spec2->order_list);
@@ -494,9 +500,15 @@ int compare_window_funcs_by_window_specs(Item_window_func *win_func1,
Let's use only one of the lists.
*/
if (!win_spec1->name() && win_spec2->name())
+ {
+ win_spec1->save_order_list= win_spec2->order_list;
win_spec1->order_list= win_spec2->order_list;
+ }
else
+ {
+ win_spec1->save_order_list= win_spec2->order_list;
win_spec2->order_list= win_spec1->order_list;
+ }
cmp= compare_window_frames(win_spec1->window_frame,
win_spec2->window_frame);