summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2003-10-28 12:45:37 +0200
committerunknown <bell@sanja.is.com.ua>2003-10-28 12:45:37 +0200
commit683dcaae6bfc101d352755f834ecda48f4ea4700 (patch)
tree1088bf30fb5febda5000cffc7db8982c9e5d1257 /sql/sql_lex.cc
parent87eb9ea2b10e5ae9d251444e9f3372b958f6a7ea (diff)
parent47f3a4fd4aa4ac7f2944c85aa20333fa0259ac77 (diff)
downloadmariadb-git-683dcaae6bfc101d352755f834ecda48f4ea4700.tar.gz
merge
sql/item.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_sum.cc: Auto merged sql/mysql_priv.h: Auto merged sql/sql_lex.cc: Auto merged sql/sql_parse.cc: Auto merged
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc66
1 files changed, 66 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 352a79843a9..ee0743d531e 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1471,7 +1471,73 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
order_group_num)* 5)) == 0;
}
+void st_select_lex_unit::print(String *str)
+{
+ for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
+ {
+ if (sl != first_select())
+ {
+ str->append(" union ");
+ if (union_option & UNION_ALL)
+ str->append("all ");
+ }
+ if (sl->braces)
+ str->append('(');
+ sl->print(thd, str);
+ if (sl->braces)
+ str->append(')');
+ }
+ if (fake_select_lex == global_parameters)
+ {
+ if (fake_select_lex->order_list.elements)
+ {
+ str->append(" order by ");
+ fake_select_lex->print_order(str,
+ (ORDER *) fake_select_lex->
+ order_list.first);
+ }
+ fake_select_lex->print_limit(thd, str);
+ }
+}
+
+
+void st_select_lex::print_order(String *str, ORDER *order)
+{
+ for (; order; order= order->next)
+ {
+ (*order->item)->print(str);
+ if (!order->asc)
+ str->append(" desc");
+ if (order->next)
+ str->append(',');
+ }
+}
+
+void st_select_lex::print_limit(THD *thd, String *str)
+{
+ if (!thd)
+ thd= current_thd;
+
+ if (select_limit != thd->variables.select_limit ||
+ select_limit != HA_POS_ERROR ||
+ offset_limit != 0L)
+ {
+ str->append(" limit ");
+ char buff[21];
+ snprintf(buff, 21, "%ld", select_limit);
+ str->append(buff);
+ if (offset_limit)
+ {
+ str->append(',');
+ snprintf(buff, 21, "%ld", offset_limit);
+ str->append(buff);
+ }
+ }
+}
+
/*
There are st_select_lex::add_table_to_list &
st_select_lex::set_lock_for_tables in sql_parse.cc
+
+ st_select_lex::print is in sql_select.h
*/