Skip to content

Commit 89df187

Browse files
committed
Bug #26271244
ASSERT FAILS WHEN SHOW CREATE TABLE CALLED ON A FILE CREATED FOR FULLTEXT INDEX
1 parent c8d3b38 commit 89df187

File tree

9 files changed

+142
-13
lines changed

9 files changed

+142
-13
lines changed

mysql-test/include/commit.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ create table t2 (a int);
823823
if (`SELECT $PS_PROTOCOL = 0`)
824824
{
825825
--replace_regex /(call p_verify_status_increment.*)11(.*6)/\1<commit_count>\2/
826-
call p_verify_status_increment(11, 4, 6, 0);
826+
call p_verify_status_increment(12, 4, 6, 0);
827827
}
828828
if (`SELECT $PS_PROTOCOL > 0`)
829829
{
@@ -883,7 +883,7 @@ create table t3 select a from t2;
883883
if (`SELECT $PS_PROTOCOL = 0`)
884884
{
885885
--replace_regex /12/<commit_count>/
886-
call p_verify_status_increment(12, 4, 4, 4);
886+
call p_verify_status_increment(13, 4, 4, 4);
887887
}
888888
if (`SELECT $PS_PROTOCOL > 0`)
889889
{
@@ -907,7 +907,7 @@ if ($have_debug)
907907
alter table t3 rename t4;
908908
call p_verify_status_increment(20, 4, 3, 0);
909909
rename table t4 to t3;
910-
call p_verify_status_increment(23, 4, 5, 0);
910+
call p_verify_status_increment(24, 4, 5, 0);
911911
truncate table t3;
912912

913913
if (!$have_debug)
@@ -923,7 +923,7 @@ if ($have_debug)
923923
}
924924

925925
create view v1 as select * from t2;
926-
call p_verify_status_increment(7, 4, 3, 0);
926+
call p_verify_status_increment(8, 4, 3, 0);
927927
check table t1;
928928
call p_verify_status_increment(2, 0, 2, 0);
929929
--echo # Sic: after this bug is fixed, CHECK leaves no pending transaction

mysql-test/r/commit_1innodb.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ SUCCESS
799799
# 28. Read-write statement: DO
800800
#
801801
create table t2 (a int);
802-
call p_verify_status_increment(<commit_count>, 4, 6, 0);
802+
call p_verify_status_increment(12, 4, 6, 0);
803803
SUCCESS
804804

805805
# One extra transaction to load table 't2' into data-dictionary cache.
@@ -843,7 +843,7 @@ call p_verify_status_increment(0, 0, 0, 0);
843843
SUCCESS
844844

845845
create table t3 select a from t2;
846-
call p_verify_status_increment(<commit_count>, 4, 4, 4);
846+
call p_verify_status_increment(13, 4, 4, 4);
847847
SUCCESS
848848

849849
alter table t3 add column (b int);
@@ -855,15 +855,15 @@ call p_verify_status_increment(20, 4, 3, 0);
855855
SUCCESS
856856

857857
rename table t4 to t3;
858-
call p_verify_status_increment(23, 4, 5, 0);
858+
call p_verify_status_increment(24, 4, 5, 0);
859859
SUCCESS
860860

861861
truncate table t3;
862862
call p_verify_status_increment(X, 4, 4, 0);
863863
SUCCESS
864864

865865
create view v1 as select * from t2;
866-
call p_verify_status_increment(7, 4, 3, 0);
866+
call p_verify_status_increment(8, 4, 3, 0);
867867
SUCCESS
868868

869869
check table t1;

mysql-test/r/create.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ create table t2 select sql_big_result f1,count(f2) from t1 group by f1;
939939
show status like 'handler_read%';
940940
Variable_name Value
941941
Handler_read_first 1
942-
Handler_read_key 23
942+
Handler_read_key 24
943943
Handler_read_last 0
944944
Handler_read_next 0
945945
Handler_read_prev 0

mysql-test/r/fulltext.result

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,3 +738,23 @@ explain format=json SELECT 1 FROM q
738738
WHERE (SELECT MATCH(b) AGAINST ('*') FROM z);
739739
ERROR HY000: Incorrect arguments to MATCH
740740
DROP TABLE z, q;
741+
#
742+
# Bug#26271244: ASSERT FAILS WHEN SHOW CREATE TABLE CALLED ON A FILE
743+
# CREATED FOR FULLTEXT INDEX
744+
#
745+
# Create Innodb table with full text index
746+
CREATE TABLE t1(id INT, c CHAR(100) , FULLTEXT KEY `msg_idx` (`c`))
747+
ENGINE INNODB;
748+
# Find name of first FTS index "table"
749+
# SHOW CREATE TABLE on an FTS index table should give error
750+
# (not crash). Query log and error message suppressed as the name of
751+
# FTS index table is not stable.
752+
Got one of the listed errors
753+
# Msg_type Error ER_NO_SUCH_TABLE,ER_NO_SUCH_TABLE
754+
# Msg_type Error ER_NO_SUCH_TABLE,ER_NO_SUCH_TABLE
755+
Got one of the listed errors
756+
Got one of the listed errors
757+
Got one of the listed errors
758+
Got one of the listed errors
759+
Got one of the listed errors
760+
DROP TABLE t1;

mysql-test/r/group_min_max.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2515,7 +2515,7 @@ FLUSH STATUS;
25152515
CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a;
25162516
SHOW STATUS LIKE 'handler_read__e%';
25172517
Variable_name Value
2518-
Handler_read_key 23
2518+
Handler_read_key 24
25192519
Handler_read_next 2
25202520
FLUSH STATUS;
25212521
SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b;

mysql-test/t/fulltext.test

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,71 @@ WHERE (SELECT MATCH(b) AGAINST ('*') FROM z);
660660
eval explain format=json $query;
661661

662662
DROP TABLE z, q;
663+
664+
--echo #
665+
--echo # Bug#26271244: ASSERT FAILS WHEN SHOW CREATE TABLE CALLED ON A FILE
666+
--echo # CREATED FOR FULLTEXT INDEX
667+
--echo #
668+
669+
let DATADIR= `SELECT @@datadir`;
670+
671+
--echo # Create Innodb table with full text index
672+
CREATE TABLE t1(id INT, c CHAR(100) , FULLTEXT KEY `msg_idx` (`c`))
673+
ENGINE INNODB;
674+
--echo # Find name of first FTS index "table"
675+
let INCFILE= $MYSQL_TMP_DIR/tmp.inc;
676+
--perl
677+
my $FTS_FILE= "";
678+
opendir(DD, "$ENV{'DATADIR'}/test") || die "Could not open $ENV{'DATADIR'}: $!";
679+
while ($_= readdir(DD)) {
680+
if (/(fts_\S+_index_1)\.ibd/) {
681+
$FTS_FILE= $1;
682+
last;
683+
}
684+
}
685+
close(DD);
686+
open(INC, ">$ENV{'INCFILE'}") || die "Could not open $ENV{'INCFILE'}: $!";
687+
print INC "let FTS_FILE= $FTS_FILE;\n";
688+
close(INC);
689+
EOF
690+
--source $INCFILE
691+
692+
--echo # SHOW CREATE TABLE on an FTS index table should give error
693+
--echo # (not crash). Query log and error message suppressed as the name of
694+
--echo # FTS index table is not stable.
695+
--disable_query_log
696+
697+
--error ER_NO_SUCH_TABLE,ER_NO_SUCH_TABLE
698+
--eval SHOW CREATE TABLE $FTS_FILE
699+
700+
--disable_result_log
701+
--echo # Msg_type Error ER_NO_SUCH_TABLE,ER_NO_SUCH_TABLE
702+
--eval OPTIMIZE TABLE $FTS_FILE
703+
704+
--echo # Msg_type Error ER_NO_SUCH_TABLE,ER_NO_SUCH_TABLE
705+
--eval REPAIR TABLE $FTS_FILE
706+
707+
--error ER_NO_SUCH_TABLE,ER_NO_SUCH_TABLE
708+
--eval ALTER TABLE $FTS_FILE DROP id
709+
710+
--enable_result_log
711+
712+
--error ER_NO_SUCH_TABLE,ER_NO_SUCH_TABLE
713+
--eval LOCK TABLE $FTS_FILE AS mytable WRITE
714+
--eval UNLOCK TABLES
715+
716+
--error ER_NO_SUCH_TABLE,ER_NO_SUCH_TABLE
717+
--eval RENAME TABLE $FTS_FILE TO SOMETHING_ELSE
718+
719+
--error ER_NO_SUCH_TABLE,ER_NO_SUCH_TABLE
720+
--eval RENAME TABLE t2 TO t3, $FTS_FILE TO SOMETHING_ELSE2
721+
722+
--error ER_NO_SUCH_TABLE,ER_NO_SUCH_TABLE
723+
--eval TRUNCATE TABLE $FTS_FILE
724+
725+
--error ER_NO_SUCH_TABLE,ER_NO_SUCH_TABLE
726+
--eval DROP TABLE $FTS_FILE
727+
728+
--enable_query_log
729+
730+
DROP TABLE t1;

sql/sql_base.cc

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,6 +3566,12 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
35663566
goto err_lock;
35673567
}
35683568

