diff options
author | unknown <monty@hundin.mysql.fi> | 2001-12-13 02:31:19 +0200 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2001-12-13 02:31:19 +0200 |
commit | 33a096829b0f2a294b162e11ad81df788732c384 (patch) | |
tree | 47a4c1a60e94a3e70ea5564124a296f7cd71605e /sql/sql_union.cc | |
parent | f0f71accfc2b6fcc6dfeaa1ac4b8b73d071ff3a1 (diff) | |
download | mariadb-git-33a096829b0f2a294b162e11ad81df788732c384.tar.gz |
Fixed sleep time in mysql-test-run
Fixed bug in query cache.
Cleaned up des_crypt code.
BitKeeper/deleted/.del-fsck.mysql~87170d4358b50d60:
Delete: fs/fsck.mysql
Docs/manual.texi:
Changed != to <>
mysql-test/mysql-test-run.sh:
Fix sleep times to take into account creation of InnoDB tables.
mysql-test/r/group_by.result:
More tests
mysql-test/r/query_cache.result:
More tests
mysql-test/r/union.result:
More tests
mysql-test/t/func_str.test:
Fix for FreeBSD
mysql-test/t/query_cache.test:
More tests
mysql-test/t/union.test:
More tests
mysys/my_winsem.c:
Cleanup comments
sql/des_key_file.cc:
Cleanup des_crypt code
sql/item_strfunc.cc:
Cleanup des_crypt code
sql/item_strfunc.h:
Cleanup des_crypt code
sql/mysql_priv.h:
Cleanup des_crypt code
sql/mysqld.cc:
Cleanup des_crypt code
sql/sql_acl.cc:
For for GRANT and lower-case-table names
sql/sql_cache.cc:
Function for integrity checking.
Fixed bug when merging blocks.
sql/sql_cache.h:
Function for integrity checking.
sql/sql_delete.cc:
Cleanup
sql/sql_parse.cc:
For for GRANT and lower-case-table names
sql/sql_union.cc:
Cleanup & fixed bug in LIMIT handling
sql/sql_yacc.yy:
C
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r-- | sql/sql_union.cc | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc index b2ffb97fa81..0d8a41e9966 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -27,7 +27,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) { - SELECT_LEX *sl, *last_sl=(SELECT_LEX *)NULL, lex_sl; + SELECT_LEX *sl, *last_sl, *lex_sl; ORDER *order; List<Item> item_list; TABLE *table; @@ -38,7 +38,10 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) DBUG_ENTER("mysql_union"); /* Fix tables 'to-be-unioned-from' list to point at opened tables */ - for (sl=&lex->select_lex; sl && sl->linkage != NOT_A_SELECT; last_sl=sl, sl=sl->next) + last_sl= &lex->select_lex; + for (sl= last_sl; + sl && sl->linkage != NOT_A_SELECT; + last_sl=sl, sl=sl->next) { for (TABLE_LIST *cursor= (TABLE_LIST *)sl->table_list.first; cursor; @@ -46,19 +49,27 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) cursor->table= ((TABLE_LIST*) cursor->table)->table; } + /* last_sel now points at the last select where the ORDER BY is stored */ if (sl) { - lex_sl=*sl; - sl=(SELECT_LEX *)NULL; - if (last_sl) last_sl->next=sl; + /* + The found SL is an extra SELECT_LEX argument that contains + the ORDER BY and LIMIT parameter for the whole UNION + */ + lex_sl= sl; + last_sl->next=0; // Remove this extra element + order= (ORDER *) lex_sl->order_list.first; + } + else if (!last_sl->braces) + { + lex_sl= last_sl; // ORDER BY is here + order= (ORDER *) lex_sl->order_list.first; } else - lex_sl.linkage=UNSPECIFIED_TYPE; - - /* Find last select part as it's here ORDER BY and GROUP BY is stored */ - for (last_sl= &lex->select_lex; - last_sl->next; - last_sl=last_sl->next) ; + { + lex_sl=0; + order=0; + } if (lex->select_lex.options & SELECT_DESCRIBE) { @@ -68,7 +79,8 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) res=mysql_select(thd, (TABLE_LIST*) sl->table_list.first, sl->item_list, sl->where, - (sl->braces) ? (ORDER *) sl->order_list.first : (ORDER *) 0, + ((sl->braces) ? + (ORDER *) sl->order_list.first : (ORDER *) 0), (ORDER*) sl->group_list.first, sl->having, (ORDER*) NULL, @@ -79,8 +91,6 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) DBUG_RETURN(0); } - order = (lex_sl.linkage == UNSPECIFIED_TYPE) ? ( (last_sl->braces) ? (ORDER *) 0 : (ORDER *) last_sl->order_list.first) : (ORDER *) lex_sl.order_list.first; - { Item *item; List_iterator<Item> it(lex->select_lex.item_list); @@ -162,11 +172,11 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) } if (!thd->fatal_error) // Check if EOM { - if (lex_sl.linkage == NOT_A_SELECT && ( lex_sl.select_limit || lex_sl.offset_limit)) + if (lex_sl) { - thd->offset_limit=lex_sl.offset_limit; - thd->select_limit=lex_sl.select_limit+lex_sl.offset_limit; - if (thd->select_limit < lex_sl.select_limit) + thd->offset_limit=lex_sl->offset_limit; + thd->select_limit=lex_sl->select_limit+lex_sl->offset_limit; + if (thd->select_limit < lex_sl->select_limit) thd->select_limit= HA_POS_ERROR; // no limit if (thd->select_limit == HA_POS_ERROR) thd->options&= ~OPTION_FOUND_ROWS; |