From: Dmitry Lenev Date: November 2 2012 6:42pm Subject: bzr push into mysql-trunk branch (Dmitry.Lenev:4892 to 4893) WL#6561 List-Archive: http://lists.mysql.com/commits/145156 Message-Id: <20121102184224.15854.57789.4893@jubjub> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4893 Dmitry Lenev 2012-11-02 WL#6561 "Deprecate and remove support for .sym files (custom symlink implementation)". Starting from Vista/Server 2008 a native symlinking mechanism is supported by Windows (through MKLINK command). Since starting from 5.6 we don't plan to support Windows XP/Server 2003 this makes MySQL Server implementation of symbolic links for Windows (based on custom .sym files) redundant. Therefore it is a good idea first to deprecate and then completely remove code implementing custom symbolic links. Note that having this custom implementation around is a bad idea not only from code complexity view point, but it also creates performance problems in some scenarios and is cause behind some bugs. This patch is the second step in this WL which completely removes this custom implementation. To do this it: * Removes USE_SYMDIR macro and all code withing #ifdef USE_SYMDIR. * Replaces usage of my_disable_symlinks with my_enable_symlinks to facilitate the next step. * Removes my_use_symdir global variable. In places where it is used to check if DATA/INDEX DIRECTORY clause should be supported we use my_enable_symlinks instead. Uses my_enable_symlinks to store value of --symbolic-links start-up option. After this change --symbolic-links option doesn't have any effect on Windows. But it still controls behavior for DATA/INDEX DIRECTORY clauses for MyISAM and Archive tables on Unix platforms. modified: cmake/os/Windows.cmake config.h.cmake extra/replace.c include/my_sys.h mysys/mf_pack.c mysys/my_static.c mysys/my_symlink2.c sql/mysqld.cc sql/sql_cache.cc sql/sql_show.cc sql/sql_table.cc sql/sql_table.h storage/archive/ha_archive.cc storage/myisam/ha_myisam.cc 4892 Dmitry Lenev 2012-11-02 [merge] Null-merged 5.6 version WL#6561 "Deprecate and remove support for .sym files (custom symlink implementation)" into 5.7 tree. === modified file 'cmake/os/Windows.cmake' --- a/cmake/os/Windows.cmake 2012-04-17 14:20:00 +0000 +++ b/cmake/os/Windows.cmake 2012-11-02 18:41:40 +0000 @@ -191,4 +191,3 @@ IF(NOT HAVE_SIZE_OF_SSIZE_T) ENDIF() SET(FN_NO_CASE_SENSE 1) -SET(USE_SYMDIR 1) === modified file 'config.h.cmake' --- a/config.h.cmake 2012-05-17 12:51:37 +0000 +++ b/config.h.cmake 2012-11-02 18:41:40 +0000 @@ -545,7 +545,6 @@ #cmakedefine BACKUP_TEST 1 #cmakedefine CYBOZU 1 #cmakedefine OPTIMIZER_TRACE 1 -#cmakedefine USE_SYMDIR 1 /* InnoDB config options === modified file 'extra/replace.c' --- a/extra/replace.c 2011-09-07 10:08:09 +0000 +++ b/extra/replace.c 2012-11-02 18:41:40 +0000 @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -1064,7 +1064,7 @@ static int convert_file(REPLACE *rep, ch /* check if name is a symlink */ #ifdef HAVE_READLINK - org_name= (!my_disable_symlinks && + org_name= (my_enable_symlinks && !my_readlink(link_name, name, MYF(0))) ? link_name : name; #endif if (!(in= my_fopen(org_name,O_RDONLY,MYF(MY_WME)))) === modified file 'include/my_sys.h' --- a/include/my_sys.h 2012-11-02 17:28:49 +0000 +++ b/include/my_sys.h 2012-11-02 18:41:40 +0000 @@ -280,11 +280,10 @@ extern int my_umask_dir, my_recived_signals, /* Signals we have got */ my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */ my_dont_interrupt; /* call remember_intr when set */ -extern my_bool my_use_symdir; extern ulong my_default_record_cache_size; extern my_bool my_disable_locking, my_disable_async_io, - my_disable_flush_key_blocks, my_disable_symlinks; + my_disable_flush_key_blocks, my_enable_symlinks; extern char wild_many,wild_one,wild_prefix; extern const char *charsets_dir; === modified file 'mysys/mf_pack.c' --- a/mysys/mf_pack.c 2012-11-02 17:28:49 +0000 +++ b/mysys/mf_pack.c 2012-11-02 18:41:40 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -227,51 +227,6 @@ size_t cleanup_dirname(register char *to } /* cleanup_dirname */ -/* - On system where you don't have symbolic links, the following - code will allow you to create a file: - directory-name.sym that should contain the real path - to the directory. This will be used if the directory name - doesn't exists -*/ - - -my_bool my_use_symdir=0; /* Set this if you want to use symdirs */ - -#ifdef USE_SYMDIR -void symdirget(char *dir) -{ - char buff[FN_REFLEN+1]; - char *pos=strend(dir); - if (dir[0] && pos[-1] != FN_DEVCHAR && my_access(dir, F_OK)) - { - File file; - size_t length; - char temp= *(--pos); /* May be "/" or "\" */ - strmov(pos,".sym"); - file= my_open(dir, O_RDONLY, MYF(0)); - *pos++=temp; *pos=0; /* Restore old filename */ - if (file >= 0) - { - if ((length= my_read(file, buff, sizeof(buff) - 1, MYF(0))) > 0) - { - for (pos= buff + length ; - pos > buff && (iscntrl(pos[-1]) || isspace(pos[-1])) ; - pos --); - - /* Ensure that the symlink ends with the directory symbol */ - if (pos == buff || pos[-1] != FN_LIBCHAR) - *pos++=FN_LIBCHAR; - - strmake(dir,buff, (size_t) (pos-buff)); - } - my_close(file, MYF(0)); - } - } -} -#endif /* USE_SYMDIR */ - - /** Convert a directory name to a format which can be compared as strings @@ -328,7 +283,6 @@ size_t normalize_dirname(char *to, const @details - Uses normalize_dirname() - Expands ~/... to home_dir/... - - Resolves MySQL's fake "foo.sym" symbolic directory names (if USE_SYMDIR) - Changes a UNIX filename to system filename (replaces / with \ on windows) @returns @@ -361,10 +315,6 @@ size_t unpack_dirname(char * to, const c } } } -#ifdef USE_SYMDIR - if (my_use_symdir) - symdirget(buff); -#endif DBUG_RETURN(system_filename(to,buff)); /* Fix for open */ } /* unpack_dirname */ === modified file 'mysys/my_static.c' --- a/mysys/my_static.c 2011-09-07 10:08:09 +0000 +++ b/mysys/my_static.c 2012-11-02 18:41:40 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -105,5 +105,5 @@ ulonglong query_performance_frequency, q my_bool my_disable_locking=0; my_bool my_disable_async_io=0; my_bool my_disable_flush_key_blocks=0; -my_bool my_disable_symlinks=0; +my_bool my_enable_symlinks= 1; === modified file 'mysys/my_symlink2.c' --- a/mysys/my_symlink2.c 2012-03-06 14:29:42 +0000 +++ b/mysys/my_symlink2.c 2012-11-02 18:41:40 +0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Advanced symlink handling. @@ -37,7 +37,7 @@ File my_create_with_symlink(const char * linkname ? linkname : "(null)", filename ? filename : "(null)")); - if (my_disable_symlinks) + if (!my_enable_symlinks) { DBUG_PRINT("info", ("Symlinks disabled")); /* Create only the file, not the link and file */ @@ -102,7 +102,7 @@ File my_create_with_symlink(const char * int my_delete_with_symlink(const char *name, myf MyFlags) { char link_name[FN_REFLEN]; - int was_symlink= (!my_disable_symlinks && + int was_symlink= (my_enable_symlinks && !my_readlink(link_name, name, MYF(0))); int result; DBUG_ENTER("my_delete_with_symlink"); @@ -131,7 +131,7 @@ int my_rename_with_symlink(const char *f return my_rename(from, to, MyFlags); #else char link_name[FN_REFLEN], tmp_name[FN_REFLEN]; - int was_symlink= (!my_disable_symlinks && + int was_symlink= (my_enable_symlinks && !my_readlink(link_name, from, MYF(0))); int result=0; int name_is_different; === modified file 'sql/mysqld.cc' --- a/sql/mysqld.cc 2012-11-01 11:49:52 +0000 +++ b/sql/mysqld.cc 2012-11-02 18:41:40 +0000 @@ -7057,7 +7057,7 @@ struct my_option my_long_options[]= NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"symbolic-links", 's', "Enable symbolic link support.", - &my_use_symdir, &my_use_symdir, 0, GET_BOOL, NO_ARG, + &my_enable_symlinks, &my_enable_symlinks, 0, GET_BOOL, NO_ARG, /* The system call realpath() produces warnings under valgrind and purify. These are not suppressed: instead we disable symlinks @@ -8302,7 +8302,7 @@ mysqld_get_one_option(int optid, myisam_concurrent_insert=0; myisam_recover_options= HA_RECOVER_OFF; sp_automatic_privileges=0; - my_use_symdir=0; + my_enable_symlinks= 0; ha_open_options&= ~(HA_OPEN_ABORT_IF_CRASHED | HA_OPEN_DELAY_KEY_WRITE); #ifdef HAVE_QUERY_CACHE query_cache_size=0; @@ -8654,15 +8654,11 @@ static int get_options(int *argc_ptr, ch global_system_variables.sql_mode= expand_sql_mode(global_system_variables.sql_mode); #if defined(HAVE_BROKEN_REALPATH) - my_use_symdir=0; - my_disable_symlinks=1; + my_enable_symlinks= 0; have_symlink=SHOW_OPTION_NO; #else - if (!my_use_symdir) - { - my_disable_symlinks=1; + if (!my_enable_symlinks) have_symlink=SHOW_OPTION_DISABLED; - } #endif if (opt_debugging) { === modified file 'sql/sql_cache.cc' --- a/sql/sql_cache.cc 2012-10-31 06:26:56 +0000 +++ b/sql/sql_cache.cc 2012-11-02 18:41:40 +0000 @@ -1741,7 +1741,7 @@ def_week_frmt: %lu, in_trans: %d, autoco qcache_se_key_len= build_table_filename(qcache_se_key_name, sizeof(qcache_se_key_name), table->db(), table->table(), - "", SKIP_SYMDIR_ACCESS); + "", 0); if (!(*table->callback())(thd, qcache_se_key_name, qcache_se_key_len, &engine_data)) === modified file 'sql/sql_show.cc' --- a/sql/sql_show.cc 2012-11-02 17:28:49 +0000 +++ b/sql/sql_show.cc 2012-11-02 18:41:40 +0000 @@ -625,21 +625,6 @@ find_files(THD *thd, List *f */ if (file->name[0] == '.') continue; -#ifdef USE_SYMDIR - char buff[FN_REFLEN]; - if (my_use_symdir && !strcmp(ext=fn_ext(file->name), ".sym")) - { - /* Only show the sym file if it points to a directory */ - char *end; - *ext=0; /* Remove extension */ - unpack_dirname(buff, file->name); - end= strend(buff); - if (end != buff && end[-1] == FN_LIBCHAR) - end[-1]= 0; // Remove end FN_LIBCHAR - if (!mysql_file_stat(key_file_misc, buff, file->mystat, MYF(0))) - continue; - } -#endif if (!MY_S_ISDIR(file->mystat->st_mode)) continue; === modified file 'sql/sql_table.cc' --- a/sql/sql_table.cc 2012-11-02 17:28:49 +0000 +++ b/sql/sql_table.cc 2012-11-02 18:41:40 +0000 @@ -574,13 +574,6 @@ uint build_table_filename(char *buff, si memcmp(pos - rootdir_len, FN_ROOTDIR, rootdir_len) != 0) pos= strnmov(pos, FN_ROOTDIR, end - pos); pos= strxnmov(pos, end - pos, dbbuff, FN_ROOTDIR, NullS); -#ifdef USE_SYMDIR - if (!(flags & SKIP_SYMDIR_ACCESS)) - { - unpack_dirname(buff, buff); - pos= strend(buff); - } -#endif pos= strxnmov(pos, end - pos, tbbuff, ext, NullS); DBUG_PRINT("exit", ("buff: '%s'", buff)); === modified file 'sql/sql_table.h' --- a/sql/sql_table.h 2012-10-31 06:26:56 +0000 +++ b/sql/sql_table.h 2012-11-02 18:41:40 +0000 @@ -136,8 +136,6 @@ static const uint NO_FRM_RENAME= 1 << static const uint FRM_ONLY= 1 << 3; /** Don't remove table in engine. Remove only .FRM and maybe .PAR files. */ static const uint NO_HA_TABLE= 1 << 4; -/** Don't resolve MySQL's fake "foo.sym" symbolic directory names. */ -static const uint SKIP_SYMDIR_ACCESS= 1 << 5; uint filename_to_tablename(const char *from, char *to, uint to_length #ifndef DBUG_OFF === modified file 'storage/archive/ha_archive.cc' --- a/storage/archive/ha_archive.cc 2012-10-31 08:28:46 +0000 +++ b/storage/archive/ha_archive.cc 2012-11-02 18:41:40 +0000 @@ -771,7 +771,7 @@ int ha_archive::create(const char *name, We reuse name_buff since it is available. */ #ifdef HAVE_READLINK - if (my_use_symdir && + if (my_enable_symlinks && create_info->data_file_name && create_info->data_file_name[0] != '#') { === modified file 'storage/myisam/ha_myisam.cc' --- a/storage/myisam/ha_myisam.cc 2012-10-31 08:28:46 +0000 +++ b/storage/myisam/ha_myisam.cc 2012-11-02 18:41:40 +0000 @@ -1980,7 +1980,7 @@ int ha_myisam::create(const char *name, create_info.language= share->table_charset->number; #ifdef HAVE_READLINK - if (my_use_symdir) + if (my_enable_symlinks) { create_info.data_file_name= ha_create_info->data_file_name; create_info.index_file_name= ha_create_info->index_file_name; No bundle (reason: useless for push emails).