Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions mysql-test/main/mdev-31255.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b CHAR(255), FULLTEXT(b));
INSERT INTO t2 VALUES ('foo'),('bar');
EXPLAIN
DELETE
FROM t1
WHERE EXISTS (
SELECT * FROM t2 WHERE MATCH (b) AGAINST ('qux' IN NATURAL LANGUAGE MODE)
);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
DROP TABLE t1, t2;
19 changes: 19 additions & 0 deletions mysql-test/main/mdev-31255.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# MDEV-31255 Crash with Explain DELETE on fulltext search query
#

CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);

CREATE TABLE t2 (b CHAR(255), FULLTEXT(b));
INSERT INTO t2 VALUES ('foo'),('bar');

EXPLAIN
DELETE
FROM t1
WHERE EXISTS (
SELECT * FROM t2 WHERE MATCH (b) AGAINST ('qux' IN NATURAL LANGUAGE MODE)
);

# Cleanup
DROP TABLE t1, t2;
16 changes: 8 additions & 8 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3238,11 +3238,6 @@ int JOIN::optimize_stage2()
if (make_join_readinfo(this, select_opts_for_readinfo, no_jbuf_after))
DBUG_RETURN(1);

/* Perform FULLTEXT search before all regular searches */
if (!(select_options & SELECT_DESCRIBE))
if (init_ftfuncs(thd, select_lex, MY_TEST(order)))
DBUG_RETURN(1);

/*
It's necessary to check const part of HAVING cond as
there is a chance that some cond parts may become
Expand Down Expand Up @@ -15653,6 +15648,11 @@ bool JOIN_TAB::preread_init()
if (!derived || !derived->is_materialized_derived())
{
preread_init_done= TRUE;

if (table->fulltext_searched &&
init_ftfuncs(join->thd, join->select_lex, MY_TEST(join->order)))
DBUG_RETURN(TRUE);

DBUG_RETURN(FALSE);
}

Expand All @@ -15679,9 +15679,9 @@ bool JOIN_TAB::preread_init()
);

/* init ftfuns for just initialized derived table */
if (table->fulltext_searched)
if (init_ftfuncs(join->thd, join->select_lex, MY_TEST(join->order)))
DBUG_RETURN(TRUE);
if (table->fulltext_searched &&
init_ftfuncs(join->thd, join->select_lex, MY_TEST(join->order)))
DBUG_RETURN(TRUE);

DBUG_RETURN(FALSE);
}
Expand Down