1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Fixes for Netware

Call pthread_mutex_destroy() on not used mutex.
Changed comments in .h and .c files from // -> /* */
Added detection of mutex on which one didn't call pthread_mutex_destroy()
Fixed bug in create_tmp_field() which causes a memory overrun in queries that uses "ORDER BY constant_expression"
Added optimisation for ORDER BY NULL
This commit is contained in:
monty@mashka.mysql.fi
2003-01-28 08:38:28 +02:00
parent 1bdd1d0626
commit 689578a099
101 changed files with 6597 additions and 4350 deletions

View File

@ -3,7 +3,7 @@
path=`dirname $0`
. "$path/SETUP.sh"
extra_flags="$pentium_cflags $debug_cflags -DHAVE_purify"
extra_flags="$pentium_cflags $debug_cflags -USAFEMALLOC -DHAVE_purify"
c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$pentium_configs $debug_configs"

View File

@ -25,7 +25,8 @@ SUBDIRS = . include @docs_dirs@ @readline_dir@ \
@thread_dirs@ pstack @sql_client_dirs@ \
@sql_server_dirs@ scripts man tests \
BUILD os2 @libmysqld_dirs@ \
@bench_dirs@ support-files @fs_dirs@ @tools_dirs@
@bench_dirs@ support-files @fs_dirs@ @tools_dirs@ \
@platform_dir@
# Relink after clean
linked_sources = linked_client_sources linked_server_sources \

View File

@ -121,7 +121,7 @@ __os_openhandle(dbenv, name, flags, mode, fhp)
} else {
#if defined(HAVE_FCNTL_F_SETFD)
/* Deny file descriptor access to any child process. */
if (fcntl(fhp->fd, F_SETFD, 1) == -1) {
if (fcntl(fhp->fd, F_SETFD, FD_CLOEXEC) == -1) {
ret = __os_get_errno();
__db_err(dbenv, "fcntl(F_SETFD): %s",
strerror(ret));

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2002 MySQL AB
/* Copyright (C) 2000-2003 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
@ -40,7 +40,7 @@
#include <signal.h>
#include <violite.h>
const char *VER= "12.16";
const char *VER= "12.17";
/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024
@ -79,7 +79,7 @@ extern "C" {
#undef bcmp // Fix problem with new readline
#if defined( __WIN__) || defined(OS2)
#include <conio.h>
#else
#elif !defined(__NETWARE__)
#include <readline/readline.h>
#define HAVE_READLINE
#endif
@ -91,12 +91,16 @@ extern "C" {
#define vidattr(A) {} // Can't get this to work
#endif
#ifdef __WIN__
#ifdef FN_NO_CASE_SENCE
#define cmp_database(A,B) my_strcasecmp((A),(B))
#else
#define cmp_database(A,B) strcmp((A),(B))
#endif
#if !defined( __WIN__) && !defined( OS2) && !defined(__NETWARE__) && (!defined(HAVE_mit_thread) || !defined(THREAD))
#define USE_POPEN
#endif
#include "completion_hash.h"
#define PROMPT_CHAR '\\'
@ -171,12 +175,12 @@ static int com_quit(String *str,char*),
com_connect(String *str,char*), com_status(String *str,char*),
com_use(String *str,char*), com_source(String *str, char*),
com_rehash(String *str, char*), com_tee(String *str, char*),
com_notee(String *str, char*), com_shell(String *str, char *),
com_notee(String *str, char*),
com_prompt(String *str, char*);
#ifndef __WIN__
#ifdef USE_POPEN
static int com_nopager(String *str, char*), com_pager(String *str, char*),
com_edit(String *str,char*);
com_edit(String *str,char*), com_shell(String *str, char *);
#endif
static int read_lines(bool execute_commands);
@ -187,7 +191,7 @@ static void safe_put_field(const char *pos,ulong length);
static void xmlencode_print(const char *src, uint length);
static void init_pager();
static void end_pager();
static int init_tee(char *);
static void init_tee(const char *);
static void end_tee();
static const char* construct_prompt();
static void init_username();
@ -210,18 +214,18 @@ static COMMANDS commands[] = {
{ "clear", 'c', com_clear, 0, "Clear command."},
{ "connect",'r', com_connect,1,
"Reconnect to the server. Optional arguments are db and host." },
#ifndef __WIN__
#ifdef USE_POPEN
{ "edit", 'e', com_edit, 0, "Edit command with $EDITOR."},
#endif
{ "ego", 'G', com_ego, 0,
"Send command to mysql server, display result vertically."},
{ "exit", 'q', com_quit, 0, "Exit mysql. Same as quit."},
{ "go", 'g', com_go, 0, "Send command to mysql server." },
#ifndef __WIN__
#ifdef USE_POPEN
{ "nopager",'n', com_nopager,0, "Disable pager, print to stdout." },
#endif
{ "notee", 't', com_notee, 0, "Don't write into outfile." },
#ifndef __WIN__
#ifdef USE_POPEN
{ "pager", 'P', com_pager, 1,
"Set PAGER [to_pager]. Print the query results via PAGER." },
#endif
@ -232,7 +236,7 @@ static COMMANDS commands[] = {
{ "source", '.', com_source, 1,
"Execute a SQL script file. Takes a file name as an argument."},
{ "status", 's', com_status, 0, "Get status information from the server."},
#ifndef __WIN__
#ifdef USE_POPEN
{ "system", '!', com_shell, 1, "Execute a system shell command."},
#endif
{ "tee", 'T', com_tee, 1,
@ -302,8 +306,8 @@ int main(int argc,char *argv[])
current_prompt = my_strdup(default_prompt,MYF(MY_WME));
prompt_counter=0;
strmov(outfile, "\0"); // no (default) outfile, unless given at least once
strmov(pager, "stdout"); // the default, if --pager wasn't given
outfile[0]=0; // no (default) outfile
strmov(pager, "stdout"); // the default, if --pager wasn't given
{
char *tmp=getenv("PAGER");
if (tmp)
@ -491,7 +495,7 @@ static struct my_option my_long_options[] =
NO_ARG, 1, 0, 0, 0, 0, 0},
{"skip-line-numbers", 'L', "Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#ifndef __WIN__
#ifdef USE_POPEN
{"no-pager", OPT_NOPAGER,
"Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
@ -512,7 +516,7 @@ static struct my_option my_long_options[] =
{"one-database", 'o',
"Only update the default database. This is useful for skipping updates to other database in the update log.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifndef __WIN__
#ifdef USE_POPEN
{"pager", OPT_PAGER,
"Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\\h) also. This option does not work in batch mode.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
@ -619,7 +623,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
end_tee();
}
else
opt_outfile= init_tee(argument);
init_tee(argument);
break;
case OPT_NOTEE:
printf("WARNING: option deprecated; use --disable-tee instead.\n");
@ -772,7 +776,7 @@ static int get_options(int argc, char **argv)
static int read_lines(bool execute_commands)
{
#if defined( __WIN__) || defined(OS2)
#if defined( __WIN__) || defined(OS2) || defined(__NETWARE__)
char linebuffer[254];
#endif
char *line;
@ -792,30 +796,33 @@ static int read_lines(bool execute_commands)
}
else
{
#if defined( __WIN__) || defined(OS2)
if (opt_outfile && glob_buffer.is_empty())
fflush(OUTFILE);
tee_fputs(glob_buffer.is_empty() ? construct_prompt() :
!in_string ? " -> " :
in_string == '\'' ?
" '> " : " \"> ",stdout);
linebuffer[0]=(char) sizeof(linebuffer);
line=_cgets(linebuffer);
#else
if (opt_outfile)
{
if (glob_buffer.is_empty())
fflush(OUTFILE);
fputs(glob_buffer.is_empty() ? construct_prompt() :
!in_string ? " -> " :
in_string == '\'' ?
" '> " : " \"> ", OUTFILE);
}
line=readline((char*) (glob_buffer.is_empty() ? construct_prompt() :
char *prompt= (char*) (glob_buffer.is_empty() ? construct_prompt() :
!in_string ? " -> " :
in_string == '\'' ?
" '> " : " \"> "));
#endif
" '> " : " \"> ");
if (opt_outfile && glob_buffer.is_empty())
fflush(OUTFILE);
#if defined( __WIN__) || defined(OS2) || defined(__NETWARE__)
tee_fputs(prompt, stdout);
#ifdef __NETWARE__
line=fgets(linebuffer, sizeof(linebuffer)-1, stdin);
/* Remove the '\n' */
{
char *p = strrchr(line, '\n');
if (p != NULL)
*p = '\0';
}
#else
linebuffer[0]= (char) sizeof(linebuffer);
line= _cgets(linebuffer);
#endif /* __NETWARE__ */
#else
if (opt_outfile)
fputs(prompt, OUTFILE);
line= readline(prompt);
#endif /* defined( __WIN__) || defined(OS2) || defined(__NETWARE__) */
if (opt_outfile)
fprintf(OUTFILE, "%s\n", line);
}
@ -1497,7 +1504,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
static void init_pager()
{
#if !defined( __WIN__) && !defined( OS2) && (!defined(HAVE_mit_thread) || !defined(THREAD))
#ifdef USE_POPEN
if (!opt_nopager)
{
if (!(PAGER= popen(pager, "w")))
@ -1513,30 +1520,35 @@ static void init_pager()
static void end_pager()
{
#if !defined( __WIN__) && !defined( OS2) && !(defined(HAVE_mit_thread) && defined(THREAD))
#ifdef USE_POPEN
if (!opt_nopager)
pclose(PAGER);
#endif
}
static int init_tee(char* newfile)
static void init_tee(const char *file_name)
{
FILE* new_outfile;
if (!(new_outfile= my_fopen(newfile, O_APPEND | O_WRONLY, MYF(MY_WME))))
return 0;
if (opt_outfile)
end_tee();
if (!(new_outfile= my_fopen(file_name, O_APPEND | O_WRONLY, MYF(MY_WME))))
{
tee_fprintf(stdout, "Error logging to file '%s'\n", file_name);
return;
}
OUTFILE = new_outfile;
strmake(outfile,newfile,FN_REFLEN-1);
tee_fprintf(stdout, "Logging to file '%s'\n", outfile);
return 1;
strmake(outfile, file_name, FN_REFLEN-1);
tee_fprintf(stdout, "Logging to file '%s'\n", file_name);
opt_outfile= 1;
return;
}
static void end_tee()
{
my_fclose(OUTFILE, MYF(0));
OUTFILE= 0;
opt_outfile= 0;
return;
}
@ -1576,6 +1588,9 @@ print_table_data(MYSQL_RES *result)
MYSQL_ROW cur;
MYSQL_FIELD *field;
bool *num_flag;
#ifdef __NETWARE__
uint lines= 0;
#endif
num_flag=(bool*) my_alloca(sizeof(bool)*mysql_num_fields(result));
if (info_flag)
@ -1631,16 +1646,24 @@ print_table_data(MYSQL_RES *result)
length, str);
}
(void) tee_fputs("\n", PAGER);
#ifdef __NETWARE__
// on a long result the screen could hog the cpu
if ((lines++ & 1023) == 0) pthread_yield();
#endif
}
tee_puts(separator.c_ptr(), PAGER);
my_afree((gptr) num_flag);
}
static void
print_table_data_html(MYSQL_RES *result)
{
MYSQL_ROW cur;
MYSQL_FIELD *field;
MYSQL_ROW cur;
MYSQL_FIELD *field;
#ifdef __NETWARE__
uint lines= 0;
#endif
mysql_field_seek(result,0);
(void) tee_fputs("<TABLE BORDER=1><TR>", PAGER);
@ -1665,6 +1688,10 @@ print_table_data_html(MYSQL_RES *result)
(void) tee_fputs("</TD>", PAGER);
}
(void) tee_fputs("</TR>", PAGER);
#ifdef __NETWARE__
// on a long result the screen could hog the cpu
if ((lines++ & 1023) == 0) pthread_yield();
#endif
}
(void) tee_fputs("</TABLE>", PAGER);
}
@ -1698,6 +1725,10 @@ print_table_data_xml(MYSQL_RES *result)
" &nbsp; ") : "NULL"));
}
(void) tee_fputs(" </row>\n", PAGER);
#ifdef __NETWARE__
// on a long result the screen could hog the cpu
if ((lines++ & 1023) == 0) pthread_yield();
#endif
}
(void) tee_fputs("</resultset>\n", PAGER);
}
@ -1730,6 +1761,10 @@ print_table_data_vertically(MYSQL_RES *result)
tee_fprintf(PAGER, "%*s: ",(int) max_length,field->name);
tee_fprintf(PAGER, "%s\n",cur[off] ? (char*) cur[off] : "NULL");
}
#ifdef __NETWARE__
// on a long result the screen could hog the cpu
if ((row_count & 1023) == 0) pthread_yield();
#endif
}
}
@ -1869,11 +1904,7 @@ com_tee(String *buffer, char *line __attribute__((unused)))
printf("No outfile specified!\n");
return 0;
}
opt_outfile= init_tee(file_name);
if (opt_outfile)
tee_fprintf(stdout, "Logging to file '%s'\n", outfile);
else
tee_fprintf(stdout, "Error logging to file '%s'\n",file_name);
init_tee(file_name);
return 0;
}
@ -1892,7 +1923,7 @@ com_notee(String *buffer __attribute__((unused)),
Sorry, this command is not available in Windows.
*/
#ifndef __WIN__
#ifdef USE_POPEN
static int
com_pager(String *buffer, char *line __attribute__((unused)))
{
@ -1903,9 +1934,9 @@ com_pager(String *buffer, char *line __attribute__((unused)))
/* Skip space from file name */
while (isspace(*line))
line++;
if (!(param = strchr(line, ' '))) // if pager was not given, use the default
if (!(param= strchr(line, ' '))) // if pager was not given, use the default
{
if (!strlen(default_pager))
if (!default_pager[0])
{
tee_fprintf(stdout, "Default pager wasn't set, using stdout.\n");
opt_nopager=1;
@ -1948,7 +1979,7 @@ com_nopager(String *buffer __attribute__((unused)),
Sorry, you can't send the result to an editor in Win32
*/
#ifndef __WIN__
#ifdef USE_POPEN
static int
com_edit(String *buffer,char *line __attribute__((unused)))
{
@ -1996,6 +2027,10 @@ static int
com_quit(String *buffer __attribute__((unused)),
char *line __attribute__((unused)))
{
#ifdef __NETWARE__
// let the screen auto close on a normal shutdown
setscreenmode(SCR_AUTOCLOSE_ON_EXIT);
#endif
status.exit_status=0;
return 1;
}
@ -2011,7 +2046,7 @@ com_rehash(String *buffer __attribute__((unused)),
}
#ifndef __WIN__
#ifdef USE_POPEN
static int
com_shell(String *buffer, char *line __attribute__((unused)))
{
@ -2327,7 +2362,7 @@ com_status(String *buffer __attribute__((unused)),
tee_fprintf(stdout, "\nAll updates ignored to this database\n");
vidattr(A_NORMAL);
}
#ifndef __WIN__
#ifdef USE_POPEN
tee_fprintf(stdout, "Current pager:\t\t%s\n", pager);
tee_fprintf(stdout, "Using outfile:\t\t'%s'\n", opt_outfile ? outfile : "");
#endif
@ -2500,7 +2535,7 @@ void tee_putc(int c, FILE *file)
putc(c, OUTFILE);
}
#if defined( __WIN__) || defined( OS2)
#if defined( __WIN__) || defined( OS2) || defined(__NETWARE__)
#include <time.h>
#else
#include <sys/times.h>
@ -2512,7 +2547,7 @@ void tee_putc(int c, FILE *file)
static ulong start_timer(void)
{
#if defined( __WIN__) || defined( OS2)
#if defined( __WIN__) || defined( OS2) || defined(__NETWARE__)
return clock();
#else
struct tms tms_tmp;

View File

@ -341,7 +341,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
tty_password=1;
break;
case 'r':
if (!(md_result_file = my_fopen(argument, O_WRONLY | O_BINARY,
if (!(md_result_file = my_fopen(argument, O_WRONLY | FILE_BINARY,
MYF(MY_WME))))
exit(1);
break;

View File

@ -677,7 +677,7 @@ int open_file(const char* name)
if (*cur_file && cur_file == file_stack_end)
die("Source directives are nesting too deep");
if (!(*(cur_file+1) = my_fopen(buff, O_RDONLY | O_BINARY, MYF(MY_WME))))
if (!(*(cur_file+1) = my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME))))
die(NullS);
cur_file++;
*++lineno=1;
@ -685,18 +685,6 @@ int open_file(const char* name)
return 0;
}
static void my_sleep(ulong m_seconds)
{
#ifndef OS2
struct timeval t;
t.tv_sec= m_seconds / 1000000L;
t.tv_usec= m_seconds % 1000000L;
select(0,0,0,0,&t); /* sleep */
#else
DosSleep(m_seconds/1000+1);
#endif
}
/* ugly long name, but we are following the convention */
int do_wait_for_slave_to_stop(struct st_query* q __attribute__((unused)))
@ -1912,7 +1900,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
argument= buff;
}
fn_format(buff, argument, "", "", 4);
if (!(*++cur_file = my_fopen(buff, O_RDONLY | O_BINARY, MYF(MY_WME))))
if (!(*++cur_file = my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME))))
die("Could not open %s: errno = %d", argument, errno);
break;
}
@ -2561,7 +2549,7 @@ static int read_server_arguments(const char* name)
embedded_server_arg_count=1;
embedded_server_args[0]= (char*) ""; /* Progname */
}
if (!(file=my_fopen(buff, O_RDONLY | O_BINARY, MYF(MY_WME))))
if (!(file=my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME))))
return 1;
while (embedded_server_arg_count < MAX_SERVER_ARGS &&
(str=fgets(argument,sizeof(argument), file)))

View File

