1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-31199: Assertion `field->table->stats_is_read' fails with hash_join_cardinality=on

Derived table creation code would call Field::make_new_field() which would
memcpy the Field object from the source table, including Field::read_stats.

But the temp. table as a whole had table->stats_is_read=false. Which was
correct but not consistent with Field::read_stats and caused an assertion.

Fixed by making sure that Field::read_stats=NULL for fields in the new
temporary (i.e. work) tables.
This commit is contained in:
Sergei Petrunia
2023-05-05 13:55:42 +03:00
parent 1c39479598
commit a24f2bb50b
3 changed files with 44 additions and 0 deletions

View File

@ -250,6 +250,26 @@ SELECT * FROM t1 AS a NATURAL JOIN t1 AS b;
DROP TABLE t1,t2,t3;
--echo #
--echo # MDEV-31199: Assertion `field->table->stats_is_read' fails with hash_join_cardinality=on
--echo #
CREATE TABLE t1 (a VARCHAR(255));
INSERT INTO t1 VALUES ('u'),('uu');
CREATE TABLE t2 (b VARCHAR(255)) CHARACTER SET utf8mb4;
INSERT INTO t2 VALUES ('x'),('xx');
CREATE TABLE t3 (c VARCHAR(255));
INSERT INTO t3 VALUES ('z'),('zz');
ANALYZE TABLE t1, t2, t3 PERSISTENT FOR ALL; # Optional, fails either way
set @tmp1=@@optimizer_switch, @tmp2=@@join_cache_level;
set optimizer_switch='hash_join_cardinality=on', join_cache_level=3;
SELECT t1.* FROM t1 JOIN (SELECT DISTINCT b FROM t2 JOIN t3) sq ON sq.b = t1.a;
set optimizer_switch=@tmp1, join_cache_level=@tmp2;
DROP TABLE t1, t2, t3;
--echo #
--echo # End of the test file
--echo #