Below is the list of changes that have just been committed into a local
5.1 repository of tsmith. When tsmith does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-18 15:14:51-06:00, tsmith@stripped +7 -0
Bug #20748: Configuration files should not be read more than once
A user could not override system-wide settings in their ~/.my.cnf,
because the DEFAULT_SYSCONFDIR was being searched last. Also, in
some configurations (especially when the --sysconfdir compile-time
option is set to /etc or /etc/mysql), the system-wide my.cnf file
was read multiple times, causing confusion and potential problems.
Move --sysconfdir=<path> (DEFAULT_SYSCONFDIR) from the last default
directory to the middle of the list. $HOME/.my.cnf should be last,
so the user is able to override the system-wide settings.
Change init_default_directories() to remove duplicates from the
list.
BitKeeper/etc/ignore@stripped, 2007-10-18 15:14:49-06:00, tsmith@stripped +5 -0
Added libmysql_r/client_settings.h libmysqld/scheduler.cc libmysqld/sql_connect.cc
libmysqld/sql_tablespace.cc ylwrap to the ignore list
include/my_sys.h@stripped, 2007-10-18 15:14:48-06:00, tsmith@stripped +2 -0
Add array_append_string_unique(), from mf_arr_appstr.c
libmysql/Makefile.shared@stripped, 2007-10-18 15:14:48-06:00, tsmith@stripped +1
-1
Add new mf_arr_appstr.lo object
mysys/CMakeLists.txt@stripped, 2007-10-18 15:14:49-06:00, tsmith@stripped +1 -1
Add new mf_arr_appstr.c source.
mysys/Makefile.am@stripped, 2007-10-18 15:14:49-06:00, tsmith@stripped +1 -1
Add new mf_arr_appstr.c source.
mysys/default.c@stripped, 2007-10-18 15:14:49-06:00, tsmith@stripped +113 -60
Change order in which defaults files are searched. Move
DEFAULT_SYSCONFDIR (and, on Windows, the executable's parent
directory) from the end to the middle (after the hard-coded
"/etc/" or "C:/", etc.; and before the run-time directories
(DEFAULT_HOME_ENV, --defaults-extra-file)).
Also, don't add duplicate entries in the defaults_directories
list. Instead of adding a new duplicate entry, move the
existing entry to the end of the list.
mysys/mf_arr_appstr.c@stripped, 2007-10-18 14:54:48-06:00, tsmith@stripped +60 -0
BitKeeper file /home/tsmith/m/bk/build/51-b20748/mysys/mf_arr_appstr.c
mysys/mf_arr_appstr.c@stripped, 2007-10-18 14:54:48-06:00, tsmith@stripped +0 -0
diff -Nrup a/BitKeeper/etc/ignore b/BitKeeper/etc/ignore
--- a/BitKeeper/etc/ignore 2007-09-06 07:51:38 -06:00
+++ b/BitKeeper/etc/ignore 2007-10-18 15:14:49 -06:00
@@ -3004,3 +3004,8 @@ win/vs71cache.txt
win/vs8cache.txt
zlib/*.ds?
zlib/*.vcproj
+libmysql_r/client_settings.h
+libmysqld/scheduler.cc
+libmysqld/sql_connect.cc
+libmysqld/sql_tablespace.cc
+ylwrap
diff -Nrup a/include/my_sys.h b/include/my_sys.h
--- a/include/my_sys.h 2007-08-13 07:11:09 -06:00
+++ b/include/my_sys.h 2007-10-18 15:14:48 -06:00
@@ -691,6 +691,8 @@ extern WF_PACK *wf_comp(char * str);
extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
extern void wf_end(struct wild_file_pack *buffer);
extern size_t strip_sp(char * str);
+extern my_bool array_append_string_unique(const char *str,
+ const char **array, size_t size);
extern void get_date(char * to,int timeflag,time_t use_time);
extern void soundex(CHARSET_INFO *, char * out_pntr, char * in_pntr,
pbool remove_garbage);
diff -Nrup a/libmysql/Makefile.shared b/libmysql/Makefile.shared
--- a/libmysql/Makefile.shared 2007-07-30 02:33:41 -06:00
+++ b/libmysql/Makefile.shared 2007-10-18 15:14:48 -06:00
@@ -59,7 +59,7 @@ mysysobjects1 = my_init.lo my_static.lo
mf_pack.lo my_messnc.lo mf_dirname.lo mf_fn_ext.lo\
mf_wcomp.lo typelib.lo safemalloc.lo my_alloc.lo \
mf_format.lo mf_path.lo mf_unixpath.lo my_fopen.lo \
- my_symlink.lo my_fstream.lo \
+ my_symlink.lo my_fstream.lo mf_arr_appstr.lo \
mf_loadpath.lo my_pthread.lo my_thr_init.lo \
thr_mutex.lo mulalloc.lo string.lo \
default.lo default_modify.lo \
diff -Nrup a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
--- a/mysys/CMakeLists.txt 2007-08-06 15:14:47 -06:00
+++ b/mysys/CMakeLists.txt 2007-10-18 15:14:49 -06:00
@@ -29,7 +29,7 @@ SET(MYSYS_SOURCES array.c charset-def.c
errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c
mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c
mf_keycaches.c mf_loadpath.c mf_pack.c mf_path.c mf_qsort.c mf_qsort2.c
- mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_strip.c mf_tempdir.c
+ mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_strip.c mf_arr_appstr.c mf_tempdir.c
mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c
my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chsize.c
my_clock.c my_compress.c my_conio.c my_copy.c my_crc32.c my_create.c my_delete.c
diff -Nrup a/mysys/Makefile.am b/mysys/Makefile.am
--- a/mysys/Makefile.am 2007-03-12 07:53:48 -06:00
+++ b/mysys/Makefile.am 2007-10-18 15:14:49 -06:00
@@ -35,7 +35,7 @@ libmysys_a_SOURCES = my_init.c my_get
my_error.c errors.c my_div.c my_messnc.c \
mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \
my_symlink.c my_symlink2.c \
- mf_pack.c mf_unixpath.c mf_strip.c \
+ mf_pack.c mf_unixpath.c mf_strip.c mf_arr_appstr.c \
mf_wcomp.c mf_wfile.c my_gethwaddr.c \
mf_qsort.c mf_qsort2.c mf_sort.c \
ptr_cmp.c mf_radix.c queues.c my_getncpus.c \
diff -Nrup a/mysys/default.c b/mysys/default.c
--- a/mysys/default.c 2007-05-10 03:59:25 -06:00
+++ b/mysys/default.c 2007-10-18 15:14:49 -06:00
@@ -83,7 +83,22 @@ static int search_default_file_with_ext(
void *func_ctx,
const char *dir, const char *ext,
const char *config_file, int recursion_level);
-static void init_default_directories();
+
+
+
+/**
+ @brief Create the list of default directories.
+
+ @details
+ On all systems, if a directory is already in the list, it will be moved
+ to the end of the list. This avoids reading defaults files multiple times,
+ while ensuring the correct precedence.
+
+ @return void
+*/
+
+static void (*init_default_directories)();
+
static char *remove_end_comment(char *ptr);
@@ -922,6 +937,34 @@ void print_defaults(const char *conf_fil
#include <help_end.h>
+#define ADD_DIRECTORY(DIR) \
+ do { \
+ my_bool rc= array_append_string_unique((DIR), default_directories, \
+ array_elements(default_directories)); \
+ DBUG_ASSERT(rc == TRUE); \
+ } while (0)
+
+
+#ifdef DEFAULT_SYSCONFDIR
+#define ADD_SYSCONF_DIRECTORY() \
+ do { \
+ if (DEFAULT_SYSCONFDIR != "") \
+ ADD_DIRECTORY(DEFAULT_SYSCONFDIR); \
+ } while (0)
+#else
+#define ADD_SYSCONF_DIRECTORY()
+#endif
+
+#define ADD_COMMON_DIRECTORIES() \
+ do { \
+ char *env; \
+ if ((env= getenv(STRINGIFY_ARG(DEFAULT_HOME_ENV)))) \
+ ADD_DIRECTORY(env); \
+ /* Placeholder for --defaults-extra-file=<path> */ \
+ ADD_DIRECTORY(""); \
+ } while (0)
+
+
#ifdef __WIN__
/*
This wrapper for GetSystemWindowsDirectory() will dynamically bind to the
@@ -956,71 +999,35 @@ static size_t my_get_system_windows_dire
}
return count;
}
-#endif
-/*
- Create the list of default directories.
-
- On Microsoft Windows, this is:
+/**
+ @brief Initialize default directories for Microsoft Windows
+ @details
1. C:/
2. GetWindowsDirectory()
3. GetSystemWindowsDirectory()
- 4. getenv(DEFAULT_HOME_ENV)
+ 4. --sysconfdir=<path> (compile-time option)
5. Directory above where the executable is located
- 6. ""
- 7. --sysconfdir=<path>
-
- On Novell NetWare, this is:
- 1. sys:/etc/
- 2. getenv(DEFAULT_HOME_ENV)
- 3. ""
- 4. --sysconfdir=<path>
-
- On OS/2, this is:
- 1. getenv(ETC)
- 2. /etc/
- 3. getenv(DEFAULT_HOME_ENV)
- 4. ""
- 5. "~/"
- 6. --sysconfdir=<path>
-
- Everywhere else, this is:
- 1. /etc/
- 2. /etc/mysql/
- 3. getenv(DEFAULT_HOME_ENV)
- 4. ""
- 5. "~/"
- 6. --sysconfdir=<path>
-
- */
+ 6. getenv(DEFAULT_HOME_ENV)
+ 7. --defaults-extra-file=<path> (run-time option)
+*/
-static void init_default_directories()
+static void init_default_directories_win()
{
- const char *env, **ptr= default_directories;
+ bzero(default_directories, sizeof(default_directories));
-#ifdef __WIN__
- *ptr++= "C:/";
+ ADD_DIRECTORY("C:/");
if (GetWindowsDirectory(system_dir,sizeof(system_dir)))
- *ptr++= (char*)&system_dir;
+ ADD_DIRECTORY(&system_dir);
+
if (my_get_system_windows_directory(shared_system_dir,
- sizeof(shared_system_dir)) &&
- strcmp(system_dir, shared_system_dir))
- *ptr++= (char *)&shared_system_dir;
+ sizeof(shared_system_dir)))
+ ADD_DIRECTORY(&shared_system_dir);
+
+ ADD_SYSCONF_DIRECTORY();
-#elif defined(__NETWARE__)
- *ptr++= "sys:/etc/";
-#else
- *ptr++= "/etc/";
- *ptr++= "/etc/mysql/";
-#endif
- if ((env= getenv(STRINGIFY_ARG(DEFAULT_HOME_ENV))))
- *ptr++= env;
- *ptr++= ""; /* Place for defaults_extra_file */
-#if !defined(__WIN__) && !defined(__NETWARE__)
- *ptr++= "~/";;
-#elif defined(__WIN__)
if (GetModuleFileName(NULL, config_dir, sizeof(config_dir)))
{
char *last= NULL, *end= strend(config_dir);
@@ -1050,12 +1057,58 @@ static void init_default_directories()
last= end;
}
}
- *ptr++= (char *)&config_dir;
+ ADD_DIRECTORY(&config_dir);
}
-#endif
-#ifdef DEFAULT_SYSCONFDIR
- if (DEFAULT_SYSCONFDIR != "")
- *ptr++= DEFAULT_SYSCONFDIR;
-#endif
- *ptr= 0; /* end marker */
+
+ ADD_COMMON_DIRECTORIES();
+}
+
+static void (*init_default_directories)()= init_default_directories_win;
+
+#elif defined(__NETWARE__)
+
+/**
+ @brief Initialize default directories for Novell Netware
+ @details
+ 1. sys:/etc/
+ 2. --sysconfdir=<path> (compile-time option)
+ 3. getenv(DEFAULT_HOME_ENV)
+ 4. --defaults-extra-file=<path> (run-time option)
+*/
+
+static void init_default_directories_netware()
+{
+ bzero(default_directories, sizeof(default_directories));
+ ADD_DIRECTORY("sys:/etc/");
+ ADD_SYSCONF_DIRECTORY();
+ ADD_COMMON_DIRECTORIES();
+}
+
+static void (*init_default_directories)()= init_default_directories_netware;
+
+#else
+
+/**
+ @brief Initialize default directories for Unix
+ @details
+ 1. /etc/
+ 2. /etc/mysql/
+ 3. --sysconfdir=<path> (compile-time option)
+ 4. getenv(DEFAULT_HOME_ENV)
+ 5. --defaults-extra-file=<path> (run-time option)
+ 6. "~/"
+*/
+
+static void init_default_directories_unix()
+{
+ bzero(default_directories, sizeof(default_directories));
+ ADD_DIRECTORY("/etc/");
+ ADD_DIRECTORY("/etc/mysql/");
+ ADD_SYSCONF_DIRECTORY();
+ ADD_COMMON_DIRECTORIES();
+ ADD_DIRECTORY("~/");
}
+
+static void (*init_default_directories)()= init_default_directories_unix;
+
+#endif
diff -Nrup a/mysys/mf_arr_appstr.c b/mysys/mf_arr_appstr.c
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/mysys/mf_arr_appstr.c 2007-10-18 14:54:48 -06:00
@@ -0,0 +1,60 @@
+/* Copyright (C) 2007 MySQL AB
+
+ 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
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ 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 */
+
+#include "mysys_priv.h"
+#include <m_string.h> /* strcmp() */
+
+
+/**
+ @brief Append str to array, or move to the end if it already exists
+
+ @param str String to be appended
+ @param array The array, terminated by a NULL element, all unused elements
+ pre-initialized to NULL
+ @param size Size of the array; array must be terminated by a NULL
+ pointer, so can hold size - 1 elements
+
+ @retval TRUE Success
+ @retval FALSE Failure, array is full
+*/
+
+my_bool array_append_string_unique(const char *str,
+ const char **array, size_t size)
+{
+ const char **p;
+ /* end points at the terminating NULL element */
+ const char **end= array + size - 1;
+
+ for (p= array; *p; ++p)
+ {
+ if (strcmp(*p, str) == 0)
+ break;
+ }
+ if (p >= end)
+ return FALSE; /* Array is full */
+
+ DBUG_ASSERT(*p == NULL || strcmp(*p, str) == 0);
+
+ while (*(p + 1))
+ {
+ *p= *(p + 1);
+ ++p;
+ }
+
+ DBUG_ASSERT(p < end);
+ *p= str;
+
+ return TRUE;
+}
| Thread |
|---|
| • bk commit into 5.1 tree (tsmith:1.2581) BUG#20748 | tim | 18 Oct |