Commit 1ef87c55 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5080 Assertion `strcmp(share->unique_file_name,filename) ||...

MDEV-5080 Assertion `strcmp(share->unique_file_name,filename) || share->last_version' fails at /storage/myisam/mi_open.c:67

extend table names discovery (ha_discover_table_names() and Discovered_table_list) to return
or optionally filter out temporary tables ("#sql..."). SHOW commands and I_S tables
typically want temp table filtered out, while DROP DATABASE wants to see them too.

additonally, remove the supression for the warning "Invalid (old?) table or database name"
from mtr, and add it to .test files as needed (we need to test that this warning
does *not* happen in drop.test)
parent 032a61fc
......@@ -108,7 +108,7 @@ INSERT INTO global_suppressions VALUES
("Incorrect definition of table"),
("Incorrect information in file"),
("InnoDB: Warning: we did not need to do crash recovery"),
("Invalid \\(old\\?\\) table or database name"),
/*("Invalid \\(old\\?\\) table or database name"),*/
("Lock wait timeout exceeded"),
("Log entry on master is longer than max_allowed_packet"),
("unknown option '--loose-"),
......
......@@ -4775,7 +4775,7 @@ sub extract_warning_lines ($$) {
qr/slave SQL thread aborted/,
qr/unknown option '--loose[-_]/,
qr/unknown variable 'loose[-_]/,
qr/Invalid .*old.* table or database name/,
#qr/Invalid .*old.* table or database name/,
qr/Now setting lower_case_table_names to [02]/,
qr/Setting lower_case_table_names=2/,
qr/You have forced lower_case_table_names to 0/,
......
call mtr.add_suppression("table or database name 't-1'");
drop table if exists t1,t2,t3,t4,t5;
drop database if exists mysqltest;
drop view if exists v1;
......
call mtr.add_suppression("table or database name 'abc`def'");
drop table if exists t1;
drop database if exists mysqltest;
drop database if exists client_test_db;
......
call mtr.add_suppression("Invalid .old.. table or database name");
DROP TABLE IF EXISTS t1, `t``1`, `t 1`;
drop view if exists v1;
drop database if exists client_test_db;
......
call mtr.add_suppression("Invalid .old.. table or database name");
drop database if exists `mysqltest1`;
drop database if exists `mysqltest-1`;
drop database if exists `#mysql50#mysqltest-1`;
......
include/master-slave.inc
[connection master]
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
call mtr.add_suppression("table or database name 'mysqltest-1'");
DROP DATABASE IF EXISTS `#mysql50#mysqltest-1`;
CREATE DATABASE `#mysql50#mysqltest-1`;
Master position is not changed
......
......@@ -11,6 +11,7 @@
--source include/have_mysql_upgrade.inc
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
call mtr.add_suppression("table or database name 'mysqltest-1'");
connection master;
--disable_warnings
......
call mtr.add_suppression("table or database name '.otherdir'");
select @@ignore_db_dirs;
@@ignore_db_dirs
e,lost+found,.mysqlgui,ignored_db
......
call mtr.add_suppression("table or database name '.otherdir'");
select @@ignore_db_dirs;
let $MYSQLD_DATADIR= `select @@datadir`;
......
call mtr.add_suppression("table or database name 't-1'");
#
# Check some special create statements.
#
......
call mtr.add_suppression("table or database name 'abc`def'");
# Initialise
--disable_warnings
drop table if exists t1;
......
call mtr.add_suppression("Invalid .old.. table or database name");
# Embedded server doesn't support external clients
--source include/not_embedded.inc
......
call mtr.add_suppression("Invalid .old.. table or database name");
-- source include/not_embedded.inc
--disable_warnings
......
......@@ -4571,10 +4571,9 @@ static int cmp_table_names(LEX_STRING * const *a, LEX_STRING * const *b)
Discovered_table_list::Discovered_table_list(THD *thd_arg,
Dynamic_array<LEX_STRING*> *tables_arg,
const LEX_STRING *wild_arg)
const LEX_STRING *wild_arg) :
thd(thd_arg), with_temps(false), tables(tables_arg)
{
thd= thd_arg;
tables= tables_arg;
if (wild_arg->str && wild_arg->str[0])
{
wild= wild_arg->str;
......@@ -4586,6 +4585,12 @@ Discovered_table_list::Discovered_table_list(THD *thd_arg,
bool Discovered_table_list::add_table(const char *tname, size_t tlen)
{
/*
TODO Check with_temps and filter out temp tables.
Implement the check, when we'll have at least one affected engine (with
custom discover_table_names() method, that calls add_table() directly).
Note: avoid comparing the same name twice (here and in add_file).
*/
if (wild && my_wildcmp(files_charset_info, tname, tname + tlen, wild, wend,
wild_prefix, wild_one, wild_many))
return 0;
......@@ -4598,8 +4603,13 @@ bool Discovered_table_list::add_table(const char *tname, size_t tlen)
bool Discovered_table_list::add_file(const char *fname)
{
bool is_temp= strncmp(fname, STRING_WITH_LEN(tmp_file_prefix)) == 0;
if (is_temp && !with_temps)
return 0;
char tname[SAFE_NAME_LEN + 1];
size_t tlen= filename_to_tablename(fname, tname, sizeof(tname));
size_t tlen= filename_to_tablename(fname, tname, sizeof(tname), is_temp);
return add_table(tname, tlen);
}
......@@ -4658,6 +4668,22 @@ static my_bool discover_names(THD *thd, plugin_ref plugin,
return 0;
}
/**
Return the list of tables
@param thd
@param db database to look into
@param dirp list of files in this database (as returned by my_dir())
@param result the object to return the list of files in
@param reusable if true, on return, 'dirp' will be a valid list of all
non-table files. If false, discovery will work much faster,
but it will leave 'dirp' corrupted and completely unusable,
only good for my_dirend().
Normally, reusable=false for SHOW and INFORMATION_SCHEMA, and reusable=true
for DROP DATABASE (as it needs to know and delete non-table files).
*/
int ha_discover_table_names(THD *thd, LEX_STRING *db, MY_DIR *dirp,
Discovered_table_list *result, bool reusable)
{
......
......@@ -3193,11 +3193,14 @@ class Discovered_table_list: public handlerton::discovered_list
{
THD *thd;
const char *wild, *wend;
bool with_temps; // whether to include temp tables in the result
public:
Dynamic_array<LEX_STRING*> *tables;
Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_STRING*> *tables_arg,
const LEX_STRING *wild_arg);
Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_STRING*> *tables_arg)
: thd(thd_arg), wild(NULL), with_temps(true), tables(tables_arg) {}
~Discovered_table_list() {}
bool add_table(const char *tname, size_t tlen);
......
......@@ -991,7 +991,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
/* first, get the list of tables */
Dynamic_array<LEX_STRING*> files(dirp->number_of_files);
Discovered_table_list tl(thd, &files, &null_lex_str);
Discovered_table_list tl(thd, &files);
if (ha_discover_table_names(thd, &db, dirp, &tl, true))
DBUG_RETURN(1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment