Commit 0150dc6e authored by Sergei Golubchik's avatar Sergei Golubchik

10.0-base merge

parents a30e8741 bf603250
...@@ -40,7 +40,7 @@ loose-aria-pagecache-buffer-size=8M ...@@ -40,7 +40,7 @@ loose-aria-pagecache-buffer-size=8M
loose-feedback-user-info= mysql-test 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_buffer_pool_size= 8M
loose-innodb_lru_scan_depth= 100 loose-innodb_lru_scan_depth= 100
loose-innodb_write_io_threads= 2 loose-innodb_write_io_threads= 2
......
...@@ -108,7 +108,7 @@ INSERT INTO global_suppressions VALUES ...@@ -108,7 +108,7 @@ INSERT INTO global_suppressions VALUES
("Incorrect definition of table"), ("Incorrect definition of table"),
("Incorrect information in file"), ("Incorrect information in file"),
("InnoDB: Warning: we did not need to do crash recovery"), ("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"), ("Lock wait timeout exceeded"),
("Log entry on master is longer than max_allowed_packet"), ("Log entry on master is longer than max_allowed_packet"),
("unknown option '--loose-"), ("unknown option '--loose-"),
......
...@@ -4783,7 +4783,7 @@ sub extract_warning_lines ($$) { ...@@ -4783,7 +4783,7 @@ sub extract_warning_lines ($$) {
qr/slave SQL thread aborted/, qr/slave SQL thread aborted/,
qr/unknown option '--loose[-_]/, qr/unknown option '--loose[-_]/,
qr/unknown variable '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/Now setting lower_case_table_names to [02]/,
qr/Setting lower_case_table_names=2/, qr/Setting lower_case_table_names=2/,
qr/You have forced lower_case_table_names to 0/, 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 table if exists t1,t2,t3,t4,t5;
drop database if exists mysqltest; drop database if exists mysqltest;
drop view if exists v1; drop view if exists v1;
......
call mtr.add_suppression("table or database name 'abc`def'");
drop table if exists t1; drop table if exists t1;
drop database if exists mysqltest; drop database if exists mysqltest;
drop database if exists client_test_db; 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 TABLE IF EXISTS t1, `t``1`, `t 1`;
drop view if exists v1; drop view if exists v1;
drop database if exists client_test_db; 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 `mysqltest1`;
drop database if exists `mysqltest-1`; drop database if exists `mysqltest-1`;
drop database if exists `#mysql50#mysqltest-1`; drop database if exists `#mysql50#mysqltest-1`;
......
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;
#
# 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;
include/master-slave.inc include/master-slave.inc
[connection master] [connection master]
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); 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`; DROP DATABASE IF EXISTS `#mysql50#mysqltest-1`;
CREATE DATABASE `#mysql50#mysqltest-1`; CREATE DATABASE `#mysql50#mysqltest-1`;
Master position is not changed Master position is not changed
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
--source include/have_mysql_upgrade.inc --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("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; connection master;
--disable_warnings --disable_warnings
......
call mtr.add_suppression("table or database name '.otherdir'");
select @@ignore_db_dirs; select @@ignore_db_dirs;
@@ignore_db_dirs @@ignore_db_dirs
e,lost+found,.mysqlgui,ignored_db e,lost+found,.mysqlgui,ignored_db
......
call mtr.add_suppression("table or database name '.otherdir'");
select @@ignore_db_dirs; select @@ignore_db_dirs;
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
......
call mtr.add_suppression("table or database name 't-1'");
# #
# Check some special create statements. # Check some special create statements.
# #
......
call mtr.add_suppression("table or database name 'abc`def'");
# Initialise # Initialise
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
......
call mtr.add_suppression("Invalid .old.. table or database name");
# Embedded server doesn't support external clients # Embedded server doesn't support external clients
--source include/not_embedded.inc --source include/not_embedded.inc
......
call mtr.add_suppression("Invalid .old.. table or database name");
-- source include/not_embedded.inc -- source include/not_embedded.inc
--disable_warnings --disable_warnings
......
...@@ -4950,10 +4950,9 @@ static int cmp_table_names(LEX_STRING * const *a, LEX_STRING * const *b) ...@@ -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, Discovered_table_list::Discovered_table_list(THD *thd_arg,
Dynamic_array<LEX_STRING*> *tables_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]) if (wild_arg->str && wild_arg->str[0])
{ {
wild= wild_arg->str; wild= wild_arg->str;
...@@ -4965,6 +4964,12 @@ Discovered_table_list::Discovered_table_list(THD *thd_arg, ...@@ -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) 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, if (wild && my_wildcmp(files_charset_info, tname, tname + tlen, wild, wend,
wild_prefix, wild_one, wild_many)) wild_prefix, wild_one, wild_many))
return 0; return 0;
...@@ -4977,8 +4982,13 @@ bool Discovered_table_list::add_table(const char *tname, size_t tlen) ...@@ -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 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]; 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); return add_table(tname, tlen);
} }
...@@ -5037,6 +5047,22 @@ static my_bool discover_names(THD *thd, plugin_ref plugin, ...@@ -5037,6 +5047,22 @@ static my_bool discover_names(THD *thd, plugin_ref plugin,
return 0; 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, int ha_discover_table_names(THD *thd, LEX_STRING *db, MY_DIR *dirp,
Discovered_table_list *result, bool reusable) Discovered_table_list *result, bool reusable)
{ {
......
...@@ -3962,11 +3962,14 @@ class Discovered_table_list: public handlerton::discovered_list ...@@ -3962,11 +3962,14 @@ class Discovered_table_list: public handlerton::discovered_list
{ {
THD *thd; THD *thd;
const char *wild, *wend; const char *wild, *wend;
bool with_temps; // whether to include temp tables in the result
public: public:
Dynamic_array<LEX_STRING*> *tables; Dynamic_array<LEX_STRING*> *tables;
Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_STRING*> *tables_arg, Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_STRING*> *tables_arg,
const LEX_STRING *wild_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() {} ~Discovered_table_list() {}
bool add_table(const char *tname, size_t tlen); bool add_table(const char *tname, size_t tlen);
......
...@@ -1872,7 +1872,9 @@ int acl_check_setrole(THD *thd, char *rolename, ulonglong *access) ...@@ -1872,7 +1872,9 @@ int acl_check_setrole(THD *thd, char *rolename, ulonglong *access)
continue; continue;
acl_user= (ACL_USER *)acl_user_base; 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; is_granted= TRUE;
break; break;
......
...@@ -992,7 +992,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp, ...@@ -992,7 +992,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
/* first, get the list of tables */ /* first, get the list of tables */
Dynamic_array<LEX_STRING*> files(dirp->number_of_files); 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)) if (ha_discover_table_names(thd, &db, dirp, &tl, true))
DBUG_RETURN(1); DBUG_RETURN(1);
......
...@@ -369,11 +369,8 @@ uint explain_filename(THD* thd, ...@@ -369,11 +369,8 @@ uint explain_filename(THD* thd,
Table name length. Table name length.
*/ */
uint filename_to_tablename(const char *from, char *to, uint to_length uint filename_to_tablename(const char *from, char *to, uint to_length,
#ifndef DBUG_OFF bool stay_quiet)
, bool stay_quiet
#endif /* DBUG_OFF */
)
{ {
uint errors; uint errors;
size_t res; size_t res;
...@@ -386,7 +383,7 @@ uint filename_to_tablename(const char *from, char *to, uint to_length ...@@ -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) - res= (strxnmov(to, to_length, MYSQL50_TABLE_NAME_PREFIX, from, NullS) -
to); to);
if (IF_DBUG(!stay_quiet,0)) if (!stay_quiet)
sql_print_error("Invalid (old?) table or database name '%s'", from); sql_print_error("Invalid (old?) table or database name '%s'", from);
} }
......
...@@ -137,11 +137,8 @@ static const uint SKIP_SYMDIR_ACCESS= 1 << 5; ...@@ -137,11 +137,8 @@ static const uint SKIP_SYMDIR_ACCESS= 1 << 5;
/** Don't check foreign key constraints while renaming table */ /** Don't check foreign key constraints while renaming table */
static const uint NO_FK_CHECKS= 1 << 6; static const uint NO_FK_CHECKS= 1 << 6;
uint filename_to_tablename(const char *from, char *to, uint to_length uint filename_to_tablename(const char *from, char *to, uint to_length,
#ifndef DBUG_OFF bool stay_quiet = false);
, bool stay_quiet = false
#endif /* DBUG_OFF */
);
uint tablename_to_filename(const char *from, char *to, uint to_length); 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); uint check_n_cut_mysql50_prefix(const char *from, char *to, uint to_length);
bool check_mysql50_prefix(const char *name); bool check_mysql50_prefix(const char *name);
......
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