diff options
author | monty@narttu.mysql.fi <> | 2003-08-26 20:23:48 +0300 |
---|---|---|
committer | monty@narttu.mysql.fi <> | 2003-08-26 20:23:48 +0300 |
commit | 1d0b539263dc18e742cca84dac56916f29290dad (patch) | |
tree | cce35b98c6515a9259db42814c404cbc8e07856b | |
parent | 7b9941298835c172e9f24adbf0f33b2958cdf987 (diff) | |
download | mariadb-git-1d0b539263dc18e742cca84dac56916f29290dad.tar.gz |
Fix for bug in ROLLUP when all tables where 'const' tables (Bug #714)
-rw-r--r-- | mysql-test/r/olap.result | 15 | ||||
-rw-r--r-- | mysql-test/t/olap.test | 11 | ||||
-rw-r--r-- | sql-common/client.c | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 25 |
4 files changed, 42 insertions, 11 deletions
diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 0b7a98e3fb3..84e37bf56a9 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -254,3 +254,18 @@ ERROR 42000: This version of MySQL doesn't yet support 'CUBE' select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube union all select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup; ERROR 42000: This version of MySQL doesn't yet support 'CUBE' drop table t1,t2; +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES(100); +CREATE TABLE t2 (i int); +INSERT INTO t2 VALUES (100),(200); +SELECT i, COUNT(*) FROM t1 GROUP BY i WITH ROLLUP; +i COUNT(*) +100 1 +NULL 1 +SELECT t1.i, t2.i, COUNT(*) FROM t1,t2 GROUP BY t1.i,t2.i WITH ROLLUP; +i i COUNT(*) +100 100 1 +100 200 1 +100 NULL 2 +NULL NULL 2 +drop table t1,t2; diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 3b1e3fac7c2..17bf6230f76 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -77,3 +77,14 @@ select product, country_id , year, sum(profit) from t1 group by product, country drop table t1,t2; +# +# Test bug with const tables +# + +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES(100); +CREATE TABLE t2 (i int); +INSERT INTO t2 VALUES (100),(200); +SELECT i, COUNT(*) FROM t1 GROUP BY i WITH ROLLUP; +SELECT t1.i, t2.i, COUNT(*) FROM t1,t2 GROUP BY t1.i,t2.i WITH ROLLUP; +drop table t1,t2; diff --git a/sql-common/client.c b/sql-common/client.c index 222f0bf0288..25b18c27d8a 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -587,7 +587,7 @@ net_safe_read(MYSQL *mysql) DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d", vio_description(net->vio),len)); #ifdef MYSQL_SERVER - if (socket_errno == SOCKET_EINTR) + if (vio_errno(net->vio) == SOCKET_EINTR) return (packet_error); #endif /*MYSQL_SERVER*/ end_server(mysql); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 15d6b3954ff..412e891bad1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -117,10 +117,8 @@ static Item* part_of_refkey(TABLE *form,Field *field); static uint find_shortest_key(TABLE *table, key_map usable_keys); static bool test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order, ha_rows select_limit, bool no_changes); -static int create_sort_index(THD *thd, JOIN_TAB *tab,ORDER *order, +static int create_sort_index(THD *thd, JOIN *join, ORDER *order, ha_rows filesort_limit, ha_rows select_limit); -static int create_sort_index(THD *thd, JOIN_TAB *tab,ORDER *order, - ha_rows select_limit); static int remove_duplicates(JOIN *join,TABLE *entry,List<Item> &fields, Item *having); static int remove_dup_with_compare(THD *thd, TABLE *entry, Field **field, @@ -916,7 +914,7 @@ JOIN::optimize() { DBUG_PRINT("info",("Sorting for group")); thd->proc_info="Sorting for group"; - if (create_sort_index(thd, &join_tab[const_tables], group_list, + if (create_sort_index(thd, this, group_list, HA_POS_ERROR, HA_POS_ERROR) || alloc_group_fields(this, group_list) || make_sum_func_list(all_fields, fields_list, 1)) @@ -931,7 +929,7 @@ JOIN::optimize() { DBUG_PRINT("info",("Sorting for order")); thd->proc_info="Sorting for order"; - if (create_sort_index(thd, &join_tab[const_tables], order, + if (create_sort_index(thd, this, order, HA_POS_ERROR, HA_POS_ERROR)) DBUG_RETURN(1); order=0; @@ -1235,7 +1233,7 @@ JOIN::exec() if (curr_join->group_list) { thd->proc_info= "Creating sort index"; - if (create_sort_index(thd, curr_join->join_tab, curr_join->group_list, + if (create_sort_index(thd, curr_join, curr_join->group_list, HA_POS_ERROR, HA_POS_ERROR) || make_group_fields(this, curr_join)) { @@ -1416,7 +1414,7 @@ JOIN::exec() } } } - if (create_sort_index(thd, &curr_join->join_tab[curr_join->const_tables], + if (create_sort_index(thd, curr_join, curr_join->group_list ? curr_join->group_list : curr_join->order, curr_join->select_limit, unit->select_limit_cnt)) @@ -6770,16 +6768,23 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, */ static int -create_sort_index(THD *thd, JOIN_TAB *tab, ORDER *order, +create_sort_index(THD *thd, JOIN *join, ORDER *order, ha_rows filesort_limit, ha_rows select_limit) { SORT_FIELD *sortorder; uint length; ha_rows examined_rows; - TABLE *table=tab->table; - SQL_SELECT *select=tab->select; + TABLE *table; + SQL_SELECT *select; + JOIN_TAB *tab; DBUG_ENTER("create_sort_index"); + if (join->tables == join->const_tables) + DBUG_RETURN(0); // One row, no need to sort + tab= join->join_tab + join->const_tables; + table= tab->table; + select= tab->select; + if (test_if_skip_sort_order(tab,order,select_limit,0)) DBUG_RETURN(0); if (!(sortorder=make_unireg_sortorder(order,&length))) |