Loading Docs/manual.texi +4 −0 Original line number Diff line number Diff line Loading @@ -48946,6 +48946,10 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. @itemize @bullet @item fixed that SQL_CALC_FOUND_ROWS works with UNIONs. It will work only if first select has this option and if there is global LIMIT for entire select. For the moment this requires using braces for individual select's. @item Don't give an error for @code{CREATE TABLE ...(... VARCHAR(0))}. @item Fixed @code{SIGINT} and @code{SIGQUIT} problems in @file{mysql.cc} on Linux mysql-test/r/union.result +7 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,13 @@ table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 4 t2 ALL NULL NULL NULL NULL 4 Using filesort t1 ALL NULL NULL NULL NULL 4 (select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2; a b 1 a 2 b select found_rows(); FOUND_ROWS() 6 explain select a,b from t1 union all select a,b from t2; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 4 Loading mysql-test/t/union.test +2 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,8 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1); (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; (select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2; select found_rows(); # Test some error conditions with UNION explain select a,b from t1 union all select a,b from t2; Loading sql/sql_union.cc +4 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) TABLE *table; int describe=(lex->select_lex.options & SELECT_DESCRIBE) ? 1 : 0; int res; bool fr=false; TABLE_LIST result_table_list; TABLE_LIST *first_table=(TABLE_LIST *)lex->select_lex.table_list.first; TMP_TABLE_PARAM tmp_table_param; Loading Loading @@ -60,6 +61,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) */ lex_sl= sl; order= (ORDER *) lex_sl->order_list.first; fr = lex->select_lex.options & OPTION_FOUND_ROWS && !describe && sl->select_limit && sl->select_limit != HA_POS_ERROR; if (!order || !describe) last_sl->next=0; // Remove this extra element } Loading Loading @@ -198,6 +200,8 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) item_list, NULL, (describe) ? 0 : order, (ORDER*) NULL, NULL, (ORDER*) NULL, thd->options, result); if (fr && !res) thd->limit_found_rows = (ulonglong)table->file->records; } } Loading Loading
Docs/manual.texi +4 −0 Original line number Diff line number Diff line Loading @@ -48946,6 +48946,10 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. @itemize @bullet @item fixed that SQL_CALC_FOUND_ROWS works with UNIONs. It will work only if first select has this option and if there is global LIMIT for entire select. For the moment this requires using braces for individual select's. @item Don't give an error for @code{CREATE TABLE ...(... VARCHAR(0))}. @item Fixed @code{SIGINT} and @code{SIGQUIT} problems in @file{mysql.cc} on Linux
mysql-test/r/union.result +7 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,13 @@ table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 4 t2 ALL NULL NULL NULL NULL 4 Using filesort t1 ALL NULL NULL NULL NULL 4 (select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2; a b 1 a 2 b select found_rows(); FOUND_ROWS() 6 explain select a,b from t1 union all select a,b from t2; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 4 Loading
mysql-test/t/union.test +2 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,8 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1); (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; (select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2; select found_rows(); # Test some error conditions with UNION explain select a,b from t1 union all select a,b from t2; Loading
sql/sql_union.cc +4 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) TABLE *table; int describe=(lex->select_lex.options & SELECT_DESCRIBE) ? 1 : 0; int res; bool fr=false; TABLE_LIST result_table_list; TABLE_LIST *first_table=(TABLE_LIST *)lex->select_lex.table_list.first; TMP_TABLE_PARAM tmp_table_param; Loading Loading @@ -60,6 +61,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) */ lex_sl= sl; order= (ORDER *) lex_sl->order_list.first; fr = lex->select_lex.options & OPTION_FOUND_ROWS && !describe && sl->select_limit && sl->select_limit != HA_POS_ERROR; if (!order || !describe) last_sl->next=0; // Remove this extra element } Loading Loading @@ -198,6 +200,8 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) item_list, NULL, (describe) ? 0 : order, (ORDER*) NULL, NULL, (ORDER*) NULL, thd->options, result); if (fr && !res) thd->limit_found_rows = (ulonglong)table->file->records; } } Loading