diff options
author | bell@sanja.is.com.ua <> | 2003-07-03 02:30:52 +0300 |
---|---|---|
committer | bell@sanja.is.com.ua <> | 2003-07-03 02:30:52 +0300 |
commit | 28207ede0222a6b1ceff6f01b3f5bfccb7f73e42 (patch) | |
tree | baf496555ea973850414a91a38ffbb81729b0bc6 /sql/sql_union.cc | |
parent | 2ae8a00b2a0e4bc11fb70f0161be34f1573a2f55 (diff) | |
download | mariadb-git-28207ede0222a6b1ceff6f01b3f5bfccb7f73e42.tar.gz |
(SCRUM)
It looks like samll revolution in SELECT_LEX tree, but it was only natural way to solve problem with name resolution of external fields inside subselect which belongs to global order of union
also it have following advantages:
- removed mess with current_select type conversion
- type checking/converting
- a lot of virtual methods
- fake select for union execution allocated only once (it was allocated for every subselect with union executing)
changes:
fixed bug with outer fields name resolution of subqueries which belong to global ORDER BY clause
remuved select_lex() function, now thd->lex.current_select always have type SELECT_LEX
new SELECT_LEX (fake_select_lex) will be allocated in case of UNION for using in UNION processing
fake_select_lex allocated for union hold global ORDER BY & LIMIT clauses and have linkage equal to GLOBAL_OPTIONS_TYPE
new description of SELECT_LEX tree
(SCRUM)
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r-- | sql/sql_union.cc | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 79e1e9843a8..7c9e6f0a24e 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -115,7 +115,7 @@ bool select_union::flush() int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, bool tables_and_fields_initied) { - SELECT_LEX_NODE *lex_select_save= thd->lex.current_select; + SELECT_LEX *lex_select_save= thd->lex.current_select; SELECT_LEX *select_cursor; DBUG_ENTER("st_select_lex_unit::prepare"); @@ -241,7 +241,7 @@ err: int st_select_lex_unit::exec() { int do_print_slow= 0; - SELECT_LEX_NODE *lex_select_save= thd->lex.current_select; + SELECT_LEX *lex_select_save= thd->lex.current_select; SELECT_LEX *select_cursor=first_select_in_union(); DBUG_ENTER("st_select_lex_unit::exec"); @@ -318,8 +318,7 @@ int st_select_lex_unit::exec() /* Send result to 'result' */ - // to correct ORDER BY reference resolving - thd->lex.current_select= select_cursor; + res= -1; { List<Item_func_match> empty_list; @@ -327,8 +326,7 @@ int st_select_lex_unit::exec() if (!thd->is_fatal_error) // Check if EOM { - SELECT_LEX *fake_select = new SELECT_LEX(&thd->lex); - fake_select->fake_select= 1; + thd->lex.current_select= fake_select_lex; offset_limit_cnt= (select_cursor->braces ? global_parameters->offset_limit : 0); select_limit_cnt= (select_cursor->braces ? @@ -338,19 +336,19 @@ int st_select_lex_unit::exec() select_limit_cnt= HA_POS_ERROR; // no limit if (select_limit_cnt == HA_POS_ERROR) thd->options&= ~OPTION_FOUND_ROWS; - fake_select->ftfunc_list= &empty_list; - fake_select->table_list.link_in_list((byte *)&result_table_list, - (byte **)&result_table_list.next); - res= mysql_select(thd, &ref_pointer_array, &result_table_list, + fake_select_lex->ftfunc_list= &empty_list; + fake_select_lex->table_list.link_in_list((byte *)&result_table_list, + (byte **) + &result_table_list.next); + res= mysql_select(thd, &fake_select_lex->ref_pointer_array, + &result_table_list, 0, item_list, NULL, global_parameters->order_list.elements, (ORDER*)global_parameters->order_list.first, (ORDER*) NULL, NULL, (ORDER*) NULL, - thd->options, result, this, fake_select, 0); + thd->options, result, this, fake_select_lex, 0); if (found_rows_for_union && !res) thd->limit_found_rows = (ulonglong)table->file->records; - fake_select->exclude(); - delete fake_select; /* Mark for slow query log if any of the union parts didn't use indexes efficiently |