Skip to content

Commit 14ff883

Browse files
author
Benny Wang
committed
Fixed bug#21098119: GCOL WITH MATCH/AGAINST --> ASSERTION FAILED:
TR && TR->TABLE->FILE Function allows_search_on_non_indexed_columns checks whether the storage engines support non-index columns to do fulltext search, which requires a Not-Null TABLE_LIST pointer as its argument. During alter...table, a temporary table is created to help to support inplace operation and Item_field->table_ref is NULL for tempoaray table. If old table has generated columns which include match()...against expression, allows_search_on_non_index_columns will be called during open the temporary table. Therefore, the Item_field->table_ref is NULL at this moment, which triggers the assertion. The solution to fix this bug is to replace the TABLE_LIST pointer arugument into TABLE pointer.
1 parent 38621ef commit 14ff883

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

mysql-test/suite/gcol/inc/gcol_blocked_sql_funcs_main.inc

+10
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,13 @@ drop table t1;
320320
--echo #
321321
--echo # Constant expression
322322
create table t1 (a int generated always as (PI()) virtual);
323+
drop table t1;
324+
325+
--echo # bug#21098119: GCOL WITH MATCH/AGAINST -->
326+
--echo # ASSERTION FAILED: TR && TR->TABLE->FILE
327+
--echo #
328+
create table t1 (a int);
329+
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
330+
alter table t1 add column r blob generated always
331+
as (match(a) against ('' in boolean mode)) virtual;
332+
drop table t1;

mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_innodb.result

+9
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,15 @@ drop table t1;
221221
#
222222
# Constant expression
223223
create table t1 (a int generated always as (PI()) virtual);
224+
drop table t1;
225+
# bug#21098119: GCOL WITH MATCH/AGAINST -->
226+
# ASSERTION FAILED: TR && TR->TABLE->FILE
227+
#
228+
create table t1 (a int);
229+
alter table t1 add column r blob generated always
230+
as (match(a) against ('' in boolean mode)) virtual;
231+
ERROR HY000: Expression of generated column 'r' contains a disallowed function.
232+
drop table t1;
224233
DROP VIEW IF EXISTS v1,v2;
225234
DROP TABLE IF EXISTS t1,t2,t3;
226235
DROP PROCEDURE IF EXISTS p1;

mysql-test/suite/gcol/r/gcol_blocked_sql_funcs_myisam.result

+9
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,15 @@ drop table t1;
223223
#
224224
# Constant expression
225225
create table t1 (a int generated always as (PI()) virtual);
226+
drop table t1;
227+
# bug#21098119: GCOL WITH MATCH/AGAINST -->
228+
# ASSERTION FAILED: TR && TR->TABLE->FILE
229+
#
230+
create table t1 (a int);
231+
alter table t1 add column r blob generated always
232+
as (match(a) against ('' in boolean mode)) virtual;
233+
ERROR HY000: Expression of generated column 'r' contains a disallowed function.
234+
drop table t1;
226235
DROP VIEW IF EXISTS v1,v2;
227236
DROP TABLE IF EXISTS t1,t2,t3;
228237
DROP PROCEDURE IF EXISTS p1;

sql/item_func.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -7461,7 +7461,7 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref)
74617461
return TRUE;
74627462
}
74637463
allows_multi_table_search &=
7464-
allows_search_on_non_indexed_columns(((Item_field *)item)->table_ref);
7464+
allows_search_on_non_indexed_columns(((Item_field *)item)->field->table);
74657465
}
74667466

74677467
/*
@@ -7557,7 +7557,7 @@ bool Item_func_match::fix_index()
75577557
*/
75587558
if (!fixed)
75597559
{
7560-
if (allows_search_on_non_indexed_columns(table_ref))
7560+
if (allows_search_on_non_indexed_columns(table_ref->table))
75617561
key= NO_SUCH_KEY;
75627562

75637563
return false;
@@ -7629,7 +7629,7 @@ bool Item_func_match::fix_index()
76297629
}
76307630

76317631
err:
7632-
if (table_ref != 0 && allows_search_on_non_indexed_columns(table_ref))
7632+
if (table_ref != 0 && allows_search_on_non_indexed_columns(table_ref->table))
76337633
{
76347634
key=NO_SUCH_KEY;
76357635
return 0;

sql/item_func.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -2569,17 +2569,17 @@ class Item_func_match :public Item_real_func
25692569
@retval true if BOOLEAN search on non-indexed columns is supported
25702570
@retval false otherwise
25712571
*/
2572-
bool allows_search_on_non_indexed_columns(const TABLE_LIST *tr)
2572+
bool allows_search_on_non_indexed_columns(const TABLE *tr)
25732573
{
25742574
// Only Boolean search may support non_indexed columns
25752575
if (!(flags & FT_BOOL))
25762576
return false;
25772577

2578-
DBUG_ASSERT(tr && tr->table->file);
2578+
DBUG_ASSERT(tr && tr->file);
25792579

25802580
// Assume that if extended fulltext API is not supported,
25812581
// non-indexed columns are allowed. This will be true for MyISAM.
2582-
if ((tr->table->file->ha_table_flags() & HA_CAN_FULLTEXT_EXT) == 0)
2582+
if ((tr->file->ha_table_flags() & HA_CAN_FULLTEXT_EXT) == 0)
25832583
return true;
25842584

25852585
return false;

0 commit comments

Comments
 (0)