Commit ee2633a7 authored by unknown's avatar unknown
Browse files

olap.test:

  Added a test case for bug #8617.
sql_select.cc:
  Fixed bug #8617.
  Queries with ROLLUP and LIMIT n returned more than n rows
  if SQL_CALC_FOUND_ROWS was used.


sql/sql_select.cc:
  Fixed bug #8617.
  Queries with ROLLUP and LIMIT n returned more than n rows
  if SQL_CALC_FOUND_ROWS was used.
mysql-test/t/olap.test:
  Added a test case for bug #8617.
parent 39a0645a
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -379,3 +379,16 @@ a sum(b)
4	4
NULL	14
DROP TABLE t1;
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES
(1,4),
(2,2), (2,2),
(4,1), (4,1), (4,1), (4,1),
(2,1), (2,1);
SELECT a, SUM(b) FROM t1 GROUP BY a WITH ROLLUP LIMIT 1;
a	SUM(b)
1	4
SELECT SQL_CALC_FOUND_ROWS a, SUM(b) FROM t1 GROUP BY a WITH ROLLUP LIMIT 1;
a	SUM(b)
1	4
DROP TABLE t1;
+16 −0
Original line number Diff line number Diff line
@@ -155,3 +155,19 @@ SELECT DISTINCT a, sum(b) FROM t1 GROUP BY a,b WITH ROLLUP;

DROP TABLE t1;

#
# Tests for bugs #8617: SQL_CACL_FOUND_ROWS with rollup and limit 
#

CREATE TABLE t1 (a int, b int);

INSERT INTO t1 VALUES
  (1,4),
  (2,2), (2,2),
  (4,1), (4,1), (4,1), (4,1),
  (2,1), (2,1);

SELECT a, SUM(b) FROM t1 GROUP BY a WITH ROLLUP LIMIT 1;
SELECT SQL_CALC_FOUND_ROWS a, SUM(b) FROM t1 GROUP BY a WITH ROLLUP LIMIT 1;

DROP TABLE t1;
+1 −1
Original line number Diff line number Diff line
@@ -9210,7 +9210,7 @@ int JOIN::rollup_send_data(uint idx)
	   ref_pointer_array_size);
    if ((!having || having->val_int()))
    {
      if (send_records < unit->select_limit_cnt &&
      if (send_records < unit->select_limit_cnt && do_send_rows &&
	  result->send_data(rollup.fields[i]))
	return 1;
      send_records++;