@ -38,9 +38,18 @@ rm -f $AVAILABLE_LANGUAGES_ERRORS_RULES
for i in $AVAILABLE_LANGUAGES
do
AVAILABLE_LANGUAGES_ERRORS="$AVAILABLE_LANGUAGES_ERRORS $i/errmsg.sys"
case $SYSTEM_TYPE in
*netware* | *modesto*)
echo "$i/errmsg.sys: $i/errmsg.txt
\$(top_builddir)/extra/comp_err.cyg \$^ $i/errmsg.sys" \
>> $AVAILABLE_LANGUAGES_ERRORS_RULES
;;
*)
echo "$i/errmsg.sys: $i/errmsg.txt
\$(top_builddir)/extra/comp_err \$^ $i/errmsg.sys" \
>> $AVAILABLE_LANGUAGES_ERRORS_RULES
;;
esac
done
#####
@ -130,7 +139,14 @@ AC_PROG_CXX
AC_PROG_CPP
# Print version of CC and CXX compiler (if they support --version)
case $SYSTEM_TYPE in
*netware*)
CC_VERSION=`$CC -version | grep -i version`
;;
*)
CC_VERSION=`$CC --version | sed 1q`
;;
esac
if test $? -eq "0"
then
AC_MSG_CHECKING("C Compiler version");
@ -138,7 +154,14 @@ then
else
CC_VERSION=""
fi
case $SYSTEM_TYPE in
*netware*)
CXX_VERSION=`$CXX -version | grep -i version`
;;
*)
CXX_VERSION=`$CXX --version | sed 1q`
;;
esac
if test $? -eq "0"
then
AC_MSG_CHECKING("C++ compiler version");
@ -186,6 +209,11 @@ AC_CHECK_PROG(DVIS, tex, manual.dvi)
AC_MSG_CHECKING("return type of sprintf")
#check the return type of sprintf
case $SYSTEM_TYPE in
*netware*)
AC_DEFINE(SPRINTF_RETURNS_INT) AC_MSG_RESULT("int")
;;
*)
AC_TRY_RUN([
int main()
{
@ -205,11 +233,13 @@ AC_DEFINE(SPRINTF_RETURNS_INT) AC_MSG_RESULT("int"),
char buf[6];
if((char*)sprintf(buf,s) == buf + strlen(s))
return 0;
return -1;
return -1;
}
], AC_DEFINE(SPRINTF_RETURNS_PTR) AC_MSG_RESULT("ptr"),
AC_DEFINE(SPRINTF_RETURNS_GARBAGE) AC_MSG_RESULT("garbage")))
;;
esac
# option, cache_name, variable,
# code to execute if yes, code to exectute if fail
@ -361,10 +391,12 @@ dnl Find paths to some shell programs
AC_PATH_PROG(LN, ln, ln)
# This must be able to take a -f flag like normal unix ln.
AC_PATH_PROG(LN_CP_F, ln, ln)
if ! ( expr "$SYSTEM_TYPE" : ".*netware.*" > /dev/null ); then
# If ln -f does not exists use -s (AFS systems)
if test -n "$LN_CP_F"; then
LN_CP_F="$LN_CP_F -s"
fi
fi
AC_PATH_PROG(MV, mv, mv)
AC_PATH_PROG(RM, rm, rm)
@ -429,6 +461,9 @@ else
*cygwin*)
FIND_PROC="$PS -e | grep mysqld | grep \" \$\$PID \" > /dev/null"
;;
*netware* | *modesto*)
FIND_PROC=
;;
*)
AC_MSG_ERROR([Could not find the right ps switches. Which OS is this ?. See the Installation chapter in the Reference Manual.])
esac
@ -853,6 +888,11 @@ fi
NON_THREADED_CLIENT_LIBS="$LIBS"
AC_MSG_CHECKING([for int8])
case $SYSTEM_TYPE in
*netware)
AC_MSG_RESULT([no])
;;
*)
AC_TRY_RUN([
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@ -873,6 +913,8 @@ int main()
}
], AC_DEFINE(HAVE_INT_8_16_32) AC_MSG_RESULT([yes]), AC_MSG_RESULT([no])
)
;;
esac
#
# Some system specific hacks
@ -1022,6 +1064,107 @@ dnl Is this the right match for DEC OSF on alpha?
CFLAGS="$CFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R"
CXXFLAGS="$CXXFLAGS -DUNDEF_HAVE_GETHOSTBYNAME_R"
;;
*netware*)
# No need for curses library so set it to null
with_named_curses=""
#
# Edit Makefile.in files.
#
echo -n "configuring Makefile.in files for NetWare... "
for file in sql/Makefile.in libmysql/Makefile.in libmysql_r/Makefile.in sql/share/Makefile.in strings/Makefile.in client/Makefile.in
do
# echo "#### $file ####"
filedir="`dirname $file`"
filebase="`basename $file`"
filesed=$filedir/$filebase.sed
#
# Backup and always use original file
#
if test -f $file.bk
then
cp -fp $file.bk $file
else
cp -fp $file $file.bk
fi
case $file in
sql/Makefile.in)
# Use gen_lex_hash.cyg instead of gen_lex_hash
# Add library dependencies to mysqld_DEPENDENCIES
lib_DEPENDENCIES="\$(bdb_libs_with_path) \$(innodb_libs) \$(pstack_libs) \$(innodb_system_libs) \$(openssl_libs)"
cat > $filesed << EOF
s,\(^.*\$(MAKE) gen_lex_hash\),#\1,
s,\(\./gen_lex_hash\),\1.cyg,
s%\(mysqld_DEPENDENCIES = \) %\1$lib_DEPENDENCIES %
EOF
;;
sql/share/Makefile.in)
cat > $filesed << EOF
s,\(extra/comp_err\),\1.cyg,
EOF
;;
libmysql/Makefile.in)
cat > $filesed << EOF
s,\(\./conf_to_src\)\( \$(top_srcdir)\),\1.cyg\2,
s,\(: conf_to_src\),\1.cyg,
EOF
;;
libmysql_r/Makefile.in)
cat > $filesed << EOF
s,\(\./conf_to_src\)\( \$(top_srcdir)\),\1.cyg\2,
s,\(: conf_to_src\),\1.cyg,
EOF
;;
strings/Makefile.in)
cat > $filesed << EOF
s,\(\./conf_to_src\)\( \$(top_srcdir)\),\1.cyg\2,
s,\(: conf_to_src\),\1.cyg,
EOF
;;
client/Makefile.in)
#
cat > $filesed << EOF
s,libmysqlclient.la,.libs/libmysqlclient.a,
EOF
;;
esac
if `sed -f $filesed $file > $file.nw`;\
then
mv -f $file.nw $file
rm -f $filesed
else
exit 1
fi
# wait for file system changes to complete
sleep 1
done
echo "done"
#
# Make sure the following files are writable.
#
# When the files are retrieved from some source code control systems they are read-only.
#
echo -n "making sure specific build files are writable... "
for file in \
Docs/include.texi \
Docs/mysql.info \
Docs/manual.txt \
Docs/manual_toc.html \
Docs/manual.html \
Docs/INSTALL-BINARY \
INSTALL-SOURCE \
COPYING \
COPYING.LIB \
MIRRORS
do
if test -e $file; then
chmod +w $file
fi
done
echo "done"
;;
esac
@ -1389,7 +1532,12 @@ LIBS="$my_save_LIBS"
AC_SUBST(LIBDL)
# System characteristics
case $SYSTEM_TYPE in
*netware* | *modesto*) ;;
*)
AC_SYS_RESTARTABLE_SYSCALLS
;;
esac
# Build optimized or debug version ?
# First check for gcc and g++
@ -1414,6 +1562,13 @@ else
OPTIMIZE_CXXFLAGS="-O"
fi
if expr "$SYSTEM_TYPE" : ".*netware.*" > /dev/null; then
DEBUG_CFLAGS="$DEBUG_CFLAGS -DDEBUG -sym internal,codeview4"
DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -DDEBUG -sym internal,codeview4"
OPTIMIZE_CFLAGS="$OPTIMIZE_CFLAGS -DNDEBUG"
OPTIMIZE_CXXFLAGS="$OPTIMIZE_CXXFLAGS -DNDEBUG"
fi
AC_ARG_WITH(debug,
[ --without-debug Build a production version without debugging code],
[with_debug=$withval],
@ -1561,6 +1716,7 @@ MYSQL_CHECK_FP_EXCEPT
# Do the c++ compiler have a bool type
MYSQL_CXX_BOOL
# Check some common bugs with gcc 2.8.# on sparc
if ! ( expr "$SYSTEM_TYPE" : ".*netware.*" > /dev/null ); then
MYSQL_CHECK_LONGLONG_TO_FLOAT
if test "$ac_cv_conv_longlong_to_float" != "yes"
then
@ -1568,6 +1724,7 @@ then
If you are using gcc 2.8.# you should upgrade to egcs 1.0.3 or newer and try
again]);
fi
fi
MYSQL_PTHREAD_YIELD
######################################################################
@ -1988,6 +2145,11 @@ AC_ARG_WITH(readline,
[ with_readline=$withval ],
[ with_readline=yes ]
)
if expr "$SYSTEM_TYPE" : ".*netware.*" > /dev/null; then
# For NetWare, do not need readline
readline_dir=""
readline_link=""
else
if test "$with_readline" = "yes"
then
readline_dir="readline"
@ -1998,6 +2160,7 @@ else
readline_dir=""
readline_link="-lreadline"
fi
fi
AC_SUBST(readline_dir)
AC_SUBST(readline_link)
@ -2031,6 +2194,13 @@ AC_ARG_WITH(extra-charsets,
[extra_charsets="$withval"],
[extra_charsets="none"])
AC_ARG_WITH(platform-dir,
[ --with-platform-dir=DIR
Add specified directory to list of SUBDIRS to build.],
[ with_platform_dir=$withval ],
[ with_platform_dir=no ]
)
AC_MSG_CHECKING("character sets")
if test "$extra_charsets" = none; then
@ -2269,11 +2439,18 @@ AC_SUBST(CLIENT_LIBS)
AC_SUBST(sql_client_dirs)
AC_SUBST(linked_client_targets)
platform_dir=
if test "$with_platform_dir" != "no"
then
platform_dir="$with_platform_dir"
fi
AC_SUBST(platform_dir)
if test "$with_server" = "yes" -o "$THREAD_SAFE_CLIENT" != "no"
then
AC_DEFINE(THREAD)
# Avoid _PROGRAMS names
THREAD_LPROGRAMS="test_thr_alarm test_thr_lock"
THREAD_LPROGRAMS="test_thr_alarm\$(EXEEXT) test_thr_lock\$(EXEEXT)"
AC_SUBST(THREAD_LPROGRAMS)
THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o"
AC_SUBST(THREAD_LOBJECTS)
@ -2377,7 +2554,7 @@ EOF
then
innodb_conf_flags=--disable-dependency-tracking
fi
(cd innobase && sh $rel_srcdir/innobase/configure $innodb_conf_flags) \
(cd innobase && sh $rel_srcdir/innobase/configure --host=$host $innodb_conf_flags) \
|| AC_MSG_ERROR([could not configure INNODB])
echo "END OF INNODB CONFIGURATION"
@ -2435,20 +2612,21 @@ AC_SUBST(GXX)
#AC_SUBST(TOOLS_LIBS)
# Output results
AC_OUTPUT(Makefile extra/Makefile mysys/Makefile isam/Makefile \
strings/Makefile regex/Makefile heap/Makefile \
bdb/Makefile \
myisam/Makefile myisammrg/Makefile \
os2/Makefile os2/include/Makefile os2/include/sys/Makefile \
man/Makefile BUILD/Makefile readline/Makefile vio/Makefile \
libmysql_r/Makefile libmysqld/Makefile libmysqld/examples/Makefile \
libmysql/Makefile client/Makefile \
pstack/Makefile pstack/aout/Makefile sql/Makefile sql/share/Makefile \
merge/Makefile dbug/Makefile scripts/Makefile \
include/Makefile sql-bench/Makefile tools/Makefile \
tests/Makefile Docs/Makefile support-files/Makefile \
mysql-test/Makefile \
include/mysql_version.h
AC_OUTPUT(Makefile extra/Makefile mysys/Makefile isam/Makefile dnl
strings/Makefile regex/Makefile heap/Makefile dnl
bdb/Makefile dnl
myisam/Makefile myisammrg/Makefile dnl
os2/Makefile os2/include/Makefile os2/include/sys/Makefile dnl
man/Makefile BUILD/Makefile readline/Makefile vio/Makefile dnl
libmysql_r/Makefile libmysqld/Makefile libmysqld/examples/Makefile dnl
libmysql/Makefile client/Makefile dnl
pstack/Makefile pstack/aout/Makefile sql/Makefile sql/share/Makefile dnl
merge/Makefile dbug/Makefile scripts/Makefile dnl
include/Makefile sql-bench/Makefile tools/Makefile dnl
tests/Makefile Docs/Makefile support-files/Makefile dnl
mysql-test/Makefile dnl
netware/Makefile dnl
include/mysql_version.h dnl
, , [
test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
])

View File

@ -16,7 +16,7 @@
/* Resolves IP's to hostname and hostnames to IP's */
#define RESOLVE_VERSION "2.2"
#define RESOLVE_VERSION "2.3"
#include <my_global.h>
#include <m_ctype.h>
@ -147,8 +147,11 @@ int main(int argc, char **argv)
else
{
printf ("Host name of %s is %s", ip,hpaddr->h_name);
#ifndef __NETWARE__
/* this information is not available on NetWare */
for (q = hpaddr->h_aliases; *q != 0; q++)
(void) printf(", %s", *q);
#endif /* __NETWARE__ */
puts("");
}
}

View File

@ -22,7 +22,7 @@ pkginclude_HEADERS = dbug.h m_string.h my_sys.h my_list.h \
errmsg.h my_global.h my_net.h my_alloc.h \
my_getopt.h sslopt-longopts.h \
sslopt-vars.h sslopt-case.h $(BUILT_SOURCES)
noinst_HEADERS = config-win.h config-os2.h \
noinst_HEADERS = config-win.h config-os2.h config-netware.h \
nisam.h heap.h merge.h my_bitmap.h\
myisam.h myisampack.h myisammrg.h ft_global.h\
my_dir.h mysys_err.h my_base.h \

86
include/config-netware.h Normal file
View File

@ -0,0 +1,86 @@
/* Copyright (C) 2000 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; either version 2 of the License, or
(at your option) any later version.
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 */
/* Defines for netware compatible with MySQL */
/* required headers */
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <screen.h>
#include <limits.h>
#include <nks/synch.h>
#include <nks/thread.h>
#include <signal.h>
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <nks/errno.h>
#include <sys/types.h>
#include <time.h>
#include <sys/time.h>
#include <nks/time.h>
#include <pthread.h>
#include <termios.h>
/* required adjustments */
#undef HAVE_READDIR_R
#undef HAVE_RWLOCK_INIT
#undef HAVE_SCHED_H
#undef HAVE_SYS_MMAN_H
#undef HAVE_SYNCH_H
#undef HAVE_CRYPT
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
#define HAVE_PTHREAD_SIGMASK 1
#define HAVE_PTHREAD_YIELD_ZERO_ARG 1
#define HAVE_BROKEN_REALPATH 1
/* no case sensitivity */
#define FN_NO_CASE_SENCE 1
/* the thread alarm is not used */
#define DONT_USE_THR_ALARM 1
/* signals do not interrupt sockets */
#define SIGNALS_DONT_BREAK_READ 1
/* signal by closing the sockets */
#define SIGNAL_WITH_VIO_CLOSE 1
/* default directory information */
#define DEFAULT_MYSQL_HOME "sys:/mysql"
#define PACKAGE "mysql"
#define DEFAULT_BASEDIR "sys:/"
#define SHAREDIR "share/"
#define DEFAULT_CHARSET_HOME "sys:/mysql/"
#define DATADIR "data/"
/* 64-bit file system calls */
#define SIZEOF_OFF_T 8
#define off_t off64_t
#define chsize chsize64
#define ftruncate ftruncate64
#define lseek lseek64
#define pread pread64
#define pwrite pwrite64
#define tell tell64
/* do not use the extended time in LibC sys\stat.h */
#define _POSIX_SOURCE
/* Some macros for portability */
#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=(SEC); (ABSTIME).tv_nsec=0; }

View File

@ -182,6 +182,8 @@ inline double ulonglong2double(ulonglong value)
#define tell(A) _telli64(A)
#endif
#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; }
#define STACK_DIRECTION -1
/* Optimized store functions for Intel x86 */
@ -276,6 +278,7 @@ inline double ulonglong2double(ulonglong value)
#define my_reinterpret_cast(A) reinterpret_cast <A>
#define my_const_cast(A) const_cast<A>
/* MYSQL OPTIONS */
#ifdef _CUSTOMCONFIG_

View File

@ -51,6 +51,12 @@
#include <config-win.h>
#elif defined(OS2)
#include <config-os2.h>
#elif defined(__NETWARE__)
#include <my_config.h>
#include <config-netware.h>
#if defined(__cplusplus) && defined(inline)
#undef inline /* fix configure problem */
#endif
#else
#include <my_config.h>
#if defined(__cplusplus) && defined(inline)
@ -442,17 +448,20 @@ typedef SOCKET_SIZE_TYPE size_socket;
/* file create flags */
#ifndef O_SHARE
#ifndef O_SHARE /* Probably not windows */
#define O_SHARE 0 /* Flag to my_open for shared files */
#ifndef O_BINARY
#define O_BINARY 0 /* Flag to my_open for binary files */
#endif
#define FILE_BINARY 0 /* Flag to my_fopen for binary streams */
#ifndef FILE_BINARY
#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */
#endif
#ifdef HAVE_FCNTL
#define HAVE_FCNTL_LOCK
#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
#endif
#endif /* O_SHARE */
#ifndef O_TEMPORARY
#define O_TEMPORARY 0
#endif
@ -795,10 +804,9 @@ typedef char bool; /* Ordinary boolean values 0 1 */
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
#ifndef set_timespec
#ifdef HAVE_TIMESPEC_TS_SEC
#define set_timespec(ABSTIME,SEC) { (ABSTIME).ts_sec=time(0) + (time_t) (SEC); (ABSTIME).ts_nsec=0; }
#elif defined(__WIN__)
#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; }
#else
#define set_timespec(ABSTIME,SEC) \
{\
@ -807,7 +815,8 @@ typedef char bool; /* Ordinary boolean values 0 1 */
(ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\
(ABSTIME).tv_nsec=tv.tv_usec*1000;\
}
#endif
#endif /* HAVE_TIMESPEC_TS_SEC */
#endif /* set_timespec */
/*
Define-funktions for reading and storing in machine independent format

View File

@ -44,7 +44,7 @@ C_MODE_START
#include <sys/ioctl.h>
#endif
#if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__)
#if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) && !defined(__NETWARE__)
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>

View File

@ -356,6 +356,14 @@ extern int my_pthread_cond_timedwait(pthread_cond_t *cond,
#define pthread_cond_timedwait(A,B,C) my_pthread_cond_timedwait((A),(B),(C))
#endif
#ifdef __NETWARE__
extern int my_pthread_cond_timedwait(pthread_cond_t *cond,
pthread_mutex_t *mutex,
struct timespec *abstime);
#define pthread_cond_timedwait(A,B,C) my_pthread_cond_timedwait((A),(B),(C))
#endif /* __NETWARE__ */
#if defined(OS2)
#define my_pthread_getspecific(T,A) ((T) &(A))
#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A))
@ -443,15 +451,39 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
/* safe_mutex adds checking to mutex for easier debugging */
#if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY)
#define SAFE_MUTEX_DETECT_DESTROY
#endif
typedef struct st_safe_mutex_t
{
pthread_mutex_t global,mutex;
char *file;
uint line,count;
pthread_t thread;
#ifdef SAFE_MUTEX_DETECT_DESTROY
struct st_safe_mutex_info_t *info; /* to track destroying of mutexes */
#endif
} safe_mutex_t;
int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr);
#ifdef SAFE_MUTEX_DETECT_DESTROY
/*
Used to track the destroying of mutexes. This needs to be a seperate
structure because the safe_mutex_t structure could be freed before
the mutexes are destroyed.
*/
typedef struct st_safe_mutex_info_t
{
struct st_safe_mutex_info_t *next;
struct st_safe_mutex_info_t *prev;
char *init_file;
uint32 init_line;
} safe_mutex_info_t;
#endif /* SAFE_MUTEX_DETECT_DESTROY */
int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr,
const char *file, uint line);
int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line);
int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line);
int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line);
@ -459,6 +491,8 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file,
uint line);
int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
struct timespec *abstime, const char *file, uint line);
void safe_mutex_global_init(void);
void safe_mutex_end(FILE *file);
/* Wrappers if safe mutex is actually used */
#ifdef SAFE_MUTEX
@ -472,7 +506,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
#undef pthread_cond_wait
#undef pthread_cond_timedwait
#undef pthread_mutex_trylock
#define pthread_mutex_init(A,B) safe_mutex_init((A),(B))
#define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__)
#define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__)
#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__)
#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__)

View File

@ -731,29 +731,32 @@ extern void my_free_lock(byte *ptr,myf flags);
#define my_free_lock(A,B) my_free((A),(B))
#endif
#define alloc_root_inited(A) ((A)->min_malloc != 0)
void init_alloc_root(MEM_ROOT *mem_root, uint block_size, uint pre_alloc_size);
gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
void free_root(MEM_ROOT *root, myf MyFLAGS);
void set_prealloc_root(MEM_ROOT *root, char *ptr);
char *strdup_root(MEM_ROOT *root,const char *str);
char *strmake_root(MEM_ROOT *root,const char *str,uint len);
char *memdup_root(MEM_ROOT *root,const char *str,uint len);
void load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv);
void free_defaults(char **argv);
void print_defaults(const char *conf_file, const char **groups);
my_bool my_compress(byte *, ulong *, ulong *);
my_bool my_uncompress(byte *, ulong *, ulong *);
byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
ulong checksum(const byte *mem, uint count);
uint my_bit_log2(ulong value);
extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
uint pre_alloc_size);
extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
extern void free_root(MEM_ROOT *root, myf MyFLAGS);
extern void set_prealloc_root(MEM_ROOT *root, char *ptr);
extern char *strdup_root(MEM_ROOT *root,const char *str);
extern char *strmake_root(MEM_ROOT *root,const char *str,uint len);
extern char *memdup_root(MEM_ROOT *root,const char *str,uint len);
extern void load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv);
extern void free_defaults(char **argv);
extern void print_defaults(const char *conf_file, const char **groups);
extern my_bool my_compress(byte *, ulong *, ulong *);
extern my_bool my_uncompress(byte *, ulong *, ulong *);
extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
extern ulong checksum(const byte *mem, uint count);
extern uint my_bit_log2(ulong value);
extern void my_sleep(ulong m_seconds);
#if defined(_MSC_VER) && !defined(__WIN__)
extern void sleep(int sec);
#endif
#ifdef __WIN__
extern my_bool have_tcpip; /* Is set if tcpip is used */
#endif
#ifdef __NETWARE__
void netware_reg_user(const char *ip, const char *user,
const char *application);
#endif
C_MODE_END
#include "raid.h"

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB
/* Copyright (C) 2000-2003 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
@ -60,6 +60,10 @@ typedef int my_socket;
extern unsigned int mysql_port;
extern char *mysql_unix_port;
#ifdef __NETWARE__
#pragma pack(push, 8) /* 8 byte alignment */
#endif
#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG)
#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG)
#define IS_BLOB(n) ((n) & BLOB_FLAG)
@ -418,6 +422,11 @@ int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
int simple_command(MYSQL *mysql,enum enum_server_command command,
const char *arg, unsigned long length, my_bool skipp_check);
unsigned long net_safe_read(MYSQL* mysql);
void STDCALL mysql_once_init(void);
#ifdef __NETWARE__
#pragma pack(pop) /* restore alignment */
#endif
#ifdef __cplusplus
}

View File

