[MDEV-21649] Crash when using nested EXISTS Created: 2020-02-03  Updated: 2020-07-25  Resolved: 2020-02-03

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.4.6, 10.4.12
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Oskar Persson Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Environment:

Docker


Issue Links:
Duplicate
is duplicated by MDEV-20557 SQL query with duplicate table aliase... Closed

 Description   

The following schema and (arguably bad) query results in a hard crash when tested against the latest (10.4.12) Docker image.

CREATE TABLE storage_storagemedium (id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id));
CREATE TABLE storage_storageobject (id INT NOT NULL AUTO_INCREMENT, ip_id INT, PRIMARY KEY(id));
CREATE TABLE storage_storagemethodtargetrelation (id INT NOT NULL AUTO_INCREMENT, storage_method_id INT, PRIMARY KEY(id));

SELECT
    W0.`id`
FROM
    `storage_storagemedium` W0
WHERE (
    EXISTS(
        SELECT
            V0.`id`
        FROM
            `storage_storageobject` V0
        WHERE (
            EXISTS(
                SELECT
                    U0.`id`
                FROM
                    `storage_storageobject` U0
                    INNER JOIN `storage_storagemethodtargetrelation` U4 ON (U0.`id` = U4.`storage_target_id`)
                WHERE (
                        U0.`ip_id` = V0.`ip_id`
                        AND U4.`storage_method_id` = (
                            SELECT
                                U5.`storage_method_id`
                            FROM
                                `storage_storagemethodtargetrelation` U5
                            WHERE
                                U5.`storage_target_id` = V0.`id`
                            LIMIT
                                1
                        )
                )
            )
        )
    )
)

Feel free to rename this issue since I can't really pinpoint what part of the query exactly that is causing the crash yet.



 Comments   
Comment by Elena Stepanova [ 2020-02-03 ]

Thanks for the report. It appears to be the same crash as in MDEV-20557 (at least it produces the same stack trace for me), so I suggest to keep tracking it there. I will add your test case to the other report.

Generated at Thu Feb 08 09:08:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.