diff options
author | unknown <gkodinov/kgeorge@magare.gmz> | 2008-05-13 18:10:46 +0300 |
---|---|---|
committer | unknown <gkodinov/kgeorge@magare.gmz> | 2008-05-13 18:10:46 +0300 |
commit | 2cc7999b123187005d84a3dd6a78c83605be420a (patch) | |
tree | 1c3410d566b7bf8c2910ab4642c23200305af835 /sql/sql_class.h | |
parent | b6fdf4d9568fd07a60557604a732968ee7d584e5 (diff) | |
download | mariadb-git-2cc7999b123187005d84a3dd6a78c83605be420a.tar.gz |
Bug #32858: Erro: "Incorrect usage of UNION and INTO" does not take
subselects into account
It is forbidden to use the SELECT INTO construction inside UNION statements
unless on the last SELECT of the union. The parser records whether it
has seen INTO or not when parsing a UNION statement. But if the INTO was
legally used in an outer query, an error is thrown if UNION is seen in a
subquery. Fixed in 5.0 by remembering the nesting level of INTO tokens and
mitigate the error unless it collides with the UNION.
mysql-test/r/union.result:
Bug#32858: Test result
mysql-test/t/union.test:
Bug#32858: Test case
sql/sql_class.cc:
Bug#32858: Initializing new member
sql/sql_class.h:
Bug#32858: Added property nest_level to select_result class.
sql/sql_yacc.yy:
Bug#32858: The fix.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 5b9ef7f381d..446b7f163d9 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2193,6 +2193,7 @@ class select_result :public Sql_alloc { protected: THD *thd; SELECT_LEX_UNIT *unit; + uint nest_level; public: select_result(); virtual ~select_result() {}; @@ -2229,6 +2230,12 @@ public: */ virtual void cleanup(); void set_thd(THD *thd_arg) { thd= thd_arg; } + /** + The nest level, if supported. + @return + -1 if nest level is undefined, otherwise a positive integer. + */ + int get_nest_level() { return nest_level; } #ifdef EMBEDDED_LIBRARY virtual void begin_dataset() {} #else @@ -2322,6 +2329,14 @@ class select_export :public select_to_file { bool fixed_row_size; public: select_export(sql_exchange *ex) :select_to_file(ex) {} + /** + Creates a select_export to represent INTO OUTFILE <filename> with a + defined level of subquery nesting. + */ + select_export(sql_exchange *ex, uint nest_level_arg) :select_to_file(ex) + { + nest_level= nest_level_arg; + } ~select_export(); int prepare(List<Item> &list, SELECT_LEX_UNIT *u); bool send_data(List<Item> &items); @@ -2331,6 +2346,15 @@ public: class select_dump :public select_to_file { public: select_dump(sql_exchange *ex) :select_to_file(ex) {} + /** + Creates a select_export to represent INTO DUMPFILE <filename> with a + defined level of subquery nesting. + */ + select_dump(sql_exchange *ex, uint nest_level_arg) : + select_to_file(ex) + { + nest_level= nest_level_arg; + } int prepare(List<Item> &list, SELECT_LEX_UNIT *u); bool send_data(List<Item> &items); }; @@ -2763,6 +2787,16 @@ class select_dumpvar :public select_result_interceptor { public: List<my_var> var_list; select_dumpvar() { var_list.empty(); row_count= 0;} + /** + Creates a select_dumpvar to represent INTO <variable> with a defined + level of subquery nesting. + */ + select_dumpvar(uint nest_level_arg) + { + var_list.empty(); + row_count= 0; + nest_level= nest_level_arg; + } ~select_dumpvar() {} int prepare(List<Item> &list, SELECT_LEX_UNIT *u); bool send_data(List<Item> &items); |