@ -110,14 +110,14 @@ case "$target" in
CFLAGS="$CFLAGS -DUNIV_INTEL_X86";;
esac
AC_OUTPUT(Makefile os/Makefile ut/Makefile btr/Makefile
buf/Makefile com/Makefile data/Makefile
dict/Makefile dyn/Makefile
eval/Makefile fil/Makefile fsp/Makefile fut/Makefile
ha/Makefile ibuf/Makefile include/Makefile
lock/Makefile log/Makefile
mach/Makefile mem/Makefile mtr/Makefile odbc/Makefile
page/Makefile pars/Makefile que/Makefile
read/Makefile rem/Makefile row/Makefile
srv/Makefile sync/Makefile thr/Makefile trx/Makefile
AC_OUTPUT(Makefile os/Makefile ut/Makefile btr/Makefile dnl
buf/Makefile com/Makefile data/Makefile dnl
dict/Makefile dyn/Makefile dnl
eval/Makefile fil/Makefile fsp/Makefile fut/Makefile dnl
ha/Makefile ibuf/Makefile include/Makefile dnl
lock/Makefile log/Makefile dnl
mach/Makefile mem/Makefile mtr/Makefile odbc/Makefile dnl
page/Makefile pars/Makefile que/Makefile dnl
read/Makefile rem/Makefile row/Makefile dnl
srv/Makefile sync/Makefile thr/Makefile trx/Makefile dnl
usr/Makefile)

View File

@ -15,9 +15,10 @@ Created 9/8/1995 Heikki Tuuri
/* Maximum number of threads which can be created in the program;
this is also the size of the wait slot array for MySQL threads which
can wait inside InnoDB */
#ifdef __WIN__
#if defined(__WIN__) || defined(__NETWARE__)
/* Create less event semaphores because Win 98/ME had difficult creating
40000 event semaphores */
/* TODO: these just take a lot of memory on NetWare. should netware move up? */
#define OS_THREAD_MAX_N 1000
#else
#define OS_THREAD_MAX_N 10000

View File

@ -495,6 +495,8 @@ os_fast_mutex_free(
ut_a(fast_mutex);
DeleteCriticalSection((LPCRITICAL_SECTION) fast_mutex);
#elif defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
pthread_mutex_destroy(fast_mutex);
#else
UT_NOT_USED(fast_mutex);

View File

@ -214,6 +214,8 @@ os_thread_sleep(
{
#ifdef __WIN__
Sleep(tm / 1000);
#elif defined(__NETWARE__)
delay(tm / 1000);
#else
struct timeval t;

View File

@ -1700,8 +1700,63 @@ srv_general_init(void)
thr_local_init();
}
#if defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
/* NetWare requires some cleanup of mutexes */
/*************************************************************************
Deinitializes the synchronization primitives, memory system, and the thread
local storage. */
void
srv_general_free(void)
/*==================*/
{
sync_close();
}
#endif /* __NETWARE__ */
/*======================= InnoDB Server FIFO queue =======================*/
#if defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
/* NetWare requires some cleanup of mutexes */
/*************************************************************************
Deinitializes the server. */
void
srv_free(void)
/*==========*/
{
srv_conc_slot_t* conc_slot;
srv_slot_t* slot;
ulint i;
for (i = 0; i < OS_THREAD_MAX_N; i++)
{
slot = srv_table_get_nth_slot(i);
os_event_free(slot->event);
}
/* TODO: free(srv_sys->threads); */
for (i = 0; i < OS_THREAD_MAX_N; i++)
{
slot = srv_mysql_table + i;
os_event_free(slot->event);
}
/* TODO: free(srv_mysql_table); */
for (i = 0; i < OS_THREAD_MAX_N; i++)
{
conc_slot = srv_conc_slots + i;
os_event_free(conc_slot->event);
}
}
#endif /* __NETWARE__ */
/*************************************************************************
Puts an OS thread to wait if there are too many concurrent threads
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */

View File

@ -1415,6 +1415,10 @@ innobase_start_or_create_for_mysql(void)
os_fast_mutex_unlock(&srv_os_test_mutex);
#if defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
os_fast_mutex_free(&srv_os_test_mutex); /* all platforms? */
#endif /* __NETWARE__ */
if (srv_print_verbose_log) {
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Started\n");
@ -1461,12 +1465,28 @@ innobase_shutdown_for_mysql(void)
srv_conc_n_threads);
}
#if defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
/*
TODO: Fix this temporary solution
We are having a race condition occure with io_handler_thread threads.
When they yield in os_aio_simulated_handle during shutdown, this
thread was able to free the memory early.
*/
os_thread_yield();
/* TODO: Where should this be called? */
srv_free();
/* TODO: Where should this be called? */
srv_general_free();
#endif
/*
TODO: We should exit the i/o-handler and other utility threads
before freeing all memory. Now this can potentially cause a seg
fault!
*/
#ifdef NOT_WORKING_YET
#if defined(NOT_WORKING_YET) || defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
/* NetWare requires this free */
ut_free_all_mem();
#endif

View File

@ -220,7 +220,7 @@ mutex_create_func(
char* cfile_name, /* in: file name where created */
ulint cline) /* in: file line where created */
{
#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER)
#if defined(_WIN32) && defined(UNIV_CAN_USE_X86_ASSEMBLER) && !defined(__NETWARE)
mutex_reset_lock_word(mutex);
#else
os_fast_mutex_init(&(mutex->os_fast_mutex));

View File

@ -16,6 +16,8 @@
/* Test av locking */
#ifndef __NETWARE__
#include "nisam.h"
#include <sys/types.h>
#ifdef HAVE_SYS_WAIT_H
@ -477,3 +479,15 @@ int test_update(N_INFO *file,int id,int lock_type)
printf("%2d: update: %5d\n",id,update); fflush(stdout);
return 0;
}
#else /* __NETWARE__ */
#include <stdio.h>
main()
{
fprintf(stderr,"this test has not been ported to NetWare\n");
return 0;
}
#endif /* __NETWARE__ */

View File

@ -58,7 +58,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
thr_mutex.lo mulalloc.lo string.lo default.lo \
my_compress.lo array.lo my_once.lo list.lo my_net.lo \
charset.lo hash.lo mf_iocache.lo \
mf_iocache2.lo my_seek.lo \
mf_iocache2.lo my_seek.lo my_sleep.lo \
my_pread.lo mf_cache.lo my_vsnprintf.lo md5.lo \
my_getopt.lo my_gethostbyname.lo my_port.lo
sqlobjects = net.lo

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB
/* Copyright (C) 2000-2003 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
@ -34,7 +34,7 @@
#include <pwd.h>
#endif /* HAVE_PWD_H */
#else /* ! HAVE_GETPASS */
#if !defined( __WIN__) && !defined(OS2)
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
#include <sys/ioctl.h>
#ifdef HAVE_TERMIOS_H /* For tty-password */
#include <termios.h>
@ -53,7 +53,9 @@
#include <asm/termiobits.h>
#endif
#else
#ifndef __NETWARE__
#include <conio.h>
#endif /* __NETWARE__ */
#endif /* __WIN__ */
#endif /* HAVE_GETPASS */
@ -61,9 +63,16 @@
#define getpass(A) getpassphrase(A)
#endif
#if defined( __WIN__) || defined(OS2)
#if defined( __WIN__) || defined(OS2) || defined(__NETWARE__)
/* were just going to fake it here and get input from the keyboard */
#ifdef __NETWARE__
#undef _getch
#undef _cputs
#define _getch getcharacter
#define _cputs(A) putstring(A)
#endif
char *get_tty_password(char *opt_message)
{
char to[80];
@ -100,12 +109,11 @@ char *get_tty_password(char *opt_message)
#else
#ifndef HAVE_GETPASS
/*
** Can't use fgets, because readline will get confused
** length is max number of chars in to, not counting \0
* to will not include the eol characters.
Can't use fgets, because readline will get confused
length is max number of chars in to, not counting \0
to will not include the eol characters.
*/
static void get_password(char *to,uint length,int fd,bool echo)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB
/* Copyright (C) 2000-2003 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
@ -73,14 +73,13 @@ ulong net_write_timeout= NET_WRITE_TIMEOUT;
#endif
#if defined(MSDOS) || defined(__WIN__)
// socket_errno is defined in my_global.h for all platforms
/* socket_errno is defined in my_global.h for all platforms */
#define perror(A)
#else
#include <errno.h>
#define SOCKET_ERROR -1
#endif /* __WIN__ */
static void mysql_once_init(void);
static MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields,
uint field_count);
static int read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row,
@ -100,6 +99,7 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)),
char **argv __attribute__((unused)),
char **groups __attribute__((unused)))
{
mysql_once_init();
return 0;
}
@ -108,6 +108,8 @@ void STDCALL mysql_server_end()
/* If library called my_init(), free memory allocated by it */
if (!org_my_init_done)
my_end(0);
else
mysql_thread_end();
}
my_bool STDCALL mysql_thread_init()
@ -159,7 +161,7 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host,
int my_connect(my_socket s, const struct sockaddr *name, uint namelen,
uint timeout)
{
#if defined(__WIN__) || defined(OS2)
#if defined(__WIN__) || defined(OS2) || defined(__NETWARE__)
return connect(s, (struct sockaddr*) name, namelen);
#else
int flags, res, s_err;
@ -528,7 +530,16 @@ struct passwd *getpwuid(uid_t);
char* getlogin(void);
#endif
#if !defined(MSDOS) && ! defined(VMS) && !defined(__WIN__) && !defined(OS2)
#if defined(__NETWARE__)
/* default to "root" on NetWare */
static void read_user_name(char *name)
{
(void)strmake(name,"root", USERNAME_LENGTH);
}
#elif !defined(MSDOS) && ! defined(VMS) && !defined(__WIN__) && !defined(OS2)
static void read_user_name(char *name)
{
DBUG_ENTER("read_user_name");
@ -1402,7 +1413,20 @@ mysql_init(MYSQL *mysql)
}
static void mysql_once_init()
/*
Initialize the MySQL library
SYNOPSIS
mysql_once_init()
NOTES
Can't be static on NetWare
This function is called by mysql_init() and indirectly called
by mysql_query(), so one should never have to call this from an
outside program.
*/
void STDCALL mysql_once_init(void)
{
if (!mysql_client_init)
{

View File

@ -34,6 +34,10 @@
#if defined(OS2)
# include <sys/un.h>
#elif defined(__NETWARE__)
#include <netdb.h>
#include <sys/select.h>
#include <sys/utsname.h>
#elif !defined( __WIN__)
#include <sys/resource.h>
#ifdef HAVE_SYS_UN_H

View File

@ -16,6 +16,8 @@
/* Test av locking */
#ifndef __NETWARE__
#include "myisam.h"
#include <sys/types.h>
#ifdef HAVE_SYS_WAIT_H
@ -483,3 +485,15 @@ int test_update(MI_INFO *file,int id,int lock_type)
printf("%2d: update: %5d\n",id,update); fflush(stdout);
return 0;
}
#else /* __NETWARE__ */
#include <stdio.h>
main()
{
fprintf(stderr,"this test has not been ported to NetWare\n");
return 0;
}
#endif /* __NETWARE__ */

View File

@ -0,0 +1,4 @@
-- require r/have_crypt.require
disable_query_log;
show variables like "have_crypt";
enable_query_log;

View File

@ -106,6 +106,7 @@ TAIL=tail
ECHO=echo # use internal echo if possible
EXPR=expr # use internal if possible
FIND=find
GREP=grep
if test $? != 0; then exit 1; fi
PRINTF=printf
RM=rm
@ -605,6 +606,30 @@ report_stats () {
$ECHO "If you want to report this error, please read first the documentation at"
$ECHO "http://www.mysql.com/doc/M/y/MySQL_test_suite.html"
fi
#
# Report if there was any fatal warnings/errors in the log files
#
$RM -f $MY_LOG_DIR/warnings $MY_LOG_DIR/warnings.tmp
# Remove some non fatal warnings from the log files
$SED -e 's!Warning: Table:.* on delete!!g' \
$MY_LOG_DIR/*.err > $MY_LOG_DIR/warnings.tmp
found_error=0
# Find errors
for i in "^Warning:" "^Error:" "^==.* at 0x"
do
if `$GREP "$i" $MY_LOG_DIR/warnings.tmp >> $MY_LOG_DIR/warnings`
then
found_error=1
fi
done
$RM -f $MY_LOG_DIR/warnings.tmp
if [ $found_error = "1" ]
then
echo "WARNING: Got errors/warnings while running tests. Please examine"
echo "$MY_LOG_DIR/warnings for details."
fi
}
mysql_install_db () {

View File

@ -36,6 +36,10 @@ select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join
isbn city libname a
007 Berkeley Berkeley Public1 2
000 New York New York Public Libra 2
select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct concat(t1.libname,'a')) > 1;
isbn city libname a
007 Berkeley Berkeley Public1 2
000 New York New York Public Libra 2
drop table t1, t2, t3;
create table t1 (f1 int);
insert into t1 values (1);

View File

@ -32,6 +32,11 @@ userid MIN(t1.score)
1 1
2 2
3 3
SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid ORDER BY NULL;
userid MIN(t1.score)
1 1
2 2
3 3
SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid;
userid MIN(t1.score)
1 1
@ -40,6 +45,10 @@ SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1
userid MIN(t1.score+0.0)
1 1.0
2 2.0
SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
userid MIN(t1.score+0.0)
1 1.0
2 2.0
drop table test.t1,test.t2;
CREATE TABLE t1 (
PID int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
@ -86,6 +95,8 @@ INSERT INTO t2 VALUES (91,2);
INSERT INTO t2 VALUES (92,2);
SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid;
cid CONCAT(firstname, ' ', surname) COUNT(call_id)
SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY NULL;
cid CONCAT(firstname, ' ', surname) COUNT(call_id)
SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname;
cid CONCAT(firstname, ' ', surname) COUNT(call_id)
drop table t1,t2;
@ -235,6 +246,9 @@ INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3);
explain select userid,count(*) from t1 group by userid desc;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
explain select userid,count(*) from t1 group by userid desc order by null;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 6 Using temporary
select userid,count(*) from t1 group by userid desc;
userid count(*)
3 3
@ -253,6 +267,9 @@ t1 range spID spID 5 NULL 2 Using where; Using index
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid;
table type possible_keys key key_len ref rows Extra
t1 range spID spID 5 NULL 2 Using where; Using index
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null;
table type possible_keys key key_len ref rows Extra
t1 range spID spID 5 NULL 2 Using where; Using index
select spid,count(*) from t1 where spid between 1 and 2 group by spid;
spid count(*)
1 1
@ -264,6 +281,9 @@ spid count(*)
explain select sql_big_result spid,sum(userid) from t1 group by spid desc;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 6 Using filesort
explain select sql_big_result spid,sum(userid) from t1 group by spid desc order by null;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 6
select sql_big_result spid,sum(userid) from t1 group by spid desc;
spid sum(userid)
5 3
@ -274,6 +294,9 @@ spid sum(userid)
explain select sql_big_result score,count(*) from t1 group by score desc;
table type possible_keys key key_len ref rows Extra
t1 index NULL score 3 NULL 6 Using index
explain select sql_big_result score,count(*) from t1 group by score desc order by null;
table type possible_keys key key_len ref rows Extra
t1 index NULL score 3 NULL 6 Using index
select sql_big_result score,count(*) from t1 group by score desc;
score count(*)
3 3
@ -481,3 +504,28 @@ NULL 9
3
b 1
drop table t1;
create table t1 (a int not null, b int not null);
insert into t1 values (1,1),(1,2),(3,1),(3,2),(2,2),(2,1);
create table t2 (a int not null, b int not null, key(a));
insert into t2 values (1,3),(3,1),(2,2),(1,1);
select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
a b
1 1
1 3
2 2
3 1
select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
a b
1 3
3 1
2 2
1 1
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
t2 ALL a NULL NULL NULL 4 Using where
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 6 Using temporary
t2 ALL a NULL NULL NULL 4 Using where
drop table t1,t2;

View File

@ -0,0 +1,2 @@
Variable_name Value
have_crypt YES

View File

@ -4,7 +4,7 @@ connection con1;
set SQL_LOG_BIN=0;
drop table if exists t1;
create table t1(n int);
--replace_result "errno = 2" "errno = X" "errno = 22" "errno = X" "errno = 23" "errno = X"
--replace_result "errno = 1" "errno = X" "errno = 2" "errno = X" "errno = 22" "errno = X" "errno = 23" "errno = X"
backup table t1 to '../bogus';
backup table t1 to '../tmp';
drop table t1;

View File

@ -31,6 +31,7 @@ insert into t1 values ('Berkeley Public2','Berkeley');
insert into t1 values ('NYC Lib','New York');
select t2.isbn,city,t1.libname,count(t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city,t1.libname;
select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct t1.libname) > 1;
select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct concat(t1.libname,'a')) > 1;
drop table t1, t2, t3;
#

View File

@ -1,3 +1,5 @@
-- source include/have_crypt.inc
select length(encrypt('foo', 'ff')) <> 0;
--replace_result $1$aa$4OSUA5cjdx0RUQ08opV27/ aaqPiZY5xR5l.
select password('test'),length(encrypt('test')),encrypt('test','aa');

View File

@ -6,7 +6,7 @@
drop table if exists test.t1,mysqltest.t1,mysqltest.t2;
reset query cache;
flush status;
connect (root,localhost,root,,test,0,master.sock);
connect (root,localhost,root,,test,$MASTER_MYPORT,master.sock);
connection root;
create database if not exists mysqltest;
@ -17,7 +17,7 @@ insert into mysqltest.t2 values (3,3,3);
create table test.t1 (a char (10));
insert into test.t1 values ("test.t1");
select * from t1;
connect (root2,localhost,root,,mysqltest,0,master.sock);
connect (root2,localhost,root,,mysqltest,$MASTER_MYPORT,master.sock);
connection root2;
# put queries in cache
select * from t1;
@ -35,7 +35,7 @@ grant SELECT on test.t1 to mysqltest_2@localhost;
grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
# The following queries should be fetched from cache
connect (user1,localhost,mysqltest_1,,mysqltest,0,master.sock);
connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,master.sock);
connection user1;
select "user1";
select * from t1;
@ -47,13 +47,14 @@ show status like "Qcache_hits";
show status like "Qcache_not_cached";
# The following queries should be fetched from cache
connect (user2,localhost,mysqltest_2,,mysqltest,0,master.sock);
connect (user2,localhost,mysqltest_2,,mysqltest,$MASTER_MYPORT,master.sock);
connection user2;
select "user2";
select * from t1;
select a from t1;
select c from t1;
select * from mysqltest.t1,test.t1;
--replace_result 127.0.0.1 localhost
--error 1142
select * from t2;
show status like "Qcache_queries_in_cache";
@ -61,16 +62,20 @@ show status like "Qcache_hits";
show status like "Qcache_not_cached";
# The following queries should not be fetched from cache
connect (user3,localhost,mysqltest_3,,mysqltest,0,master.sock);
connect (user3,localhost,mysqltest_3,,mysqltest,$MASTER_MYPORT,master.sock);
connection user3;
select "user3";
--replace_result 127.0.0.1 localhost
--error 1143
select * from t1;
select a from t1;
--replace_result 127.0.0.1 localhost
--error 1143
select c from t1;
--replace_result 127.0.0.1 localhost
--error 1142
select * from t2;
--replace_result 127.0.0.1 localhost
--error 1143
select mysqltest.t1.c from test.t1,mysqltest.t1;
show status like "Qcache_queries_in_cache";
@ -78,7 +83,7 @@ show status like "Qcache_hits";
show status like "Qcache_not_cached";
# Connect without a database
connect (user4,localhost,mysqltest_1,,*NO-ONE*,0,master.sock);
connect (user4,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,master.sock);
connection user4;
select "user4";
--error 1046

View File

@ -36,8 +36,10 @@ INSERT INTO t2 VALUES (2,'name','pass','mail','Y','v','n','adr','1','1','1');
INSERT INTO t2 VALUES (3,'name','pass','mail','Y','v','n','adr','1','1','1');
SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid;
SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid ORDER BY NULL;
SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid;
SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid;
SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
drop table test.t1,test.t2;
#
@ -100,6 +102,7 @@ INSERT INTO t2 VALUES (91,2);
INSERT INTO t2 VALUES (92,2);
SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid;
SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY NULL;
SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname;
drop table t1,t2;
@ -234,16 +237,20 @@ CREATE TABLE t1 (
INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3);
explain select userid,count(*) from t1 group by userid desc;
explain select userid,count(*) from t1 group by userid desc order by null;
select userid,count(*) from t1 group by userid desc;
select userid,count(*) from t1 group by userid desc having (count(*)+1) IN (4,3);
select userid,count(*) from t1 group by userid desc having 3 IN (1,COUNT(*));
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid;
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null;
select spid,count(*) from t1 where spid between 1 and 2 group by spid;
select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
explain select sql_big_result spid,sum(userid) from t1 group by spid desc;
explain select sql_big_result spid,sum(userid) from t1 group by spid desc order by null;
select sql_big_result spid,sum(userid) from t1 group by spid desc;
explain select sql_big_result score,count(*) from t1 group by score desc;
explain select sql_big_result score,count(*) from t1 group by score desc order by null;
select sql_big_result score,count(*) from t1 group by score desc;
drop table t1;
@ -365,3 +372,17 @@ select a,count(*) from t1 group by a;
set option sql_big_tables=1;
select a,count(*) from t1 group by a;
drop table t1;
#
# Test of GROUP BY ... ORDER BY NULL optimization
#
create table t1 (a int not null, b int not null);
insert into t1 values (1,1),(1,2),(3,1),(3,2),(2,2),(2,1);
create table t2 (a int not null, b int not null, key(a));
insert into t2 values (1,3),(3,1),(2,2),(1,1);
select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
drop table t1,t2;

View File

@ -1,5 +1,5 @@
connect (master,localhost,root,,test,0,master.sock);
connect (slave,localhost,root,,test,0, slave.sock);
connect (master,localhost,root,,test,$MASTER_MYPORT,master.sock);
connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock);
connection master;
reset master;
show master status;

View File

@ -1,5 +1,5 @@
connect (master,localhost,root,,test,0,master.sock);
connect (slave,localhost,root,,test,0,slave.sock);
connect (master,localhost,root,,test,$MASTER_MYPORT,master.sock);
connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock);
connection master;
reset master;
grant replication slave on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab';

View File

@ -9,9 +9,9 @@
# changes
# - Test creating a duplicate key error and recover from it
#
connect (master,localhost,root,,test,0,master.sock);
connect (master,localhost,root,,test,$MASTER_MYPORT,master.sock);
drop table if exists t1, t2, t3, t4;
connect (slave,localhost,root,,test,0,slave.sock);
connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock);
system cat /dev/null > var/slave-data/master.info;
system chmod 000 var/slave-data/master.info;
connection slave;

View File

@ -49,9 +49,10 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
my_quick.c my_lockmem.c my_static.c \
my_getopt.c my_mkdir.c \
default.c my_compress.c checksum.c raid.cc \
my_net.c my_semaphore.c my_port.c \
my_net.c my_semaphore.c my_port.c my_sleep.c \
my_vsnprintf.c charset.c my_bitmap.c my_bit.c md5.c \
my_gethostbyname.c rijndael.c my_aes.c sha1.c
my_gethostbyname.c rijndael.c my_aes.c sha1.c \
my_netware.c
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c
libmysys_a_LIBADD = @THREAD_LOBJECTS@
@ -77,32 +78,32 @@ FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
# which automaticly removes the object files you use to compile a final program
#
test_thr_alarm: thr_alarm.c $(LIBRARIES)
test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES)
$(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c
$(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS)
$(RM) -f ./test_thr_alarm.*
$(RM) -f ./test_thr_alarm.c
test_thr_lock: thr_lock.c $(LIBRARIES)
test_thr_lock$(EXEEXT): thr_lock.c $(LIBRARIES)
$(CP) $(srcdir)/thr_lock.c test_thr_lock.c
$(LINK) $(FLAGS) -DMAIN ./test_thr_lock.c $(LDADD) $(LIBS)
$(RM) -f ./test_thr_lock.*
$(RM) -f ./test_thr_lock.c
test_vsnprintf: my_vsnprintf.c $(LIBRARIES)
test_vsnprintf$(EXEEXT): my_vsnprintf.c $(LIBRARIES)
$(CP) $(srcdir)/my_vsnprintf.c test_vsnprintf.c
$(LINK) $(FLAGS) -DMAIN ./test_vsnprintf.c $(LDADD) $(LIBS)
$(RM) -f test_vsnprintf.*
test_io_cache: mf_iocache.c $(LIBRARIES)
$(RM) -f test_vsnprintf.c
test_io_cache$(EXEEXT): mf_iocache.c $(LIBRARIES)
$(CP) $(srcdir)/mf_iocache.c test_io_cache.c
$(LINK) $(FLAGS) -DMAIN ./test_io_cache.c $(LDADD) $(LIBS)
$(RM) -f test_io_cache.*
$(RM) -f test_io_cache.c
test_dir: test_dir.c $(LIBRARIES)
test_dir$(EXEEXT): test_dir.c $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN $(srcdir)/test_dir.c $(LDADD) $(LIBS)
test_charset$(EXEEXT): test_charset.c $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN $(srcdir)/test_charset.c $(LDADD) $(LIBS)
testhash: testhash.c $(LIBRARIES)
testhash$(EXEEXT): testhash.c $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN $(srcdir)/testhash.c $(LDADD) $(LIBS)
# Don't update the files from bitkeeper

View File

@ -164,7 +164,11 @@ static my_bool read_charset_index(CS_ID ***charsets, myf myflags)
}
#ifdef __NETWARE__
my_bool STDCALL init_available_charsets(myf myflags)
#else
static my_bool init_available_charsets(myf myflags)
#endif
{
my_bool error=0;
/*

View File

@ -46,6 +46,8 @@ char *defaults_extra_file=0;
const char *default_directories[]= {
#ifdef __WIN__
"C:/",
#elif defined(__NETWARE__)
"sys:/etc/",
#else
"/etc/",
#endif
@ -53,7 +55,7 @@ const char *default_directories[]= {
DATADIR,
#endif
"", /* Place for defaults_extra_dir */
#ifndef __WIN__
#if !defined(__WIN__) && !defined(__NETWARE__)
"~/",
#endif
NullS,

View File

@ -24,7 +24,7 @@
#endif
#ifdef HAVE_TEMPNAM
#if !defined( MSDOS) && !defined(OS2)
#if !defined(MSDOS) && !defined(OS2) && !defined(__NETWARE__)
extern char **environ;
#endif
#endif
@ -129,7 +129,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
if (buffer[strlen(buffer)-1] == '\\')
buffer[strlen(buffer)-1] = '\0';
putenv( buffer);
#else
#elif !defined(__NETWARE__)
old_env= (char**) environ;
if (dir)
{ /* Don't use TMPDIR if dir is given */
@ -151,7 +151,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
{
DBUG_PRINT("error",("Got error: %d from tempnam",errno));
}
#ifndef OS2
#if !defined(OS2) && !defined(__NETWARE__)
environ=(const char**) old_env;
#endif
}

View File

@ -17,14 +17,14 @@
#define USES_TYPES
#include "my_global.h"
#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(OS2)
#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(OS2) && !defined(__NETWARE__)
#include "mysys_priv.h"
#include <sys/times.h>
#endif
long my_clock(void)
{
#if !defined(MSDOS) && !defined(__WIN__) && !defined(OS2)
#if !defined(MSDOS) && !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
struct tms tmsbuf;
VOID(times(&tmsbuf));
return (tmsbuf.tms_utime + tmsbuf.tms_stime);

View File

@ -80,7 +80,7 @@ int my_copy(const char *from, const char *to, myf MyFlags)
if (MyFlags & MY_HOLD_ORIGINAL_MODES && new_file_stat)
DBUG_RETURN(0); /* File copyed but not stat */
VOID(chmod(to, stat_buff.st_mode & 07777)); /* Copy modes */
#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) && !defined(__NETWARE__)
VOID(chown(to, stat_buff.st_uid,stat_buff.st_gid)); /* Copy ownership */
#endif
#if !defined(VMS) && !defined(__ZTC__)

View File

@ -32,7 +32,7 @@
#endif
#ifdef __EMX__
// chdir2 support also drive change
/* chdir2 support also drive change */
#define chdir _chdir2
#endif

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB
/* Copyright (C) 2000-2003 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
@ -41,6 +41,12 @@ static my_bool win32_init_tcp_ip();
#else
#define my_win_init()
#endif
#ifdef __NETWARE__
static void netware_init();
#else
#define netware_init()
#endif
my_bool my_init_done=0;
@ -64,12 +70,16 @@ void my_init(void)
if (my_init_done)
return;
my_init_done=1;
#if defined(THREAD) && defined(SAFE_MUTEX)
safe_mutex_global_init(); /* Must be called early */
#endif
netware_init();
#ifdef THREAD
#if defined(HAVE_PTHREAD_INIT)
pthread_init(); /* Must be called before DBUG_ENTER */
#endif
my_thread_global_init();
#if !defined( __WIN__) && !defined(OS2)
#if !defined( __WIN__) && !defined(OS2) && !defined(__NETWARE__)
sigfillset(&my_signals); /* signals blocked by mf_brkhant */
#endif
#endif /* THREAD */
@ -143,7 +153,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
rus.ru_msgsnd, rus.ru_msgrcv, rus.ru_nsignals,
rus.ru_nvcsw, rus.ru_nivcsw);
#endif
#if defined(MSDOS) && !defined(__WIN__)
#if ( defined(MSDOS) || defined(__NETWARE__) ) && !defined(__WIN__)
fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC);
#endif
#if defined(SAFEMALLOC)
@ -160,21 +170,27 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
#endif
}
#ifdef THREAD
pthread_mutex_destroy(&THR_LOCK_keycache);
pthread_mutex_destroy(&THR_LOCK_malloc);
pthread_mutex_destroy(&THR_LOCK_open);
DBUG_POP(); /* Must be done before my_thread_end */
my_once_free();
my_thread_end();
my_thread_global_end();
#endif
#if defined(SAFE_MUTEX)
/*
Check on destroying of mutexes. A few may be left that will get cleaned
up by C++ destructors
*/
safe_mutex_end(infoflag & MY_GIVE_INFO ? stderr : (FILE *) 0);
#endif /* defined(SAFE_MUTEX) */
#endif /* THREAD */
#ifdef __WIN__
if (have_tcpip);
WSACleanup( );
if (have_tcpip)
WSACleanup();
#endif /* __WIN__ */
my_init_done=0;
my_init_done=0;
} /* my_end */
#ifdef __WIN__
/*
@ -263,10 +279,10 @@ static void my_win_init(void)
/*------------------------------------------------------------------
** Name: CheckForTcpip| Desc: checks if tcpip has been installed on system
** According to Microsoft Developers documentation the first registry
** entry should be enough to check if TCP/IP is installed, but as expected
** this doesn't work on all Win32 machines :(
Name: CheckForTcpip| Desc: checks if tcpip has been installed on system
According to Microsoft Developers documentation the first registry
entry should be enough to check if TCP/IP is installed, but as expected
this doesn't work on all Win32 machines :(
------------------------------------------------------------------*/
#define TCPIPKEY "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"
@ -292,6 +308,7 @@ static my_bool win32_have_tcpip(void)
return (TRUE);
}
static my_bool win32_init_tcp_ip()
{
if (win32_have_tcpip())
@ -323,4 +340,64 @@ static my_bool win32_init_tcp_ip()
}
return(0);
}
#endif
#endif /* __WIN__ */
#ifdef __NETWARE__
/****************************************************************************
Do basic initialisation for netware needed by most programs
****************************************************************************/
static void netware_init()
{
char cwd[PATH_MAX], *name
/* init only if we are not a client library */
if (my_progname)
{
#if SUPPORTED_BY_LIBC /* Removed until supported in Libc */
struct termios tp;
/* Disable control characters */
tcgetattr(STDIN_FILENO, &tp);
tp.c_cc[VINTR] = _POSIX_VDISABLE;
tp.c_cc[VEOF] = _POSIX_VDISABLE;
tp.c_cc[VSUSP] = _POSIX_VDISABLE;
tcsetattr(STDIN_FILENO, TCSANOW, &tp);
#endif /* SUPPORTED_BY_LIBC */
/* With stdout redirection */
if (!isatty(STDOUT_FILENO))
{
setscreenmode(SCR_AUTOCLOSE_ON_EXIT); /* auto close the screen */
}
else
{
setscreenmode(SCR_NO_MODE); /* keep the screen up */
}
/* Parse program name and change to base format */
name= my_progname;
for (; *name; name++)
{
if (*name == '\\')
{
*name = '/';
}
else
{
*name = tolower(*name);
}
}
/*
Set the current working directory to the base directory of the file
name (assuming the binary is in 'base-file-name/bin/'
*/
strmov(cwd, my_progname);
if ((name= strindex(cwd, "/bin/")) != NULL)
{
*name= 0;
chdir(cwd);
}
}
}
#endif /* __NETWARE__ */

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB
/* Copyright (C) 2000-2003 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
@ -30,6 +30,9 @@
#define INCL_BASE
#define INCL_NOPMAPI
#include <os2emx.h>
#endif
#ifdef __NETWARE__
#include <nks/fsio.h>
#endif
/* Lock a part of a file */
@ -40,6 +43,9 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
#ifdef HAVE_FCNTL
int value;
ALARM_VARIABLES;
#endif
#ifdef __NETWARE__
int nxErrno;
#endif
DBUG_ENTER("my_lock");
DBUG_PRINT("my",("Fd: %d Op: %d start: %ld Length: %ld MyFlags: %d",
@ -50,7 +56,47 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
if (my_disable_locking)
DBUG_RETURN(0);
#if defined(__EMX__) || defined(OS2)
#if defined(__NETWARE__)
{
NXSOffset_t nxLength = length;
unsigned long nxLockFlags = 0;
if (length == F_TO_EOF)
{
/* EOF is interpreted as a very large length. */
nxLength = 0x7FFFFFFFFFFFFFFF;
}
if (locktype == F_UNLCK)
{
/* The lock flags are currently ignored by NKS. */
if (!(nxErrno= NXFileRangeUnlock(fd, 0L, start, nxLength)))
DBUG_RETURN(0);
}
else
{
if (locktype == F_RDLCK)
{
/* A read lock is mapped to a shared lock. */
nxLockFlags = NX_RANGE_LOCK_SHARED;
}
else
{
/* A write lock is mapped to an exclusive lock. */
nxLockFlags = NX_RANGE_LOCK_EXCL;
}
if (MyFlags & MY_DONT_WAIT)
{
/* Don't block on the lock. */
nxLockFlags |= NX_RANGE_LOCK_TRYLOCK;
}
if (!(nxErrno= NXFileRangeLock(fd, nxLockFlags, start, nxLength)))
DBUG_RETURN(0);
}
}
#elif defined(__EMX__) || defined(OS2)
if (!_lock64( fd, locktype, start, length, MyFlags))
DBUG_RETURN(0);
@ -103,8 +149,12 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
#endif /* HAVE_FCNTL */
#endif /* HAVE_LOCKING */
#ifdef __NETWARE__
my_errno = nxErrno;
#else
/* We got an error. We don't want EACCES errors */
my_errno=(errno == EACCES) ? EAGAIN : errno ? errno : -1;
#endif
if (MyFlags & MY_WME)
{
if (locktype == F_UNLCK)

View File

@ -23,7 +23,11 @@ int my_message_no_curses(uint error __attribute__((unused)),
DBUG_PRINT("enter",("message: %s",str));
(void) fflush(stdout);
if (MyFlags & ME_BELL)
#ifdef __NETWARE__
ringbell(); /* Bell */
#else
(void) fputc('\007',stderr); /* Bell */
#endif /* __NETWARE__ */
if (my_progname)
{
(void)fputs(my_progname,stderr); (void)fputs(": ",stderr);

150
mysys/my_netware.c Normal file
View File

@ -0,0 +1,150 @@
/* Copyright (C) 2003 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; either version 2 of the License, or
(at your option) any later version.
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 */
/*
Function specific to netware
*/
#include <mysys_priv.h>
#ifdef __NETWARE__
#include <library.h>
/*
PMUserLicenseRequest is an API exported by the polimgr.nlm
(loaded by the NetWare OS when it comes up) for use by other
NLM-based NetWare products/services.
PMUserLicenseRequest provides a couple of functions:
1) it will optionally request a User license or ensure that
one already exists for the specified User in userInfo
2) it utilizes the NetWare usage metering service to
record usage information about your product/service.
*/
long PMMeteredUsageRequest
(
/*
NDS distinguished name or IP address or ??. asciiz string, e.g.
".CN=Admin.O=this.T=MYTREE."
*/
char *userInfo,
long infoType, /* see defined values */
/*
string used to identify the calling service, used to index the
metered info e.g. "iPrint"
*/
char *serviceID,
char tranAddrType, /* type of address that follows */
char *tranAddr, /* ptr to a 10-byte array */
long flags, /* see defined values */
/* NLS error code, if any. NULL input is okay */
long *licRequestErrCode,
/* meter service error code, if any. NULL input is okay */
long *storeMeterInfoErrCode,
/*
error code from NLSMeter if
storeMeterInfoErrCode == PM_LICREQ_NLSMETERERROR.
NULL input is okay
*/
long *NLSMeterErrCode
);
ypedef long(*PMUR)(char*, long, char*, char, char*, long, long*, long*,
long*);
/* infoType */
/* indicates that the info in the userInfo param is an NDS user */
#define PM_USERINFO_TYPE_NDS 1
/* indicates that the info in the userInfo param is NOT an NDS user */
#define PM_USERINFO_TYPE_ADDRESS 2
/* Flags */
/*
Tells the service that it should not check to see if the NDS user
contained in the userInfo param has a NetWare User License - just
record metering information; this is ignored if infoType !=
PM_USERINFO_TYPE_NDS
*/
#define PM_FLAGS_METER_ONLY 0x0000001
/*
Indicates that the values in the userInfo and serviceID parameters
are unicode strings, so that the metering service bypasses
converting these to unicode (again)
*/
#define PM_LICREQ_ALREADY_UNICODE 0x0000002
/*
Useful only if infoType is PM_USERINFO_TYPE_NDS - indicates a "no
stop" policy of the calling service
*/
#define PM_LICREQ_ALWAYS_METER 0x0000004
/*
net Address Types - system-defined types of net addresses that can
be used in the tranAddrType field
*/
#define NLS_TRAN_TYPE_IPX 0x00000001 /* An IPX address */
#define NLS_TRAN_TYPE_IP 0x00000008 /* An IP address */
#define NLS_ADDR_TYPE_MAC 0x000000F1 /* a MAC address */
/*
Net Address Sizes - lengths that correspond to the tranAddrType
field (just fyi)
*/
#define NLS_IPX_ADDR_SIZE 10 /* the size of an IPX address */
#define NLS_IP_ADDR_SIZE 4 /* the size of an IP address */
#define NLS_MAC_ADDR_SIZE 6 /* the size of a MAC address */
void netware_reg_user(const char *ip, const char *user,
const char *application)
{
PMUR usage_request;
long licRequestErrCode = 0;
long storeMeterInfoErrCode = 0;
long nlsMeterErrCode = 0;
/* import the symbol */
usage_request= ((PMUR)ImportPublicObject(getnlmhandle(),
"PMMeteredUsageRequest"));
if (usage_request != NULL)
{
unsigned long iaddr;
char addr[NLS_IPX_ADDR_SIZE];
/* create address */
iaddr = htonl(inet_addr(ip));
bzero(addr, NLS_IPX_ADDR_SIZE);
memcpy(addr, &iaddr, NLS_IP_ADDR_SIZE);
/* call to NLS */
usage_request(user,
PM_USERINFO_TYPE_ADDRESS,
application,
NLS_TRAN_TYPE_IP,
addr,
PM_FLAGS_METER_ONLY,
&licRequestErrCode,
&storeMeterInfoErrCode,
&nlsMeterErrCode);
/* release symbol */
UnImportPublicObject(getnlmhandle(), "PMMeteredUsageRequest");
}
}
#endif /* __NETWARE__ */

View File

@ -26,7 +26,6 @@
#include "mysys_priv.h"
#if defined(THREAD) && defined(OS2)
#include <m_string.h>
//#undef getpid
#include <process.h>
#include <sys/timeb.h>

View File

@ -1,4 +1,4 @@
/* Copyright (C) Yuri Dario & 2000 MySQL AB
/* Copyright (C) Yuri Dario & 2000-2003 MySQL AB
All the above parties has a full, independent copyright to
the following code, including the right to use the code in
any manner without any demands from the other parties.
@ -18,77 +18,79 @@
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
/* Win32 directory search emulation */
#if defined(OS2)
//#define _DEBUG
long _findfirst( char* path, struct _finddata_t* dos_file)
{
HDIR hdir = HDIR_CREATE;
APIRET rc;
FILEFINDBUF3 buf3;
ULONG entries = 1;
HDIR hdir = HDIR_CREATE;
APIRET rc;
FILEFINDBUF3 buf3;
ULONG entries = 1;
#ifdef _DEBUG
printf( "_findfirst path %s\n", path);
printf( "_findfirst path %s\n", path);
#endif
memset( &buf3, 0, sizeof( buf3));
rc = DosFindFirst(
path, /* Address of the ASCIIZ path name of the file or subdirectory to be found. */
&hdir, /* Address of the handle associated with this DosFindFirst request. */
FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */
&buf3, /* Result buffer. */
sizeof( buf3), /* The length, in bytes, of pfindbuf. */
&entries, /* Pointer to the number of entries: */
FIL_STANDARD); /* The level of file information required. */
memset( &buf3, 0, sizeof( buf3));
rc = DosFindFirst(
path, /* The ASCIIZ path name of the file or subdirectory to be found. */
&hdir, /* The handle associated with this DosFindFirst request. */
FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */
&buf3, /* Result buffer. */
sizeof( buf3), /* The length, in bytes, of pfindbuf. */
&entries, /* Pointer to the number of entries: */
FIL_STANDARD); /* The level of file information required. */
#ifdef _DEBUG
printf( "_findfirst rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries, buf3.achName);
printf( "_findfirst rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries,
buf3.achName);
#endif
if (rc /* && entries == 0 */)
return -1;
if (rc /* && entries == 0 */)
return -1;
if (dos_file) {
memset( dos_file, 0, sizeof( struct _finddata_t));
strcpy( dos_file->name, buf3.achName);
dos_file->size = buf3.cbFile;
dos_file->attrib = buf3.attrFile;
}
return (ULONG) hdir;
if (dos_file)
{
memset( dos_file, 0, sizeof( struct _finddata_t));
strcpy( dos_file->name, buf3.achName);
dos_file->size = buf3.cbFile;
dos_file->attrib = buf3.attrFile;
}
return (ULONG) hdir;
}
long _findnext( long hdir, struct _finddata_t* dos_file)
{
APIRET rc;
FILEFINDBUF3 buf3;
ULONG entries = 1;
APIRET rc;
FILEFINDBUF3 buf3;
ULONG entries = 1;
memset( &buf3, 0, sizeof( buf3));
rc = DosFindNext(
hdir,
&buf3, /* Result buffer. */
sizeof( buf3), /* The length, in bytes, of pfindbuf. */
&entries); /* Pointer to the number of entries: */
memset( &buf3, 0, sizeof( buf3));
rc = DosFindNext(hdir,
&buf3, /* Result buffer. */
sizeof( buf3), /* Length, in bytes, of pfindbuf. */
&entries); /* Pointer to the number of entries */
#ifdef _DEBUG
printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries, buf3.achName);
printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries,
buf3.achName);
#endif
if (rc /* && entries == 0 */)
return -1;
if (rc /* && entries == 0 */)
return -1;
if (dos_file) {
memset( dos_file, 0, sizeof( struct _finddata_t));
strcpy( dos_file->name, buf3.achName);
dos_file->size = buf3.cbFile;
dos_file->attrib = buf3.attrFile;
}
return 0;
if (dos_file)
{
memset( dos_file, 0, sizeof( struct _finddata_t));
strcpy( dos_file->name, buf3.achName);
dos_file->size = buf3.cbFile;
dos_file->attrib = buf3.attrFile;
}
return 0;
}
void _findclose( long hdir)
@ -101,82 +103,82 @@ void _findclose( long hdir)
#endif
}
DIR* opendir( char* path)
DIR* opendir(char* path)
{
DIR* dir = (DIR*) calloc( 1, sizeof( DIR));
char buffer[260];
APIRET rc;
ULONG entries = 1;
DIR* dir = (DIR*) calloc(1, sizeof( DIR));
char buffer[260];
APIRET rc;
ULONG entries = 1;
strcpy( buffer, path);
strcat( buffer, "*.*");
strmov(strmov(buffer, path), "*.*");
#ifdef _DEBUG
printf( "_findfirst path %s\n", buffer);
printf( "_findfirst path %s\n", buffer);
#endif
dir->hdir = HDIR_CREATE;
memset( &dir->buf3, 0, sizeof( dir->buf3));
rc = DosFindFirst(
buffer, /* Address of the ASCIIZ path name of the file or subdirectory to be found. */
&dir->hdir, /* Address of the handle associated with this DosFindFirst request. */
FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */
&dir->buf3, /* Result buffer. */
sizeof( dir->buf3), /* The length, in bytes, of pfindbuf. */
&entries, /* Pointer to the number of entries: */
FIL_STANDARD); /* The level of file information required. */
dir->hdir = HDIR_CREATE;
memset( &dir->buf3, 0, sizeof( dir->buf3));
rc = DosFindFirst(
buffer, /* Address of the ASCIIZ path name of the file or subdirectory to be found. */
&dir->hdir, /* Address of the handle associated with this DosFindFirst request. */
FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */
&dir->buf3, /* Result buffer. */
sizeof( dir->buf3), /* The length, in bytes, of pfindbuf. */
&entries, /* Pointer to the number of entries: */
FIL_STANDARD); /* The level of file information required. */
#ifdef _DEBUG
printf( "opendir rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries, dir->buf3.achName);
printf( "opendir rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries, dir->buf3.achName);
#endif
if (rc /* && entries == 0 */)
return NULL;
if (rc /* && entries == 0 */)
return NULL;
return dir;
return dir;
}
struct dirent* readdir( DIR* dir)
{
APIRET rc;
//FILEFINDBUF3 buf3;
ULONG entries = 1;
APIRET rc;
ULONG entries = 1;
if (!dir->buf3.achName[0]) // file not found on previous query
return NULL;
if (!dir->buf3.achName[0]) /* file not found on previous query */
return NULL;
// copy last file name
strcpy( dir->ent.d_name, dir->buf3.achName);
/* copy last file name */
strcpy( dir->ent.d_name, dir->buf3.achName);
// query next file
memset( &dir->buf3, 0, sizeof( dir->buf3));
rc = DosFindNext(
dir->hdir,
&dir->buf3, /* Result buffer. */
sizeof( dir->buf3), /* The length, in bytes, of pfindbuf. */
&entries); /* Pointer to the number of entries: */
/* query next file */
memset( &dir->buf3, 0, sizeof( dir->buf3));
rc= DosFindNext(
dir->hdir,
&dir->buf3, /* Result buffer. */
sizeof(dir->buf3), /* Length, in bytes, of pfindbuf. */
&entries); /* Pointer to the number of entries */
#ifdef _DEBUG
printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries, dir->buf3.achName);
printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries,
dir->buf3.achName);
#endif
if (rc /* && entries == 0 */)
strcpy( dir->buf3.achName, ""); // reset name for next query
if (rc /* && entries == 0 */)
*dir->buf3.achName= 0; /* reset name for next query */
return &dir->ent;
return &dir->ent;
}
int closedir (DIR *dir)
{
APIRET rc;
APIRET rc;
rc = DosFindClose( dir->hdir);
rc = DosFindClose( dir->hdir);
#ifdef _DEBUG
printf( "_findclose rc=%d hdir=%d\n", rc, dir->hdir);
printf( "_findclose rc=%d hdir=%d\n", rc, dir->hdir);
#endif
free(dir);
return 0;
free(dir);
return 0;
}
#endif // OS2
#endif /* OS2 */

View File

@ -29,26 +29,35 @@ extern "C" {
struct _finddata_t
{
unsigned attrib;
//unsigned long time_create; /* -1 for FAT file systems */
//unsigned long time_access; /* -1 for FAT file systems */
//unsigned long time_write;
unsigned long size;
char name[260];
//uint16 wr_date;
//uint16 wr_time;
unsigned attrib;
#ifdef NOT_USED
unsigned long time_create; /* -1 for FAT file systems */
unsigned long time_access; /* -1 for FAT file systems */
unsigned long time_write;
#endif
unsigned long size;
char name[260];
#ifdef NOT_USED
uint16 wr_date;
uint16 wr_time;
#endif
};
struct dirent
{
//unsigned attrib;
//unsigned long time_create; /* -1 for FAT file systems */
//unsigned long time_access; /* -1 for FAT file systems */
//unsigned long time_write;
//unsigned long size;
char d_name[260];
//uint16 wr_date;
//uint16 wr_time;
#ifdef NOT_USED
unsigned attrib;
unsigned long time_create; /* -1 for FAT file systems */
unsigned long time_access; /* -1 for FAT file systems */
unsigned long time_write;
unsigned long size;
#endif
char d_name[260];
#ifdef NOT_USED
uint16 wr_date;
uint16 wr_time;
#endif
};
struct DIR
@ -62,16 +71,18 @@ DIR *opendir ( char *);
struct dirent *readdir (DIR *);
int closedir (DIR *);
//#define _A_NORMAL FILE_NORMAL
//#define _A_SUBDIR FILE_DIRECTORY
//#define _A_RDONLY FILE_READONLY
#ifdef NOT_USED
#define _A_NORMAL FILE_NORMAL
#define _A_SUBDIR FILE_DIRECTORY
#define _A_RDONLY FILE_READONLY
//long _findfirst( char*, struct _finddata_t*);
//long _findnext( long, struct _finddata_t*);
//void _findclose( long);
long _findfirst( char*, struct _finddata_t*);
long _findnext( long, struct _finddata_t*);
void _findclose( long);
#endif
#ifdef __cplusplus_00
}
#endif
#endif // __MY_OS2DIRSRCH2_H__
#endif /* __MY_OS2DIRSRCH2_H__ */

View File

@ -24,10 +24,11 @@ int _lock64( int fd, int locktype, my_off_t start,
my_off_t length, myf MyFlags);
int _sopen64( const char *name, int oflag, int shflag, int mask);
//
// this class is used to define a global c++ variable, that
// is initialized before main() gets called.
//
/*
This class is used to define a global c++ variable, that
is initialized before main() gets called.
*/
class File64bit
{
public:
@ -150,7 +151,7 @@ static unsigned char const errno_tab[] =
_DosSetFilePtrL = NULL;
return;
}
// notify success
/* notify success */
#ifdef MYSQL_SERVER
printf( "WSeB 64bit file API loaded.\n");
#endif
@ -164,230 +165,230 @@ void _OS2errno( APIRET rc)
errno = errno_tab[rc];
}
longlong _lseek64( int fd, longlong offset, int seektype)
longlong _lseek64( int fd, longlong offset, int seektype)
{
APIRET rc;
longlong actual;
APIRET rc;
longlong actual;
if (_DosSetFilePtrL)
rc = _DosSetFilePtrL( fd, offset, seektype, &actual);
else {
ULONG ulActual;
rc = DosSetFilePtr( fd, (long) offset, seektype, &ulActual);
actual = ulActual;
}
if (_DosSetFilePtrL)
rc = _DosSetFilePtrL( fd, offset, seektype, &actual);
else
{
ULONG ulActual;
rc = DosSetFilePtr( fd, (long) offset, seektype, &ulActual);
actual = ulActual;
}
if (!rc)
return( actual);/* NO_ERROR */
if (!rc)
return( actual); /* NO_ERROR */
// set errno
_OS2errno( rc);
// seek failed
return(-1);
_OS2errno( rc); /* set errno */
return(-1); /* seek failed */
}
inline _SetFileLocksL(HFILE hFile,
PFILELOCKL pflUnlock,
PFILELOCKL pflLock,
ULONG timeout,
ULONG flags)
inline APIRET _SetFileLocksL(HFILE hFile,
PFILELOCKL pflUnlock,
PFILELOCKL pflLock,
ULONG timeout,
ULONG flags)
{
if (_DosSetFileLocksL) {
APIRET rc;
rc = _DosSetFileLocksL( hFile, pflUnlock, pflLock, timeout, flags);
if (_DosSetFileLocksL)
{
APIRET rc;
rc = _DosSetFileLocksL( hFile, pflUnlock, pflLock, timeout, flags);
// on FAT/HPFS/LAN a INVALID_PARAMETER is returned, seems that
// only JFS can handle >2GB ranges.
if (rc != 87)
return rc;
/*
on FAT/HPFS/LAN a INVALID_PARAMETER is returned, seems that
only JFS can handle >2GB ranges.
*/
if (rc != 87)
return rc;
/* got INVALID_PARAMETER, fallback to standard call */
}
// got INVALID_PARAMETER, fallback to standard call
}
FILELOCK flUnlock = { pflUnlock->lOffset, pflUnlock->lRange };
FILELOCK flLock = { pflLock->lOffset, pflLock->lRange };
return DosSetFileLocks( hFile, &flUnlock, &flLock, timeout, flags);
FILELOCK flUnlock = { pflUnlock->lOffset, pflUnlock->lRange };
FILELOCK flLock = { pflLock->lOffset, pflLock->lRange };
return DosSetFileLocks( hFile, &flUnlock, &flLock, timeout, flags);
}
int _lock64( int fd, int locktype, my_off_t start,
my_off_t length, myf MyFlags)
int _lock64( int fd, int locktype, my_off_t start,
my_off_t length, myf MyFlags)
{
FILELOCKL LockArea = {0,0}, UnlockArea = {0,0};
ULONG readonly = 0;
APIRET rc = -1;
FILELOCKL LockArea = {0,0}, UnlockArea = {0,0};
ULONG readonly = 0;
APIRET rc = -1;
switch( locktype) {
case F_UNLCK:
UnlockArea.lOffset = start;
UnlockArea.lRange = length ? length : LONGLONG_MAX;
break;
switch (locktype) {
case F_UNLCK:
UnlockArea.lOffset = start;
UnlockArea.lRange = length ? length : LONGLONG_MAX;
break;
case F_RDLCK:
case F_WRLCK:
LockArea.lOffset = start;
LockArea.lRange = length ? length : LONGLONG_MAX;
readonly = (locktype == F_RDLCK ? 1 : 0);
break;
case F_RDLCK:
case F_WRLCK:
LockArea.lOffset = start;
LockArea.lRange = length ? length : LONGLONG_MAX;
readonly = (locktype == F_RDLCK ? 1 : 0);
break;
default:
errno = EINVAL;
rc = -1;
break;
}
default:
errno = EINVAL;
rc = -1;
break;
}
if (MyFlags & MY_DONT_WAIT) {
if (MyFlags & MY_DONT_WAIT)
{
rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 0, readonly);
/* printf("fd %d, locktype %d, rc %d (dont_wait)\n", fd, locktype, rc); */
if (rc == 33) { /* Lock Violation */
rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 0, readonly);
//printf( "fd %d, locktype %d, rc %d (dont_wait)\n", fd, locktype, rc);
if (rc == 33) { /* Lock Violation */
DBUG_PRINT("info",("Was locked, trying with timeout"));
rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 1 * 1000, readonly);
//printf( "fd %d, locktype %d, rc %d (dont_wait with timeout)\n", fd, locktype, rc);
}
} else {
while( rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 0, readonly) && (rc == 33)) {
printf(".");
DosSleep(1 * 1000);
}
//printf( "fd %d, locktype %d, rc %d (wait2)\n", fd, locktype, rc);
}
if (!rc)
return( 0);/* NO_ERROR */
// set errno
_OS2errno( rc);
// lock failed
return(-1);
DBUG_PRINT("info",("Was locked, trying with timeout"));
rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 1 * 1000, readonly);
/* printf( "fd %d, locktype %d, rc %d (dont_wait with timeout)\n", fd, locktype, rc); */
}
}
else
{
while (rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 0, readonly) &&
(rc == 33))
{
printf(".");
DosSleep(1 * 1000);
}
/* printf( "fd %d, locktype %d, rc %d (wait2)\n", fd, locktype, rc); */
}
if (!rc)
return(0); /* NO_ERROR */
_OS2errno( rc); /* set errno */
return(-1); /* lock failed */
}
int sopen( const char *name, int oflag, int shflag, int mask)
int sopen(const char *name, int oflag, int shflag, int mask)
{
int fail_errno;
APIRET rc = 0;
HFILE hf = 0;
ULONG ulAction = 0;
LONGLONG cbFile = 0;
ULONG ulAttribute = FILE_NORMAL;
ULONG fsOpenFlags = 0;
ULONG fsOpenMode = 0;
int fail_errno;
APIRET rc = 0;
HFILE hf = 0;
ULONG ulAction = 0;
LONGLONG cbFile = 0;
ULONG ulAttribute = FILE_NORMAL;
ULONG fsOpenFlags = 0;
ULONG fsOpenMode = 0;
/* Extract the access mode and sharing mode bits. */
fsOpenMode = (shflag & 0xFF) | (oflag & 0x03);
/* Extract the access mode and sharing mode bits. */
fsOpenMode = (shflag & 0xFF) | (oflag & 0x03);
/* Translate ERROR_OPEN_FAILED to ENOENT unless O_EXCL is set (see
below). */
fail_errno = ENOENT;
/*
Translate ERROR_OPEN_FAILED to ENOENT unless O_EXCL is set (see
below).
*/
fail_errno = ENOENT;
/* Compute `open_flag' depending on `flags'. Note that _SO_CREAT is
set for O_CREAT. */
/*
Compute `open_flag' depending on `flags'. Note that _SO_CREAT is
set for O_CREAT.
*/
if (oflag & O_CREAT)
{
if (oflag & O_EXCL)
{
fsOpenFlags = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
fail_errno = EEXIST;
}
else if (oflag & O_TRUNC)
fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
else
fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
if (oflag & O_CREAT)
{
if (oflag & O_EXCL)
{
fsOpenFlags = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
fail_errno = EEXIST;
}
else if (oflag & O_TRUNC)
fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
else
fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
if (mask & S_IWRITE)
ulAttribute = FILE_NORMAL;
else
ulAttribute = FILE_READONLY;
if (mask & S_IWRITE)
ulAttribute = FILE_NORMAL;
else
ulAttribute = FILE_READONLY;
}
else if (oflag & O_TRUNC)
fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
else
fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
}
else if (oflag & O_TRUNC)
fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
else
fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
/* Try to open the file and handle errors. */
if (_DosOpenL)
rc = _DosOpenL( name, &hf, &ulAction, cbFile,
ulAttribute, fsOpenFlags, fsOpenMode, NULL);
else
rc = DosOpen( name, &hf, &ulAction, (LONG) cbFile,
ulAttribute, fsOpenFlags, fsOpenMode, NULL);
/* Try to open the file and handle errors. */
if (_DosOpenL)
rc = _DosOpenL( name, &hf, &ulAction, cbFile,
ulAttribute, fsOpenFlags, fsOpenMode, NULL);
else
rc = DosOpen( name, &hf, &ulAction, (LONG) cbFile,
ulAttribute, fsOpenFlags, fsOpenMode, NULL);
if (rc == ERROR_OPEN_FAILED)
{
errno = fail_errno;
return -1;
}
if (rc != 0)
{
// set errno
_OS2errno( rc);
return -1;
}
if (oflag & O_APPEND)
_lseek64( hf, 0L, SEEK_END);
return hf;
if (rc == ERROR_OPEN_FAILED)
{
errno = fail_errno;
return -1;
}
if (rc != 0)
{
_OS2errno( rc); /* set errno */
return -1;
}
if (oflag & O_APPEND)
_lseek64( hf, 0L, SEEK_END);
return hf;
}
int read( int fd, void *buffer, unsigned int count)
int read(int fd, void *buffer, unsigned int count)
{
APIRET rc;
ULONG actual;
APIRET rc;
ULONG actual;
rc = DosRead( fd, (PVOID) buffer, count, &actual);
rc= DosRead( fd, (PVOID) buffer, count, &actual);
if (!rc)
return( actual);/* NO_ERROR */
// set errno
_OS2errno( rc);
// write failed
return(-1);
if (!rc)
return( actual); /* NO_ERROR */
_OS2errno( rc); /* set errno */
return(-1); /* read failed */
}
int write( int fd, const void *buffer, unsigned int count)
int write(int fd, const void *buffer, unsigned int count)
{
APIRET rc;
ULONG actual;
APIRET rc;
ULONG actual;
rc = DosWrite( fd, (PVOID) buffer, count, &actual);
rc = DosWrite( fd, (PVOID) buffer, count, &actual);
if (!rc)
return( actual);/* NO_ERROR */
// set errno
_OS2errno( rc);
// write failed
return(-1);
if (!rc)
return( actual); /* NO_ERROR */
_OS2errno( rc); /* set errno */
return(-1); /* write failed */
}
int close( int fd)
int close( int fd)
{
APIRET rc;
ULONG actual;
APIRET rc;
ULONG actual;
rc = DosClose( fd);
rc = DosClose( fd);
if (!rc)
return( 0);/* NO_ERROR */
// set errno
_OS2errno( rc);
// write failed
return(-1);
if (!rc)
return( 0); /* NO_ERROR */
_OS2errno( rc); /* set errno */
return(-1); /* close failed */
}
inline int open( const char *name, int oflag)
int open( const char *name, int oflag)
{
return sopen( name, oflag, OPEN_SHARE_DENYNONE, S_IREAD | S_IWRITE);
}
inline int open( const char *name, int oflag, int mask)
int open( const char *name, int oflag, int mask)
{
return sopen( name, oflag, OPEN_SHARE_DENYNONE, mask);
}

