mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
Merge bk-internal:/home/bk/mysql-5.0
into serg.mylan:/usr/home/serg/Abk/mysql-5.0 BitKeeper/etc/ignore: auto-union configure.in: Auto merged dbug/dbug.c: Auto merged include/my_dbug.h: Auto merged include/my_sys.h: Auto merged sql/filesort.cc: Auto merged sql/ha_isam.cc: Auto merged sql/ha_isammrg.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/ha_myisammrg.cc: Auto merged sql/sql_select.cc: Auto merged
This commit is contained in:
commit
03d82a4652
323 changed files with 10073 additions and 8173 deletions
152
mysys/default.c
152
mysys/default.c
|
|
@ -37,6 +37,9 @@
|
|||
#include "m_string.h"
|
||||
#include "m_ctype.h"
|
||||
#include <my_dir.h>
|
||||
#ifdef __WIN__
|
||||
#include <winbase.h>
|
||||
#endif
|
||||
|
||||
char *defaults_extra_file=0;
|
||||
|
||||
|
|
@ -60,10 +63,10 @@ DATADIR,
|
|||
NullS,
|
||||
};
|
||||
|
||||
#define default_ext ".cnf" /* extension for config file */
|
||||
#ifdef __WIN__
|
||||
#include <winbase.h>
|
||||
#define windows_ext ".ini"
|
||||
static const char *f_extensions[]= { ".ini", ".cnf", 0 };
|
||||
#else
|
||||
static const char *f_extensions[]= { ".cnf", 0 };
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -81,8 +84,11 @@ struct handle_option_ctx
|
|||
};
|
||||
|
||||
static int search_default_file(Process_option_func func, void *func_ctx,
|
||||
const char *dir, const char *config_file,
|
||||
const char *ext);
|
||||
const char *dir, const char *config_file);
|
||||
static int search_default_file_with_ext(Process_option_func func,
|
||||
void *func_ctx,
|
||||
const char *dir, const char *ext,
|
||||
const char *config_file);
|
||||
|
||||
static char *remove_end_comment(char *ptr);
|
||||
|
||||
|
|
@ -137,8 +143,8 @@ static int search_files(const char *conf_file, int *argc, char ***argv,
|
|||
|
||||
if (forced_default_file)
|
||||
{
|
||||
if ((error= search_default_file(func, func_ctx, "",
|
||||
forced_default_file, "")) < 0)
|
||||
if ((error= search_default_file_with_ext(func, func_ctx, "", "",
|
||||
forced_default_file)) < 0)
|
||||
goto err;
|
||||
if (error > 0)
|
||||
{
|
||||
|
|
@ -149,8 +155,7 @@ static int search_files(const char *conf_file, int *argc, char ***argv,
|
|||
}
|
||||
else if (dirname_length(conf_file))
|
||||
{
|
||||
if ((error= search_default_file(func, func_ctx, NullS, conf_file,
|
||||
default_ext)) < 0)
|
||||
if ((error= search_default_file(func, func_ctx, NullS, conf_file)) < 0)
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
|
|
@ -158,28 +163,30 @@ static int search_files(const char *conf_file, int *argc, char ***argv,
|
|||
#ifdef __WIN__
|
||||
char system_dir[FN_REFLEN];
|
||||
GetWindowsDirectory(system_dir,sizeof(system_dir));
|
||||
if ((search_default_file(func, func_ctx, system_dir, conf_file,
|
||||
windows_ext)))
|
||||
if ((search_default_file(func, func_ctx, system_dir, conf_file)))
|
||||
goto err;
|
||||
#endif
|
||||
#if defined(__EMX__) || defined(OS2)
|
||||
if (getenv("ETC") &&
|
||||
(search_default_file(func, func_ctx, getenv("ETC"), conf_file,
|
||||
default_ext)) < 0)
|
||||
{
|
||||
const char *etc;
|
||||
if ((etc= getenv("ETC")) &&
|
||||
(search_default_file(func, func_ctx, etc, conf_file)) < 0)
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
for (dirs= default_directories ; *dirs; dirs++)
|
||||
{
|
||||
if (**dirs)
|
||||
{
|
||||
if (search_default_file(func, func_ctx, *dirs, conf_file, default_ext) < 0)
|
||||
if (search_default_file(func, func_ctx, *dirs, conf_file) < 0)
|
||||
goto err;
|
||||
}
|
||||
else if (defaults_extra_file)
|
||||
{
|
||||
if (search_default_file(func, func_ctx, NullS, defaults_extra_file,
|
||||
default_ext) < 0)
|
||||
if (search_default_file(func, func_ctx, NullS,
|
||||
defaults_extra_file) < 0)
|
||||
goto err; /* Fatal error */
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -226,22 +233,23 @@ int process_default_option_files(const char *conf_file,
|
|||
return search_files(conf_file, &argc, NULL, &args_used, func, func_ctx);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The option handler for load_defaults.
|
||||
|
||||
SYNOPSIS
|
||||
handle_deault_option()
|
||||
in_ctx Handler context. In this case it is a
|
||||
handle_deault_option()
|
||||
in_ctx Handler context. In this case it is a
|
||||
handle_option_ctx structure.
|
||||
group_name The name of the group the option belongs to.
|
||||
option The very option to be processed. It is already
|
||||
group_name The name of the group the option belongs to.
|
||||
option The very option to be processed. It is already
|
||||
prepared to be used in argv (has -- prefix)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This handler checks whether a group is one of the listed and adds an option
|
||||
to the array if yes. Some other handler can record, for instance, all groups
|
||||
and their options, not knowing in advance the names and amount of groups.
|
||||
This handler checks whether a group is one of the listed and adds an option
|
||||
to the array if yes. Some other handler can record, for instance, all
|
||||
groups and their options, not knowing in advance the names and amount of
|
||||
groups.
|
||||
|
||||
RETURN
|
||||
0 - ok
|
||||
|
|
@ -249,12 +257,12 @@ int process_default_option_files(const char *conf_file,
|
|||
*/
|
||||
|
||||
static int handle_default_option(void *in_ctx, const char *group_name,
|
||||
const char *option)
|
||||
const char *option)
|
||||
{
|
||||
char *tmp;
|
||||
struct handle_option_ctx *ctx;
|
||||
ctx= (struct handle_option_ctx *) in_ctx;
|
||||
if(find_type((char *)group_name, ctx->group, 3))
|
||||
struct handle_option_ctx *ctx= (struct handle_option_ctx *) in_ctx;
|
||||
|
||||
if (find_type((char *)group_name, ctx->group, 3))
|
||||
{
|
||||
if (!(tmp= alloc_root(ctx->alloc, (uint) strlen(option) + 1)))
|
||||
return 1;
|
||||
|
|
@ -299,7 +307,7 @@ static int handle_default_option(void *in_ctx, const char *group_name,
|
|||
|
||||
|
||||
int load_defaults(const char *conf_file, const char **groups,
|
||||
int *argc, char ***argv)
|
||||
int *argc, char ***argv)
|
||||
{
|
||||
DYNAMIC_ARRAY args;
|
||||
TYPELIB group;
|
||||
|
|
@ -405,18 +413,37 @@ void free_defaults(char **argv)
|
|||
}
|
||||
|
||||
|
||||
static int search_default_file(Process_option_func opt_handler,
|
||||
void *handler_ctx,
|
||||
const char *dir,
|
||||
const char *config_file)
|
||||
{
|
||||
char **ext;
|
||||
|
||||
for (ext= (char**) f_extensions; *ext; *ext++)
|
||||
{
|
||||
int error;
|
||||
if ((error= search_default_file_with_ext(opt_handler, handler_ctx,
|
||||
dir, *ext,
|
||||
config_file)) < 0)
|
||||
return error;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Open a configuration file (if exists) and read given options from it
|
||||
|
||||
SYNOPSIS
|
||||
search_default_file()
|
||||
search_default_file_with_ext()
|
||||
opt_handler Option handler function. It is used to process
|
||||
every separate option.
|
||||
handler_ctx Pointer to the structure to store actual
|
||||
parameters of the function.
|
||||
dir directory to read
|
||||
config_file Name of configuration file
|
||||
ext Extension for configuration file
|
||||
config_file Name of configuration file
|
||||
group groups to read
|
||||
|
||||
RETURN
|
||||
|
|
@ -425,9 +452,11 @@ void free_defaults(char **argv)
|
|||
1 File not found (Warning)
|
||||
*/
|
||||
|
||||
static int search_default_file(Process_option_func opt_handler, void *handler_ctx,
|
||||
const char *dir, const char *config_file,
|
||||
const char *ext)
|
||||
static int search_default_file_with_ext(Process_option_func opt_handler,
|
||||
void *handler_ctx,
|
||||
const char *dir,
|
||||
const char *ext,
|
||||
const char *config_file)
|
||||
{
|
||||
char name[FN_REFLEN+10], buff[4096], curr_gr[4096], *ptr, *end;
|
||||
char *value, option[4096];
|
||||
|
|
@ -618,10 +647,11 @@ static char *remove_end_comment(char *ptr)
|
|||
void print_defaults(const char *conf_file, const char **groups)
|
||||
{
|
||||
#ifdef __WIN__
|
||||
bool have_ext=fn_ext(conf_file)[0] != 0;
|
||||
my_bool have_ext= fn_ext(conf_file)[0] != 0;
|
||||
#endif
|
||||
char name[FN_REFLEN];
|
||||
char name[FN_REFLEN], **ext;
|
||||
const char **dirs;
|
||||
|
||||
puts("\nDefault options are read from the following files in the given order:");
|
||||
|
||||
if (dirname_length(conf_file))
|
||||
|
|
@ -630,27 +660,43 @@ void print_defaults(const char *conf_file, const char **groups)
|
|||
{
|
||||
#ifdef __WIN__
|
||||
GetWindowsDirectory(name,sizeof(name));
|
||||
printf("%s\\%s%s ",name,conf_file,have_ext ? "" : windows_ext);
|
||||
if (!have_ext)
|
||||
{
|
||||
for (ext= (char**) f_extensions; *ext; *ext++)
|
||||
printf("%s\\%s%s ", name, conf_file, *ext);
|
||||
}
|
||||
else
|
||||
printf("%s\\%s ", name, conf_file);
|
||||
#endif
|
||||
#if defined(__EMX__) || defined(OS2)
|
||||
if (getenv("ETC"))
|
||||
printf("%s\\%s%s ", getenv("ETC"), conf_file, default_ext);
|
||||
{
|
||||
const char *etc;
|
||||
|
||||
if ((etc= getenv("ETC")))
|
||||
{
|
||||
for (ext= (char**) f_extensions; *ext; *ext++)
|
||||
printf("%s\\%s%s ", etc, conf_file, *ext);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (dirs=default_directories ; *dirs; dirs++)
|
||||
{
|
||||
const char *pos;
|
||||
char *end;
|
||||
if (**dirs)
|
||||
pos= *dirs;
|
||||
else if (defaults_extra_file)
|
||||
pos= defaults_extra_file;
|
||||
else
|
||||
continue;
|
||||
end=convert_dirname(name, pos, NullS);
|
||||
if (name[0] == FN_HOMELIB) /* Add . to filenames in home */
|
||||
*end++='.';
|
||||
strxmov(end,conf_file,default_ext," ",NullS);
|
||||
fputs(name,stdout);
|
||||
for (ext= (char**) f_extensions; *ext; *ext++)
|
||||
{
|
||||
const char *pos;
|
||||
char *end;
|
||||
if (**dirs)
|
||||
pos= *dirs;
|
||||
else if (defaults_extra_file)
|
||||
pos= defaults_extra_file;
|
||||
else
|
||||
continue;
|
||||
end= convert_dirname(name, pos, NullS);
|
||||
if (name[0] == FN_HOMELIB) /* Add . to filenames in home */
|
||||
*end++='.';
|
||||
strxmov(end, conf_file, *ext, " ", NullS);
|
||||
fputs(name,stdout);
|
||||
}
|
||||
}
|
||||
puts("");
|
||||
}
|
||||
|
|
|
|||
117
mysys/my_error.c
117
mysys/my_error.c
|
|
@ -22,6 +22,15 @@
|
|||
|
||||
/* Define some external variables for error handling */
|
||||
|
||||
/*
|
||||
WARNING!
|
||||
my_error family functions have to be used according following rules:
|
||||
- if message have not parameters use my_message(ER_CODE, ER(ER_CODE), MYF(N))
|
||||
- if message registered use my_error(ER_CODE, MYF(N), ...).
|
||||
- With some special text of errror message use:
|
||||
my_printf_error(ER_CODE, format, MYF(N), ...)
|
||||
*/
|
||||
|
||||
const char ** NEAR my_errmsg[MAXMAPS]={0,0,0,0};
|
||||
char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
|
||||
|
||||
|
|
@ -41,107 +50,22 @@ char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
|
|||
the length value is ignored.
|
||||
*/
|
||||
|
||||
int my_error(int nr,myf MyFlags, ...)
|
||||
int my_error(int nr, myf MyFlags, ...)
|
||||
{
|
||||
va_list ap;
|
||||
uint olen, plen;
|
||||
reg1 const char *tpos;
|
||||
reg2 char *endpos;
|
||||
char * par;
|
||||
char ebuff[ERRMSGSIZE+20];
|
||||
int prec_chars; /* output precision */
|
||||
my_bool prec_supplied;
|
||||
const char *format;
|
||||
va_list args;
|
||||
char ebuff[ERRMSGSIZE + 20];
|
||||
DBUG_ENTER("my_error");
|
||||
LINT_INIT(prec_chars); /* protected by prec_supplied */
|
||||
|
||||
va_start(ap,MyFlags);
|
||||
DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d", nr, MyFlags, errno));
|
||||
|
||||
if (nr / ERRMOD == GLOB && my_errmsg[GLOB] == 0)
|
||||
init_glob_errs();
|
||||
format= my_errmsg[nr / ERRMOD][nr % ERRMOD];
|
||||
|
||||
olen=(uint) strlen(tpos=my_errmsg[nr / ERRMOD][nr % ERRMOD]);
|
||||
endpos=ebuff;
|
||||
|
||||
while (*tpos)
|
||||
{
|
||||
if (tpos[0] != '%')
|
||||
{
|
||||
*endpos++= *tpos++; /* Copy ordinary char */
|
||||
continue;
|
||||
}
|
||||
if (*++tpos == '%') /* test if %% */
|
||||
{
|
||||
olen--;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
Skip size/precision flags to be compatible with printf.
|
||||
The only size/precision flag supported is "%.*s".
|
||||
If "%.*u" or "%.*d" are encountered, the precision number is read
|
||||
from the variable argument list but its value is ignored.
|
||||
*/
|
||||
prec_supplied= 0;
|
||||
if (*tpos== '.')
|
||||
{
|
||||
tpos++;
|
||||
olen--;
|
||||
if (*tpos == '*')
|
||||
{
|
||||
tpos++;
|
||||
olen--;
|
||||
prec_chars= va_arg(ap, int); /* get length parameter */
|
||||
prec_supplied= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!prec_supplied)
|
||||
{
|
||||
while (my_isdigit(&my_charset_latin1, *tpos) || *tpos == '.' ||
|
||||
*tpos == '-')
|
||||
tpos++;
|
||||
|
||||
if (*tpos == 'l') /* Skip 'l' argument */
|
||||
tpos++;
|
||||
}
|
||||
|
||||
if (*tpos == 's') /* String parameter */
|
||||
{
|
||||
par= va_arg(ap, char *);
|
||||
plen= (uint) strlen(par);
|
||||
if (prec_supplied && prec_chars > 0)
|
||||
plen= min((uint)prec_chars, plen);
|
||||
if (olen + plen < ERRMSGSIZE+2) /* Replace if possible */
|
||||
{
|
||||
strmake(endpos, par, plen);
|
||||
endpos+= plen;
|
||||
tpos++;
|
||||
olen+= plen-2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (*tpos == 'd' || *tpos == 'u') /* Integer parameter */
|
||||
{
|
||||
register int iarg;
|
||||
iarg= va_arg(ap, int);
|
||||
if (*tpos == 'd')
|
||||
plen= (uint) (int10_to_str((long) iarg, endpos, -10) - endpos);
|
||||
else
|
||||
plen= (uint) (int10_to_str((long) (uint) iarg, endpos, 10) - endpos);
|
||||
if (olen + plen < ERRMSGSIZE+2) /* Replace parameter if possible */
|
||||
{
|
||||
endpos+= plen;
|
||||
tpos++;
|
||||
olen+= plen-2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
*endpos++= '%'; /* % used as % or unknown code */
|
||||
}
|
||||
*endpos= '\0'; /* End of errmessage */
|
||||
va_end(ap);
|
||||
va_start(args,MyFlags);
|
||||
(void) my_vsnprintf (ebuff, sizeof(ebuff), format, args);
|
||||
va_end(args);
|
||||
DBUG_RETURN((*error_handler_hook)(nr, ebuff, MyFlags));
|
||||
}
|
||||
|
||||
|
|
@ -160,11 +84,14 @@ int my_printf_error(uint error, const char *format, myf MyFlags, ...)
|
|||
{
|
||||
va_list args;
|
||||
char ebuff[ERRMSGSIZE+20];
|
||||
DBUG_ENTER("my_printf_error");
|
||||
DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d Format: %s",
|
||||
error, MyFlags, errno, format));
|
||||
|
||||
va_start(args,MyFlags);
|
||||
(void) vsprintf (ebuff,format,args);
|
||||
(void) my_vsnprintf (ebuff, sizeof(ebuff), format, args);
|
||||
va_end(args);
|
||||
return (*error_handler_hook)(error, ebuff, MyFlags);
|
||||
DBUG_RETURN((*error_handler_hook)(error, ebuff, MyFlags));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ static void netware_init();
|
|||
#define netware_init()
|
||||
#endif
|
||||
|
||||
|
||||
my_bool my_init_done=0;
|
||||
my_bool my_init_done= 0;
|
||||
uint mysys_usage_id= 0; /* Incremented for each my_init() */
|
||||
|
||||
static ulong atoi_octal(const char *str)
|
||||
{
|
||||
|
|
@ -51,7 +51,7 @@ static ulong atoi_octal(const char *str)
|
|||
while (*str && my_isspace(&my_charset_latin1, *str))
|
||||
str++;
|
||||
str2int(str,
|
||||
(*str == '0' ? 8 : 10), /* Octalt or decimalt */
|
||||
(*str == '0' ? 8 : 10), /* Octalt or decimalt */
|
||||
0, INT_MAX, &tmp);
|
||||
return (ulong) tmp;
|
||||
}
|
||||
|
|
@ -74,6 +74,9 @@ my_bool my_init(void)
|
|||
if (my_init_done)
|
||||
return 0;
|
||||
my_init_done=1;
|
||||
mysys_usage_id++;
|
||||
my_umask= 0660; /* Default umask for new files */
|
||||
my_umask_dir= 0700; /* Default umask for new directories */
|
||||
#if defined(THREAD) && defined(SAFE_MUTEX)
|
||||
safe_mutex_global_init(); /* Must be called early */
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue