Monty
16258677b3
MDEV-6768 Wrong result with aggregate with join with no result set
...
When a query does implicit grouping and join operation produces an empty
result set, a NULL-complemented row combination is generated.
However, constant table fields still show non-NULL values.
What happens in the is that end_send_group() is called with a
const row but without any rows matching the WHERE clause.
This last part is shown by 'join->first_record' not being set.
This causes item->no_rows_in_result() to be called for all items to reset
all sum functions to their initial state. However fields are not set
to NULL.
The used fix is to produce NULL-complemented records for constant tables
as well. Also, reset the constant table's records back in case we're
in a subquery which may get re-executed.
An alternative fix would have item->no_rows_in_result() also work
with Item_field objects.
There is some other issues with the code:
- join->no_rows_in_result_called is used but never set.
- Tables that are used with group functions are not properly marked as
maybe_null, which is required if the table rows should be regarded as
null-complemented (not existing).
- The code that tries to detect if mixed_implicit_grouping should be set
didn't take into account all usage of fields and sum functions.
- Item_func::restore_to_before_no_rows_in_result() called the wrong
function.
- join->clear() does not use a table_map argument to clear_tables(),
which caused it to ignore constant tables.
- unclear_tables() does not correctly restore status to what is
was before clear_tables().
Main bug fix was to always use a table_map argument to clear_tables() and
always use join->clear() and clear_tables() together with unclear_tables().
Other fixes:
- Fixed Item_func::restore_to_before_no_rows_in_result()
- Set 'join->no_rows_in_result_called' when no_rows_in_result_set()
is called.
- Removed not used argument from setup_end_select_func().
- More code comments
- Ensure that end_send_group() modifies the same fields as are in the
result set.
- Changed return_zero_rows() to use pointers instead of references,
similar to the rest of the code.
Reviewer: Sergei Petrunia <sergey@mariadb.com >
2023-05-22 17:15:46 +03:00
..
2023-02-10 12:02:11 +02:00
2020-04-08 14:51:14 +04:00
2022-09-05 13:28:56 +03:00
2023-01-27 13:54:14 +01:00
2020-08-03 14:44:06 +02:00
2021-04-20 12:30:09 +03:00
2022-03-23 10:47:27 +11:00
2021-02-15 16:43:15 +01:00
2022-03-14 09:28:55 +02:00
2020-07-04 01:44:46 +02:00
2023-04-03 09:34:26 +02:00
2020-06-10 07:43:18 +03:00
2022-12-12 11:24:07 +11:00
2023-02-09 16:09:08 +02:00
2020-08-04 17:24:15 +02:00
2022-03-14 09:28:55 +02:00
2023-01-27 13:54:14 +01:00
2020-08-03 14:44:06 +02:00
2023-02-10 12:02:11 +02:00
2021-04-22 08:25:40 +03:00
2022-04-21 15:33:50 +03:00
2023-02-09 16:09:08 +02:00
2020-08-03 14:44:06 +02:00
2022-09-26 13:34:38 +03:00
2021-06-21 14:22:22 +03:00
2022-09-05 13:28:56 +03:00
2020-08-03 14:44:06 +02:00
2023-04-05 16:16:19 +04:00
2023-04-05 16:16:19 +04:00
2020-07-15 14:51:22 +03:00
2023-02-10 12:02:11 +02:00
2023-03-31 21:32:41 +02:00
2022-09-26 13:34:38 +03:00
2023-02-09 16:09:08 +02:00
2022-05-15 20:37:51 +02:00
2022-05-15 20:37:51 +02:00
2021-05-27 00:40:23 +02:00
2021-04-22 15:51:55 +02:00
2021-09-22 07:27:02 +02:00
2023-02-10 12:02:11 +02:00
2023-01-27 13:54:14 +01:00
2023-03-31 21:32:41 +02:00
2023-05-02 13:54:54 +02:00
2020-04-19 17:33:51 +03:00
2020-10-30 11:15:30 +02:00
2020-08-10 17:33:48 +00:00
2023-05-22 00:39:43 +02:00
2023-02-10 12:02:11 +02:00
2023-02-10 12:02:11 +02:00
2023-02-10 12:02:11 +02:00
2023-02-09 16:09:08 +02:00
2023-05-02 13:54:54 +02:00
2023-05-02 13:54:54 +02:00
2023-02-10 12:02:11 +02:00
2023-02-10 12:02:11 +02:00
2023-02-10 12:02:11 +02:00
2023-05-22 17:15:46 +03:00
2023-02-10 12:02:11 +02:00
2021-03-31 11:05:21 +03:00
2023-02-14 11:55:11 +11:00
2023-03-31 21:32:41 +02:00
2023-03-31 21:32:41 +02:00
2023-01-27 13:54:14 +01:00
2023-05-04 11:23:37 +02:00
2023-02-10 12:02:11 +02:00
2023-03-31 21:32:41 +02:00
2023-02-10 12:02:11 +02:00
2021-10-28 08:48:36 +03:00
2020-10-30 11:15:30 +02:00
2021-10-13 12:03:32 +03:00
2021-05-05 23:03:01 +03:00
2022-02-10 21:04:51 +01:00
2020-08-01 14:42:51 +03:00
2020-08-04 17:24:15 +02:00
2023-05-02 13:54:54 +02:00
2023-05-02 13:54:54 +02:00
2023-04-05 16:16:19 +04:00
2020-11-03 16:24:47 +02:00
2021-07-02 13:02:26 +03:00
2022-09-05 13:28:56 +03:00
2020-04-19 17:33:51 +03:00
2023-03-21 17:19:44 +04:00
2020-09-04 18:44:44 +03:00
2023-05-03 09:46:49 +02:00
2023-05-03 10:32:29 +03:00
2023-04-24 16:20:36 -06:00
2023-04-27 09:39:53 +03:00
2023-02-10 12:02:11 +02:00
2023-02-10 12:02:11 +02:00
2023-02-10 12:02:11 +02:00
2020-11-02 15:48:47 +02:00
2021-04-21 07:25:48 +03:00
2021-03-22 18:10:39 +11:00
2023-02-09 16:09:08 +02:00
2023-02-09 16:09:08 +02:00
2020-11-03 14:49:17 +02:00
2021-11-16 14:26:13 +02:00
2023-02-10 12:02:11 +02:00
2021-09-11 00:23:14 +02:00
2023-01-28 18:22:55 +01:00
2021-12-26 12:51:04 +01:00
2023-04-27 09:39:53 +03:00
2023-03-31 21:32:41 +02:00
2022-09-26 13:34:38 +03:00
2020-09-10 13:32:27 +02:00
2020-05-30 11:04:27 +03:00
2023-04-24 12:43:47 +02:00
2023-02-10 12:02:11 +02:00
2023-05-03 15:53:14 +02:00
2023-02-27 19:25:44 +02:00
2022-06-09 12:22:55 +03:00
2023-01-03 19:44:19 +02:00
2023-02-09 16:09:08 +02:00
2020-04-08 10:36:41 +03:00
2022-10-02 14:38:13 +02:00
2023-02-09 16:09:08 +02:00
2023-02-09 16:09:08 +02:00
2022-12-13 14:39:18 +02:00
2023-02-10 12:02:11 +02:00
2022-10-25 11:26:37 +03:00
2022-02-01 20:33:04 +01:00
2023-02-10 12:02:11 +02:00
2022-09-26 13:34:38 +03:00
2020-08-10 21:38:55 +03:00
2022-02-01 20:33:04 +01:00
2023-02-09 16:09:08 +02:00
2020-09-03 09:26:54 +03:00
2021-09-10 17:16:18 +03:00
2022-05-09 22:04:06 +02:00
2023-02-10 12:02:11 +02:00
2023-02-10 12:02:11 +02:00
2021-10-21 15:26:25 +03:00
2021-10-21 14:57:00 +03:00
2023-05-02 13:54:54 +02:00
2023-03-31 21:32:41 +02:00
2022-09-23 13:40:42 +03:00
2020-06-12 11:25:27 +03:00
2023-03-31 21:32:41 +02:00
2021-03-22 18:10:39 +11:00
2022-01-21 19:28:48 +04:00
2023-02-27 19:25:44 +02:00
2023-02-09 16:09:08 +02:00
2021-04-27 09:10:47 +03:00
2023-02-09 16:09:08 +02:00
2023-03-31 21:32:41 +02:00
2023-02-10 12:02:11 +02:00
2022-04-22 12:59:54 -06:00
2023-02-09 16:09:08 +02:00
2023-05-22 00:39:43 +02:00
2020-10-30 11:15:30 +02:00
2023-02-10 12:02:11 +02:00
2021-12-27 13:28:25 +01:00
2023-02-10 12:02:11 +02:00
2023-03-31 21:32:41 +02:00
2023-05-02 13:54:54 +02:00
2023-05-02 10:09:27 +02:00
2022-05-09 22:04:06 +02:00
2023-01-19 08:24:41 +02:00
2023-02-10 12:02:11 +02:00
2022-09-20 13:17:02 +03:00
2023-02-10 12:02:11 +02:00
2022-12-13 14:39:18 +02:00
2023-02-10 12:02:11 +02:00
2023-03-31 21:32:41 +02:00
2023-02-10 12:02:11 +02:00
2023-01-28 18:22:55 +01:00
2023-02-09 16:09:08 +02:00
2023-01-27 13:54:14 +01:00
2023-02-10 12:02:11 +02:00
2022-10-05 10:09:49 +03:00
2022-10-26 15:26:06 +02:00
2022-09-20 13:17:02 +03:00
2021-08-18 18:22:35 +03:00
2023-03-31 21:32:41 +02:00
2023-02-10 12:02:11 +02:00
2022-09-26 13:34:38 +03:00
2023-02-10 12:02:11 +02:00
2020-06-14 19:39:43 +03:00
2022-08-02 16:35:15 +10:00
2021-11-09 17:04:49 +02:00
2022-11-26 04:05:19 +11:00
2023-02-10 12:02:11 +02:00
2023-05-22 00:39:43 +02:00
2023-05-22 00:39:43 +02:00
2023-02-10 12:02:11 +02:00
2023-01-03 17:08:42 +02:00
2021-08-12 18:32:01 +02:00
2022-11-30 13:10:52 +02:00
2023-02-09 16:09:08 +02:00
2023-01-28 18:22:55 +01:00
2023-01-28 18:22:55 +01:00
2023-02-10 12:02:11 +02:00
2021-10-28 12:01:25 +02:00
2023-02-09 16:09:08 +02:00
2023-03-31 21:32:41 +02:00
2023-04-24 12:43:47 +02:00
2021-06-30 18:41:46 +03:00
2021-05-27 00:40:23 +02:00
2021-07-15 16:28:13 +02:00
2023-02-10 12:02:11 +02:00
2023-03-31 21:32:41 +02:00
2023-03-31 21:32:41 +02:00
2023-02-27 19:25:44 +02:00
2023-02-10 12:02:11 +02:00
2022-05-09 22:04:06 +02:00
2021-01-06 10:53:00 +01:00
2022-04-28 12:12:16 +04:00
2023-05-04 18:19:47 +02:00
2020-10-21 03:09:29 +03:00
2023-01-13 10:18:30 +02:00
2023-02-09 16:09:08 +02:00
2023-05-02 13:54:54 +02:00
2023-05-02 13:54:54 +02:00
2023-02-09 16:09:08 +02:00
2022-01-19 14:04:10 +03:00
2023-01-28 18:22:55 +01:00
2020-07-03 23:31:12 +03:00
2023-02-15 22:39:38 +11:00
2020-07-13 19:50:07 +04:00
2022-05-09 22:04:06 +02:00
2021-01-24 11:35:55 +01:00
2023-05-22 00:39:43 +02:00
2021-03-05 12:54:43 +02:00
2022-09-05 13:28:56 +03:00
2023-02-09 16:09:08 +02:00
2022-10-07 00:46:38 +03:00
2023-05-22 00:39:43 +02:00
2023-01-27 13:54:14 +01:00
2021-02-15 16:43:15 +01:00
2023-02-10 12:02:11 +02:00
2023-02-10 12:02:11 +02:00
2022-10-03 18:07:41 +05:30
2020-08-14 09:14:07 +04:00
2022-09-05 13:28:56 +03:00
2022-09-05 13:28:56 +03:00
2023-03-31 21:32:41 +02:00
2021-02-12 17:44:22 +01:00
2023-04-29 08:06:46 +04:00
2023-05-02 13:54:54 +02:00
2023-05-22 17:15:46 +03:00
2023-05-22 17:15:46 +03:00
2023-05-02 13:54:54 +02:00
2021-04-20 12:30:09 +03:00
2020-04-04 15:52:31 +04:00
2023-03-31 21:32:41 +02:00
2021-02-12 18:17:07 +01:00
2023-02-10 12:02:11 +02:00
2023-03-31 21:32:41 +02:00
2023-05-02 13:54:54 +02:00
2021-02-23 09:25:57 +01:00
2023-03-31 21:32:41 +02:00
2023-03-31 21:32:41 +02:00
2023-04-24 12:43:47 +02:00
2023-01-27 13:54:14 +01:00
2023-03-28 11:44:24 +03:00
2022-10-25 11:26:37 +03:00
2020-07-31 18:09:08 +03:00
2022-10-20 10:30:34 +02:00
2022-10-02 14:38:13 +02:00
2021-09-17 19:57:13 +03:00
2023-02-09 16:09:08 +02:00
2023-03-31 21:32:41 +02:00
2020-06-10 18:09:35 +04:00
2021-04-08 08:08:53 +03:00
2022-11-08 17:01:28 +02:00
2021-04-21 09:01:01 +03:00
2022-01-21 19:28:48 +04:00
2023-02-09 16:09:08 +02:00
2023-03-31 21:32:41 +02:00
2023-03-31 21:32:41 +02:00
2022-09-26 13:34:38 +03:00
2020-10-22 13:27:18 +03:00
2023-02-27 19:25:44 +02:00
2023-03-31 21:32:41 +02:00
2023-03-31 21:32:41 +02:00
2022-10-24 14:09:46 +02:00
2023-02-10 12:02:11 +02:00
2023-02-09 16:09:08 +02:00
2023-05-02 13:54:54 +02:00
2022-08-10 12:24:31 +02:00
2023-05-02 13:54:54 +02:00
2023-02-09 16:09:08 +02:00
2023-04-27 09:39:53 +03:00
2022-02-01 20:33:04 +01:00
2023-05-04 18:19:47 +02:00
2023-05-22 17:15:46 +03:00
2023-03-09 08:51:00 +11:00
2020-05-06 13:50:35 +04:00
2021-08-19 21:16:22 +02:00
2022-09-07 15:28:58 +02:00
2023-02-10 12:02:11 +02:00
2020-05-29 13:05:35 +02:00
2020-05-29 13:05:35 +02:00
2023-02-10 12:02:11 +02:00
2021-07-02 13:02:26 +03:00
2023-02-10 12:02:11 +02:00
2023-02-10 12:02:11 +02:00
2021-03-22 18:10:39 +11:00
2020-06-14 10:13:53 +03:00
2020-06-14 10:13:53 +03:00
2022-03-29 12:59:18 +03:00
2023-01-03 17:08:42 +02:00
2021-02-01 13:49:33 +01:00
2023-02-10 12:02:11 +02:00
2023-02-09 09:15:08 +01:00
2020-07-15 09:49:48 +02:00
2020-12-01 14:55:46 +02:00
2022-09-05 13:28:56 +03:00
2022-08-31 11:05:23 +03:00
2023-04-24 12:43:47 +02:00
2020-11-11 07:37:05 +02:00
2023-02-09 16:09:08 +02:00
2023-05-22 00:39:43 +02:00
2023-05-22 00:39:43 +02:00
2022-02-23 07:18:00 +02:00
2023-05-22 00:39:43 +02:00
2022-11-30 13:10:52 +02:00
2021-02-19 10:37:51 +01:00
2022-08-31 11:05:23 +03:00
2022-08-31 11:05:23 +03:00
2023-05-02 15:47:10 +02:00
2023-05-22 00:39:43 +02:00
2023-05-22 00:39:43 +02:00
2023-02-09 16:09:08 +02:00
2023-01-27 13:54:14 +01:00
2022-06-27 10:14:37 +03:00
2020-12-02 16:16:29 +02:00
2023-05-22 00:39:43 +02:00
2023-05-22 00:39:43 +02:00
2023-05-22 00:39:43 +02:00
2020-08-26 12:02:07 +03:00
2022-04-21 11:33:59 +03:00
2022-11-30 13:10:52 +02:00
2021-04-08 07:47:49 +03:00
2023-01-23 19:01:48 +02:00