View File

@ -36,63 +36,48 @@
#include <stdlib.h>
#include <errno.h>
#ifdef _THREAD_SAFE
//#include <pthread.h>
//#include "pthread_private.h"
int
pthread_mutex_init(pthread_mutex_t * mutex,
const pthread_mutexattr_t * mutex_attr)
{
APIRET rc = 0;
rc = DosCreateMutexSem(NULL,mutex,0,0);
/* Return the completion status: */
return (0);
(void) DosCreateMutexSem(NULL,mutex,0,0);
return (0); /* Return the completion status: */
}
int
pthread_mutex_destroy(pthread_mutex_t * mutex)
{
APIRET rc = 0;
APIRET rc;
do
{
rc = DosCloseMutexSem(*mutex);
if (rc == 301) DosReleaseMutexSem(*mutex);
} while (rc == 301);
do {
rc = DosCloseMutexSem(*mutex);
if (rc == 301) DosReleaseMutexSem(*mutex);
} while (rc == 301);
*mutex = 0;
/* Return the completion status: */
return (0);
*mutex = 0;
return (0); /* Return the completion status: */
}
int
pthread_mutex_lock(pthread_mutex_t * mutex)
{
int ret = 0;
int status = 0;
APIRET rc = 0;
APIRET rc;
rc = DosRequestMutexSem(*mutex,SEM_INDEFINITE_WAIT);
if (rc)
return(EINVAL);
/* Return the completion status: */
return (0);
rc = DosRequestMutexSem(*mutex,SEM_INDEFINITE_WAIT);
if (rc)
return(EINVAL);
return (0); /* Return the completion status: */
}
int
pthread_mutex_unlock(pthread_mutex_t * mutex)
{
int ret = 0;
APIRET rc = 0;
int status;
rc = DosReleaseMutexSem(*mutex);
/* Return the completion status: */
return (0);
(void) DosReleaseMutexSem(*mutex);
return (0); /* Return the completion status: */
}
#endif