3569+
if (table_def && table_def->hidden() == dd::Abstract_table::HT_HIDDEN_SE)
3570+
{
3571+
my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db,
3572+
table_list->table_name);
3573+
DBUG_RETURN(true);
3574+
}
35693575

35703576
/* make a new table */
35713577
if (!(table= (TABLE*) my_malloc(key_memory_TABLE,
@@ -6196,8 +6202,36 @@ lock_table_names(THD *thd,
61966202
dictionary to get hold of the tablespace name, and in order
61976203
to do this, we must have acquired a lock on the table.
61986204
*/
6199-
return get_and_lock_tablespace_names(
6200-
thd, tables_start, tables_end, lock_wait_timeout, flags);
6205+
if (get_and_lock_tablespace_names(
6206+
thd, tables_start, tables_end, lock_wait_timeout, flags))
6207+
return true;
6208+
6209+
const dd::Table *table_def= nullptr;
6210+
for (table= tables_start; table && table != tables_end;
6211+
table= table->next_local)
6212+
{
6213+
if (table->table_name == NULL)
6214+
continue;
6215+
6216+
if (!thd->mdl_context.owns_equal_or_stronger_lock(MDL_key::TABLE, table->db,
6217+
table->table_name,
6218+
MDL_INTENTION_EXCLUSIVE))
6219+
continue;
6220+
6221+
dd::cache::Dictionary_client::Auto_releaser releaser(thd->dd_client());
6222+
if (thd->dd_client()->acquire(table->db,
6223+
table->table_name, &table_def))
6224+
{
6225+
return true;
6226+
}
6227+
if (table_def && table_def->hidden() == dd::Abstract_table::HT_HIDDEN_SE)
6228+
{
6229+
my_error(ER_NO_SUCH_TABLE, MYF(0),
6230+
table->db, table->table_name);
6231+
return true;
6232+
}
6233+
}
6234+
return false;
62016235
}
62026236

62036237

sql/sql_rename.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
181181
for (ren_table= table_list; ren_table; ren_table= ren_table->next_local)
182182
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, ren_table->db,
183183
ren_table->table_name, FALSE);
184-
185184
bool error= false;
186185
bool int_commit_done= false;
187186
std::set<handlerton*> post_ddl_htons;

sql/sql_table.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,6 +2504,14 @@ drop_base_table(THD *thd, const Drop_tables_ctx &drop_ctx,
25042504
return true;
25052505
DBUG_ASSERT(table_def != nullptr);
25062506

2507+
if (table_def && table_def->hidden() == dd::Abstract_table::HT_HIDDEN_SE)
2508+
{
2509+
my_error(ER_NO_SUCH_TABLE, MYF(0), table->db,
2510+
table->table_name);
2511+
DBUG_ASSERT(true);
2512+
return true;
2513+
}
2514+
25072515
handlerton *hton;
25082516
if (dd::table_storage_engine(thd, table_def, &hton))
25092517
{

0 commit comments

Comments
 (0)