Commit fcb0ecfa authored by Chaithra Gopalareddy's avatar Chaithra Gopalareddy

Merge from 5.1 to 5.5

parents 40360f02 4db726c0
......@@ -3009,11 +3009,12 @@ int dump_leaf_key(void* key_arg, element_count count __attribute__((unused)),
Item_func_group_concat::
Item_func_group_concat(Name_resolution_context *context_arg,
bool distinct_arg, List<Item> *select_list,
SQL_I_List<ORDER> *order_list, String *separator_arg)
const SQL_I_List<ORDER> &order_list,
String *separator_arg)
:tmp_table_param(0), separator(separator_arg), tree(0),
unique_filter(NULL), table(0),
order(0), context(context_arg),
arg_count_order(order_list ? order_list->elements : 0),
arg_count_order(order_list.elements),
arg_count_field(select_list->elements),
row_count(0),
distinct(distinct_arg),
......@@ -3053,7 +3054,7 @@ Item_func_group_concat(Name_resolution_context *context_arg,
if (arg_count_order)
{
ORDER **order_ptr= order;
for (ORDER *order_item= order_list->first;
for (ORDER *order_item= order_list.first;
order_item != NULL;
order_item= order_item->next)
{
......
#ifndef ITEM_SUM_INCLUDED
#define ITEM_SUM_INCLUDED
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2013, 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
......@@ -1402,7 +1403,7 @@ class Item_func_group_concat : public Item_sum
public:
Item_func_group_concat(Name_resolution_context *context_arg,
bool is_distinct, List<Item> *is_select,
SQL_I_List<ORDER> *is_order, String *is_separator);
const SQL_I_List<ORDER> &is_order, String *is_separator);
Item_func_group_concat(THD *thd, Item_func_group_concat *item);
~Item_func_group_concat();
......
......@@ -3673,6 +3673,11 @@ inline bool add_order_to_list(THD *thd, Item *item, bool asc)
return thd->lex->current_select->add_order_to_list(thd, item, asc);
}
inline bool add_gorder_to_list(THD *thd, Item *item, bool asc)
{
return thd->lex->current_select->add_gorder_to_list(thd, item, asc);
}
inline bool add_group_to_list(THD *thd, Item *item, bool asc)
{
return thd->lex->current_select->add_group_to_list(thd, item, asc);
......
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
/*
Copyright (c) 2000, 2013, 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
......@@ -2066,6 +2067,11 @@ bool st_select_lex::add_order_to_list(THD *thd, Item *item, bool asc)
}
bool st_select_lex::add_gorder_to_list(THD *thd, Item *item, bool asc)
{
return add_to_list(thd, gorder_list, item, asc);
}
bool st_select_lex::add_item_to_list(THD *thd, Item *item)
{
DBUG_ENTER("st_select_lex::add_item_to_list");
......
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2013, 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
......@@ -727,7 +728,7 @@ public:
const char *type; /* type of select for EXPLAIN */
SQL_I_List<ORDER> order_list; /* ORDER clause */
SQL_I_List<ORDER> *gorder_list;
SQL_I_List<ORDER> gorder_list;
Item *select_limit, *offset_limit; /* LIMIT clause parameters */
// Arrays of pointers to top elements of all_fields list
Item **ref_pointer_array;
......@@ -850,6 +851,7 @@ public:
bool add_group_to_list(THD *thd, Item *item, bool asc);
bool add_ftfunc_to_list(Item_func_match *func);
bool add_order_to_list(THD *thd, Item *item, bool asc);
bool add_gorder_to_list(THD *thd, Item *item, bool asc);
TABLE_LIST* add_table_to_list(THD *thd, Table_ident *table,
LEX_STRING *alias,
ulong table_options,
......
......@@ -8981,6 +8981,7 @@ sum_expr:
if ($$ == NULL)
MYSQL_YYABORT;
$5->empty();
sel->gorder_list.empty();
}
;
......@@ -9050,18 +9051,27 @@ opt_gconcat_separator:
opt_gorder_clause:
/* empty */
| ORDER_SYM BY
{
Select->gorder_list = NULL;
}
| order_clause
{
SELECT_LEX *select= Select;
select->gorder_list= new (YYTHD->mem_root)
SQL_I_List<ORDER>(select->order_list);
if (select->gorder_list == NULL)
LEX *lex= Lex;
SELECT_LEX *sel= lex->current_select;
if (sel->linkage != GLOBAL_OPTIONS_TYPE &&
sel->olap != UNSPECIFIED_OLAP_TYPE &&
(sel->linkage != UNION_TYPE || sel->braces))
{
my_error(ER_WRONG_USAGE, MYF(0),
"CUBE/ROLLUP", "ORDER BY");
MYSQL_YYABORT;
select->order_list.empty();
}
}
gorder_list;
;
gorder_list:
gorder_list ',' order_ident order_dir
{ if (add_gorder_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; }
| order_ident order_dir
{ if (add_gorder_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; }
;
in_sum_expr:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment