mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
972879f413
Based on the current logic, objects of classes Item_func_charset and Item_func_coercibility (responsible for CHARSET() and COERCIBILITY() functions) are always considered constant. However, SQL syntax allows their use in a non-constant manner, such as CHARSET(t1.a), COERCIBILITY(t1.a). In these cases, the `used_tables()` parameter corresponds to table names in the function parameters, creating an inconsistency: the item is marked as constant but accesses tables. This leads to crashes when conditions with CHARSET()/COERCIBILITY() are pushed into derived tables. This commit addresses the issue by setting `used_tables()` to 0 for `Item_func_charset` and `Item_func_coercibility`. Additionally, the items now store the return values during the preparation phase and return them during the execution phase. This ensures that the items do not call its arguments methods during the execution and are truly constant. Reviewer: Alexander Barkov <bar@mariadb.com>
31 lines
821 B
Text
31 lines
821 B
Text
--source include/have_innodb.inc
|
|
|
|
--echo #
|
|
--echo # MDEV-33010: Crash when pushing condition with CHARSET()/COERCIBILITY()
|
|
--echo # into derived table
|
|
--echo #
|
|
CREATE TABLE t1 (c1 BIGINT, KEY (c1)) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES (1);
|
|
CREATE TABLE t2 (c2 DOUBLE UNSIGNED);
|
|
INSERT INTO t2 VALUES (1);
|
|
|
|
SET optimizer_switch='derived_merge=off';
|
|
|
|
EXPLAIN EXTENDED
|
|
SELECT dt1_c1 FROM
|
|
(SELECT c1 AS dt1_c1 FROM t1) AS dt1
|
|
JOIN
|
|
(SELECT 1 AS dt2_c2 FROM t2) AS dt2
|
|
ON CHARSET(dt2_c2) BETWEEN dt1_c1 AND dt1_c1;
|
|
|
|
EXPLAIN EXTENDED
|
|
SELECT dt1_c1 FROM
|
|
(SELECT c1 AS dt1_c1 FROM t1) AS dt1
|
|
JOIN
|
|
(SELECT 1 AS dt2_c2 FROM t2) AS dt2
|
|
ON COERCIBILITY(dt2_c2) BETWEEN dt1_c1 AND dt1_c1;
|
|
|
|
SET optimizer_switch=DEFAULT;
|
|
DROP TABLE t1, t2;
|
|
|
|
--echo # End of 10.4 tests
|