diff options
-rw-r--r-- | mysql-test/include/default_mysqld.cnf | 2 | ||||
-rw-r--r-- | mysql-test/include/mtr_warnings.sql | 2 | ||||
-rwxr-xr-x | mysql-test/mysql-test-run.pl | 2 | ||||
-rw-r--r-- | mysql-test/r/create.result | 1 | ||||
-rw-r--r-- | mysql-test/r/drop.result | 1 | ||||
-rw-r--r-- | mysql-test/r/mysqlcheck.result | 1 | ||||
-rw-r--r-- | mysql-test/r/upgrade.result | 1 | ||||
-rw-r--r-- | mysql-test/suite/roles/set_role-5232.result | 15 | ||||
-rw-r--r-- | mysql-test/suite/roles/set_role-5232.test | 20 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_mysql_upgrade.result | 1 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_mysql_upgrade.test | 1 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/r/ignore_db_dirs_basic.result | 1 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/t/ignore_db_dirs_basic.test | 2 | ||||
-rw-r--r-- | mysql-test/t/create.test | 1 | ||||
-rw-r--r-- | mysql-test/t/drop.test | 2 | ||||
-rw-r--r-- | mysql-test/t/mysqlcheck.test | 1 | ||||
-rw-r--r-- | mysql-test/t/upgrade.test | 1 | ||||
-rw-r--r-- | sql/handler.cc | 34 | ||||
-rw-r--r-- | sql/handler.h | 3 | ||||
-rw-r--r-- | sql/sql_acl.cc | 4 | ||||
-rw-r--r-- | sql/sql_db.cc | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 9 | ||||
-rw-r--r-- | sql/sql_table.h | 7 |
23 files changed, 94 insertions, 20 deletions
diff --git a/mysql-test/include/default_mysqld.cnf b/mysql-test/include/default_mysqld.cnf index 46d545050b3..33881666b57 100644 --- a/mysql-test/include/default_mysqld.cnf +++ b/mysql-test/include/default_mysqld.cnf @@ -40,7 +40,7 @@ loose-aria-pagecache-buffer-size=8M loose-feedback-user-info= mysql-test -loose-innodb_data_file_path= ibdata1:10M:autoextend +loose-innodb_data_file_path= ibdata1:12M:autoextend loose-innodb_buffer_pool_size= 8M loose-innodb_lru_scan_depth= 100 loose-innodb_write_io_threads= 2 diff --git a/mysql-test/include/mtr_warnings.sql b/mysql-test/include/mtr_warnings.sql index 0a6077c21d2..0ad1079cd92 100644 --- a/mysql-test/include/mtr_warnings.sql +++ b/mysql-test/include/mtr_warnings.sql @@ -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-"), diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3b8cb96eacb..bd3a7f8d81d 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -4783,7 +4783,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/, diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index ab9cddb2c06..4f4cd9ed4d6 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1,3 +1,4 @@ +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; diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index 209eb896978..a3b7be855eb 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -1,3 +1,4 @@ +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; diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result index 81ed26ce96b..5abce8af9c9 100644 --- a/mysql-test/r/mysqlcheck.result +++ b/mysql-test/r/mysqlcheck.result @@ -1,3 +1,4 @@ +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; diff --git a/mysql-test/r/upgrade.result b/mysql-test/r/upgrade.result index d9252791c0a..b6e924c71cc 100644 --- a/mysql-test/r/upgrade.result +++ b/mysql-test/r/upgrade.result @@ -1,3 +1,4 @@ +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`; diff --git a/mysql-test/suite/roles/set_role-5232.result b/mysql-test/suite/roles/set_role-5232.result new file mode 100644 index 00000000000..888a5f10c3d --- /dev/null +++ b/mysql-test/suite/roles/set_role-5232.result @@ -0,0 +1,15 @@ +create user ''@localhost; +create user c; +grant select on mysql.* to c; +create role r1; +grant r1 to c; +select user(), current_user(); +user() current_user() +c@localhost @localhost +select user from mysql.user group by user; +ERROR 42000: SELECT command denied to user ''@'localhost' for table 'user' +set role r1; +ERROR OP000: Invalid role specification `r1`. +drop role r1; +drop user c; +drop user ''@localhost; diff --git a/mysql-test/suite/roles/set_role-5232.test b/mysql-test/suite/roles/set_role-5232.test new file mode 100644 index 00000000000..c6cb3d925a4 --- /dev/null +++ b/mysql-test/suite/roles/set_role-5232.test @@ -0,0 +1,20 @@ +# +# MDEV-5232 SET ROLE checks privileges differently from check_access() +# +--source include/not_embedded.inc +create user ''@localhost; +create user c; +grant select on mysql.* to c; +create role r1; +grant r1 to c; +connect (c,localhost,c,,,,,); +select user(), current_user(); +--error ER_TABLEACCESS_DENIED_ERROR +select user from mysql.user group by user; +--error ER_INVALID_ROLE +set role r1; +disconnect c; +connection default; +drop role r1; +drop user c; +drop user ''@localhost; diff --git a/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result b/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result index 632529ce2b9..9e360beba2c 100644 --- a/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result +++ b/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result @@ -1,6 +1,7 @@ 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 diff --git a/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test b/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test index a47526d5716..597e3f8a590 100644 --- a/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test +++ b/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test @@ -12,6 +12,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 diff --git a/mysql-test/suite/sys_vars/r/ignore_db_dirs_basic.result b/mysql-test/suite/sys_vars/r/ignore_db_dirs_basic.result index 5802c71d280..6ae3fd70188 100644 --- a/mysql-test/suite/sys_vars/r/ignore_db_dirs_basic.result +++ b/mysql-test/suite/sys_vars/r/ignore_db_dirs_basic.result @@ -1,3 +1,4 @@ +call mtr.add_suppression("table or database name '.otherdir'"); select @@ignore_db_dirs; @@ignore_db_dirs e,lost+found,.mysqlgui,ignored_db diff --git a/mysql-test/suite/sys_vars/t/ignore_db_dirs_basic.test b/mysql-test/suite/sys_vars/t/ignore_db_dirs_basic.test index 9544fc540f9..78f6479dea6 100644 --- a/mysql-test/suite/sys_vars/t/ignore_db_dirs_basic.test +++ b/mysql-test/suite/sys_vars/t/ignore_db_dirs_basic.test @@ -1,3 +1,5 @@ +call mtr.add_suppression("table or database name '.otherdir'"); + select @@ignore_db_dirs; let $MYSQLD_DATADIR= `select @@datadir`; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index f82d859243a..a1152045dd9 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -1,3 +1,4 @@ +call mtr.add_suppression("table or database name 't-1'"); # # Check some special create statements. # diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index 079b10cf708..2cd87b1d980 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -1,3 +1,5 @@ +call mtr.add_suppression("table or database name 'abc`def'"); + # Initialise --disable_warnings drop table if exists t1; diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test index 06d702495c2..d7dab675dc6 100644 --- a/mysql-test/t/mysqlcheck.test +++ b/mysql-test/t/mysqlcheck.test @@ -1,3 +1,4 @@ +call mtr.add_suppression("Invalid .old.. table or database name"); # Embedded server doesn't support external clients --source include/not_embedded.inc diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index 6025fc31415..ab9330176f8 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -1,3 +1,4 @@ +call mtr.add_suppression("Invalid .old.. table or database name"); -- source include/not_embedded.inc --disable_warnings diff --git a/sql/handler.cc b/sql/handler.cc index c06da7194be..dece51839c7 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4950,10 +4950,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; @@ -4965,6 +4964,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; @@ -4977,8 +4982,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); } @@ -5037,6 +5047,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) { diff --git a/sql/handler.h b/sql/handler.h index ee961010b2c..360120615f3 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3962,11 +3962,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); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 7abe3899a2a..fd664e14208 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1872,7 +1872,9 @@ int acl_check_setrole(THD *thd, char *rolename, ulonglong *access) continue; acl_user= (ACL_USER *)acl_user_base; - if (acl_user->wild_eq(thd->security_ctx->user, thd->security_ctx->host)) + /* Yes! priv_user@host. Don't ask why - that's what check_access() does. */ + if (acl_user->wild_eq(thd->security_ctx->priv_user, + thd->security_ctx->host)) { is_granted= TRUE; break; diff --git a/sql/sql_db.cc b/sql/sql_db.cc index b649ddc1900..8db305e45c5 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -992,7 +992,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); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f1c6d85c659..f78f1b56489 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -369,11 +369,8 @@ uint explain_filename(THD* thd, Table name length. */ -uint filename_to_tablename(const char *from, char *to, uint to_length -#ifndef DBUG_OFF - , bool stay_quiet -#endif /* DBUG_OFF */ - ) +uint filename_to_tablename(const char *from, char *to, uint to_length, + bool stay_quiet) { uint errors; size_t res; @@ -386,7 +383,7 @@ uint filename_to_tablename(const char *from, char *to, uint to_length { res= (strxnmov(to, to_length, MYSQL50_TABLE_NAME_PREFIX, from, NullS) - to); - if (IF_DBUG(!stay_quiet,0)) + if (!stay_quiet) sql_print_error("Invalid (old?) table or database name '%s'", from); } diff --git a/sql/sql_table.h b/sql/sql_table.h index 3d8ad3c8875..c42f8aaa39e 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -137,11 +137,8 @@ static const uint SKIP_SYMDIR_ACCESS= 1 << 5; /** Don't check foreign key constraints while renaming table */ static const uint NO_FK_CHECKS= 1 << 6; -uint filename_to_tablename(const char *from, char *to, uint to_length -#ifndef DBUG_OFF - , bool stay_quiet = false -#endif /* DBUG_OFF */ - ); +uint filename_to_tablename(const char *from, char *to, uint to_length, + bool stay_quiet = false); uint tablename_to_filename(const char *from, char *to, uint to_length); uint check_n_cut_mysql50_prefix(const char *from, char *to, uint to_length); bool check_mysql50_prefix(const char *name); |