diff options
author | unknown <gkodinov/kgeorge@magare.gmz> | 2007-10-24 11:15:08 +0300 |
---|---|---|
committer | unknown <gkodinov/kgeorge@magare.gmz> | 2007-10-24 11:15:08 +0300 |
commit | e2433cbcaa81a1a1f16cf5576f7c6d045b6a9f67 (patch) | |
tree | f380fde5197f86428a6d49872c33a639b7d06316 /sql/opt_sum.cc | |
parent | 62a7e160bc0e960ec1374a546dde4a7f26120ceb (diff) | |
download | mariadb-git-e2433cbcaa81a1a1f16cf5576f7c6d045b6a9f67.tar.gz |
Bug #30715: Assertion failed: item_field->field->real_maybe_null(),
file .\opt_sum.cc, line
The optimizer pre-calculates the MIN/MAX values for queries like
SELECT MIN(kp_k) WHERE kp_1 = const AND ... AND kp_k-1 = const
when there is a key over kp_1...kp_k
In doing so it was not checking correctly nullability and
there was a superfluous assert().
Fixed by making sure that the field can be null before checking and
taking out the wrong assert().
.
Introduced a correct check for nullability
The MIN(field) can return NULL when all the row values in the group
are NULL-able or if there were no rows.
Fixed the assertion to reflect the case when there are no rows.
mysql-test/r/func_group.result:
Bug #30715: test case
mysql-test/t/func_group.test:
Bug #30715: test case
sql/opt_sum.cc:
Bug #30715: correct nullability check for MIN/MAX pre-calculation over index.
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r-- | sql/opt_sum.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index b9de54dbf5c..3fc62d05ae5 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -249,20 +249,20 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) Check if case 1 from above holds. If it does, we should read the skipped tuple. */ - if (ref.key_buff[prefix_len] == 1 && - /* + if (item_field->field->real_maybe_null() && + ref.key_buff[prefix_len] == 1 && + /* Last keypart (i.e. the argument to MIN) is set to NULL by find_key_for_maxmin only if all other keyparts are bound to constants in a conjunction of equalities. Hence, we can detect this by checking only if the last keypart is NULL. - */ + */ (error == HA_ERR_KEY_NOT_FOUND || key_cmp_if_same(table, ref.key_buff, ref.key, prefix_len))) { - DBUG_ASSERT(item_field->field->real_maybe_null()); error= table->file->index_read(table->record[0], ref.key_buff, - ref.key_length, + ref.key_length, HA_READ_KEY_EXACT); } } |