summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2003-10-22 20:52:47 +0300
committerunknown <bell@sanja.is.com.ua>2003-10-22 20:52:47 +0300
commit47f3a4fd4aa4ac7f2944c85aa20333fa0259ac77 (patch)
tree094f3d63a932eeaa346520cc5605255beab9debe /sql/sql_lex.cc
parent9a4aa99769b29cb4084b3b16d2bfb7067d817d2c (diff)
parentb7aac7df29e716ab0bfd95e2c7349287912dcbf6 (diff)
downloadmariadb-git-47f3a4fd4aa4ac7f2944c85aa20333fa0259ac77.tar.gz
Merge
mysql-test/t/subselect.test: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_func.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/item_sum.cc: Auto merged sql/item_sum.h: Auto merged sql/item_timefunc.cc: Auto merged sql/item_timefunc.h: Auto merged sql/mysql_priv.h: Auto merged sql/sql_derived.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_yacc.yy: Auto merged mysql-test/r/subselect.result: SCCS 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 5b05bf096cb..ee9831c1f5b 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1454,7 +1454,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
*/