From: kevin.lewis Date: February 7 2012 11:35pm Subject: bzr push into mysql-trunk branch (kevin.lewis:3855 to 3856) WL#6145 List-Archive: http://lists.mysql.com/commits/142793 Message-Id: <20120207233512.E260B1DEF781@dhcp-adc-twvpn-2-vpnpool-10-154-45-59.vpn.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3856 kevin.lewis@stripped 2012-02-07 WL#6145 - This patch moves to the storage engine the code that determines whether DATA DIRECTORY and INDEX DIRECTORY on a CREATE TABLE command is ignored. It affects Archive and MyISAM storage engines where these clauses are used, and it affects the Partition engine where these clauses are passed through to the lower engine. In the future, WL5980, InnoDB will also use these clauses. modified: mysql-test/r/partition_windows.result sql/log_event.cc sql/partition_info.cc sql/sql_parse.cc sql/sql_table.cc storage/archive/ha_archive.cc storage/myisam/ha_myisam.cc 3855 Guilhem Bichot 2012-02-07 [merge] merge from trunk modified: mysql-test/r/ps.result mysql-test/t/ps.test === modified file 'mysql-test/r/partition_windows.result' --- a/mysql-test/r/partition_windows.result revid:guilhem.bichot@stripped +++ b/mysql-test/r/partition_windows.result revid:kevin.lewis@stripped @@ -26,5 +26,9 @@ ALTER TABLE t1 ADD PARTITION (PARTITION Warnings: Warning 1618 option ignored Warning 1618 option ignored +Warning 1618 option ignored +Warning 1618 option ignored +Warning 1618 option ignored +Warning 1618 option ignored INSERT INTO t1 VALUES (NULL, "last", 4); DROP TABLE t1; === modified file 'sql/log_event.cc' --- a/sql/log_event.cc revid:guilhem.bichot@stripped +++ b/sql/log_event.cc revid:kevin.lewis@stripped @@ -4316,11 +4316,11 @@ int Query_log_event::do_apply_event(Rela nothing to do. */ /* - We do not replicate IGNORE_DIR_IN_CREATE. That is, if the master is a - slave which runs with SQL_MODE=IGNORE_DIR_IN_CREATE, this should not + We do not replicate MODE_NO_DIR_IN_CREATE. That is, if the master is a + slave which runs with SQL_MODE=MODE_NO_DIR_IN_CREATE, this should not force us to ignore the dir too. Imagine you are a ring of machines, and one has a disk problem so that you temporarily need - IGNORE_DIR_IN_CREATE on this machine; you don't want it to propagate + MODE_NO_DIR_IN_CREATE on this machine; you don't want it to propagate elsewhere (you don't want all slaves to start ignoring the dirs). */ if (sql_mode_inited) === modified file 'sql/partition_info.cc' --- a/sql/partition_info.cc revid:guilhem.bichot@stripped +++ b/sql/partition_info.cc revid:kevin.lewis@stripped @@ -1233,9 +1233,7 @@ end: */ static void warn_if_dir_in_part_elem(THD *thd, partition_element *part_elem) { -#ifdef HAVE_READLINK - if (!my_use_symdir || (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)) -#endif + if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE) { if (part_elem->data_file_name) push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, === modified file 'sql/sql_parse.cc' --- a/sql/sql_parse.cc revid:guilhem.bichot@stripped +++ b/sql/sql_parse.cc revid:kevin.lewis@stripped @@ -2603,14 +2603,13 @@ case SQLCOM_PREPARE: /* Might have been updated in create_table_precheck */ create_info.alias= create_table->alias; -#ifdef HAVE_READLINK - /* Fix names if symlinked tables */ + /* Fix names if symlinked or relocated tables */ if (append_file_to_dir(thd, &create_info.data_file_name, create_table->table_name) || append_file_to_dir(thd, &create_info.index_file_name, create_table->table_name)) goto end_with_restore_list; -#endif + /* If no engine type was given, work out the default now rather than at parse-time. === modified file 'sql/sql_table.cc' --- a/sql/sql_table.cc revid:guilhem.bichot@stripped +++ b/sql/sql_table.cc revid:kevin.lewis@stripped @@ -4431,7 +4431,6 @@ bool mysql_create_table_no_lock(THD *thd THD_STAGE_INFO(thd, stage_creating_table); -#ifdef HAVE_READLINK { size_t dirlen; char dirpath[FN_REFLEN]; @@ -4478,8 +4477,7 @@ bool mysql_create_table_no_lock(THD *thd } #endif /* WITH_PARTITION_STORAGE_ENGINE */ - if (!my_use_symdir || (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)) -#endif /* HAVE_READLINK */ + if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE) { if (create_info->data_file_name) push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, === modified file 'storage/archive/ha_archive.cc' --- a/storage/archive/ha_archive.cc revid:guilhem.bichot@stripped +++ b/storage/archive/ha_archive.cc revid:kevin.lewis@stripped @@ -737,12 +737,12 @@ void ha_archive::frm_load(const char *na { if (!mysql_file_fstat(frm_file, &file_stat, MYF(MY_WME))) { - frm_ptr= (uchar *) my_malloc(sizeof(uchar) * file_stat.st_size, MYF(0)); + frm_ptr= (uchar *) my_malloc(sizeof(uchar) * (size_t) file_stat.st_size, MYF(0)); if (frm_ptr) { - if (my_read(frm_file, frm_ptr, file_stat.st_size, MYF(0)) == + if (my_read(frm_file, frm_ptr, (size_t) file_stat.st_size, MYF(0)) == (size_t) file_stat.st_size) - azwrite_frm(dst, (char *) frm_ptr, file_stat.st_size); + azwrite_frm(dst, (char *) frm_ptr, (size_t) file_stat.st_size); my_free(frm_ptr); } } @@ -831,7 +831,10 @@ int ha_archive::create(const char *name, /* We reuse name_buff since it is available. */ - if (create_info->data_file_name && create_info->data_file_name[0] != '#') +#ifdef HAVE_READLINK + if (my_use_symdir && + create_info->data_file_name && + create_info->data_file_name[0] != '#') { DBUG_PRINT("ha_archive", ("archive will create stream file %s", create_info->data_file_name)); @@ -842,12 +845,29 @@ int ha_archive::create(const char *name, MY_REPLACE_EXT | MY_UNPACK_FILENAME); } else +#endif /* HAVE_READLINK */ { + if (create_info->data_file_name) + { + push_warning_printf(table_arg->in_use, Sql_condition::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED, + ER_DEFAULT(WARN_OPTION_IGNORED), + "DATA DIRECTORY"); + } fn_format(name_buff, name, "", ARZ, MY_REPLACE_EXT | MY_UNPACK_FILENAME); linkname[0]= 0; } + /* Archive engine never uses INDEX DIRECTORY. */ + if (create_info->index_file_name) + { + push_warning_printf(table_arg->in_use, Sql_condition::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED, + ER_DEFAULT(WARN_OPTION_IGNORED), + "INDEX DIRECTORY"); + } + /* There is a chance that the file was "discovered". In this case just use whatever file is there. === modified file 'storage/myisam/ha_myisam.cc' --- a/storage/myisam/ha_myisam.cc revid:guilhem.bichot@stripped +++ b/storage/myisam/ha_myisam.cc revid:kevin.lewis@stripped @@ -1942,10 +1942,27 @@ int ha_myisam::create(const char *name, (ulonglong) 0); create_info.data_file_length= ((ulonglong) share->max_rows * share->avg_row_length); - create_info.data_file_name= ha_create_info->data_file_name; - create_info.index_file_name= ha_create_info->index_file_name; create_info.language= share->table_charset->number; +#ifdef HAVE_READLINK + if (my_use_symdir) + { + create_info.data_file_name= ha_create_info->data_file_name; + create_info.index_file_name= ha_create_info->index_file_name; + } + else +#endif /* HAVE_READLINK */ + { + if (ha_create_info->data_file_name) + push_warning_printf(table_arg->in_use, Sql_condition::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED), + "DATA DIRECTORY"); + if (ha_create_info->index_file_name) + push_warning_printf(table_arg->in_use, Sql_condition::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED), + "INDEX DIRECTORY"); + } + if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE) create_flags|= HA_CREATE_TMP_TABLE; if (ha_create_info->options & HA_CREATE_KEEP_FILES) No bundle (reason: useless for push emails).