diff options
author | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2009-05-15 12:11:07 +0500 |
---|---|---|
committer | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2009-05-15 12:11:07 +0500 |
commit | 376d67e5c0718fc611917523435c1a753eaffe7a (patch) | |
tree | de162ac67331aad8bb2ab68081ce0d6cb5183c0f /sql/sql_union.cc | |
parent | 5f3dc895b0b80228a3c09385f82be001db2bf2c4 (diff) | |
parent | fc57b4cfb569635edc1613154d9b7ed14efaf840 (diff) | |
download | mariadb-git-376d67e5c0718fc611917523435c1a753eaffe7a.tar.gz |
5.0-bugteam->5.1-bugteam merge
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r-- | sql/sql_union.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc index fd3036e3d80..cbf94ad7181 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -653,10 +653,22 @@ bool st_select_lex_unit::cleanup() join->tables= 0; } error|= fake_select_lex->cleanup(); - if (fake_select_lex->order_list.elements) + /* + There are two cases when we should clean order items: + 1. UNION with SELECTs which all enclosed into braces + in this case global_parameters == fake_select_lex + 2. UNION where last SELECT is not enclosed into braces + in this case global_parameters == 'last select' + So we should use global_parameters->order_list for + proper order list clean up. + Note: global_parameters and fake_select_lex are always + initialized for UNION + */ + DBUG_ASSERT(global_parameters); + if (global_parameters->order_list.elements) { ORDER *ord; - for (ord= (ORDER*)fake_select_lex->order_list.first; ord; ord= ord->next) + for (ord= (ORDER*)global_parameters->order_list.first; ord; ord= ord->next) (*ord->item)->cleanup(); } } |