View File

@ -61,10 +61,9 @@ static pthread_handler_decl(pthread_start,param)
win_pthread_self=((struct pthread_map *) param)->pthreadself;
pthread_mutex_unlock(&THR_LOCK_thread);
free((char*) param); /* Free param from create */
//pthread_exit((void*) (*func)(func_param));
/* pthread_exit((void*) (*func)(func_param)); */
(*func)(func_param);
DBUG_RETURN(0);
//return 0; /* Safety */
}

View File

@ -30,115 +30,122 @@ PULONG tls_storage; /* TLS local storage */
DWORD tls_bits[2]; /* TLS in-use bits */
pthread_mutex_t tls_mutex; /* TLS mutex for in-use bits */
DWORD TlsAlloc( void)
{
DWORD index = -1;
DWORD mask, tibidx;
int i;
DWORD index = -1;
DWORD mask, tibidx;
int i;
if (tls_storage == NULL) {
if (tls_storage == NULL)
{
APIRET rc;
APIRET rc;
// allocate memory for TLS storage
rc = DosAllocThreadLocalMemory( 1, &tls_storage);
if (rc) {
fprintf( stderr, "DosAllocThreadLocalMemory error: return code = %u\n", rc);
}
/* allocate memory for TLS storage */
rc = DosAllocThreadLocalMemory( 1, &tls_storage);
if (rc)
fprintf( stderr, "DosAllocThreadLocalMemory error: return code = %u\n",
rc);
/* create a mutex */
if (pthread_mutex_init( &tls_mutex, NULL))
fprintf( stderr, "Failed to init TLS mutex\n");
}
// create a mutex
if (pthread_mutex_init( &tls_mutex, NULL))
fprintf( stderr, "Failed to init TLS mutex\n");
}
pthread_mutex_lock( &tls_mutex);
pthread_mutex_lock( &tls_mutex);
tibidx = 0;
if (tls_bits[0] == 0xFFFFFFFF) {
if (tls_bits[1] == 0xFFFFFFFF) {
fprintf( stderr, "tid#%d, no more TLS bits available\n", _threadid);
pthread_mutex_unlock( &tls_mutex);
return -1;
}
tibidx = 1;
}
for( i=0; i<32; i++) {
mask = (1 << i);
if ((tls_bits[ tibidx] & mask) == 0) {
tls_bits[ tibidx] |= mask;
index = (tibidx*32) + i;
break;
}
}
tls_storage[index] = 0;
pthread_mutex_unlock( &tls_mutex);
//fprintf( stderr, "tid#%d, TlsAlloc index %d\n", _threadid, index);
return index;
}
BOOL TlsFree( DWORD index)
{
int tlsidx;
DWORD mask;
if (index >= TLS_MINIMUM_AVAILABLE)
return NULL;
pthread_mutex_lock( &tls_mutex);
tlsidx = 0;
if (index > 32) {
tlsidx++;
}
mask = (1 << index);
if (tls_bits[ tlsidx] & mask) {
tls_bits[tlsidx] &= ~mask;
tls_storage[index] = 0;
tibidx = 0;
if (tls_bits[0] == 0xFFFFFFFF)
{
if (tls_bits[1] == 0xFFFFFFFF)
{
fprintf( stderr, "tid#%d, no more TLS bits available\n", _threadid);
pthread_mutex_unlock( &tls_mutex);
return TRUE;
}
return -1;
}
tibidx = 1;
}
pthread_mutex_unlock( &tls_mutex);
return FALSE;
for (i=0; i<32; i++)
{
mask = (1 << i);
if ((tls_bits[ tibidx] & mask) == 0)
{
tls_bits[ tibidx] |= mask;
index = (tibidx*32) + i;
break;
}
}
tls_storage[index] = 0;
pthread_mutex_unlock( &tls_mutex);
/* fprintf( stderr, "tid#%d, TlsAlloc index %d\n", _threadid, index); */
return index;
}
PVOID TlsGetValue( DWORD index)
BOOL TlsFree( DWORD index)
{
if (index >= TLS_MINIMUM_AVAILABLE)
return NULL;
int tlsidx;
DWORD mask;
// verify if memory has been allocated for this thread
if (*tls_storage == NULL) {
// allocate memory for indexes
*tls_storage = (ULONG)calloc( TLS_MINIMUM_AVAILABLE, sizeof(int));
//fprintf( stderr, "tid#%d, tls_storage %x\n", _threadid, *tls_storage);
}
if (index >= TLS_MINIMUM_AVAILABLE)
return NULL;
ULONG* tls_array = (ULONG*) *tls_storage;
return (PVOID) tls_array[ index];
pthread_mutex_lock( &tls_mutex);
tlsidx = 0;
if (index > 32)
tlsidx++;
mask = (1 << index);
if (tls_bits[ tlsidx] & mask)
{
tls_bits[tlsidx] &= ~mask;
tls_storage[index] = 0;
pthread_mutex_unlock( &tls_mutex);
return TRUE;
}
pthread_mutex_unlock( &tls_mutex);
return FALSE;
}
BOOL TlsSetValue( DWORD index, PVOID val)
PVOID TlsGetValue( DWORD index)
{
if (index >= TLS_MINIMUM_AVAILABLE)
return NULL;
/* verify if memory has been allocated for this thread */
if (*tls_storage == NULL)
{
/* allocate memory for indexes */
*tls_storage = (ULONG)calloc( TLS_MINIMUM_AVAILABLE, sizeof(int));
/* fprintf(stderr, "tid#%d, tls_storage %x\n", _threadid, *tls_storage); */
}
ULONG* tls_array = (ULONG*) *tls_storage;
return (PVOID) tls_array[index];
}
BOOL TlsSetValue( DWORD index, PVOID val)
{
// verify if memory has been allocated for this thread
if (*tls_storage == NULL) {
// allocate memory for indexes
*tls_storage = (ULONG)calloc( TLS_MINIMUM_AVAILABLE, sizeof(int));
//fprintf( stderr, "tid#%d, tls_storage %x\n", _threadid, *tls_storage);
}
/* verify if memory has been allocated for this thread */
if (*tls_storage == NULL)
{
/* allocate memory for indexes */
*tls_storage = (ULONG)calloc( TLS_MINIMUM_AVAILABLE, sizeof(int));
/* fprintf(stderr, "tid#%d, tls_storage %x\n", _threadid, *tls_storage); */
}
if (index >= TLS_MINIMUM_AVAILABLE)
return FALSE;
if (index >= TLS_MINIMUM_AVAILABLE)
return FALSE;
ULONG* tls_array = (ULONG*) *tls_storage;
//fprintf( stderr, "tid#%d, TlsSetValue array %08x index %d -> %08x (old)\n", _threadid, tls_array, index, tls_array[ index]);
tls_array[ index] = (ULONG) val;
//fprintf( stderr, "tid#%d, TlsSetValue array %08x index %d -> %08x\n", _threadid, tls_array, index, val);
return TRUE;
ULONG* tls_array = (ULONG*) *tls_storage;
/* fprintf( stderr, "tid#%d, TlsSetValue array %08x index %d -> %08x (old)\n", _threadid, tls_array, index, tls_array[ index]); */
tls_array[ index] = (ULONG) val;
/* fprintf( stderr, "tid#%d, TlsSetValue array %08x index %d -> %08x\n", _threadid, tls_array, index, val); */
return TRUE;
}

View File

@ -425,6 +425,19 @@ int my_pthread_cond_init(pthread_cond_t *mp, const pthread_condattr_t *attr)
#endif
#ifdef __NETWARE__
/* NetWare does not re-acquire the lock if the condition fails */
int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
struct timespec *abstime)
{
int err= pthread_cond_timedwait(cond, mutex, abstime);
if (err)
pthread_mutex_lock(mutex);
return err;
}
#endif /* __NETWARE__ */
/*****************************************************************************
Patches for HPUX
We need these because the pthread_mutex.. code returns -1 on error,

View File

@ -90,7 +90,7 @@ int my_copystat(const char *from, const char *to, int MyFlags)
return 1;
VOID(chmod(to, statbuf.st_mode & 07777)); /* Copy modes */
#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) && !defined(__NETWARE__)
if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
{
if (MyFlags & MY_LINK_WARNING)

View File

@ -14,22 +14,25 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Wait a given time (On systems that dont have sleep !!; MSDOS) */
/* Wait a given number of microseconds */
#include "mysys_priv.h"
#include <m_string.h>
#ifdef _MSC_VER
void sleep(sec)
int sec;
void my_sleep(ulong m_seconds)
{
ulong start;
DBUG_ENTER("sleep");
start=(ulong) time((time_t*) 0);
#ifdef __NETWARE__
delay(m_seconds/1000+1);
#elif defined(OS2)
DosSleep(m_seconds/1000+1);
#elif defined(HAVE_SELECT)
struct timeval t;
t.tv_sec= m_seconds / 1000000L;
t.tv_usec= m_seconds % 1000000L;
select(0,0,0,0,&t); /* sleep */
#else
uint sec= (uint) (m_seconds / 1000000L);
ulong start= (ulong) time((time_t*) 0);
while ((ulong) time((time_t*) 0) < start+sec);
DBUG_VOID_RETURN;
} /* sleep */
#endif /* MSDOS */
#endif
}

View File

