diff options
author | Monty <monty@mariadb.org> | 2021-02-27 19:56:46 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2021-03-01 22:09:05 +0200 |
commit | 6983ce704baff7a6e5dd411a289e3580bc7bea1a (patch) | |
tree | 565c9fd66978b9f0eeaca90a2c9bdde6dd60d4ef /mysql-test/main/group_by.test | |
parent | 43a0a8139727314f89fc0f0f0d2ba80ffa33b221 (diff) | |
download | mariadb-git-6983ce704baff7a6e5dd411a289e3580bc7bea1a.tar.gz |
MDEV-24710 Uninitialized value upon CREATE .. SELECT ... VALUE...
The failure happened for group by queries when all tables where marked as
'const tables' (tables with 0-1 matching rows) and no row matched the
where clause and there was in addition a direct reference to a field.
In this case the field would not be properly reset and the query would
return 'random data' that happended to be in table->record[0].
Fixed by marking all const tables as null tables in this particular case.
Sergei also provided an extra test case for the code.
@reviewer Sergei Petrunia <psergey@askmonty.org>
Diffstat (limited to 'mysql-test/main/group_by.test')
-rw-r--r-- | mysql-test/main/group_by.test | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mysql-test/main/group_by.test b/mysql-test/main/group_by.test index 2866fab3822..8d690222bcc 100644 --- a/mysql-test/main/group_by.test +++ b/mysql-test/main/group_by.test @@ -2041,5 +2041,28 @@ SELECT d != '2023-03-04' AS f, COUNT(*) FROM t1 GROUP BY d WITH ROLLUP; DROP TABLE t1; --echo # +--echo # MDEV-24710 Uninitialized value upon CREATE .. SELECT ... VALUE +--echo # + +CREATE TABLE t1 (a VARCHAR(8) NOT NULL DEFAULT ''); +INSERT INTO t1 (a) VALUES ('foo'); +CREATE TABLE t2 AS SELECT MAX(a) AS f1, a AS f2 FROM t1 WHERE VALUE(a) IS NOT NULL; +SELECT * from t2; +SELECT MAX(a) AS f1, a AS f2 FROM t1 WHERE VALUE(a) IS NOT NULL; +SELECT MAX(a) AS f1, a AS f2 FROM t1 WHERE 1=0; +drop table t1,t2; + +--echo # Extra test by to check the fix for MDEV-24710 + +create table t20 (pk int primary key, a int); +insert into t20 values (1,1);create table t21 (pk int primary key, b int not null); +insert into t21 values (1,1); +create table t22 (a int); +insert into t22 values (1),(2); +select a, (select max(t21.b) from t20 left join t21 on t21.pk=t20.a+10 + where t20.pk=1 and rand(123) < 0.5) as SUBQ from t22; +drop table t20, t21, t22; + +--echo # --echo # End of 10.3 tests --echo # |