1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-24019 Assertion is hit for query using recursive CTE with no default DB

When the query using a recursive CTE whose definition contained wildcard
symbols in the recursive part was processed at the prepare stage an
assertion was hit if the query was executed without any default database
set. The failure happened when the function insert_fields() tried to check
column privileges for the temporary table created for a recursive
reference to the CTE. No acl checks are needed for any CTE. That's why this
check should be blocked as well. The patch formulates a stricter condition
at which this check is to be blocked that covers the case when a query
using recursive CTEs is executed with no default database set.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
This commit is contained in:
Igor Babaev
2020-12-08 11:13:36 -08:00
parent 2db6eb1429
commit a3f7f2334a
3 changed files with 90 additions and 24 deletions

View File

@ -2690,6 +2690,41 @@ deallocate prepare stmt;
drop table t1;
--echo #
--echo # MDEV-24019: query with recursive CTE when no default database is set
--echo #
drop database test;
let $q=
with recursive a as
(select 1 from dual union select * from a as r)
select * from a;
eval $q;
create database db1;
create table db1.t1 (a int);
insert into db1.t1 values (3), (7), (1);
let $q=
with recursive cte as
(select * from db1.t1 union select * from (select * from cte) as t)
select * from cte;
eval $q;
eval explain $q;
eval prepare stmt from "$q";
execute stmt;
execute stmt;
deallocate prepare stmt;
drop database db1;
create database test;
use test;
--echo #
--echo # End of 10.2 tests
--echo #