1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-32086 Server crash when inserting from derived table containing insert target table

Use original solution for INSERT ... SELECT - select result buferisation.

Also fix MDEV-36447 and MDEV-33139
This commit is contained in:
Oleksandr Byelkin
2025-04-01 20:57:29 +02:00
parent 2f5c260f55
commit 9b313d2de1
7 changed files with 260 additions and 79 deletions

View File

@@ -591,6 +591,60 @@ SELECT * FROM t1;
DROP VIEW v1;
DROP TABLE t1;
#
# MDEV-32086: condition pushdown into two mergeable derived tables,
# one containing the other, when they are forced to be
# materialized in INSERT
#
create table t1 (pk int, id int);
insert into t1 values (2,2), (3,3), (4,4);
let $q=
insert into t1
select 1,10
from
(
select dt2.id from (select id from t1) dt2, t1 t where t.id=dt2.id
) dt
where dt.id=3;
eval $q;
select * from t1;
eval explain $q;
eval explain format=json $q;
eval prepare stmt from "$q";
execute stmt;
select * from t1;
execute stmt;
select * from t1;
deallocate prepare stmt;
eval create procedure p() $q;
call p();
select * from t1;
call p();
select * from t1;
drop procedure p;
drop table t1;
--echo #
--echo # End of 10.5 test
--echo # MDEV-33139: Crash of INSERT SELECT when preparing structures for
--echo # split optimization
--echo #
CREATE TABLE v0 ( v1 INT UNIQUE ) ;
INSERT INTO v0 ( v1 ) VALUES
( ( SELECT 1
FROM
( SELECT v1
FROM v0 GROUP BY v1 ) AS v6 NATURAL JOIN
v0 AS v2 NATURAL JOIN
v0 AS v4 NATURAL JOIN
v0 AS v3 NATURAL JOIN
( SELECT v1 FROM v0 ) AS v7 ) ) ;
DROP TABLE v0;
--echo # End of 10.5 tests