Skip to content

Commit 5c5a049

Browse files
author
Nisha Gopalakrishnan
committed
Merge branch 'mysql-5.6' into mysql-5.7
2 parents 9079331 + 2599a5b commit 5c5a049

File tree

6 files changed

+96
-3
lines changed

6 files changed

+96
-3
lines changed

sql/handler.cc

+36
Original file line numberDiff line numberDiff line change
@@ -8785,3 +8785,39 @@ bool set_tx_isolation(THD *thd,
87858785
}
87868786
return false;
87878787
}
8788+
8789+
8790+
/**
8791+
Checks if the file name is reserved word used by SE by invoking
8792+
the handlerton method.
8793+
8794+
@param unused1 thread handler which is unused.
8795+
@param plugin SE plugin.
8796+
@param name Database name.
8797+
8798+
@retval true If the name is reserved word.
8799+
@retval false If the name is not reserved word.
8800+
*/
8801+
static my_bool is_reserved_db_name_handlerton(THD *unused1, plugin_ref plugin,
8802+
void *name)
8803+
{
8804+
handlerton *hton= plugin_data<handlerton*>(plugin);
8805+
if (hton->state == SHOW_OPTION_YES && hton->is_reserved_db_name)
8806+
return (hton->is_reserved_db_name(hton, (const char *)name));
8807+
return false;
8808+
}
8809+
8810+
8811+
/**
8812+
Check if the file name is reserved word used by SE.
8813+
8814+
@param name Database name.
8815+
8816+
@retval true If the name is a reserved word.
8817+
@retval false If the name is not a reserved word.
8818+
*/
8819+
bool ha_check_reserved_db_name(const char* name)
8820+
{
8821+
return (plugin_foreach(NULL, is_reserved_db_name_handlerton,
8822+
MYSQL_STORAGE_ENGINE_PLUGIN, (char *)name));
8823+
}

sql/handler.h

+11
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,16 @@ struct handlerton
984984
true on failure
985985
*/
986986
bool (*rotate_encryption_master_key)(void);
987+
/**
988+
Check if the given database name is reserved.
989+
990+
@param hton Handlerton for SE.
991+
@param name Database name.
992+
993+
@retval true Database name is reserved by SE.
994+
@retval false Database name is not reserved.
995+
*/
996+
bool (*is_reserved_db_name)(handlerton *hton, const char *name);
987997

988998
uint32 license; /* Flag for Engine License */
989999
void *data; /* Location for engines to keep personal structures */
@@ -4163,5 +4173,6 @@ int commit_owned_gtid_by_partial_command(THD *thd);
41634173
bool set_tx_isolation(THD *thd,
41644174
enum_tx_isolation tx_isolation,
41654175
bool one_shot);
4176+
bool ha_check_reserved_db_name(const char *name);
41664177

41674178
#endif /* HANDLER_INCLUDED */

sql/sql_db.cc

+6
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,12 @@ int mysql_create_db(THD *thd, const char *db, HA_CREATE_INFO *create_info,
572572
DBUG_RETURN(-1);
573573
}
574574

575+
if (ha_check_reserved_db_name(db))
576+
{
577+
my_error(ER_WRONG_DB_NAME, MYF(0), db);
578+
DBUG_RETURN(-1);
579+
}
580+
575581
if (lock_schema_name(thd, db))
576582
DBUG_RETURN(-1);
577583

storage/innobase/handler/ha_innodb.cc

+39
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,17 @@ innobase_fts_store_docid(
12721272
dbug_tmp_restore_column_map(tbl->write_set, old_map);
12731273
}
12741274

1275+
/*****************************************************************//**
1276+
Checks if the filename name is reserved in InnoDB.
1277+
@return true if the name is reserved */
1278+
static
1279+
bool
1280+
innobase_check_reserved_file_name(
1281+
/*===================*/
1282+
handlerton* hton, /*!< in: handlerton of Innodb */
1283+
const char* name); /*!< in: Name of the database */
1284+
1285+
12751286
/*************************************************************//**
12761287
Check for a valid value of innobase_commit_concurrency.
12771288
@return 0 for valid innodb_commit_concurrency */
@@ -3547,6 +3558,7 @@ innobase_init(
35473558
innobase_hton->replace_native_transaction_in_thd =
35483559
innodb_replace_trx_in_thd;
35493560
innobase_hton->data = &innodb_api_cb;
3561+
innobase_hton->is_reserved_db_name= innobase_check_reserved_file_name;
35503562

35513563
innobase_hton->is_supported_system_table=
35523564
innobase_is_supported_system_table;
@@ -21360,3 +21372,30 @@ innodb_buffer_pool_size_validate(
2136021372

2136121373
return(0);
2136221374
}
21375+
21376+
/*****************************************************************//**
21377+
Checks if the file name is reserved in InnoDB. Currently
21378+
redo log files(ib_logfile*) is reserved.
21379+
@return true if the name is reserved */
21380+
static
21381+
bool
21382+
innobase_check_reserved_file_name(
21383+
/*===================*/
21384+
handlerton* hton, /*!< in: handlerton of Innodb */
21385+
const char* name) /*!< in: Name of the database */
21386+
{
21387+
CHARSET_INFO *ci= system_charset_info;
21388+
size_t logname_size = strlen(ib_logfile_basename);
21389+
21390+
/* Name is smaller than reserved name */
21391+
if (strlen(name) < logname_size) {
21392+
return (false);
21393+
}
21394+
/* Do case insensitive comparison for name. */
21395+
for (uint i=0; i < logname_size; i++) {
21396+
if (my_tolower(ci, name[i]) != ib_logfile_basename[i]){
21397+
return (false);
21398+
}
21399+
}
21400+
return (true);
21401+
}

storage/innobase/include/log0log.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
3+
Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
44
Copyright (c) 2009, Google Inc.
55
66
Portions of this file contain modifications contributed and copyrighted by
@@ -67,6 +67,8 @@ typedef ulint (*log_checksum_func_t)(const byte* log_block);
6767
log_sys->mutex. */
6868
extern log_checksum_func_t log_checksum_algorithm_ptr;
6969

70+
static const char ib_logfile_basename[] = "ib_logfile";
71+
7072
/*******************************************************************//**
7173
Calculates where in log files we find a specified lsn.
7274
@return log file number */

storage/innobase/log/log0recv.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2012, Facebook Inc.
55
66
This program is free software; you can redistribute it and/or modify it under
@@ -4484,7 +4484,6 @@ recv_reset_log_files_for_backup(
44844484
ulint i;
44854485
ulint log_dir_len;
44864486
char name[5000];
4487-
static const char ib_logfile_basename[] = "ib_logfile";
44884487

44894488
log_dir_len = strlen(log_dir);
44904489
/* full path name of ib_logfile consists of log dir path + basename

0 commit comments

Comments
 (0)