summaryrefslogtreecommitdiff
path: root/mysql-test/main/having.test
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2021-03-01 14:44:18 +0200
committerMonty <monty@mariadb.org>2021-03-01 22:09:05 +0200
commit415409579af68ee2e3c55d5294d7bb5e6397b03f (patch)
treeb60db15f52345496b34afd8288bd0a9f8b8119ba /mysql-test/main/having.test
parent6983ce704baff7a6e5dd411a289e3580bc7bea1a (diff)
downloadmariadb-git-415409579af68ee2e3c55d5294d7bb5e6397b03f.tar.gz
MDEV-24958 Server crashes in my_strtod ... with DEFAULT(blob)
Fixes also: MDEV-24942 Server crashes in _ma_rec_pack... with DEFAULT() on BLOB This was caused by two different bugs, both related to that the default value for the blob was not calculated before it was used: - There where now Item_default_value::..result() wrappers, which is needed as item in HAVING uses these. This causes crashes when using a reference to a DEFAULT(blob_field) in HAVING. It also caused wrong results when used with other fields with default value expressions that are not constants. - create_tmp_field() did not take into account that blob fields with default expressions are not yet initialized. Fixed by treating Item_default_value(blob) like a normal item expression.
Diffstat (limited to 'mysql-test/main/having.test')
-rw-r--r--mysql-test/main/having.test20
1 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/main/having.test b/mysql-test/main/having.test
index 179af14559f..8b0cc244f51 100644
--- a/mysql-test/main/having.test
+++ b/mysql-test/main/having.test
@@ -890,3 +890,23 @@ SELECT t, next_seq_value() r FROM t1 FORCE INDEX(t)
DROP TABLE t1;
DROP FUNCTION next_seq_value;
DROP TABLE series;
+
+--echo #
+--echo # MDEV-24958 Server crashes in my_strtod /
+--echo # Value_source::Converter_strntod::Converter_strntod with DEFAULT(blob)
+--echo #
+--echo # MDEV-24942 Server crashes in _ma_rec_pack / _ma_write_blob_record with
+--echo # DEFAULT() on BLOB
+--echo #
+
+CREATE TABLE t1 (id INT, f MEDIUMTEXT NOT NULL DEFAULT 'A');
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+SELECT f FROM t1 GROUP BY id ORDER BY DEFAULT(f);
+SELECT DEFAULT(f) AS h FROM t1 HAVING h > 5;
+SELECT DEFAULT(f) AS h FROM t1 HAVING h >= 0;
+SELECT DEFAULT(f) AS h FROM t1 HAVING h >= 'A';
+
+alter table t1 add column b int default (rand()+1+3);
+--replace_column 1 #
+select default(b) AS h FROM t1 HAVING h > "2";
+drop table t1;