1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-32164 Server crashes in JOIN::cleanup after erroneous query with view

The problem was that we did not handle errors properly in
JOIN::get_best_combination. In case an early error, JOIN->join_tab would
contain unintialized values, which would cause errors on cleanup().

The error in question was reported earlier, but not noticed until later.
One cause of this is that most of the sql_select.cc code just checks
thd->fatal_error and not thd->is_error().
Fixed by changing of checks of fatal_error to is_error().
This commit is contained in:
Michael Widenius
2023-09-27 17:26:24 +03:00
committed by Monty
parent d4347177c7
commit 9ba8dc1413
3 changed files with 56 additions and 19 deletions

View File

@ -2,6 +2,7 @@
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc
--source include/default_optimizer_switch.inc
--source include/have_innodb.inc
SET optimizer_switch='outer_join_with_cache=off';
@ -6773,6 +6774,21 @@ SELECT * FROM v;
DROP VIEW v;
DROP FUNCTION f;
--echo #
--echo # MDEV-32164 Server crashes in JOIN::cleanup after erroneous query with
--echo # view
--echo #
CREATE TABLE t1 (a INT, b INT, KEY (a,b)) ENGINE=InnoDB;
CREATE VIEW v1 AS SELECT a FROM t1 WHERE a != '' GROUP BY a;
INSERT INTO t1 VALUES (1,NULL),(2,0),(3,NULL);
CREATE TABLE t2 (c INT) ENGINE=InnoDB;
--error ER_TRUNCATED_WRONG_VALUE
CREATE TEMPORARY TABLE tmp SELECT v1.a FROM v1 JOIN t2 ON (v1.a = t2.c);
# Cleanup
DROP VIEW v1;
DROP TABLE t1, t2;
--echo #
--echo # End of 10.6 tests
--echo #