Bug #26867652: INCORRECT BEHAVIOR WITH PREPARE STATEMENT
AND PARAM IN ORDER BY Issue: ------ This issue can occur when the ORDER BY list refers to a column that contains a parameter in the select list. Solution: --------- In JOIN::update_depend_map and get_sort_by_table, the ORDER BY list's used_tables isn't checked for parameters. This can result in incorrect behavior. This is a partial backport of Roy's
This commit is contained in:
parent
6ca6899683
commit
84c32cdbe7
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -7430,7 +7430,8 @@ static void update_depend_map(JOIN *join, ORDER *order)
|
||||
{
|
||||
table_map depend_map;
|
||||
order->item[0]->update_used_tables();
|
||||
order->depend_map=depend_map=order->item[0]->used_tables();
|
||||
order->depend_map=depend_map=
|
||||
order->item[0]->used_tables() & ~PARAM_TABLE_BIT;
|
||||
order->used= 0;
|
||||
// Not item_sum(), RAND() and no reference to table outside of sub select
|
||||
if (!(order->depend_map & (OUTER_REF_TABLE_BIT | RAND_TABLE_BIT))
|
||||
@ -15583,6 +15584,7 @@ get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables)
|
||||
DBUG_RETURN(0);
|
||||
map|=a->item[0]->used_tables();
|
||||
}
|
||||
map&= ~PARAM_TABLE_BIT;
|
||||
if (!map || (map & (RAND_TABLE_BIT | OUTER_REF_TABLE_BIT)))
|
||||
DBUG_RETURN(0);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user