summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/func_group.result5
-rw-r--r--mysql-test/r/type_decimal.result10
-rw-r--r--mysql-test/t/func_group.test9
-rw-r--r--mysql-test/t/type_decimal.test15
-rw-r--r--sql/item.cc2
-rw-r--r--sql/opt_sum.cc7
6 files changed, 44 insertions, 4 deletions
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index ce29d25b736..a87337f6451 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -1378,4 +1378,9 @@ SELECT 1 FROM t1 GROUP BY (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) );
1
1
DROP TABLE t1;
+CREATE TABLE t1 (a int, b date NOT NULL, KEY k1 (a,b));
+SELECT MIN(b) FROM t1 WHERE a=1 AND b>'2007-08-01';
+MIN(b)
+NULL
+DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result
index 42276a004bb..cd7902c8ae9 100644
--- a/mysql-test/r/type_decimal.result
+++ b/mysql-test/r/type_decimal.result
@@ -812,4 +812,14 @@ select group_concat(f1),group_concat(f2) from t1;
group_concat(f1) group_concat(f2)
-0.123456 0.123456
drop table t1;
+create table t1 (
+ua_id decimal(22,0) not null,
+ua_invited_by_id decimal(22,0) default NULL,
+primary key(ua_id)
+);
+insert into t1 values (123, NULL), (456, NULL);
+this must not produce error 1048:
+select * from t1 where ua_invited_by_id not in (select ua_id from t1);
+ua_id ua_invited_by_id
+drop table t1;
End of 5.0 tests
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index e1ec6906cd6..d80d853b9cc 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -880,5 +880,14 @@ SELECT 1 FROM t1 GROUP BY (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) );
DROP TABLE t1;
+#
+# Bug #30715: Assertion failed: item_field->field->real_maybe_null(), file
+# .\opt_sum.cc, line
+#
+
+CREATE TABLE t1 (a int, b date NOT NULL, KEY k1 (a,b));
+SELECT MIN(b) FROM t1 WHERE a=1 AND b>'2007-08-01';
+DROP TABLE t1;
+
###
--echo End of 5.0 tests
diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test
index 4d61350a613..12d4398dd57 100644
--- a/mysql-test/t/type_decimal.test
+++ b/mysql-test/t/type_decimal.test
@@ -425,5 +425,20 @@ insert into t1 values (-0.123456,0.123456);
select group_concat(f1),group_concat(f2) from t1;
drop table t1;
+#
+# BUG#31450 "Query causes error 1048"
+#
+create table t1 (
+ ua_id decimal(22,0) not null,
+ ua_invited_by_id decimal(22,0) default NULL,
+ primary key(ua_id)
+);
+insert into t1 values (123, NULL), (456, NULL);
+
+--echo this must not produce error 1048:
+select * from t1 where ua_invited_by_id not in (select ua_id from t1);
+
+drop table t1;
+
--echo End of 5.0 tests
diff --git a/sql/item.cc b/sql/item.cc
index 95c8cd582cd..565081a600a 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -4649,7 +4649,7 @@ int Item::save_in_field(Field *field, bool no_conversions)
my_decimal decimal_value;
my_decimal *value= val_decimal(&decimal_value);
if (null_value)
- return set_field_to_null(field);
+ return set_field_to_null_with_conversions(field, no_conversions);
field->set_notnull();
error=field->store_decimal(value);
}
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 6836c53db4e..12ad504d738 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -295,14 +295,15 @@ 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)))
{