@ -38,7 +38,7 @@
#endif
#ifdef HAVE_TEMPNAM
#if !defined( MSDOS) && !defined(OS2)
#if !defined( MSDOS) && !defined(OS2) && !defined(__NETWARE__)
extern char **environ;
#endif
#endif
@ -104,14 +104,14 @@ my_string my_tempnam(const char *dir, const char *pfx,
dir=temp;
}
#ifdef OS2
// changing environ variable doesn't work with VACPP
/* changing environ variable doesn't work with VACPP */
char buffer[256];
sprintf( buffer, "TMP=%s", dir);
// remove ending backslash
/* remove ending backslash */
if (buffer[strlen(buffer)-1] == '\\')
buffer[strlen(buffer)-1] = '\0';
putenv( buffer);
#else
#elif !defined(__NETWARE__)
old_env=(char**)environ;
if (dir)
{ /* Don't use TMPDIR if dir is given */
@ -120,7 +120,7 @@ my_string my_tempnam(const char *dir, const char *pfx,
}
#endif
res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */
#ifndef OS2
#if !defined(OS2) && !defined(__NETWARE__)
((char**) environ)=(char**) old_env;
#endif
if (!res)

View File

@ -93,6 +93,18 @@ void my_thread_global_end(void)
#endif
#ifdef PPTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
pthread_mutexattr_destroy(&my_errchk_mutexattr);
#endif
pthread_mutex_destroy(&THR_LOCK_malloc);
pthread_mutex_destroy(&THR_LOCK_open);
pthread_mutex_destroy(&THR_LOCK_keycache);
pthread_mutex_destroy(&THR_LOCK_lock);
pthread_mutex_destroy(&THR_LOCK_isam);
pthread_mutex_destroy(&THR_LOCK_myisam);
pthread_mutex_destroy(&THR_LOCK_heap);
pthread_mutex_destroy(&THR_LOCK_net);
pthread_mutex_destroy(&THR_LOCK_charset);
#ifndef HAVE_LOCALTIME_R
pthread_mutex_destroy(&LOCK_localtime_r);
#endif
#ifndef HAVE_GETHOSTBYNAME_R
pthread_mutex_destroy(&LOCK_gethostbyname_r);

View File

@ -23,9 +23,9 @@
#ifdef THREAD
#include <my_pthread.h>
extern pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache,
THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_net,THR_LOCK_charset;
extern pthread_mutex_t LOCK_bitmap;
extern pthread_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache;
extern pthread_mutex_t THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_net;
extern pthread_mutex_t THR_LOCK_charset;
#else
#include <my_no_pthread.h>
#endif

View File

@ -239,8 +239,8 @@ gptr _myrealloc (register gptr pPtr, register uint uSize,
if (*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc))
!= MAGICKEY)
{
fprintf (stderr, "Reallocating unallocated data at line %d, '%s'\n",
uLine, sFile);
fprintf(stderr, "Error: Reallocating unallocated data at line %d, '%s'\n",
uLine, sFile);
DBUG_PRINT("safe",("Reallocating unallocated data at line %d, '%s'",
uLine, sFile));
(void) fflush(stderr);
@ -295,8 +295,8 @@ void _myfree (gptr pPtr, const char *sFile, uint uLine, myf myflags)
if (*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc))
!= MAGICKEY)
{
fprintf (stderr, "Freeing unallocated data at line %d, '%s'\n",
uLine, sFile);
fprintf(stderr, "Error: Freeing unallocated data at line %d, '%s'\n",
uLine, sFile);
DBUG_PRINT("safe",("Unallocated data at line %d, '%s'",uLine,sFile));
(void) fflush(stderr);
DBUG_VOID_RETURN;
@ -336,8 +336,8 @@ static int check_ptr(const char *where, byte *ptr, const char *sFile,
{
if (!ptr)
{
fprintf (stderr, "%s NULL pointer at line %d, '%s'\n",
where,uLine, sFile);
fprintf(stderr, "Error: %s NULL pointer at line %d, '%s'\n",
where,uLine, sFile);
DBUG_PRINT("safe",("Null pointer at line %d '%s'", uLine, sFile));
(void) fflush(stderr);
return 1;
@ -345,8 +345,8 @@ static int check_ptr(const char *where, byte *ptr, const char *sFile,
#ifndef _MSC_VER
if ((long) ptr & (ALIGN_SIZE(1)-1))
{
fprintf (stderr, "%s wrong aligned pointer at line %d, '%s'\n",
where,uLine, sFile);
fprintf(stderr, "Error: %s wrong aligned pointer at line %d, '%s'\n",
where,uLine, sFile);
DBUG_PRINT("safe",("Wrong aligned pointer at line %d, '%s'",
uLine,sFile));
(void) fflush(stderr);
@ -355,8 +355,8 @@ static int check_ptr(const char *where, byte *ptr, const char *sFile,
#endif
if (ptr < sf_min_adress || ptr > sf_max_adress)
{
fprintf (stderr, "%s pointer out of range at line %d, '%s'\n",
where,uLine, sFile);
fprintf(stderr, "Error: %s pointer out of range at line %d, '%s'\n",
where,uLine, sFile);
DBUG_PRINT("safe",("Pointer out of range at line %d '%s'",
uLine,sFile));
(void) fflush(stderr);
@ -388,7 +388,7 @@ void TERMINATE (FILE *file)
{
if (file)
{
fprintf (file, "cNewCount: %d\n", cNewCount);
fprintf(file, "Warning: Not freed memory segments: %d\n", cNewCount);
(void) fflush(file);
}
DBUG_PRINT("safe",("cNewCount: %d",cNewCount));
@ -403,7 +403,7 @@ void TERMINATE (FILE *file)
{
if (file)
{
fprintf(file, "Memory that was not free'ed (%ld bytes):\n",lCurMemory);
fprintf(file, "Warning: Memory that was not free'ed (%ld bytes):\n",lCurMemory);
(void) fflush(file);
}
DBUG_PRINT("safe",("Memory that was not free'ed (%ld bytes):",lCurMemory));
@ -411,11 +411,11 @@ void TERMINATE (FILE *file)
{
if (file)
{
fprintf (file,
"\t%6u bytes at 0x%09lx, allocated at line %4u in '%s'",
pPtr -> uDataSize,
(ulong) &(pPtr -> aData[sf_malloc_prehunc]),
pPtr -> uLineNum, pPtr -> sFileName);
fprintf(file,
"\t%6u bytes at 0x%09lx, allocated at line %4u in '%s'",
pPtr -> uDataSize,
(ulong) &(pPtr -> aData[sf_malloc_prehunc]),
pPtr -> uLineNum, pPtr -> sFileName);
fprintf(file, "\n");
(void) fflush(file);
}
@ -429,8 +429,8 @@ void TERMINATE (FILE *file)
/* Report the memory usage statistics */
if (file)
{
fprintf (file, "Maximum memory usage: %ld bytes (%ldk)\n",
lMaxMemory, (lMaxMemory + 1023L) / 1024L);
fprintf(file, "Maximum memory usage: %ld bytes (%ldk)\n",
lMaxMemory, (lMaxMemory + 1023L) / 1024L);
(void) fflush(file);
}
DBUG_PRINT("safe",("Maximum memory usage: %ld bytes (%ldk)",
@ -453,9 +453,9 @@ static int _checkchunk (register struct remember *pRec, const char *sFile,
if (*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc))
!= MAGICKEY)
{
fprintf (stderr, "Memory allocated at %s:%d was underrun,",
pRec -> sFileName, pRec -> uLineNum);
fprintf (stderr, " discovered at %s:%d\n", sFile, uLine);
fprintf(stderr, "Error: Memory allocated at %s:%d was underrun,",
pRec -> sFileName, pRec -> uLineNum);
fprintf(stderr, " discovered at %s:%d\n", sFile, uLine);
(void) fflush(stderr);
DBUG_PRINT("safe",("Underrun at %lx, allocated at %s:%d",
&(pRec -> aData[sf_malloc_prehunc]),
@ -472,9 +472,9 @@ static int _checkchunk (register struct remember *pRec, const char *sFile,
*magicp++ != MAGICEND2 ||
*magicp++ != MAGICEND3)
{
fprintf (stderr, "Memory allocated at %s:%d was overrun,",
pRec -> sFileName, pRec -> uLineNum);
fprintf (stderr, " discovered at '%s:%d'\n", sFile, uLine);
fprintf(stderr, "Error: Memory allocated at %s:%d was overrun,",
pRec -> sFileName, pRec -> uLineNum);
fprintf(stderr, " discovered at '%s:%d'\n", sFile, uLine);
(void) fflush(stderr);
DBUG_PRINT("safe",("Overrun at %lx, allocated at %s:%d",
&(pRec -> aData[sf_malloc_prehunc]),
@ -505,9 +505,9 @@ int _sanity (const char *sFile, uint uLine)
pthread_mutex_unlock(&THR_LOCK_malloc);
if (count || pTmp)
{
const char *format="Safemalloc link list destroyed, discovered at '%s:%d'";
fprintf (stderr, format, sFile, uLine); fputc('\n',stderr);
fprintf (stderr, "root=%p,count=%d,pTmp=%p\n", pRememberRoot,count,pTmp);
const char *format="Error: Safemalloc link list destroyed, discovered at '%s:%d'";
fprintf(stderr, format, sFile, uLine); fputc('\n',stderr);
fprintf(stderr, "root=%p,count=%d,pTmp=%p\n", pRememberRoot,count,pTmp);
(void) fflush(stderr);
DBUG_PRINT("safe",(format, sFile, uLine));
flag=1;

View File

@ -229,8 +229,13 @@ void thr_end_alarm(thr_alarm_t *alarmed)
(long) *alarmed));
}
if (alarm_aborted && !alarm_queue.elements)
{
delete_queue(&alarm_queue);
pthread_mutex_unlock(&LOCK_alarm);
pthread_mutex_unlock(&LOCK_alarm);
pthread_mutex_destroy(&LOCK_alarm);
}
else
pthread_mutex_unlock(&LOCK_alarm);
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
DBUG_VOID_RETURN;
}
@ -367,19 +372,25 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused)))
void end_thr_alarm(void)
{
DBUG_ENTER("end_thr_alarm");
pthread_mutex_lock(&LOCK_alarm);
if (!alarm_aborted)
{
{
my_bool deleted=0;
pthread_mutex_lock(&LOCK_alarm);
DBUG_PRINT("info",("Resheduling %d waiting alarms",alarm_queue.elements));
alarm_aborted=1; /* mark aborted */
if (!alarm_queue.elements)
{
deleted= 1;
delete_queue(&alarm_queue);
}
if (pthread_equal(pthread_self(),alarm_thread))
alarm(1); /* Shut down everything soon */
else
reschedule_alarms();
pthread_mutex_unlock(&LOCK_alarm);
if (deleted)
pthread_mutex_destroy(&LOCK_alarm);
}
pthread_mutex_unlock(&LOCK_alarm);
DBUG_VOID_RETURN;
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB
/* Copyright (C) 2000-2003 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
@ -20,13 +20,15 @@
#if defined(HAVE_LINUXTHREADS) && !defined (__USE_UNIX98)
#define __USE_UNIX98 /* To get rw locks under Linux */
#endif
#include <m_string.h>
#if defined(THREAD) && defined(SAFE_MUTEX)
#undef SAFE_MUTEX /* Avoid safe_mutex redefinitions */
#include <my_pthread.h>
#include "mysys_priv.h"
#include "my_static.h"
#include <m_string.h>
#ifndef DO_NOT_REMOVE_THREAD_WRAPPERS
/* Remove wrappers */
#undef pthread_mutex_t
#undef pthread_mutex_init
#undef pthread_mutex_lock
#undef pthread_mutex_unlock
@ -38,15 +40,55 @@
#endif
#endif /* DO_NOT_REMOVE_THREAD_WRAPPERS */
static pthread_mutex_t THR_LOCK_mutex;
static ulong safe_mutex_count= 0; /* Number of mutexes created */
#ifdef SAFE_MUTEX_DETECT_DESTROY
static struct st_safe_mutex_info_t *safe_mutex_root= NULL;
#endif
void safe_mutex_global_init(void)
{
pthread_mutex_init(&THR_LOCK_mutex,MY_MUTEX_INIT_FAST);
}
int safe_mutex_init(safe_mutex_t *mp,
const pthread_mutexattr_t *attr __attribute__((unused)))
const pthread_mutexattr_t *attr __attribute__((unused)),
const char *file __attribute__((unused)),
uint line __attribute__((unused)))
{
bzero((char*) mp,sizeof(*mp));
pthread_mutex_init(&mp->global,MY_MUTEX_INIT_ERRCHK);
pthread_mutex_init(&mp->mutex,attr);
#ifdef SAFE_MUTEX_DETECT_DESTROY
/*
Monitor the freeing of mutexes. This code depends on single thread init
and destroy
*/
if ((mp->info= (safe_mutex_info_t *) malloc(sizeof(safe_mutex_info_t))))
{
struct st_safe_mutex_info_t *info =mp->info;
info->init_file= (char *) file;
info->init_line= line;
info->prev= NULL;
info->next= NULL;
pthread_mutex_lock(&THR_LOCK_mutex);
if ((info->next= safe_mutex_root))
safe_mutex_root->prev= info;
safe_mutex_root= info;
safe_mutex_count++;
pthread_mutex_unlock(&THR_LOCK_mutex);
}
#else
thread_safe_increment(safe_mutex_count, &THR_LOCK_mutex);
#endif /* SAFE_MUTEX_DETECT_DESTROY */
return 0;
}
int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line)
{
int error;
@ -199,6 +241,11 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
fflush(stderr);
abort();
}
#ifdef __NETWARE__
/* NetWare doesn't re-acquire the mutex on an error */
if (error && pthread_mutex_lock(&mp->mutex))
mp->count--;
#endif /* __NETWARE__ */
mp->thread=pthread_self();
mp->file= (char*) file;
mp->line=line;
@ -206,6 +253,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
return error;
}
int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
{
int error=0;
@ -225,7 +273,70 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
if (pthread_mutex_destroy(&mp->mutex))
error=1;
#endif
#ifdef SAFE_MUTEX_DETECT_DESTROY
if (mp->info)
{
struct st_safe_mutex_info_t *info= mp->info;
pthread_mutex_lock(&THR_LOCK_mutex);
if (info->prev)
info->prev->next = info->next;
else
safe_mutex_root = info->next;
if (info->next)
info->next->prev = info->prev;
safe_mutex_count--;
pthread_mutex_unlock(&THR_LOCK_mutex);
free(info);
mp->info= NULL; /* Get crash if double free */
}
#else
thread_safe_sub(safe_mutex_count, 1, &THR_LOCK_mutex);
#endif /* SAFE_MUTEX_DETECT_DESTROY */
return error;
}
/*
Free global resources and check that all mutex has been destroyed
SYNOPSIS
safe_mutex_end()
file Print errors on this file
NOTES
We can't use DBUG_PRINT() here as we have in my_end() disabled
DBUG handling before calling this function.
In MySQL one may get one warning for a mutex created in my_thr_init.c
This is ok, as this thread may not yet have been exited.
*/
void safe_mutex_end(FILE *file __attribute__((unused)))
{
if (!safe_mutex_count) /* safetly */
pthread_mutex_destroy(&THR_LOCK_mutex);
#ifdef SAFE_MUTEX_DETECT_DESTROY
if (!file)
return;
if (safe_mutex_count)
{
fprintf(file, "Warning: Not destroyed mutex: %lu\n", safe_mutex_count);
(void) fflush(file);
}
{
struct st_safe_mutex_info_t *ptr;
for (ptr= safe_mutex_root ; ptr ; ptr= ptr->next)
{
fprintf(file, "\tMutex initiated at line %4u in '%s'\n",
ptr->init_line, ptr->init_file);
(void) fflush(file);
}
}
#endif /* SAFE_MUTEX_DETECT_DESTROY */
}
#endif /* THREAD && SAFE_MUTEX */

0
netware/Makefile.am Normal file
View File

4162
netware/netware.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -46,16 +46,37 @@ if [ -d $BASE ] ; then
rm -r -f $BASE
fi
BS=""
EXTRA_BIN_FILES=""
BASE_SYSTEM="any"
MYSQL_SHARE=$BASE/share/mysql
case $system in
*netware*)
BASE_SYSTEM="netware"
BS=".nlm"
MYSQL_SHARE=$BASE/share
EXTRA_BIN_FILES="netware/mysqld_safe.nlm netware/mysql_install_db.nlm \
netware/init_db.sql netware/test_db.sql netware/mysql_explain_log.nlm \
netware/mysqlhotcopy.nlm netware/libmysql.nlm"
;;
esac
mkdir $BASE $BASE/bin $BASE/data $BASE/data/mysql $BASE/data/test \
$BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/share/mysql \
$BASE/tests $BASE/scripts $BASE/sql-bench $BASE/mysql-test \
$BASE/mysql-test/t $BASE/mysql-test/r \
$BASE/mysql-test/include $BASE/mysql-test/std_data $BASE/man $BASE/man/man1
$BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/scripts \
$BASE/mysql-test $BASE/mysql-test/t $BASE/mysql-test/r \
$BASE/mysql-test/include $BASE/mysql-test/std_data
if [ $BASE_SYSTEM != "netware" ] ; then
mkdir $BASE/share/mysql $BASE/tests $BASE/sql-bench $BASE/man $BASE/man/man1
fi
chmod o-rwx $BASE/data $BASE/data/*
for i in ChangeLog COPYING COPYING.LIB README Docs/INSTALL-BINARY \
MySQLEULA.txt Docs/manual.html Docs/manual.txt Docs/manual_toc.html
MySQLEULA.txt Docs/manual.html Docs/manual.txt Docs/manual_toc.html \
LICENSE.doc README.NW Docs/mysqlbug.txt
do
if [ -f $i ]
then
@ -63,18 +84,23 @@ do
fi
done
for i in extra/comp_err extra/replace extra/perror extra/resolveip \
extra/my_print_defaults extra/resolve_stack_dump \
isam/isamchk isam/pack_isam myisam/myisamchk \
myisam/myisampack sql/mysqld client/mysqlbinlog \
client/mysql sql/mysqld client/mysqlshow client/mysqlcheck \
client/mysqladmin client/mysqldump client/mysqlimport client/mysqltest \
client/mysqlmanagerc client/mysqlmanager-pwgen tools/mysqlmanager \
client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \
client/.libs/mysqldump client/.libs/mysqlimport client/.libs/mysqltest \
client/.libs/mysqlcheck client/.libs/mysqlbinlog \
client/.libs/mysqlmanagerc client/.libs/mysqlmanager-pwgen \
tools/.libs/mysqlmanager
for i in extra/comp_err$BS extra/replace$BS extra/perror$BS \
extra/resolveip$BS extra/my_print_defaults$BS \
extra/resolve_stack_dump$BS \
isam/isamchk$BS isam/pack_isam$BS \
myisam/myisamchk$BS myisam/myisampack$BS myisam/myisamlog$BS \
sql/mysqld$BS \
client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \
client/mysqldump$BS client/mysqlimport$BS \
client/mysqltest$BS client/mysqlcheck$BS \
client/mysqlbinlog$BS client/mysqlmanagerc$BS \
client/mysqlmanager-pwgen$BS tools/mysqlmanager$BS \
client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \
client/.libs/mysqldump client/.libs/mysqlimport \
client/.libs/mysqltest client/.libs/mysqlcheck \
client/.libs/mysqlbinlog client/.libs/mysqlmanagerc \
client/.libs/mysqlmanager-pwgen tools/.libs/mysqlmanager \
$EXTRA_BIN_FILES
do
if [ -f $i ]
then
@ -86,6 +112,7 @@ if [ x$STRIP = x1 ] ; then
strip $BASE/bin/*
fi
# Copy not binary files
for i in sql/mysqld.sym.gz
do
if [ -f $i ]
@ -94,7 +121,11 @@ do
fi
done
for i in libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so* libmysql/libmysqlclient.* libmysql_r/.libs/libmysqlclient_r.a libmysql_r/.libs/libmysqlclient_r.so* libmysql_r/libmysqlclient_r.* mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a libmysqld/.libs/libmysqld.a libmysqld/.libs/libmysqld.so* libmysqld/libmysqld.a
if [ $BASE_SYSTEM = "netware" ] ; then
$CP -r netware/scripts/* $BASE/scripts
fi
for i in libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so* libmysql/libmysqlclient.* libmysql_r/.libs/libmysqlclient_r.a libmysql_r/.libs/libmysqlclient_r.so* libmysql_r/libmysqlclient_r.* mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a libmysqld/.libs/libmysqld.a libmysqld/.libs/libmysqld.so* libmysqld/libmysqld.a netware/libmysql.imp
do
if [ -f $i ]
then
@ -102,39 +133,72 @@ do
fi
done
# convert the libs to .lib for NetWare
if [ $BASE_SYSTEM = "netware" ] ; then
for i in $BASE/lib/*.a
do
libname=`basename $i .a`
$MV $i $BASE/lib/$libname.lib
done
fi
$CP config.h include/* $BASE/include
rm $BASE/include/Makefile*; rm $BASE/include/*.in
rm -f $BASE/include/Makefile* $BASE/include/*.in $BASE/include/config-win.h
if [ $BASE_SYSTEM != "netware" ] ; then
rm -f $BASE/include/config-netware.h
fi
$CP tests/*.res tests/*.tst tests/*.pl $BASE/tests
if [ -d tests ] ; then
$CP tests/*.res tests/*.tst tests/*.pl $BASE/tests
fi
if [ -d man ] ; then
$CP man/*.1 $BASE/man/man1
fi
$CP support-files/* $BASE/support-files
$CP man/*.1 $BASE/man/man1
$CP -r sql/share/* $BASE/share/mysql
rm -f $BASE/share/mysql/Makefile* $BASE/share/mysql/*/*.OLD
if [ $BASE_SYSTEM == "netware" ] ; then
rm -f $BASE/support-files/magic \
$BASE/support-files/mysql.server \
$BASE/support-files/mysql*.spec \
$BASE/support-files/mysql-log-rotate \
$BASE/support-files/binary-configure
fi
$CP -r sql/share/* $MYSQL_SHARE
rm -f $MYSQL_SHARE/Makefile* $MYSQL_SHARE/*/*.OLD
for i in mysql-test/mysql-test-run mysql-test/install_test_db \
mysql-test/README \
netware/mysql_test_run.nlm netware/install_test_db.ncf
do
if [ -f $i ]
then
$CP $i $BASE/mysql-test
fi
done
$CP mysql-test/mysql-test-run mysql-test/install_test_db $BASE/mysql-test/
$CP mysql-test/README $BASE/mysql-test/README
$CP mysql-test/include/*.inc $BASE/mysql-test/include
$CP mysql-test/std_data/*.dat mysql-test/std_data/*.001 $BASE/mysql-test/std_data
$CP mysql-test/t/*.test mysql-test/t/*.opt mysql-test/t/*.sh $BASE/mysql-test/t
$CP mysql-test/r/*.result mysql-test/r/*.require $BASE/mysql-test/r
$CP mysql-test/t/*test mysql-test/t/*.opt mysql-test/t/*.sh $BASE/mysql-test/t
$CP mysql-test/r/*result mysql-test/r/*.require $BASE/mysql-test/r
if [ $BASE_SYSTEM != "netware" ] ; then
$CP scripts/* $BASE/bin
$BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ ./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ @HOSTNAME@ < $SOURCE/scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db
$BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \@MYSQLD_USER\@ root \@localstatedir\@ /usr/local/mysql/data \@HOSTNAME\@ @HOSTNAME@ < $SOURCE/support-files/mysql.server.sh > $BASE/support-files/mysql.server
$BASE/bin/replace /my/gnu/bin/hostname /bin/hostname -- $BASE/bin/mysqld_safe
mv $BASE/support-files/binary-configure $BASE/configure
chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* $BASE/support-files/mysql.server $BASE/configure
$CP -r sql-bench/* $BASE/sql-bench
rm -f $BASE/sql-bench/*.sh $BASE/sql-bench/Makefile* $BASE/lib/*.la
fi
$CP scripts/* $BASE/bin
rm -f $BASE/bin/Makefile* $BASE/bin/*.in $BASE/bin/*.sh $BASE/bin/mysql_install_db $BASE/bin/make_binary_distribution $BASE/bin/setsomevars $BASE/support-files/Makefile* $BASE/support-files/*.sh
$BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ ./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ @HOSTNAME@ < $SOURCE/scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db
$BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \@MYSQLD_USER\@ root \@localstatedir\@ /usr/local/mysql/data \@HOSTNAME\@ @HOSTNAME@ < $SOURCE/support-files/mysql.server.sh > $BASE/support-files/mysql.server
$BASE/bin/replace /my/gnu/bin/hostname /bin/hostname -- $BASE/bin/mysqld_safe
# Make safe_mysqld a symlink to mysqld_safe for backwards portability
# To be removed in MySQL 4.1
(cd $BASE/bin ; ln -s mysqld_safe safe_mysqld )
mv $BASE/support-files/binary-configure $BASE/configure
chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* $BASE/support-files/mysql.server $BASE/configure
$CP -r sql-bench/* $BASE/sql-bench
rm -f $BASE/sql-bench/*.sh $BASE/sql-bench/Makefile* $BASE/lib/*.la
# Clean up if we did this from a bk tree
if [ -d $BASE/sql-bench/SCCS ] ; then
find $BASE/share -name SCCS -print | xargs rm -r -f

File diff suppressed because it is too large Load Diff

View File

@ -104,4 +104,15 @@ error:
VOID(pthread_mutex_unlock(&LOCK_des_key_file));
DBUG_RETURN(result);
}
void free_des_key_file()
{
if (initialized)
{
initialized= 01;
pthread_mutex_destroy(&LOCK_des_key_file);
}
}
#endif /* HAVE_OPENSSL */

View File

@ -830,6 +830,7 @@ innobase_end(void)
err = innobase_shutdown_for_mysql();
hash_free(&innobase_open_tables);
my_free(internal_innobase_data_file_path,MYF(MY_ALLOW_ZERO_PTR));
pthread_mutex_destroy(&innobase_mutex);
if (err != DB_SUCCESS) {

View File

@ -497,7 +497,7 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
(uint) (T_RETRY_WITHOUT_QUICK | T_QUICK)))
{
param.testflag&= ~T_RETRY_WITHOUT_QUICK;
sql_print_error("Warning: Retrying repair of: '%s' without quick",
sql_print_error("Note: Retrying repair of: '%s' without quick",
table->path);
continue;
}
@ -505,7 +505,7 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
if ((param.testflag & T_REP_BY_SORT))
{
param.testflag= (param.testflag & ~T_REP_BY_SORT) | T_REP;
sql_print_error("Warning: Retrying repair of: '%s' with keycache",
sql_print_error("Note: Retrying repair of: '%s' with keycache",
table->path);
continue;
}
@ -515,7 +515,7 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
!(check_opt->flags & T_VERY_SILENT))
{
char llbuff[22],llbuff2[22];
sql_print_error("Warning: Found %s of %s rows when repairing '%s'",
sql_print_error("Note: Found %s of %s rows when repairing '%s'",
llstr(file->state->records, llbuff),
llstr(start_records, llbuff2),
table->path);

View File

@ -27,7 +27,9 @@
extern "C" { // Because of SCO 3.2V4.2
#endif
#if !defined( __WIN__) && !defined(OS2)
#if !defined(__NETWARE__)
#include <sys/resource.h>
#endif /* __NETWARE__ */
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#endif

View File

@ -86,6 +86,9 @@ public:
virtual bool is_null() { return 0; }
virtual unsigned int size_of()= 0;
virtual void top_level_item() {}
virtual void set_result_field(Field *field) {}
virtual bool is_result_field() { return 0; }
virtual void save_in_result_field(bool no_conversions) {}
};
@ -356,12 +359,19 @@ public:
table_map used_tables() const { return 1; }
virtual void fix_length_and_dec()=0;
unsigned int size_of() { return sizeof(*this);}
void set_result_field(Field *field) { result_field= field; }
bool is_result_field() { return 1; }
void save_in_result_field(bool no_conversions)
{
save_in_field(result_field, no_conversions);
}
};
class Item_ref :public Item_ident
{
public:
Field *result_field; /* Save result here */
Item **ref;
Item_ref(char *db_par,char *table_name_par,char *field_name_par)
:Item_ident(db_par,table_name_par,field_name_par),ref(0) {}
@ -407,6 +417,12 @@ public:
enum Item_result result_type () const { return (*ref)->result_type(); }
table_map used_tables() const { return (*ref)->used_tables(); }
unsigned int size_of() { return sizeof(*this);}
void set_result_field(Field *field) { result_field= field; }
bool is_result_field() { return 1; }
void save_in_result_field(bool no_conversions)
{
(*ref)->save_in_field(result_field, no_conversions);
}
};

View File

@ -1509,6 +1509,7 @@ void item_user_lock_init(void)
void item_user_lock_free(void)
{
hash_free(&hash_user_locks);
pthread_mutex_destroy(&LOCK_user_locks);
}
void item_user_lock_release(ULL *ull)

View File

@ -1089,7 +1089,7 @@ bool Item_sum_count_distinct::add()
if (always_null)
return 0;
copy_fields(tmp_table_param);
copy_funcs(tmp_table_param->funcs);
copy_funcs(tmp_table_param->items_to_copy);
for (Field **field=table->field ; *field ; field++)
if ((*field)->is_real_null(0))

View File

@ -96,9 +96,16 @@ MYSQL_LOG::MYSQL_LOG()
MYSQL_LOG::~MYSQL_LOG()
{
cleanup();
}
void MYSQL_LOG::cleanup()
{
if (inited)
{
close(1);
inited= 0;
(void) pthread_mutex_destroy(&LOCK_log);
(void) pthread_mutex_destroy(&LOCK_index);
(void) pthread_cond_destroy(&update_cond);
@ -1430,6 +1437,10 @@ void MYSQL_LOG:: wait_for_update(THD* thd)
at once after close, in which case we don't want to
close the index file.
We only write a 'stop' event to the log if exiting is set
NOTES
One can do an open on the object at once after doing a close.
The internal structures are not freed until cleanup() is called
*/
void MYSQL_LOG::close(bool exiting)

View File

@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef __EMX__
#if defined(__EMX__) || defined(__NETWARE__)
#include "../mysys/my_lock.c"
#else

View File

@ -397,7 +397,7 @@ int mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &list,COND *conds,
ulong select_type,select_result *result);
int mysql_union(THD *thd,LEX *lex,select_result *result);
Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
Item_result_field ***copy_func, Field **from_field,
Item ***copy_func, Field **from_field,
bool group,bool modify_item);
int mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
@ -474,6 +474,7 @@ extern struct st_des_keyschedule des_keyschedule[10];
extern uint des_default_key;
extern pthread_mutex_t LOCK_des_key_file;
bool load_des_key_file(const char *file_name);
void free_des_key_file();
#endif /* HAVE_OPENSSL */
/* sql_do.cc */
@ -700,6 +701,7 @@ extern struct rand_struct sql_rand;
extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db;
extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink;
extern SHOW_COMP_OPTION have_query_cache, have_berkeley_db, have_innodb;
extern SHOW_COMP_OPTION have_crypt;
#ifndef __WIN__
extern pthread_t signal_thread;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
/* Copyright (C) 2000-2003 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
@ -79,7 +79,9 @@ extern "C" { // Because of SCO 3.2V4.2
#if defined(OS2)
# include <sys/un.h>
#elif !defined( __WIN__)
# ifndef __NETWARE__
#include <sys/resource.h>
# endif /* __NETWARE__ */
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
@ -117,6 +119,15 @@ int deny_severity = LOG_WARNING;
#include <sys/mman.h>
#endif
#ifdef __NETWARE__
#include <nks/vm.h>
#include <library.h>
#include <monitor.h>
event_handle_t eh;
Report_t ref;
#endif /* __NETWARE__ */
#ifdef _AIX41
int initgroups(const char *,unsigned int);
#endif
@ -240,6 +251,11 @@ SHOW_COMP_OPTION have_query_cache=SHOW_OPTION_YES;
#else
SHOW_COMP_OPTION have_query_cache=SHOW_OPTION_NO;
#endif
#ifdef HAVE_CRYPT
SHOW_COMP_OPTION have_crypt=SHOW_OPTION_YES;
#else
SHOW_COMP_OPTION have_crypt=SHOW_OPTION_NO;
#endif
bool opt_large_files= sizeof(my_off_t) > 4;
#if SIZEOF_OFF_T > 4 && defined(BIG_TABLES)
@ -361,8 +377,8 @@ ulong bytes_sent = 0L, bytes_received = 0L;
bool opt_endinfo,using_udf_functions, locked_in_memory;
bool opt_using_transactions, using_update_log;
bool volatile abort_loop,select_thread_in_use,grant_option;
bool volatile ready_to_exit,shutdown_in_progress;
bool volatile abort_loop, select_thread_in_use, signal_thread_in_use;
bool volatile ready_to_exit, shutdown_in_progress, grant_option;
ulong refresh_version=1L,flush_version=1L; /* Increments on each reload */
ulong query_id=1L,long_query_count,aborted_threads,
aborted_connects,delayed_insert_timeout,delayed_insert_limit,
@ -471,6 +487,7 @@ static uint set_maximum_open_files(uint max_file_limit);
#endif
static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
static void clean_up(bool print_message);
static void clean_up_mutexes(void);
/****************************************************************************
** Code to end mysqld
@ -498,7 +515,7 @@ static void close_connections(void)
(void) pthread_mutex_unlock(&LOCK_manager);
/* kill connection thread */
#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) && !defined(__NETWARE__)
DBUG_PRINT("quit",("waiting for select thread: %lx",select_thread));
(void) pthread_mutex_lock(&LOCK_thread_count);
@ -640,14 +657,11 @@ static void close_connections(void)
}
(void) pthread_mutex_unlock(&LOCK_thread_count);
mysql_log.close(1);
mysql_slow_log.close(1);
mysql_update_log.close(1);
mysql_bin_log.close(1);
DBUG_PRINT("quit",("close_connections thread"));
DBUG_VOID_RETURN;
}
static void close_server_sock()
{
#ifdef HAVE_CLOSE_SERVER_SOCK
@ -659,10 +673,10 @@ static void close_server_sock()
ip_sock=INVALID_SOCKET;
DBUG_PRINT("info",("calling shutdown on TCP/IP socket"));
VOID(shutdown(tmp_sock,2));
#ifdef NOT_USED
#if defined(__NETWARE__)
/*
The following code is disabled as it causes MySQL to hang on
AIX 4.3 during shutdown
The following code is disabled for normal systems as it causes MySQL
to hang on AIX 4.3 during shutdown
*/
DBUG_PRINT("info",("calling closesocket on TCP/IP socket"));
VOID(closesocket(tmp_sock));
@ -674,9 +688,9 @@ static void close_server_sock()
unix_sock=INVALID_SOCKET;
DBUG_PRINT("info",("calling shutdown on unix socket"));
VOID(shutdown(tmp_sock,2));
#ifdef NOT_USED
#if defined(__NETWARE__)
/*
The following code is disabled as it may cause MySQL to hang on
The following code is disabled for normal systems as it causes MySQL
AIX 4.3 during shutdown (not tested, but likely)
*/
DBUG_PRINT("info",("calling closesocket on unix/IP socket"));
@ -741,7 +755,7 @@ void kill_mysql(void)
/* Force server down. kill all connections and threads and exit */
#if defined(OS2)
#if defined(OS2) || defined(__NETWARE__)
extern "C" void kill_server(int sig_ptr)
#define RETURN_FROM_KILL_SERVER DBUG_RETURN
#elif !defined(__WIN__)
@ -760,13 +774,16 @@ static void __cdecl kill_server(int sig_ptr)
RETURN_FROM_KILL_SERVER;
kill_in_progress=TRUE;
abort_loop=1; // This should be set
#ifdef __NETWARE__
ActivateScreen(getscreenhandle()); // Show the screen going down
#endif
signal(sig,SIG_IGN);
if (sig == MYSQL_KILL_SIGNAL || sig == 0)
sql_print_error(ER(ER_NORMAL_SHUTDOWN),my_progname);
else
sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
#if defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) && !defined(OS2)
#if defined(__NETWARE__) || (defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) && !defined(OS2))
my_thread_init(); // If this is a new thread
#endif
close_connections();
@ -774,12 +791,18 @@ static void __cdecl kill_server(int sig_ptr)
unireg_abort(1); /* purecov: inspected */
else
unireg_end();
#ifdef __NETWARE__
pthread_join(select_thread, NULL); // wait for main thread
#else
pthread_exit(0); /* purecov: deadcode */
#endif /* __NETWARE__ */
RETURN_FROM_KILL_SERVER;
}
#ifdef USE_ONE_SIGNAL_HAND
#if defined(USE_ONE_SIGNAL_HAND) || (defined(__NETWARE__) && defined(SIGNALS_DONT_BREAK_READ))
extern "C" pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
{
SHUTDOWN_THD;
@ -806,7 +829,7 @@ extern "C" sig_handler print_signal_warning(int sig)
#ifdef DONT_REMEMBER_SIGNAL
sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
#if !defined(__WIN__) && !defined(OS2)
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
if (sig == SIGALRM)
alarm(2); /* reschedule alarm */
#endif
@ -830,11 +853,13 @@ void unireg_end(void)
{
clean_up(1);
my_thread_end();
#ifndef __NETWARE__
#ifdef SIGNALS_DONT_BREAK_READ
exit(0);
#else
pthread_exit(0); // Exit is in main thread
#endif
#endif /* __NETWARE__ */
}
@ -846,6 +871,8 @@ extern "C" void unireg_abort(int exit_code)
clean_up(1); /* purecov: inspected */
DBUG_PRINT("quit",("done with cleanup in unireg_abort"));
my_thread_end();
clean_up_mutexes();
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
exit(exit_code); /* purecov: inspected */
}
@ -855,6 +882,12 @@ void clean_up(bool print_message)
DBUG_PRINT("exit",("clean_up"));
if (cleanup_done++)
return; /* purecov: inspected */
mysql_log.cleanup();
mysql_slow_log.cleanup();
mysql_update_log.cleanup();
mysql_bin_log.cleanup();
if (use_slave_mask)
bitmap_free(&slave_error_mask);
acl_free(1);
@ -884,6 +917,9 @@ void clean_up(bool print_message)
bitmap_free(&temp_pool);
free_max_user_conn();
end_slave_list();
#ifdef HAVE_OPENSSL
free_des_key_file();
#endif /* HAVE_OPENSSL */
#ifdef USE_REGEX
regex_end();
#endif
@ -911,6 +947,35 @@ void clean_up(bool print_message)
} /* clean_up */
static void clean_up_mutexes()
{
(void) pthread_mutex_destroy(&LOCK_mysql_create_db);
(void) pthread_mutex_destroy(&LOCK_Acl);
(void) pthread_mutex_destroy(&LOCK_grant);
(void) pthread_mutex_destroy(&LOCK_open);
(void) pthread_mutex_destroy(&LOCK_thread_count);
(void) pthread_mutex_destroy(&LOCK_mapped_file);
(void) pthread_mutex_destroy(&LOCK_status);
(void) pthread_mutex_destroy(&LOCK_error_log);
(void) pthread_mutex_destroy(&LOCK_delayed_insert);
(void) pthread_mutex_destroy(&LOCK_delayed_status);
(void) pthread_mutex_destroy(&LOCK_delayed_create);
(void) pthread_mutex_destroy(&LOCK_manager);
(void) pthread_mutex_destroy(&LOCK_crypt);
(void) pthread_mutex_destroy(&LOCK_bytes_sent);
(void) pthread_mutex_destroy(&LOCK_bytes_received);
(void) pthread_mutex_destroy(&LOCK_timezone);
(void) pthread_mutex_destroy(&LOCK_user_conn);
(void) pthread_mutex_destroy(&LOCK_rpl_status);
(void) pthread_mutex_destroy(&LOCK_active_mi);
(void) pthread_mutex_destroy(&LOCK_global_system_variables);
(void) pthread_cond_destroy(&COND_thread_count);
(void) pthread_cond_destroy(&COND_refresh);
(void) pthread_cond_destroy(&COND_thread_cache);
(void) pthread_cond_destroy(&COND_flush_thread_cache);
(void) pthread_cond_destroy(&COND_manager);
(void) pthread_cond_destroy(&COND_rpl_status);
}
/****************************************************************************
** Init IP and UNIX socket
@ -944,7 +1009,7 @@ static void set_ports()
static void set_user(const char *user)
{
#if !defined(__WIN__) && !defined(OS2)
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
struct passwd *ent;
// don't bother if we aren't superuser
@ -1005,7 +1070,7 @@ static void set_user(const char *user)
static void set_root(const char *path)
{
#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) && !defined(__NETWARE__)
if (chroot(path) == -1)
{
sql_perror("chroot");
@ -1317,6 +1382,89 @@ static void start_signal_handler(void)
{
}
#elif defined(__NETWARE__)
// down server event callback
void mysql_down_server_cb(void *, void *)
{
setscreenmode(SCR_AUTOCLOSE_ON_EXIT); // auto close the screen
kill_server(0);
}
// destroy callback resources
void mysql_cb_destroy(void *)
{
UnRegisterEventNotification(eh); // cleanup down event notification
NX_UNWRAP_INTERFACE(ref);
}
// initialize callbacks
void mysql_cb_init()
{
// register for down server event
void *handle = getnlmhandle();
rtag_t rt = AllocateResourceTag(handle, "MySQL Down Server Callback",
EventSignature);
NX_WRAP_INTERFACE((void *)mysql_down_server_cb, 2, (void **)&ref);
eh = RegisterForEventNotification(rt, EVENT_DOWN_SERVER,
EVENT_PRIORITY_APPLICATION,
NULL, ref, NULL);
NXVmRegisterExitHandler(mysql_cb_destroy, NULL); // clean-up
}
static void init_signals(void)
{
int signals[] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGABRT};
for (uint i=0 ; i < sizeof(signals)/sizeof(int) ; i++)
signal(signals[i], kill_server);
mysql_cb_init(); // initialize callbacks
}
static void start_signal_handler(void)
{
// Save vm id of this process
if (!opt_bootstrap)
{
File pidFile;
if ((pidFile = my_create(pidfile_name,0664, O_WRONLY, MYF(MY_WME))) >= 0)
{
char buff[21];
sprintf(buff,"%lu",(ulong) getpid());
(void) my_write(pidFile, buff,strlen(buff),MYF(MY_WME));
(void) my_close(pidFile,MYF(0));
}
}
// no signal handler
}
/* Warn if the data is on a Traditional volume */
static void check_data_home(const char *path)
{
struct volume_info vol;
char buff[PATH_MAX], *pos;
bzero((char*) &vol, sizeof(vol)); // clear struct
// find volume name
if ((pos= strchr(path, ':')))
{
uint length= (uint) (pos-path);
strmake(buff, path, min(length, sizeof(buff)-1));
}
else
strmov(buff, "SYS"); // assume SYS volume
netware_vol_info_from_name(&vol, buff); // retrieve information
if ((vol.flags & VOL_NSS_PRESENT) == 0)
{
sql_print_error("Error: %s is not on an NSS volume!", path);
unireg_abort(-1);
}
}
#elif defined(__EMX__)
static void sig_reload(int signo)
{
@ -1352,6 +1500,10 @@ static void start_signal_handler(void)
{
}
static void check_data_home(const char *path)
{
}
#else /* if ! __WIN__ && ! __EMX__ */
#ifdef HAVE_LINUXTHREADS
@ -1554,7 +1706,8 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
int sig;
my_thread_init(); // Init new thread
DBUG_ENTER("signal_hand");
SIGNAL_THD;
signal_thread_in_use= 1;
/*
Setup alarm handler
The two extra handlers are for slave threads
@ -1621,6 +1774,7 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
if (cleanup_done)
{
my_thread_end();
signal_thread_in_use= 0;
pthread_exit(0); // Safety
}
switch (sig) {
@ -1672,6 +1826,10 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
return(0); /* purecov: deadcode */
}
static void check_data_home(const char *path)
{
}
#endif /* __WIN__*/
@ -1844,6 +2002,12 @@ int main(int argc, char **argv)
tzset(); // Set tzname
start_time=time((time_t*) 0);
#ifdef __NETWARE__
printf("MySQL Server %s, for %s (%s)\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE);
fflush(stdout);
#endif /* __NETWARE__ */
#ifdef OS2
{
// fix timezone for daylight saving
@ -2006,6 +2170,7 @@ int main(int argc, char **argv)
We have enough space for fiddling with the argv, continue
*/
umask(((~my_umask) & 0666));
check_data_home(mysql_real_data_home);
if (my_setwd(mysql_real_data_home,MYF(MY_WME)))
{
unireg_abort(1); /* purecov: inspected */
@ -2054,7 +2219,7 @@ int main(int argc, char **argv)
sql_print_error("Can't init databases");
if (unix_sock != INVALID_SOCKET)
unlink(mysql_unix_port);
exit(1);
unireg_abort(1);
}
ha_key_cache();
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
@ -2091,21 +2256,23 @@ int main(int argc, char **argv)
sql_print_error("Can't create thread-keys");
if (unix_sock != INVALID_SOCKET)
unlink(mysql_unix_port);
exit(1);
unireg_abort(1);
}
start_signal_handler(); // Creates pidfile
if (acl_init((THD*) 0, opt_noacl))
{
abort_loop=1;
select_thread_in_use=0;
(void) pthread_kill(signal_thread,MYSQL_KILL_SIGNAL);
#ifndef __NETWARE__
(void) pthread_kill(signal_thread, MYSQL_KILL_SIGNAL);
#endif /* __NETWARE__ */
#ifndef __WIN__
if (!opt_bootstrap)
(void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore
#endif
if (unix_sock != INVALID_SOCKET)
unlink(mysql_unix_port);
exit(1);
unireg_abort(1);
}
if (!opt_noacl)
(void) grant_init((THD*) 0);
@ -2194,7 +2361,9 @@ The server will not act as a slave.");
sql_print_error("Warning: Can't create thread to manage maintenance");
}
printf(ER(ER_READY),my_progname,server_version,"");
if (unix_sock == INVALID_SOCKET)
mysql_unix_port[0]= 0;
printf(ER(ER_READY),my_progname,server_version, mysql_unix_port, mysql_port);
fflush(stdout);
#ifdef __NT__
@ -2277,6 +2446,22 @@ The server will not act as a slave.");
CloseHandle(hEventShutdown);
}
#endif
#ifndef __NETWARE__
{
uint i;
/*
Wait up to 10 seconds for signal thread to die. We use this mainly to
avoid getting warnings that my_thread_end has not been called
*/
for (i= 0 ; i < 100 && signal_thread_in_use; i++)
{
if (pthread_kill(signal_thread, MYSQL_KILL_SIGNAL))
break;
my_sleep(100); // Give it time to die
}
}
#endif
clean_up_mutexes();
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
exit(0);
return(0); /* purecov: deadcode */
@ -2552,7 +2737,10 @@ static void create_new_thread(THD *thd)
inline void kill_broken_server()
{
/* hack to get around signals ignored in syscalls for problem OS's */
if (unix_sock == INVALID_SOCKET ||
if (
#if !defined(__NETWARE__)
unix_sock == INVALID_SOCKET ||
#endif
(!opt_disable_networking && ip_sock == INVALID_SOCKET))
{
select_thread_in_use = 0;
@ -2566,7 +2754,8 @@ inline void kill_broken_server()
/* Handle new connections and spawn new process to handle them */
extern "C" pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
extern "C" pthread_handler_decl(handle_connections_sockets,
arg __attribute__((unused)))
{
my_socket sock,new_sock;
uint error_count=0;
@ -2652,6 +2841,13 @@ extern "C" pthread_handler_decl(handle_connections_sockets,arg __attribute__((un
size_socket length=sizeof(struct sockaddr_in);
new_sock = accept(sock, my_reinterpret_cast(struct sockaddr *) (&cAddr),
&length);
#ifdef __NETWARE__
// TODO: temporary fix, waiting for TCP/IP fix - DEFECT000303149
if ((new_sock == INVALID_SOCKET) && (socket_errno == EINVAL))
{
kill_server(SIGTERM);
}
#endif
if (new_sock != INVALID_SOCKET ||
(socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN))
break;
@ -2880,7 +3076,7 @@ enum options {
OPT_BDB_HOME, OPT_BDB_LOG,
OPT_BDB_TMP, OPT_BDB_NOSYNC,
OPT_BDB_LOCK, OPT_BDB_SKIP,
OPT_BDB_NO_RECOVER, OPT_BDB_SHARED,
OPT_BDB_NO_RECOVER, OPT_BDB_SHARED,
OPT_MASTER_HOST, OPT_MASTER_USER,
OPT_MASTER_PASSWORD, OPT_MASTER_PORT,
OPT_MASTER_INFO_FILE, OPT_MASTER_CONNECT_RETRY,
@ -2964,7 +3160,8 @@ enum options {
OPT_INNODB_FORCE_RECOVERY,
OPT_BDB_CACHE_SIZE,
OPT_BDB_LOG_BUFFER_SIZE,
OPT_BDB_MAX_LOCK
OPT_BDB_MAX_LOCK,
OPT_AUTOCLOSE
};
@ -2974,6 +3171,9 @@ struct my_option my_long_options[] =
{
{"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __NETWARE__
{"autoclose", OPT_AUTOCLOSE, "Auto close screen. (NetWare only)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif /* __NETWARE__ */
{"basedir", 'b',
"Path to installation directory. All paths are usually resolved relative to this.",
(gptr*) &mysql_home_ptr, (gptr*) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG,
@ -3971,8 +4171,8 @@ static void set_options(void)
global_system_variables.max_join_size= HA_POS_ERROR;
max_system_variables.max_join_size= HA_POS_ERROR;
#ifdef __WIN__
/* Allow Win32 users to move MySQL anywhere */
#if defined(__WIN__) || defined(__NETWARE__)
/* Allow Win32 and NetWare users to move MySQL anywhere */
{
char prg_dev[LIBLEN];
my_path(prg_dev,my_progname,"mysql/bin");
@ -4290,6 +4490,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
#ifdef __WIN__
case (int) OPT_STANDALONE: /* Dummy option for NT */
break;
#endif
#ifdef __NETWARE__
case (int) OPT_AUTOCLOSE:
setscreenmode(SCR_AUTOCLOSE_ON_EXIT);
break;
#endif
case (int) OPT_FLUSH:
#ifdef HAVE_ISAM
@ -4462,7 +4667,7 @@ static void get_options(int argc,char **argv)
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error);
#ifdef HAVE_BROKEN_REALPATH
#if defined(HAVE_BROKEN_REALPATH)
my_use_symdir=0;
my_disable_symlinks=1;
have_symlink=SHOW_OPTION_NO;

View File

@ -75,7 +75,7 @@ static int init_failsafe_rpl_thread(THD* thd)
DBUG_RETURN(-1);
}
#if !defined(__WIN__) && !defined(OS2)
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));

View File

@ -416,6 +416,7 @@ struct show_var_st init_vars[]= {
{"ft_max_word_len_for_sort",(char*) &ft_max_word_len_for_sort, SHOW_LONG},
{"ft_boolean_syntax", (char*) ft_boolean_syntax, SHOW_CHAR},
{"have_bdb", (char*) &have_berkeley_db, SHOW_HAVE},
{"have_crypt", (char*) &have_crypt, SHOW_HAVE},
{"have_innodb", (char*) &have_innodb, SHOW_HAVE},
{"have_isam", (char*) &have_isam, SHOW_HAVE},
{"have_raid", (char*) &have_raid, SHOW_HAVE},

View File

@ -77,7 +77,7 @@
"BLOB column '%-.64s' can't be used in key specification with the used table type",
"Too big column length for column '%-.64s' (max = %d). Use BLOB instead",
"Incorrect table definition; There can only be one auto column and it must be defined as a key",
"%s: ready for connections\n",
"%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d\n",
"%s: Normal shutdown\n",
"%s: Got signal %d. Aborting!\n",
"%s: Shutdown Complete\n",

View File

@ -33,8 +33,7 @@ typedef bool (*CHECK_KILLED_FUNC)(THD*,void*);
volatile bool slave_sql_running = 0, slave_io_running = 0;
char* slave_load_tmpdir = 0;
MASTER_INFO main_mi;
MASTER_INFO* active_mi;
MASTER_INFO *active_mi;
volatile int active_mi_in_use = 0;
HASH replicate_do_table, replicate_ignore_table;
DYNAMIC_ARRAY replicate_wild_do_table, replicate_wild_ignore_table;
@ -120,18 +119,19 @@ int init_slave()
TODO: re-write this to interate through the list of files
for multi-master
*/
active_mi = &main_mi;
active_mi= new MASTER_INFO;
/*
If master_host is not specified, try to read it from the master_info file.
If master_host is specified, create the master_info file if it doesn't
exists.
*/
if (init_master_info(active_mi,master_info_file,relay_log_info_file,
if (!active_mi ||
init_master_info(active_mi,master_info_file,relay_log_info_file,
!master_host))
{
sql_print_error("Warning: failed to initialized master info");
DBUG_RETURN(0);
sql_print_error("Note: Failed to initialized master info");
goto err;
}
/*
@ -149,9 +149,15 @@ int init_slave()
master_info_file,
relay_log_info_file,
SLAVE_IO | SLAVE_SQL))
{
sql_print_error("Warning: Can't create threads to handle slave");
goto err;
}
}
DBUG_RETURN(0);
err:
DBUG_RETURN(1);
}
@ -755,23 +761,29 @@ static int end_slave_on_walk(MASTER_INFO* mi, gptr /*unused*/)
}
#endif
void end_slave()
{
/*
TODO: replace the line below with
list_walk(&master_list, (list_walk_action)end_slave_on_walk,0);
once multi-master code is ready.
*/
terminate_slave_threads(active_mi,SLAVE_FORCE_ALL);
end_master_info(active_mi);
if (do_table_inited)
hash_free(&replicate_do_table);
if (ignore_table_inited)
hash_free(&replicate_ignore_table);
if (wild_do_table_inited)
free_string_array(&replicate_wild_do_table);
if (wild_ignore_table_inited)
free_string_array(&replicate_wild_ignore_table);
if (active_mi)
{
/*
TODO: replace the line below with
list_walk(&master_list, (list_walk_action)end_slave_on_walk,0);
once multi-master code is ready.
*/
terminate_slave_threads(active_mi,SLAVE_FORCE_ALL);
end_master_info(active_mi);
if (do_table_inited)
hash_free(&replicate_do_table);
if (ignore_table_inited)
hash_free(&replicate_ignore_table);
if (wild_do_table_inited)
free_string_array(&replicate_wild_do_table);
if (wild_ignore_table_inited)
free_string_array(&replicate_wild_ignore_table);
delete active_mi;
active_mi= 0;
}
}
@ -1563,6 +1575,42 @@ bool flush_master_info(MASTER_INFO* mi)
DBUG_RETURN(0);
}
st_relay_log_info::st_relay_log_info()
:info_fd(-1), cur_log_fd(-1), master_log_pos(0), save_temporary_tables(0),
cur_log_old_open_count(0), log_space_total(0),
slave_skip_counter(0), abort_pos_wait(0), slave_run_id(0),
sql_thd(0), last_slave_errno(0), inited(0), abort_slave(0),
slave_running(0), log_pos_current(0), skip_log_purge(0),
inside_transaction(0) /* the default is autocommit=1 */
{
relay_log_name[0] = master_log_name[0] = 0;
last_slave_error[0]=0;
bzero(&info_file,sizeof(info_file));
bzero(&cache_buf, sizeof(cache_buf));
pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&log_space_lock, MY_MUTEX_INIT_FAST);
pthread_cond_init(&data_cond, NULL);
pthread_cond_init(&start_cond, NULL);
pthread_cond_init(&stop_cond, NULL);
pthread_cond_init(&log_space_cond, NULL);
}
st_relay_log_info::~st_relay_log_info()
{
pthread_mutex_destroy(&run_lock);
pthread_mutex_destroy(&data_lock);
pthread_mutex_destroy(&log_space_lock);
pthread_cond_destroy(&data_cond);
pthread_cond_destroy(&start_cond);
pthread_cond_destroy(&stop_cond);
pthread_cond_destroy(&log_space_cond);
}
/*
Waits until the SQL thread reaches (has executed up to) the
log/position or timed out.
@ -1755,7 +1803,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type)
DBUG_RETURN(-1);
}
#if !defined(__WIN__) && !defined(OS2)
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
@ -2281,14 +2329,16 @@ err:
THD_CHECK_SENTRY(thd);
delete thd;
pthread_mutex_unlock(&LOCK_thread_count);
my_thread_end(); // clean-up before broadcast
pthread_cond_broadcast(&mi->stop_cond); // tell the world we are done
pthread_mutex_unlock(&mi->run_lock);
#ifndef DBUG_OFF
if (abort_slave_event_count && !events_till_abort)
goto slave_begin;
#endif
my_thread_end();
#ifndef __NETWARE__
pthread_exit(0);
#endif /* __NETWARE__ */
DBUG_RETURN(0); // Can't return anything here
}
@ -2420,7 +2470,6 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
THD_CHECK_SENTRY(thd);
delete thd;
pthread_mutex_unlock(&LOCK_thread_count);
my_thread_end(); // clean-up before broadcasting termination
pthread_cond_broadcast(&rli->stop_cond);
// tell the world we are done
pthread_mutex_unlock(&rli->run_lock);
@ -2428,10 +2477,14 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
if (abort_slave_event_count && !rli->events_till_abort)
goto slave_begin;
#endif
my_thread_end(); // clean-up before broadcasting termination
#ifndef __NETWARE__
pthread_exit(0);
#endif /* __NETWARE__ */
DBUG_RETURN(0); // Can't return anything here
}
static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev)
{
int error = 1;
@ -2464,9 +2517,10 @@ static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev)
goto err;
}
/* this dummy block is so we could instantiate Append_block_log_event
once and then modify it slightly instead of doing it multiple times
in the loop
/*
This dummy block is so we could instantiate Append_block_log_event
once and then modify it slightly instead of doing it multiple times
in the loop
*/
{
Append_block_log_event aev(thd,0,0,0);

View File

@ -103,7 +103,7 @@ typedef struct st_relay_log_info
created temporary tables. Modified only on init/end and by the SQL
thread, read only by SQL thread.
*/
TABLE* save_temporary_tables;
TABLE *save_temporary_tables;
/*
standard lock acquistion order to avoid deadlocks:
@ -171,33 +171,8 @@ typedef struct st_relay_log_info
bool skip_log_purge;
bool inside_transaction;
st_relay_log_info()
:info_fd(-1),cur_log_fd(-1), cur_log_old_open_count(0), abort_pos_wait(0),
slave_run_id(0), inited(0), abort_slave(0), slave_running(0),
log_pos_current(0), skip_log_purge(0),
inside_transaction(0) /* the default is autocommit=1 */
{
relay_log_name[0] = master_log_name[0] = 0;
bzero(&info_file,sizeof(info_file));
bzero(&cache_buf, sizeof(cache_buf));
pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&log_space_lock, MY_MUTEX_INIT_FAST);
pthread_cond_init(&data_cond, NULL);
pthread_cond_init(&start_cond, NULL);
pthread_cond_init(&stop_cond, NULL);
pthread_cond_init(&log_space_cond, NULL);
}
~st_relay_log_info()
{
pthread_mutex_destroy(&run_lock);
pthread_mutex_destroy(&data_lock);
pthread_mutex_destroy(&log_space_lock);
pthread_cond_destroy(&data_cond);
pthread_cond_destroy(&start_cond);
pthread_cond_destroy(&stop_cond);
pthread_cond_destroy(&log_space_cond);
}
st_relay_log_info();
~st_relay_log_info();
inline void inc_pending(ulonglong val)
{
pending += val;

View File

@ -549,7 +549,7 @@ void close_temporary_tables(THD *thd)
query_buf_size= 50; // Enough for DROP ... TABLE
for (table=thd->temporary_tables ; table ; table=table->next)
query_buf_size += table->key_length;
query_buf_size+= table->key_length+1;
if ((query = alloc_root(&thd->mem_root, query_buf_size)))
end=strmov(query, "DROP /*!40005 TEMPORARY */ TABLE ");

View File

@ -111,6 +111,7 @@ public:
void init(enum_log_type log_type_arg,
enum cache_type io_cache_type_arg = WRITE_CACHE,
bool no_auto_events_arg = 0);
void cleanup();
bool open(const char *log_name,enum_log_type log_type,
const char *new_name, const char *index_file_name_arg,
enum cache_type io_cache_type_arg,
@ -320,7 +321,8 @@ struct system_variables
a thread/connection descriptor
*/
class THD :public ilink {
class THD :public ilink
{
public:
NET net; // client connection descriptor
LEX lex; // parse tree descriptor
@ -478,7 +480,7 @@ public:
active_vio = 0;
pthread_mutex_unlock(&LOCK_delete);
}
void THD::close_active_vio();
void close_active_vio();
#endif
void awake(bool prepare_to_die);
inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex,
@ -796,12 +798,7 @@ public:
class multi_delete : public select_result {
TABLE_LIST *delete_tables, *table_being_deleted;
#ifdef SINISAS_STRIP
IO_CACHE **tempfiles;
byte *memory_lane;
#else
Unique **tempfiles;
#endif
THD *thd;
ha_rows deleted;
uint num_of_tables;

View File

@ -939,7 +939,7 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg)
strmov(thd->net.last_error,ER(thd->net.last_errno=ER_OUT_OF_RESOURCES));
goto end;
}
#if !defined(__WIN__) && !defined(OS2)
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));

View File

@ -652,7 +652,7 @@ pthread_handler_decl(handle_one_connection,arg)
#if defined(__WIN__)
init_signals(); // IRENA; testing ?
#elif !defined(OS2)
#elif !defined(OS2) && !defined(__NETWARE__)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
@ -682,7 +682,9 @@ pthread_handler_decl(handle_one_connection,arg)
statistic_increment(aborted_connects,&LOCK_status);
goto end_thread;
}
#ifdef __NETWARE__
netware_reg_user(thd->ip, thd->user, "MySQL");
#endif
if (thd->variables.max_join_size == HA_POS_ERROR)
thd->options |= OPTION_BIG_SELECTS;
if (thd->client_capabilities & CLIENT_COMPRESS)
@ -751,12 +753,10 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg)
pthread_detach_this_thread();
thd->thread_stack= (char*) &thd;
#if !defined(__WIN__) && !defined(OS2)
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
#endif
if (thd->variables.max_join_size == HA_POS_ERROR)

View File

@ -506,7 +506,16 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
error= -1; /* if goto err */
/* Optimize distinct away if possible */
order=remove_const(&join,order,conds,&simple_order);
{
ORDER *org_order= order;
order=remove_const(&join,order,conds,&simple_order);
/*
If we are using ORDER BY NULL or ORDER BY const_expression,
return result in any order (even if we are using a GROUP BY)
*/
if (!order && org_order)
skip_sort_order= 1;
}
if (group || join.tmp_table_param.sum_func_count)
{
if (! hidden_group_fields)
@ -776,7 +785,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
procedure->update_refs();
if (tmp_table->group)
{ // Already grouped
if (!order && !no_order)
if (!order && !no_order && !skip_sort_order)
order=group; /* order by group */
group=0;
}
@ -3529,7 +3538,7 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item)
*/
Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
Item_result_field ***copy_func, Field **from_field,
Item ***copy_func, Field **from_field,
bool group, bool modify_item)
{
switch (type) {
@ -3590,12 +3599,12 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
}
return new_field;
}
case Item::PROC_ITEM:
case Item::FUNC_ITEM:
case Item::COND_ITEM:
case Item::FIELD_AVG_ITEM:
case Item::FIELD_STD_ITEM:
/* The following can only happen with 'CREATE TABLE ... SELECT' */
case Item::PROC_ITEM:
case Item::INT_ITEM:
case Item::REAL_ITEM:
case Item::STRING_ITEM:
@ -3624,10 +3633,10 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
item->name,table,item->binary);
break;
}
if (copy_func)
*((*copy_func)++) = (Item_result_field*) item; // Save for copy_funcs
if (copy_func && item->is_result_field())
*((*copy_func)++) = item; // Save for copy_funcs
if (modify_item)
((Item_result_field*) item)->result_field=new_field;
item->set_result_field(new_field);
return new_field;
}
default: // Dosen't have to be stored
@ -3661,7 +3670,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
Copy_field *copy=0;
KEY *keyinfo;
KEY_PART_INFO *key_part_info;
Item_result_field **copy_func;
Item **copy_func;
MI_COLUMNDEF *recinfo;
uint temp_pool_slot=MY_BIT_NONE;
@ -3725,7 +3734,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
my_free((gptr) table,MYF(0)); /* purecov: inspected */
DBUG_RETURN(NULL); /* purecov: inspected */
}
param->funcs=copy_func;
param->items_to_copy= copy_func;
strmov(tmpname,path);
/* make table according to fields */
@ -5257,7 +5266,7 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if (!end_of_records)
{
copy_fields(&join->tmp_table_param);
copy_funcs(join->tmp_table_param.funcs);
copy_funcs(join->tmp_table_param.items_to_copy);
#ifdef TO_BE_DELETED
if (!table->uniques) // If not unique handling
@ -5357,7 +5366,7 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
memcpy(table->record[0]+key_part->offset, group->buff, key_part->length);
init_tmptable_sum_functions(join->sum_funcs);
copy_funcs(join->tmp_table_param.funcs);
copy_funcs(join->tmp_table_param.items_to_copy);
if ((error=table->file->write_row(table->record[0])))
{
if (create_myisam_from_heap(table, &join->tmp_table_param, error, 0))
@ -5390,7 +5399,7 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
init_tmptable_sum_functions(join->sum_funcs);
copy_fields(&join->tmp_table_param); // Groups are copied twice.
copy_funcs(join->tmp_table_param.funcs);
copy_funcs(join->tmp_table_param.items_to_copy);
if (!(error=table->file->write_row(table->record[0])))
join->send_records++; // New group
@ -5475,7 +5484,7 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if (idx < (int) join->send_group_parts)
{
copy_fields(&join->tmp_table_param);
copy_funcs(join->tmp_table_param.funcs);
copy_funcs(join->tmp_table_param.items_to_copy);
init_sum_functions(join->sum_funcs);
if (join->procedure)
join->procedure->add();
@ -7144,7 +7153,7 @@ copy_sum_funcs(Item_sum **func_ptr)
{
Item_sum *func;
for (; (func = *func_ptr) ; func_ptr++)
(void) func->save_in_field(func->result_field, 1);
(void) func->save_in_result_field(1);
return;
}
@ -7171,12 +7180,11 @@ update_sum_func(Item_sum **func_ptr)
/* Copy result of functions to record in tmp_table */
void
copy_funcs(Item_result_field **func_ptr)
copy_funcs(Item **func_ptr)
{
Item_result_field *func;
Item *func;
for (; (func = *func_ptr) ; func_ptr++)
(void) func->save_in_field(func->result_field, 1);
return;
func->save_in_result_field(1);
}

View File

@ -122,7 +122,7 @@ class TMP_TABLE_PARAM :public Sql_alloc
List_iterator_fast<Item> copy_funcs_it;
Copy_field *copy_field, *copy_field_end;
byte *group_buff;
Item_result_field **funcs;
Item **items_to_copy; /* Fields in tmp table */
MI_COLUMNDEF *recinfo,*start_recinfo;
KEY *keyinfo;
ha_rows end_write_records;
@ -194,7 +194,7 @@ void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields,
bool reset_with_sum_func);
bool setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,List<Item> &fields);
void copy_fields(TMP_TABLE_PARAM *param);
void copy_funcs(Item_result_field **func_ptr);
void copy_funcs(Item **func_ptr);
bool create_myisam_from_heap(TABLE *table, TMP_TABLE_PARAM *param, int error,
bool ignore_last_dupp_error);

View File

@ -800,7 +800,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
field=item->tmp_table_field(&tmp_table);
else
field=create_tmp_field(thd, &tmp_table, item, item->type(),
(Item_result_field***) 0, &tmp_field,0,0);
(Item ***) 0, &tmp_field,0,0);
if (!field ||
!(cr_field=new create_field(field,(item->type() == Item::FIELD_ITEM ?
((Item_field *)item)->field :

View File

@ -229,6 +229,11 @@ void udf_free()
}
hash_free(&udf_hash);
free_root(&mem,MYF(0));
if (initialized)
{
initialized= 0;
pthread_mutex_destroy(&THR_LOCK_udf);
}
DBUG_VOID_RETURN;
}

View File

@ -22,9 +22,6 @@
#include "mysql.h"
#include "errmsg.h"
#include <my_dir.h>
#ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h
#endif
#include <my_getopt.h>
#include <signal.h>
#include <violite.h>
@ -50,95 +47,100 @@ print_usage()
printf("viossl-test server-key server-cert client-key client-cert [CAfile] [CApath]\n");
}
int
main( int argc,
char** argv)
main(int argc, char** argv)
{
char* server_key = 0, *server_cert = 0;
char* client_key = 0, *client_cert = 0;
char* ca_file = 0, *ca_path = 0;
char* cipher=0;
int child_pid,sv[2];
my_bool unused;
struct st_VioSSLAcceptorFd* ssl_acceptor=0;
struct st_VioSSLConnectorFd* ssl_connector=0;
Vio* client_vio=0, *server_vio=0;
MY_INIT(argv[0]);
DBUG_PROCESS(argv[0]);
DBUG_PUSH(default_dbug_option);
char* server_key = 0, *server_cert = 0;
char* client_key = 0, *client_cert = 0;
char* ca_file = 0, *ca_path = 0;
char* cipher=0;
int child_pid,sv[2];
my_bool unused;
struct st_VioSSLAcceptorFd* ssl_acceptor=0;
struct st_VioSSLConnectorFd* ssl_connector=0;
Vio* client_vio=0, *server_vio=0;
MY_INIT(argv[0]);
DBUG_PROCESS(argv[0]);
DBUG_PUSH(default_dbug_option);
if (argc<5)
{
print_usage();
return 1;
}
if (argc<5)
{
print_usage();
return 1;
}
server_key = argv[1];
server_cert = argv[2];
client_key = argv[3];
client_cert = argv[4];
if (argc>5)
ca_file = argv[5];
if (argc>6)
ca_path = argv[6];
printf("Server key/cert : %s/%s\n", server_key, server_cert);
printf("Client key/cert : %s/%s\n", client_key, client_cert);
if (ca_file!=0)
printf("CAfile : %s\n", ca_file);
if (ca_path!=0)
printf("CApath : %s\n", ca_path);
server_key = argv[1];
server_cert = argv[2];
client_key = argv[3];
client_cert = argv[4];
if (argc>5)
ca_file = argv[5];
if (argc>6)
ca_path = argv[6];
printf("Server key/cert : %s/%s\n", server_key, server_cert);
printf("Client key/cert : %s/%s\n", client_key, client_cert);
if (ca_file!=0)
printf("CAfile : %s\n", ca_file);
if (ca_path!=0)
printf("CApath : %s\n", ca_path);
if (socketpair(PF_UNIX, SOCK_STREAM, IPPROTO_IP, sv)==-1)
fatal_error("socketpair");
if (socketpair(PF_UNIX, SOCK_STREAM, IPPROTO_IP, sv)==-1)
fatal_error("socketpair");
ssl_acceptor = new_VioSSLAcceptorFd(server_key, server_cert, ca_file, ca_path, cipher);
ssl_connector = new_VioSSLConnectorFd(client_key, client_cert, ca_file, ca_path, cipher);
ssl_acceptor = new_VioSSLAcceptorFd(server_key, server_cert, ca_file,
ca_path, cipher);
ssl_connector = new_VioSSLConnectorFd(client_key, client_cert, ca_file,
ca_path, cipher);
client_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0));
client_vio->sd = sv[0];
client_vio->vioblocking(client_vio, 0, &unused);
sslconnect(ssl_connector,client_vio,60L);
server_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0));
server_vio->sd = sv[1];
server_vio->vioblocking(client_vio, 0, &unused);
sslaccept(ssl_acceptor,server_vio,60L);
client_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0));
client_vio->sd = sv[0];
client_vio->vioblocking(client_vio, 0, &unused);
sslconnect(ssl_connector,client_vio,60L);
server_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0));
server_vio->sd = sv[1];
server_vio->vioblocking(client_vio, 0, &unused);
sslaccept(ssl_acceptor,server_vio,60L);
printf("Socketpair: %d , %d\n", client_vio->sd, server_vio->sd);
printf("Socketpair: %d , %d\n", client_vio->sd, server_vio->sd);
child_pid = fork();
if (child_pid==-1) {
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
fatal_error("fork");
}
if (child_pid==0) {
//child, therefore, client
char xbuf[100];
int r = client_vio->read(client_vio,xbuf, sizeof(xbuf));
if (r<=0) {
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
fatal_error("client:SSL_read");
}
xbuf[r] = 0;
printf("client:got %s\n", xbuf);
my_free((gptr)client_vio,MYF(0));
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
} else {
const char* s = "Huhuhuh";
int r = server_vio->write(server_vio,(gptr)s, strlen(s));
if (r<=0) {
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
fatal_error("server:SSL_write");
}
my_free((gptr)server_vio,MYF(0));
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
}
return 0;
child_pid = fork();
if (child_pid==-1) {
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
fatal_error("fork");
}
if (child_pid==0)
{
/* child, therefore, client */
char xbuf[100];
int r = client_vio->read(client_vio,xbuf, sizeof(xbuf));
if (r<=0) {
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
fatal_error("client:SSL_read");
}
xbuf[r] = 0;
printf("client:got %s\n", xbuf);
my_free((gptr)client_vio,MYF(0));
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
}
else
{
const char* s = "Huhuhuh";
int r = server_vio->write(server_vio,(gptr)s, strlen(s));
if (r<=0) {
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
fatal_error("server:SSL_write");
}
my_free((gptr)server_vio,MYF(0));
my_free((gptr)ssl_acceptor,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
}
return 0;
}
#else /* HAVE_OPENSSL */

View File

@ -22,9 +22,6 @@
#include "mysql.h"
#include "errmsg.h"
#include <my_dir.h>
#ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h
#endif
#include <my_getopt.h>
#include <signal.h>
#include <violite.h>

View File

@ -22,9 +22,6 @@
#include "mysql.h"
#include "errmsg.h"
#include <my_dir.h>
#ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h
#endif
#include <my_getopt.h>
#include <signal.h>
#include <violite.h>

Some files were not shown because too many files have changed in this diff Show More