unknown
213476ef3e
Fix for bug lp:992405
...
The patch backports two patches from mysql 5.6:
- BUG#12640437: USING SQL_BUFFER_RESULT RESULTS IN A DIFFERENT QUERY OUTPUT
- Bug#12578908: SELECT SQL_BUFFER_RESULT OUTPUTS TOO MANY ROWS WHEN GROUP IS OPTIMIZED AWAY
Original comment:
-----------------
3714 Jorgen Loland 2012-03-01
BUG#12640437 - USING SQL_BUFFER_RESULT RESULTS IN A DIFFERENT
QUERY OUTPUT
For all but simple grouped queries, temporary tables are used to
resolve grouping. In these cases, the list of grouping fields is
stored in the temporary table and grouping is resolved
there (e.g. by adding a unique constraint on the involved
fields). Because of this, grouping is already done when the rows
are read from the temporary table.
In the case where a group clause may be optimized away, grouping
does not have to be resolved using a temporary table. However, if
a temporary table is explicitly requested (e.g. because the
SQL_BUFFER_RESULT hint is used, or the statement is
INSERT...SELECT), a temporary table is used anyway. In this case,
the temporary table is created with an empty group list (because
the group clause was optimized away) and it will therefore not
create groups. Since the temporary table does not take care of
grouping, JOIN::group shall not be set to false in
make_simple_join(). This was fixed in bug 12578908.
However, there is an exception where make_simple_join() should
set JOIN::group to false even if the query uses a temporary table
that was explicitly requested but is not strictly needed. That
exception is if the loose index scan access method (explain
says "Using index for group-by") is used to read into the
temporary table. With loose index scan, grouping is resolved
by the access method. This is exactly what happens in this bug.
2012-05-07 11:02:58 +03:00
..
2009-08-25 15:56:50 +02:00
2010-09-15 15:48:15 +03:00
2010-05-24 21:54:08 +08:00
2011-11-21 19:13:14 +02:00
2011-04-14 12:11:57 +04:00
2011-05-18 14:01:43 +04:00
2012-02-20 16:23:18 +02:00
2011-01-04 14:36:37 +01:00
2010-02-09 11:30:50 +01:00
2010-02-25 23:13:11 +04:00
2010-05-28 00:07:40 +04:00
2010-02-02 14:17:21 +02:00
2010-04-22 15:52:00 +02:00
2009-09-18 16:01:18 +03:00
2010-01-15 17:27:55 +02:00
2009-10-27 12:09:19 +04:00
2011-04-07 14:44:26 +03:00
2011-02-28 19:39:30 +02:00
2011-01-14 19:50:34 +05:30
2011-01-28 12:09:15 +00:00
2010-03-09 07:36:26 -03:00
2009-05-15 12:15:56 +02:00
2009-05-15 12:15:56 +02:00
2011-02-28 19:39:30 +02:00
2009-05-11 20:54:00 -03:00
2009-12-22 13:52:23 +04:00
2010-05-24 21:54:08 +08:00
2009-12-27 15:54:41 +02:00
2011-05-11 14:09:48 +03:00
2011-01-25 12:14:28 +05:30
2012-04-04 00:14:07 +03:00
2009-05-31 13:44:41 +08:00
2011-03-30 14:33:53 +02:00
2011-02-17 12:43:53 +01:00
2011-02-17 12:43:53 +01:00
2011-02-17 12:43:53 +01:00
2009-07-24 11:27:23 +05:00
2009-09-30 08:35:31 +02:00
2010-11-18 11:53:08 +03:00
2010-03-22 16:27:59 +04:00
2011-01-17 15:11:33 +03:00
2009-08-10 15:46:20 -03:00
2011-03-03 18:39:26 +03:00
2009-11-30 14:42:24 +02:00
2011-05-02 20:58:45 +03:00
2010-11-11 13:25:23 +03:00
2012-04-05 10:49:38 +02:00
2010-11-12 13:12:15 +03:00
2011-02-22 19:28:50 +05:30
2011-02-22 19:28:50 +05:30
2009-09-29 17:38:40 +02:00
2010-02-17 16:13:42 +04:00
2010-01-15 17:27:55 +02:00
2010-08-31 02:16:38 +04:00
2010-12-14 12:33:03 +03:00
2009-09-06 00:42:17 +04:00
2010-09-03 19:20:30 +03:00
2011-10-05 13:28:20 +04:00
2011-05-04 16:59:24 +04:00
2011-11-24 18:48:58 +02:00
2011-05-04 16:59:24 +04:00
2010-05-19 11:18:59 +02:00
2009-08-03 22:09:53 +02:00
2011-11-24 18:48:58 +02:00
2010-05-24 21:54:08 +08:00
2010-03-10 15:39:02 +02:00
2009-12-22 17:52:15 +02:00
2010-11-25 00:57:34 +02:00
2009-06-19 11:27:19 +02:00
2010-04-03 00:30:22 +04:00
2009-06-01 16:00:38 +04:00
2011-03-03 15:04:04 +03:00
2010-12-14 23:52:53 +03:00
2012-05-03 14:49:52 +03:00
2012-03-08 22:33:01 -08:00
2011-04-12 13:51:36 +04:00
2010-06-08 10:22:40 +04:00
2011-01-17 12:30:22 +03:00
2011-05-26 14:06:39 +04:00
2010-11-25 00:57:34 +02:00
2010-08-13 16:05:46 +03:00
2009-06-16 16:36:15 +02:00
2011-01-13 08:57:15 +01:00
2012-05-02 22:00:31 +02:00
2011-11-21 19:13:14 +02:00
2011-11-30 18:44:51 +02:00
2010-03-29 17:13:53 +02:00
2010-10-18 21:03:53 +07:00
2009-05-15 12:15:56 +02:00
2009-05-15 12:15:56 +02:00
2009-10-27 12:09:19 +04:00
2011-05-03 19:10:10 +03:00
2012-05-07 11:02:58 +03:00
2011-12-12 12:36:46 +02:00
2009-05-05 17:03:23 -04:00
2009-09-29 17:38:40 +02:00
2009-10-05 15:22:23 +02:00
2012-02-25 09:03:06 +02:00
2009-05-06 15:00:14 +05:30
2011-09-27 17:38:51 +05:30
2011-05-14 21:44:49 +05:30
2011-11-23 10:25:27 +02:00
2012-01-13 19:00:50 -08:00
2010-09-11 20:43:48 +02:00
2010-11-29 18:51:46 -06:00
2010-11-29 18:51:46 -06:00
2012-01-02 06:25:48 +00:00
2010-12-19 18:07:28 +01:00
2010-04-12 14:56:24 +03:00
2010-04-12 14:56:24 +03:00
2010-04-12 14:56:24 +03:00
2010-01-15 16:58:25 +01:00
2009-06-09 15:19:13 +02:00
2009-06-09 15:19:13 +02:00
2009-06-09 15:19:13 +02:00
2010-01-15 16:58:25 +01:00
2010-01-15 16:58:25 +01:00
2010-01-15 16:58:25 +01:00
2010-06-10 11:11:52 +02:00
2009-06-09 15:19:13 +02:00
2010-05-28 00:07:40 +04:00
2010-04-12 14:56:24 +03:00
2009-12-27 15:54:41 +02:00
2009-06-09 15:19:13 +02:00
2010-01-15 16:58:25 +01:00
2009-06-09 15:19:13 +02:00
2010-04-12 14:56:24 +03:00
2010-04-12 14:56:24 +03:00
2010-04-12 14:56:24 +03:00
2010-01-18 13:56:10 +01:00
2010-08-04 10:39:53 +02:00
2011-02-16 21:43:12 +01:00
2010-10-19 15:58:35 +02:00
2010-09-12 21:25:57 -07:00
2012-02-22 00:10:39 -08:00
2012-04-05 10:49:38 +02:00
2012-02-22 00:10:39 -08:00
2012-02-20 17:49:21 +02:00
2009-06-07 13:05:19 +03:00
2011-05-05 12:10:49 +03:00
2009-10-19 13:44:44 +05:00
2009-08-28 18:49:16 -03:00
2009-08-28 18:49:16 -03:00
2011-01-10 23:22:40 +02:00
2011-03-29 10:09:05 +02:00
2011-06-06 16:39:06 +03:00
2009-10-19 20:14:48 +03:00
2010-05-12 13:19:12 +02:00
2009-06-15 20:27:27 -03:00
2010-09-06 02:15:34 +03:00
2011-02-28 19:39:30 +02:00
2009-10-27 12:09:19 +04:00
2009-09-09 14:38:50 +05:00
2011-04-04 16:04:15 +03:00
2009-08-28 16:13:27 +02:00
2010-10-19 12:27:09 +02:00
2010-06-25 15:59:44 +03:00
2010-11-02 17:22:57 +02:00
2009-10-03 21:12:24 +02:00
2011-11-21 19:13:14 +02:00
2010-03-12 10:33:16 +04:00
2010-12-14 12:33:03 +03:00
2009-10-14 16:26:16 +05:00
2009-10-28 09:52:34 +02:00
2012-04-05 12:01:52 +02:00
2011-09-16 15:30:31 +04:00
2010-07-30 09:17:10 -03:00
2010-09-06 02:15:34 +03:00
2009-06-25 02:44:14 +04:00
2009-06-10 11:24:47 +04:00
2010-12-01 12:25:31 +05:30
2011-01-16 02:04:08 +05:30
2011-05-05 23:48:15 +01:00
2011-01-12 19:32:45 +00:00
2010-03-22 13:10:18 +01:00
2009-08-27 10:32:27 +01:00
2009-09-30 08:35:31 +02:00
2011-01-13 13:28:36 +01:00
2011-03-25 15:16:13 +01:00
2012-02-20 17:49:21 +02:00
2009-10-02 14:09:01 +03:00
2010-12-19 18:07:28 +01:00
2012-04-05 12:01:52 +02:00
2010-06-03 10:31:26 +02:00
2010-06-03 10:31:26 +02:00
2011-05-02 20:58:45 +03:00
2009-10-09 10:09:24 +02:00
2011-11-24 18:48:58 +02:00
2011-07-21 12:29:00 +03:00
2010-02-05 17:51:55 +00:00
2011-02-04 10:47:46 +06:00
2010-09-05 13:52:33 +03:00
2009-06-05 18:36:14 +03:00
2009-09-25 11:26:49 +02:00
2009-11-06 17:54:19 +03:00
2010-06-14 01:13:32 +03:00
2012-01-05 11:06:52 +02:00
2010-05-07 00:41:37 +04:00
2011-03-25 12:57:27 +02:00
2009-05-20 17:04:44 -07:00
2010-11-24 18:51:31 +01:00
2009-12-13 23:29:50 +03:00
2009-09-03 08:38:06 +02:00
2010-02-01 16:07:00 +01:00
2011-06-11 14:53:08 +03:00
2010-05-11 16:49:23 +02:00
2010-08-27 10:43:51 +02:00
2009-09-25 11:26:49 +02:00
2011-10-12 14:34:44 +03:00
2010-12-08 14:34:08 +01:00
2012-04-04 00:14:07 +03:00
2011-04-27 17:51:06 +02:00
2010-07-08 14:36:55 +02:00
2009-10-08 15:36:43 +02:00
2010-08-26 17:14:18 +02:00
2010-08-27 10:43:51 +02:00
2009-07-27 16:50:43 +05:30
2012-01-27 11:13:13 +01:00
2011-06-21 17:40:51 +02:00
2010-06-16 19:01:22 +02:00
2010-12-01 13:54:50 +01:00
2010-12-31 10:39:14 +01:00
2009-09-08 00:50:10 +04:00
2010-11-23 23:39:59 +02:00
2010-11-23 23:39:59 +02:00
2010-11-23 23:39:59 +02:00
2010-11-23 23:39:59 +02:00
2011-12-27 13:19:13 -08:00
2010-10-27 10:41:45 +02:00
2009-10-27 14:09:36 +04:00
2010-11-30 23:11:03 +02:00
2009-06-17 16:28:11 +02:00
2010-01-11 14:15:28 +01:00
2010-03-24 17:37:41 +01:00
2010-01-11 14:15:28 +01:00
2012-04-05 12:01:52 +02:00
2009-10-11 11:06:55 +02:00
2010-05-21 22:47:32 +04:00
2009-06-09 17:08:46 +02:00
2009-06-09 17:08:46 +02:00
2010-09-09 16:46:13 +04:00
2011-11-23 10:25:27 +02:00
2010-06-26 19:36:00 +02:00
2011-05-04 15:47:29 +03:00
2012-02-22 00:10:39 -08:00
2011-09-28 15:39:21 +05:30
2012-02-22 00:10:39 -08:00
2011-03-28 13:32:25 +03:00
2011-11-23 19:32:14 +02:00
2010-03-31 16:12:37 +03:00
2010-06-01 21:52:20 +02:00
2011-06-23 20:41:04 +07:00
2010-05-24 21:54:08 +08:00
2011-07-12 06:08:52 +01:00
2012-01-30 11:57:33 +05:30
2011-05-02 20:58:45 +03:00
2011-06-09 23:30:52 +07:00
2009-07-03 10:19:32 +02:00
2011-04-13 09:57:16 +02:00
2009-12-02 15:17:08 +04:00
2012-04-05 12:01:52 +02:00
2009-06-12 18:11:19 -03:00
2011-03-11 16:16:34 +05:30
2010-07-19 21:08:06 +03:00
2009-06-10 11:58:36 +03:00
2010-04-28 14:52:24 +02:00
2011-02-20 18:51:43 +02:00
2012-01-20 23:54:43 -08:00
2011-12-28 18:47:01 -08:00
2010-04-01 18:49:02 +04:00
2010-04-08 14:10:05 +02:00
2009-10-29 20:50:33 +03:00
2011-11-01 12:36:43 +04:00
2010-12-31 10:39:14 +01:00
2010-08-06 23:29:37 +04:00
2010-11-23 23:39:59 +02:00
2011-06-10 10:52:39 +07:00
2011-11-24 18:48:58 +02:00
2011-11-23 10:25:27 +02:00
2010-02-16 13:13:49 +04:00
2010-10-31 19:04:38 +03:00
2012-05-02 16:53:02 +02:00
2011-01-19 15:09:32 +01:00
2011-07-18 09:08:19 +02:00
2011-10-14 10:44:27 +02:00
2010-05-31 13:25:11 +04:00
2011-04-18 10:44:41 +02:00
2011-01-12 10:37:15 +01:00
2010-11-02 17:22:57 +02:00
2011-02-09 10:50:09 +01:00
2011-11-23 19:32:14 +02:00
2010-07-19 11:03:52 +02:00
2011-05-11 14:09:48 +03:00
2010-12-06 23:38:31 +03:00
2010-02-11 14:26:58 +01:00
2009-10-03 22:56:54 +04:00
2010-09-22 23:33:18 +04:00
2010-11-15 16:17:38 +01:00
2011-12-01 22:37:45 +01:00
2011-09-13 18:46:47 +03:00
2010-03-09 07:36:26 -03:00
2011-09-29 10:56:21 +01:00
2012-02-03 12:24:55 +02:00
2010-11-03 22:40:53 +01:00
2010-08-17 11:14:46 +04:00
2010-04-28 14:52:24 +02:00
2009-09-22 08:22:07 -03:00
2010-03-10 19:31:22 +04:00
2011-03-01 15:30:18 +03:00