Skip to content
/ server Public

MDEV-29360 Crash when pushing condition with always false IS NULL int…#4788

Draft
mariadb-RexJohnston wants to merge 1 commit into10.11from
10.11-MDEV-29360
Draft

MDEV-29360 Crash when pushing condition with always false IS NULL int…#4788
mariadb-RexJohnston wants to merge 1 commit into10.11from
10.11-MDEV-29360

Conversation

@mariadb-RexJohnston
Copy link
Member

…o derived

When a condition containing an always FALSE range part is pushed down into a derived table, an enclosed outer reference can cause a null pointer crash. An example

SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt1, (SELECT id FROM t2) dt2, t3
WHERE dt2.id = t3.id AND dt1.id BETWEEN 0 AND (dt2.id IS NULL);

is considered as one that can be pushed into the derived table dt1 because the expression (dt2.id IS NULL) is identified as always false. On the on other hand the condition still contains a reference to a column of the table dt2. When pushing the condition to the where clause of the derived table dt1 a copy of it is created and this copy is transformed to be used in the new where clause. When the transformation procedure encounters a reference dt2.id it crashes the server as only the references to the columns used in the group by list of the specification of dt1 or those equal to them are expected in the condition that can be pushed into the where clause of the derived table.

Based on patch by Igor Babaev.

…o derived

When a condition containing an always FALSE range part is pushed
down into a derived table, an enclosed outer reference can cause
a null pointer crash.  An example

SELECT * FROM (SELECT id  FROM t1 GROUP BY id) dt1, (SELECT id FROM t2) dt2, t3
  WHERE dt2.id = t3.id AND dt1.id BETWEEN 0 AND (dt2.id IS NULL);

is considered as one that can be pushed into the derived table dt1
because the expression (dt2.id IS NULL) is identified as always false.
On the on other hand the condition still contains a reference to a
column of the table dt2. When pushing the condition to the where clause
of the derived table dt1 a copy of it is created and this copy is
transformed to be used in the new where clause. When the transformation
procedure encounters a reference dt2.id it crashes the server as only
the references to the columns used in the group by list of the
specification of dt1 or those equal to them are expected in the
condition that can be pushed into the where clause of the derived table.

Based on patch by Igor Babaev.
@mariadb-RexJohnston mariadb-RexJohnston marked this pull request as draft March 12, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants