Commit d15fefa9 authored by unknown's avatar unknown

Code style fixes.

Initialize LOG_error_log before get_options to not use an uninitalized mutex in case of an error from handle_options()


mysql-test/r/lowercase_table.result:
  Changed foo database -> mysqltest
  More test cases
mysql-test/t/lowercase_table.test:
  Changed foo database -> mysqltest
  More test cases
mysys/my_getopt.c:
  Fix new code to use MySQL indentation style
sql/log.cc:
  Change to use MySQL indentation style and naming conventions
  Remove usage of strlen() and strcat()
sql/mysqld.cc:
  Initialize LOG_error_log before get_options to not use an uninitalized mutex in case of an error from handle_options()
sql/sql_base.cc:
  Added comment
sql/table.cc:
  Added #if MYSQL_VERSION_ID < 40100 to ensure code is merged correctly
parent 2fddfe2f
drop table if exists t1,t2,t3,t4,T1; drop table if exists t1,t2,t3,t4,T1;
drop database if exists mysqltest;
create table T1 (id int primary key, Word varchar(40) not null, Index(Word)); create table T1 (id int primary key, Word varchar(40) not null, Index(Word));
create table t4 (id int primary key, Word varchar(40) not null); create table t4 (id int primary key, Word varchar(40) not null);
INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c'); INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c');
...@@ -39,12 +40,22 @@ Unknown table 'T1' in field list ...@@ -39,12 +40,22 @@ Unknown table 'T1' in field list
select count(bags.a) from t1 as Bags; select count(bags.a) from t1 as Bags;
Unknown table 'bags' in field list Unknown table 'bags' in field list
drop table t1; drop table t1;
create database foo; create database mysqltest;
use foo; use MYSQLTEST;
create table t1 (a int); create table t1 (a int);
select FOO.t1.* from FOO.t1; select T1.a from MYSQLTEST.T1;
a
select t1.a from MYSQLTEST.T1;
Unknown table 't1' in field list
select mysqltest.t1.* from MYSQLTEST.t1;
a
select MYSQLTEST.t1.* from MYSQLTEST.t1;
a
select MYSQLTEST.T1.* from MYSQLTEST.T1;
a
select MYSQLTEST.T1.* from T1;
a a
alter table t1 rename to T1; alter table t1 rename to T1;
select FOO.t1.* from FOO.t1; select MYSQLTEST.t1.* from MYSQLTEST.t1;
a a
drop database FOO; drop database mysqltest;
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# #
drop table if exists t1,t2,t3,t4,T1; drop table if exists t1,t2,t3,t4,T1;
drop database if exists mysqltest;
create table T1 (id int primary key, Word varchar(40) not null, Index(Word)); create table T1 (id int primary key, Word varchar(40) not null, Index(Word));
create table t4 (id int primary key, Word varchar(40) not null); create table t4 (id int primary key, Word varchar(40) not null);
INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c'); INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c');
...@@ -34,10 +35,16 @@ drop table t1; ...@@ -34,10 +35,16 @@ drop table t1;
# #
# Test all caps database name # Test all caps database name
# #
create database foo; create database mysqltest;
use foo; use MYSQLTEST;
create table t1 (a int); create table t1 (a int);
select FOO.t1.* from FOO.t1; select T1.a from MYSQLTEST.T1;
--error 1109
select t1.a from MYSQLTEST.T1;
select mysqltest.t1.* from MYSQLTEST.t1;
select MYSQLTEST.t1.* from MYSQLTEST.t1;
select MYSQLTEST.T1.* from MYSQLTEST.T1;
select MYSQLTEST.T1.* from T1;
alter table t1 rename to T1; alter table t1 rename to T1;
select FOO.t1.* from FOO.t1; select MYSQLTEST.t1.* from MYSQLTEST.t1;
drop database FOO; drop database mysqltest;
...@@ -56,12 +56,12 @@ char *disabled_my_option= (char*) "0"; ...@@ -56,12 +56,12 @@ char *disabled_my_option= (char*) "0";
my_bool my_getopt_print_errors= 1; my_bool my_getopt_print_errors= 1;
void default_reporter( enum loglevel level, const char *format, ... ) void default_reporter(enum loglevel level, const char *format, ...)
{ {
va_list args; va_list args;
va_start( args, format ); va_start(args, format);
vfprintf( stderr, format, args ); vfprintf(stderr, format, args);
va_end( args ); va_end(args);
} }
/* /*
...@@ -75,8 +75,9 @@ void default_reporter( enum loglevel level, const char *format, ... ) ...@@ -75,8 +75,9 @@ void default_reporter( enum loglevel level, const char *format, ... )
*/ */
int handle_options(int *argc, char ***argv, int handle_options(int *argc, char ***argv,
const struct my_option *longopts, my_get_one_option get_one_option, const struct my_option *longopts,
my_error_reporter reporter ) my_get_one_option get_one_option,
my_error_reporter reporter)
{ {
uint opt_found, argvpos= 0, length, i; uint opt_found, argvpos= 0, length, i;
my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used, my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used,
...@@ -90,7 +91,8 @@ int handle_options(int *argc, char ***argv, ...@@ -90,7 +91,8 @@ int handle_options(int *argc, char ***argv,
(*argv)++; /* --- || ---- */ (*argv)++; /* --- || ---- */
init_variables(longopts); init_variables(longopts);
if (! reporter) reporter = &default_reporter; if (! reporter)
reporter= &default_reporter;
for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++) for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
{ {
...@@ -116,7 +118,8 @@ int handle_options(int *argc, char ***argv, ...@@ -116,7 +118,8 @@ int handle_options(int *argc, char ***argv,
if (!*++pos) if (!*++pos)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( ERROR_LEVEL, "%s: Option '-O' requires an argument\n", progname ); reporter(ERROR_LEVEL,
"%s: Option '-O' requires an argument\n", progname);
return EXIT_ARGUMENT_REQUIRED; return EXIT_ARGUMENT_REQUIRED;
} }
cur_arg= *pos; cur_arg= *pos;
...@@ -132,7 +135,9 @@ int handle_options(int *argc, char ***argv, ...@@ -132,7 +135,9 @@ int handle_options(int *argc, char ***argv,
if (!*cur_arg) if (!*cur_arg)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( ERROR_LEVEL, "%s: Option '--set-variable' requires an argument\n", progname ); reporter(ERROR_LEVEL,
"%s: Option '--set-variable' requires an argument\n",
progname);
return EXIT_ARGUMENT_REQUIRED; return EXIT_ARGUMENT_REQUIRED;
} }
} }
...@@ -144,7 +149,9 @@ int handle_options(int *argc, char ***argv, ...@@ -144,7 +149,9 @@ int handle_options(int *argc, char ***argv,
if (!*++pos) if (!*++pos)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( ERROR_LEVEL, "%s: Option '--set-variable' requires an argument\n", progname ); reporter(ERROR_LEVEL,
"%s: Option '--set-variable' requires an argument\n",
progname);
return EXIT_ARGUMENT_REQUIRED; return EXIT_ARGUMENT_REQUIRED;
} }
cur_arg= *pos; cur_arg= *pos;
...@@ -203,10 +210,10 @@ int handle_options(int *argc, char ***argv, ...@@ -203,10 +210,10 @@ int handle_options(int *argc, char ***argv,
if (opt_found > 1) if (opt_found > 1)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( ERROR_LEVEL, reporter(ERROR_LEVEL,
"%s: ambiguous option '--%s-%s' (--%s-%s)\n", "%s: ambiguous option '--%s-%s' (--%s-%s)\n",
progname, special_opt_prefix[i], cur_arg, progname, special_opt_prefix[i], cur_arg,
special_opt_prefix[i], prev_found); special_opt_prefix[i], prev_found);
return EXIT_AMBIGUOUS_OPTION; return EXIT_AMBIGUOUS_OPTION;
} }
switch (i) { switch (i) {
...@@ -238,16 +245,16 @@ int handle_options(int *argc, char ***argv, ...@@ -238,16 +245,16 @@ int handle_options(int *argc, char ***argv,
if (must_be_var) if (must_be_var)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, reporter(option_is_loose ? WARNING_LEVEL : ERROR_LEVEL,
"%s: unknown variable '%s'\n", progname, cur_arg ); "%s: unknown variable '%s'\n", progname, cur_arg);
if (!option_is_loose) if (!option_is_loose)
return EXIT_UNKNOWN_VARIABLE; return EXIT_UNKNOWN_VARIABLE;
} }
else else
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( option_is_loose ? WARNING_LEVEL : ERROR_LEVEL, reporter(option_is_loose ? WARNING_LEVEL : ERROR_LEVEL,
"%s: unknown option '--%s'\n", progname, cur_arg ); "%s: unknown option '--%s'\n", progname, cur_arg);
if (!option_is_loose) if (!option_is_loose)
return EXIT_UNKNOWN_OPTION; return EXIT_UNKNOWN_OPTION;
} }
...@@ -263,23 +270,23 @@ int handle_options(int *argc, char ***argv, ...@@ -263,23 +270,23 @@ int handle_options(int *argc, char ***argv,
if (must_be_var) if (must_be_var)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( ERROR_LEVEL, "%s: variable prefix '%s' is not unique\n", reporter(ERROR_LEVEL, "%s: variable prefix '%s' is not unique\n",
progname, cur_arg); progname, cur_arg);
return EXIT_VAR_PREFIX_NOT_UNIQUE; return EXIT_VAR_PREFIX_NOT_UNIQUE;
} }
else else
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( ERROR_LEVEL, "%s: ambiguous option '--%s' (%s, %s)\n", reporter(ERROR_LEVEL, "%s: ambiguous option '--%s' (%s, %s)\n",
progname, cur_arg, prev_found, optp->name); progname, cur_arg, prev_found, optp->name);
return EXIT_AMBIGUOUS_OPTION; return EXIT_AMBIGUOUS_OPTION;
} }
} }
if (must_be_var && optp->var_type == GET_NO_ARG) if (must_be_var && optp->var_type == GET_NO_ARG)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( ERROR_LEVEL, "%s: option '%s' cannot take an argument\n", reporter(ERROR_LEVEL, "%s: option '%s' cannot take an argument\n",
progname, optp->name); progname, optp->name);
return EXIT_NO_ARGUMENT_ALLOWED; return EXIT_NO_ARGUMENT_ALLOWED;
} }
if (optp->arg_type == NO_ARG) if (optp->arg_type == NO_ARG)
...@@ -287,8 +294,9 @@ int handle_options(int *argc, char ***argv, ...@@ -287,8 +294,9 @@ int handle_options(int *argc, char ***argv,
if (optend && optp->var_type != GET_BOOL) if (optend && optp->var_type != GET_BOOL)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( ERROR_LEVEL, "%s: option '--%s' cannot take an argument\n", reporter(ERROR_LEVEL,
progname, optp->name); "%s: option '--%s' cannot take an argument\n",
progname, optp->name);
return EXIT_NO_ARGUMENT_ALLOWED; return EXIT_NO_ARGUMENT_ALLOWED;
} }
if (optp->var_type == GET_BOOL) if (optp->var_type == GET_BOOL)
...@@ -325,8 +333,9 @@ int handle_options(int *argc, char ***argv, ...@@ -325,8 +333,9 @@ int handle_options(int *argc, char ***argv,
if (!*++pos) if (!*++pos)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( ERROR_LEVEL, "%s: option '--%s' requires an argument\n", reporter(ERROR_LEVEL,
progname, optp->name); "%s: option '--%s' requires an argument\n",
progname, optp->name);
return EXIT_ARGUMENT_REQUIRED; return EXIT_ARGUMENT_REQUIRED;
} }
argument= *pos; argument= *pos;
...@@ -375,9 +384,9 @@ int handle_options(int *argc, char ***argv, ...@@ -375,9 +384,9 @@ int handle_options(int *argc, char ***argv,
if (!pos[1]) if (!pos[1])
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( ERROR_LEVEL, reporter(ERROR_LEVEL,
"%s: option '-%c' requires an argument\n", "%s: option '-%c' requires an argument\n",
progname, optp->id); progname, optp->id);
return EXIT_ARGUMENT_REQUIRED; return EXIT_ARGUMENT_REQUIRED;
} }
argument= *++pos; argument= *++pos;
...@@ -387,9 +396,9 @@ int handle_options(int *argc, char ***argv, ...@@ -387,9 +396,9 @@ int handle_options(int *argc, char ***argv,
} }
if ((error= setval(optp, argument, set_maximum_value))) if ((error= setval(optp, argument, set_maximum_value)))
{ {
reporter( ERROR_LEVEL, reporter(ERROR_LEVEL,
"%s: Error while setting value '%s' to '%s'\n", "%s: Error while setting value '%s' to '%s'\n",
progname, argument, optp->name); progname, argument, optp->name);
return error; return error;
} }
get_one_option(optp->id, optp, argument); get_one_option(optp->id, optp, argument);
...@@ -399,8 +408,8 @@ int handle_options(int *argc, char ***argv, ...@@ -399,8 +408,8 @@ int handle_options(int *argc, char ***argv,
if (!opt_found) if (!opt_found)
{ {
if (my_getopt_print_errors) if (my_getopt_print_errors)
reporter( ERROR_LEVEL, reporter(ERROR_LEVEL,
"%s: unknown option '-%c'\n", progname, *optend); "%s: unknown option '-%c'\n", progname, *optend);
return EXIT_UNKNOWN_OPTION; return EXIT_UNKNOWN_OPTION;
} }
} }
...@@ -409,9 +418,9 @@ int handle_options(int *argc, char ***argv, ...@@ -409,9 +418,9 @@ int handle_options(int *argc, char ***argv,
} }
if ((error= setval(optp, argument, set_maximum_value))) if ((error= setval(optp, argument, set_maximum_value)))
{ {
reporter( ERROR_LEVEL, reporter(ERROR_LEVEL,
"%s: Error while setting value '%s' to '%s'\n", "%s: Error while setting value '%s' to '%s'\n",
progname, argument, optp->name); progname, argument, optp->name);
return error; return error;
} }
get_one_option(optp->id, optp, argument); get_one_option(optp->id, optp, argument);
......
...@@ -43,37 +43,41 @@ static bool test_if_number(const char *str, ...@@ -43,37 +43,41 @@ static bool test_if_number(const char *str,
#ifdef __NT__ #ifdef __NT__
static int eventSource = 0; static int eventSource = 0;
void setupWindowsEventSource()
{
if (eventSource) return;
eventSource = 1; void setup_windows_event_source()
HKEY hRegKey = NULL; {
DWORD dwError = 0; HKEY hRegKey= NULL;
TCHAR szPath[ MAX_PATH ]; DWORD dwError= 0;
TCHAR szPath[MAX_PATH];
DWORD dwTypes;
// Create the event source registry key if (eventSource) // Ensure that we are only called once
dwError = RegCreateKey( HKEY_LOCAL_MACHINE, return;
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\MySQL", eventSource= 1;
&hRegKey );
// Name of the PE module that contains the message resource // Create the event source registry key
GetModuleFileName( NULL, szPath, MAX_PATH ); dwError= RegCreateKey(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\MySQL",
&hRegKey);
// Register EventMessageFile /* Name of the PE module that contains the message resource */
dwError = RegSetValueEx( hRegKey, "EventMessageFile", 0, REG_EXPAND_SZ, GetModuleFileName(NULL, szPath, MAX_PATH);
(PBYTE) szPath, strlen(szPath)+1 );
/ Register EventMessageFile */
dwError = RegSetValueEx(hRegKey, "EventMessageFile", 0, REG_EXPAND_SZ,
(PBYTE) szPath, strlen(szPath)+1);
// Register supported event types /* Register supported event types */
DWORD dwTypes = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; dwTypes= (EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
dwError = RegSetValueEx( hRegKey, "TypesSupported", 0, REG_DWORD, EVENTLOG_INFORMATION_TYPE);
(LPBYTE) &dwTypes, sizeof dwTypes ); dwError= RegSetValueEx(hRegKey, "TypesSupported", 0, REG_DWORD,
(LPBYTE) &dwTypes, sizeof dwTypes);
RegCloseKey( hRegKey ); RegCloseKey(hRegKey);
} }
#endif #endif /* __NT__ */
/**************************************************************************** /****************************************************************************
...@@ -1732,33 +1736,33 @@ static bool test_if_number(register const char *str, ...@@ -1732,33 +1736,33 @@ static bool test_if_number(register const char *str,
} /* test_if_number */ } /* test_if_number */
void print_buffer_to_file( enum loglevel level, const char *buffer ) void print_buffer_to_file(enum loglevel level, const char *buffer)
{ {
time_t skr; time_t skr;
struct tm tm_tmp; struct tm tm_tmp;
struct tm *start; struct tm *start;
DBUG_ENTER("print_buffer_to_file");
DBUG_ENTER("print_buffer_to_log"); DBUG_PRINT("enter",("buffer: %s", buffer));
VOID(pthread_mutex_lock(&LOCK_error_log)); VOID(pthread_mutex_lock(&LOCK_error_log));
skr=time(NULL); skr=time(NULL);
localtime_r(&skr, &tm_tmp); localtime_r(&skr, &tm_tmp);
start=&tm_tmp; start=&tm_tmp;
fprintf( stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n", fprintf(stderr, "%02d%02d%02d %2d:%02d:%02d [%s] %s\n",
start->tm_year % 100, start->tm_year % 100,
start->tm_mon+1, start->tm_mon+1,
start->tm_mday, start->tm_mday,
start->tm_hour, start->tm_hour,
start->tm_min, start->tm_min,
start->tm_sec, start->tm_sec,
level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? "WARNING" : "INFORMATION", (level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ?
buffer ); "WARNING" : "INFORMATION"),
buffer);
fflush(stderr); fflush(stderr);
VOID(pthread_mutex_unlock(&LOCK_error_log)); VOID(pthread_mutex_unlock(&LOCK_error_log));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1772,6 +1776,7 @@ void sql_perror(const char *message) ...@@ -1772,6 +1776,7 @@ void sql_perror(const char *message)
#endif #endif
} }
bool flush_error_log() bool flush_error_log()
{ {
bool result=0; bool result=0;
...@@ -1820,122 +1825,124 @@ bool flush_error_log() ...@@ -1820,122 +1825,124 @@ bool flush_error_log()
#ifdef __NT__ #ifdef __NT__
void print_buffer_to_nt_eventlog( enum loglevel level, char *buff, int buffLen ) void print_buffer_to_nt_eventlog(enum loglevel level, char *buff,
uint length, int buffLen)
{ {
HANDLE event; HANDLE event;
char *buffptr; char *buffptr;
LPCSTR *buffmsgptr; LPCSTR *buffmsgptr;
DBUG_ENTER("print_buffer_to_nt_eventlog");
DBUG_ENTER( "print_buffer_to_nt_eventlog" ); buffptr= buff;
if (length > (uint)(buffLen-4))
buffptr = buff;
if (strlen(buff) > (uint)(buffLen-4))
{ {
char *newBuff = new char[ strlen(buff) + 4 ]; char *newBuff= new char[length + 4];
strcpy( newBuff, buff ); strcpy(newBuff, buff);
buffptr = newBuff; buffptr= newBuff;
} }
strcat( buffptr, "\r\n\r\n" ); strmov(buffptr+length, "\r\n\r\n");
buffmsgptr = (LPCSTR*)&buffptr; buffmsgptr= (LPCSTR*) &buffptr; // Keep windows happy
setupWindowsEventSource(); setup_windows_event_source();
if (event = RegisterEventSource(NULL,"MySQL")) if ((event= RegisterEventSource(NULL,"MySQL")))
{ {
switch (level){ switch (level) {
case ERROR_LEVEL: case ERROR_LEVEL:
ReportEvent(event, EVENTLOG_ERROR_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, buffmsgptr, NULL); ReportEvent(event, EVENTLOG_ERROR_TYPE, 0, MSG_DEFAULT, NULL, 1, 0,
buffmsgptr, NULL);
break; break;
case WARNING_LEVEL: case WARNING_LEVEL:
ReportEvent(event, EVENTLOG_WARNING_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, buffmsgptr, NULL); ReportEvent(event, EVENTLOG_WARNING_TYPE, 0, MSG_DEFAULT, NULL, 1, 0,
buffmsgptr, NULL);
break; break;
case INFORMATION_LEVEL: case INFORMATION_LEVEL:
ReportEvent(event, EVENTLOG_INFORMATION_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, buffmsgptr, NULL); ReportEvent(event, EVENTLOG_INFORMATION_TYPE, 0, MSG_DEFAULT, NULL, 1,
0, buffmsgptr, NULL);
break; break;
} }
DeregisterEventSource(event); DeregisterEventSource(event);
} }
// if we created a string buffer, then delete it /* if we created a string buffer, then delete it */
if ( buffptr != buff ) if (buffptr != buff)
delete[] buffptr; delete[] buffptr;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
#endif #endif /* __NT__ */
/* /*
Prints a printf style message to the error log and, under NT, to the Windows event log. Prints a printf style message to the error log and, under NT, to the
Windows event log.
SYNOPSIS SYNOPSIS
vprint_msg_to_log() vprint_msg_to_log()
event_type Type of event to write (Error, Warning, or Info) event_type Type of event to write (Error, Warning, or Info)
format Printf style format of message format Printf style format of message
args va_list list of arguments for the message args va_list list of arguments for the message
NOTE NOTE
IMPLEMENTATION IMPLEMENTATION
This function prints the message into a buffer and then sends that buffer to other This function prints the message into a buffer and then sends that buffer
functions to write that message to other logging sources. to other functions to write that message to other logging sources.
RETURN VALUES RETURN VALUES
void void
*/ */
void vprint_msg_to_log(enum loglevel level, const char *format, va_list args) void vprint_msg_to_log(enum loglevel level, const char *format, va_list args)
{ {
char buff[1024]; char buff[1024];
uint length;
DBUG_ENTER("vprint_msg_to_log"); DBUG_ENTER("vprint_msg_to_log");
my_vsnprintf( buff, sizeof(buff)-5, format, args ); length= my_vsnprintf(buff, sizeof(buff)-5, format, args);
print_buffer_to_file(level, buff);
print_buffer_to_file( level, buff );
#ifndef DBUG_OFF
DBUG_PRINT("error",("%s",buff));
#endif
#ifdef __NT__ #ifdef __NT__
print_buffer_to_nt_eventlog( level, buff, sizeof(buff) ); print_buffer_to_nt_eventlog(level, buff, length, sizeof(buff));
#endif #endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
void sql_print_error( const char *format, ... ) void sql_print_error(const char *format, ...)
{ {
DBUG_ENTER( "sql_print_error" );
va_list args; va_list args;
va_start( args, format ); DBUG_ENTER("sql_print_error");
vprint_msg_to_log( ERROR_LEVEL, format, args );
va_end( args ); va_start(args, format);
vprint_msg_to_log(ERROR_LEVEL, format, args);
va_end(args);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
void sql_print_warning( const char *format, ... )
{
DBUG_ENTER( "sql_print_warning" );
void sql_print_warning(const char *format, ...)
{
va_list args; va_list args;
va_start( args, format ); DBUG_ENTER("sql_print_warning");
vprint_msg_to_log( WARNING_LEVEL, format, args );
va_end( args ); va_start(args, format);
vprint_msg_to_log(WARNING_LEVEL, format, args);
va_end(args);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
void sql_print_information( const char *format, ... )
{
DBUG_ENTER( "sql_print_information" );
void sql_print_information(const char *format, ...)
{
va_list args; va_list args;
va_start( args, format ); DBUG_ENTER("sql_print_information");
vprint_msg_to_log( INFORMATION_LEVEL, format, args );
va_end( args ); va_start(args, format);
vprint_msg_to_log(INFORMATION_LEVEL, format, args);
va_end(args);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -2247,6 +2247,10 @@ int main(int argc, char **argv) ...@@ -2247,6 +2247,10 @@ int main(int argc, char **argv)
if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0]) if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0])
opt_mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */ opt_mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
/* needed by get_options */
(void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST);
set_options(); set_options();
get_options(argc,argv); get_options(argc,argv);
set_server_version(); set_server_version();
...@@ -2263,7 +2267,6 @@ int main(int argc, char **argv) ...@@ -2263,7 +2267,6 @@ int main(int argc, char **argv)
(void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_mapped_file,MY_MUTEX_INIT_SLOW); (void) pthread_mutex_init(&LOCK_mapped_file,MY_MUTEX_INIT_SLOW);
(void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_status,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_error_log,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_delayed_insert,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_delayed_insert,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_delayed_status,MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_delayed_status,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW); (void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
...@@ -5100,21 +5103,24 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -5100,21 +5103,24 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
} }
return 0; return 0;
} }
/* Initiates DEBUG - but no debugging here ! */
void option_error_reporter( enum loglevel level, const char *format, ... )
void option_error_reporter(enum loglevel level, const char *format, ...)
{ {
va_list args; va_list args;
va_start( args, format ); va_start(args, format);
vprint_msg_to_log( level, format, args ); vprint_msg_to_log(level, format, args);
va_end( args ); va_end(args);
} }
/* Initiates DEBUG - but no debugging here ! */
static void get_options(int argc,char **argv) static void get_options(int argc,char **argv)
{ {
int ho_error; int ho_error;
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, option_error_reporter ))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option,
option_error_reporter)))
exit(ho_error); exit(ho_error);
#if defined(HAVE_BROKEN_REALPATH) #if defined(HAVE_BROKEN_REALPATH)
......
...@@ -2066,13 +2066,16 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name, ...@@ -2066,13 +2066,16 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
uint found; uint found;
DBUG_ENTER("insert_fields"); DBUG_ENTER("insert_fields");
if (db_name && lower_case_table_names) if (db_name && lower_case_table_names)
{ {
/* convert database to lower case for comparison */ /*
strmake( name_buff, db_name, sizeof(name_buff)-1 ); convert database to lower case for comparison
casedn_str( name_buff ); We can't do this in Item_field as this would change the
db_name = name_buff; 'name' of the item which may be used in the select list
*/
strmake(name_buff, db_name, sizeof(name_buff)-1);
casedn_str(name_buff);
db_name= name_buff;
} }
......
...@@ -999,10 +999,7 @@ void append_unescaped(String *res,const char *pos) ...@@ -999,10 +999,7 @@ void append_unescaped(String *res,const char *pos)
for (; *pos ; ) for (; *pos ; )
{ {
#ifdef USE_MB #if defined(USE_MB) && MYSQL_VERSION_ID < 40100
/*
Note, there is no needs to propagate this code into 4.1.
*/
uint mblen; uint mblen;
if (use_mb(default_charset_info) && if (use_mb(default_charset_info) &&
(mblen= my_ismbchar(default_charset_info, pos, end))) (mblen= my_ismbchar(default_charset_info, pos, end)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment