mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Merge WL#5138 to mysql-next-mr
This commit is contained in:
commit
0c91c582eb
191 changed files with 5132 additions and 1451 deletions
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2006 MySQL AB
|
||||
# Copyright (C) 2006 MySQL AB, 2009 Sun Microsystems, Inc
|
||||
#
|
||||
# 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
|
||||
|
@ -284,10 +284,16 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
|
|||
SET (ENGINE_BUILD_TYPE "STATIC")
|
||||
FOREACH(DIR ${STATIC_ENGINE_DIRECTORIES})
|
||||
ADD_SUBDIRECTORY(${DIR})
|
||||
IF(EXISTS ${DIR}/unittest)
|
||||
ADD_SUBDIRECTORY(${DIR}/unittest)
|
||||
ENDIF(EXISTS ${DIR}/unittest)
|
||||
ENDFOREACH(DIR ${STATIC_ENGINE_DIRECTORIES})
|
||||
|
||||
SET (ENGINE_BUILD_TYPE "DYNAMIC")
|
||||
FOREACH(DIR ${DYNAMIC_ENGINE_DIRECTORIES})
|
||||
IF(EXISTS ${DIR}/unittest)
|
||||
ADD_SUBDIRECTORY(${DIR}/unittest)
|
||||
ENDIF(EXISTS ${DIR}/unittest)
|
||||
ADD_SUBDIRECTORY(${DIR})
|
||||
ENDFOREACH(DIR ${DYNAMIC_ENGINE_DIRECTORIES})
|
||||
|
||||
|
@ -313,6 +319,9 @@ ADD_SUBDIRECTORY(sql)
|
|||
ADD_SUBDIRECTORY(libmysql)
|
||||
ADD_SUBDIRECTORY(libservices)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
ADD_SUBDIRECTORY(unittest/mytap)
|
||||
ADD_SUBDIRECTORY(unittest/examples)
|
||||
ADD_SUBDIRECTORY(unittest/mysys)
|
||||
IF(WITH_EMBEDDED_SERVER)
|
||||
ADD_SUBDIRECTORY(libmysqld)
|
||||
ADD_SUBDIRECTORY(libmysqld/examples)
|
||||
|
|
|
@ -325,8 +325,8 @@ int main(int argc,char *argv[])
|
|||
if (tty_password)
|
||||
opt_password = get_tty_password(NullS);
|
||||
|
||||
VOID(signal(SIGINT,endprog)); /* Here if abort */
|
||||
VOID(signal(SIGTERM,endprog)); /* Here if abort */
|
||||
(void) signal(SIGINT,endprog); /* Here if abort */
|
||||
(void) signal(SIGTERM,endprog); /* Here if abort */
|
||||
|
||||
if (opt_compress)
|
||||
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
|
||||
|
|
|
@ -2001,7 +2001,7 @@ static uint dump_events_for_db(char *db)
|
|||
mysql_free_result(event_list_res);
|
||||
|
||||
if (lock_tables)
|
||||
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
|
||||
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
@ -2204,7 +2204,7 @@ static uint dump_routines_for_db(char *db)
|
|||
DBUG_RETURN(1);
|
||||
|
||||
if (lock_tables)
|
||||
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
|
||||
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
@ -4086,7 +4086,7 @@ static int dump_all_tables_in_db(char *database)
|
|||
check_io(md_result_file);
|
||||
}
|
||||
if (lock_tables)
|
||||
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
|
||||
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
|
||||
if (flush_privileges && using_mysql_db == 0)
|
||||
{
|
||||
fprintf(md_result_file,"\n--\n-- Flush Grant Tables \n--\n");
|
||||
|
@ -4160,7 +4160,7 @@ static my_bool dump_all_views_in_db(char *database)
|
|||
check_io(md_result_file);
|
||||
}
|
||||
if (lock_tables)
|
||||
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
|
||||
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
|
||||
return 0;
|
||||
} /* dump_all_tables_in_db */
|
||||
|
||||
|
@ -4332,7 +4332,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
|
|||
check_io(md_result_file);
|
||||
}
|
||||
if (lock_tables)
|
||||
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
|
||||
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
|
||||
DBUG_RETURN(0);
|
||||
} /* dump_selected_tables */
|
||||
|
||||
|
|
|
@ -610,8 +610,8 @@ int main(int argc, char **argv)
|
|||
pthread_attr_setdetachstate(&attr,
|
||||
PTHREAD_CREATE_DETACHED);
|
||||
|
||||
VOID(pthread_mutex_init(&counter_mutex, NULL));
|
||||
VOID(pthread_cond_init(&count_threshhold, NULL));
|
||||
pthread_mutex_init(&counter_mutex, NULL);
|
||||
pthread_cond_init(&count_threshhold, NULL);
|
||||
|
||||
for (counter= 0; *argv != NULL; argv++) /* Loop through tables */
|
||||
{
|
||||
|
@ -650,8 +650,8 @@ int main(int argc, char **argv)
|
|||
pthread_cond_timedwait(&count_threshhold, &counter_mutex, &abstime);
|
||||
}
|
||||
pthread_mutex_unlock(&counter_mutex);
|
||||
VOID(pthread_mutex_destroy(&counter_mutex));
|
||||
VOID(pthread_cond_destroy(&count_threshhold));
|
||||
pthread_mutex_destroy(&counter_mutex);
|
||||
pthread_cond_destroy(&count_threshhold);
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -352,10 +352,10 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
VOID(pthread_mutex_init(&counter_mutex, NULL));
|
||||
VOID(pthread_cond_init(&count_threshhold, NULL));
|
||||
VOID(pthread_mutex_init(&sleeper_mutex, NULL));
|
||||
VOID(pthread_cond_init(&sleep_threshhold, NULL));
|
||||
pthread_mutex_init(&counter_mutex, NULL);
|
||||
pthread_cond_init(&count_threshhold, NULL);
|
||||
pthread_mutex_init(&sleeper_mutex, NULL);
|
||||
pthread_cond_init(&sleep_threshhold, NULL);
|
||||
|
||||
/* Main iterations loop */
|
||||
eptr= engine_options;
|
||||
|
@ -386,10 +386,10 @@ int main(int argc, char **argv)
|
|||
|
||||
} while (eptr ? (eptr= eptr->next) : 0);
|
||||
|
||||
VOID(pthread_mutex_destroy(&counter_mutex));
|
||||
VOID(pthread_cond_destroy(&count_threshhold));
|
||||
VOID(pthread_mutex_destroy(&sleeper_mutex));
|
||||
VOID(pthread_cond_destroy(&sleep_threshhold));
|
||||
pthread_mutex_destroy(&counter_mutex);
|
||||
pthread_cond_destroy(&count_threshhold);
|
||||
pthread_mutex_destroy(&sleeper_mutex);
|
||||
pthread_cond_destroy(&sleep_threshhold);
|
||||
|
||||
if (!opt_only_print)
|
||||
mysql_close(&mysql); /* Close & free connection */
|
||||
|
|
|
@ -696,12 +696,12 @@ pthread_handler_t send_one_query(void *arg)
|
|||
struct st_connection *cn= (struct st_connection*)arg;
|
||||
|
||||
mysql_thread_init();
|
||||
VOID(mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len));
|
||||
(void) mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len);
|
||||
|
||||
mysql_thread_end();
|
||||
pthread_mutex_lock(&cn->mutex);
|
||||
cn->query_done= 1;
|
||||
VOID(pthread_cond_signal(&cn->cond));
|
||||
pthread_cond_signal(&cn->cond);
|
||||
pthread_mutex_unlock(&cn->mutex);
|
||||
pthread_exit(0);
|
||||
return 0;
|
||||
|
@ -9063,7 +9063,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
|
|||
free_sets(&sets);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
VOID(make_new_set(&sets)); /* Set starting set */
|
||||
(void) make_new_set(&sets); /* Set starting set */
|
||||
make_sets_invisible(&sets); /* Hide previus sets */
|
||||
used_sets=-1;
|
||||
word_states=make_new_set(&sets); /* Start of new word */
|
||||
|
@ -9534,7 +9534,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
|
|||
pa->flag[pa->typelib.count]=0; /* Reset flag */
|
||||
pa->typelib.type_names[pa->typelib.count++]= (char*) pa->str+pa->length;
|
||||
pa->typelib.type_names[pa->typelib.count]= NullS; /* Put end-mark */
|
||||
VOID(strmov((char*) pa->str+pa->length,name));
|
||||
(void) strmov((char*) pa->str+pa->length,name);
|
||||
pa->length+=length;
|
||||
DBUG_RETURN(0);
|
||||
} /* insert_pointer_name */
|
||||
|
|
|
@ -130,7 +130,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
|
|||
int decpt,sign;
|
||||
char *pos,*to;
|
||||
|
||||
VOID(fconvert(num,(int) decimals,&decpt,&sign,buff+1));
|
||||
(void) fconvert(num,(int) decimals,&decpt,&sign,buff+1);
|
||||
if (!my_isdigit(&my_charset_latin1, buff[1]))
|
||||
{ // Nan or Inf
|
||||
pos=buff+1;
|
||||
|
|
162
configure.in
162
configure.in
|
@ -1,6 +1,21 @@
|
|||
dnl -*- ksh -*-
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 2008-2009 Sun Microsystems, Inc
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
AC_PREREQ(2.52)dnl Minimum Autoconf version required.
|
||||
|
||||
AC_INIT(sql/mysqld.cc)
|
||||
|
@ -1750,64 +1765,74 @@ then
|
|||
fi
|
||||
|
||||
AC_ARG_WITH([atomic-ops],
|
||||
AC_HELP_STRING([--with-atomic-ops=rwlocks|smp|up],
|
||||
[Implement atomic operations using pthread rwlocks or atomic CPU
|
||||
instructions for multi-processor (default) or uniprocessor
|
||||
configuration]), , [with_atomic_ops=smp])
|
||||
AS_HELP_STRING([--with-atomic-ops=rwlocks|smp|up],
|
||||
[Implement atomic operations using pthread rwlocks or atomic CPU
|
||||
instructions for multi-processor or uniprocessor
|
||||
configuration. By default gcc built-in sync functions are used,
|
||||
if available and 'smp' configuration otherwise.]))
|
||||
case "$with_atomic_ops" in
|
||||
"up") AC_DEFINE([MY_ATOMIC_MODE_DUMMY], [1],
|
||||
[Assume single-CPU mode, no concurrency]) ;;
|
||||
"rwlocks") AC_DEFINE([MY_ATOMIC_MODE_RWLOCKS], [1],
|
||||
[Use pthread rwlocks for atomic ops]) ;;
|
||||
"smp") ;;
|
||||
"")
|
||||
;;
|
||||
*) AC_MSG_ERROR(["$with_atomic_ops" is not a valid value for --with-atomic-ops]) ;;
|
||||
esac
|
||||
|
||||
AC_CACHE_CHECK([whether the compiler provides atomic builtins],
|
||||
[mysql_cv_gcc_atomic_builtins], [AC_TRY_RUN([
|
||||
int main()
|
||||
{
|
||||
int foo= -10; int bar= 10;
|
||||
if (!__sync_fetch_and_add(&foo, bar) || foo)
|
||||
return -1;
|
||||
bar= __sync_lock_test_and_set(&foo, bar);
|
||||
if (bar || foo != 10)
|
||||
return -1;
|
||||
bar= __sync_val_compare_and_swap(&bar, foo, 15);
|
||||
if (bar)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
], [mysql_cv_gcc_atomic_builtins=yes],
|
||||
[mysql_cv_gcc_atomic_builtins],
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[
|
||||
],
|
||||
[[
|
||||
int foo= -10; int bar= 10;
|
||||
if (!__sync_fetch_and_add(&foo, bar) || foo)
|
||||
return -1;
|
||||
bar= __sync_lock_test_and_set(&foo, bar);
|
||||
if (bar || foo != 10)
|
||||
return -1;
|
||||
bar= __sync_val_compare_and_swap(&bar, foo, 15);
|
||||
if (bar)
|
||||
return -1;
|
||||
return 0;
|
||||
]]
|
||||
)],
|
||||
[mysql_cv_gcc_atomic_builtins=yes],
|
||||
[mysql_cv_gcc_atomic_builtins=no],
|
||||
[mysql_cv_gcc_atomic_builtins=no])])
|
||||
|
||||
[mysql_cv_gcc_atomic_builtins=no]
|
||||
)])
|
||||
if test "x$mysql_cv_gcc_atomic_builtins" = xyes; then
|
||||
AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS, 1,
|
||||
[Define to 1 if compiler provides atomic builtins.])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([whether the OS provides atomic_* functions like Solaris],
|
||||
[mysql_cv_solaris_atomic], [AC_TRY_RUN([
|
||||
#include <atomic.h>
|
||||
int
|
||||
main()
|
||||
{
|
||||
int foo = -10; int bar = 10;
|
||||
if (atomic_add_int_nv((uint_t *)&foo, bar) || foo)
|
||||
return -1;
|
||||
bar = atomic_swap_uint((uint_t *)&foo, (uint_t)bar);
|
||||
if (bar || foo != 10)
|
||||
return -1;
|
||||
bar = atomic_cas_uint((uint_t *)&bar, (uint_t)foo, 15);
|
||||
if (bar)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
], [mysql_cv_solaris_atomic=yes],
|
||||
[mysql_cv_solaris_atomic],
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[
|
||||
#include <atomic.h>
|
||||
]
|
||||
[[
|
||||
int foo = -10; int bar = 10;
|
||||
if (atomic_add_int_nv((uint_t *)&foo, bar) || foo)
|
||||
return -1;
|
||||
bar = atomic_swap_uint((uint_t *)&foo, (uint_t)bar);
|
||||
if (bar || foo != 10)
|
||||
return -1;
|
||||
bar = atomic_cas_uint((uint_t *)&bar, (uint_t)foo, 15);
|
||||
if (bar)
|
||||
return -1;
|
||||
return 0;
|
||||
]]
|
||||
)],
|
||||
[mysql_cv_solaris_atomic=yes],
|
||||
[mysql_cv_solaris_atomic=no],
|
||||
[mysql_cv_solaris_atomic=no])])
|
||||
|
||||
[mysql_cv_solaris_atomic=no]
|
||||
)])
|
||||
if test "x$mysql_cv_solaris_atomic" = xyes; then
|
||||
AC_DEFINE(HAVE_SOLARIS_ATOMIC, 1,
|
||||
[Define to 1 if OS provides atomic_* functions like Solaris.])
|
||||
|
@ -2098,13 +2123,11 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
|
|||
localtime_r gethrtime gmtime_r \
|
||||
locking longjmp lrand48 madvise mallinfo memcpy memmove \
|
||||
mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \
|
||||
pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \
|
||||
pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \
|
||||
pthread_key_delete pthread_rwlock_rdlock pthread_setprio \
|
||||
pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \
|
||||
realpath rename rint rwlock_init setupterm \
|
||||
pthread_attr_getstacksize pthread_attr_setstacksize pthread_condattr_create \
|
||||
pthread_getsequence_np pthread_key_delete pthread_rwlock_rdlock pthread_sigmask \
|
||||
readlink realpath rename rint rwlock_init setupterm \
|
||||
shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
|
||||
sighold sigset sigthreadmask port_create sleep \
|
||||
sighold sigset sigthreadmask port_create sleep thr_yield \
|
||||
snprintf socket stpcpy strcasecmp strerror strsignal strnlen strpbrk strstr \
|
||||
strtol strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr \
|
||||
posix_fallocate backtrace backtrace_symbols backtrace_symbols_fd)
|
||||
|
@ -2906,7 +2929,54 @@ case $SYSTEM_TYPE in
|
|||
esac
|
||||
AC_SUBST(MAKE_BINARY_DISTRIBUTION_OPTIONS)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Support for WL#2373 (Use cycle counter for timing)
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
AC_CHECK_HEADERS(time.h)
|
||||
AC_CHECK_HEADERS(sys/time.h)
|
||||
AC_CHECK_HEADERS(sys/times.h)
|
||||
AC_CHECK_HEADERS(asm/msr.h)
|
||||
#msr.h has rdtscll()
|
||||
|
||||
AC_CHECK_HEADERS(ia64intrin.h)
|
||||
|
||||
AC_CHECK_FUNCS(times)
|
||||
AC_CHECK_FUNCS(gettimeofday)
|
||||
AC_CHECK_FUNCS(read_real_time)
|
||||
# This should work on AIX.
|
||||
|
||||
AC_CHECK_FUNCS(ftime)
|
||||
# This is still a normal call for milliseconds.
|
||||
|
||||
AC_CHECK_FUNCS(time)
|
||||
# We can use time() on Macintosh if there is no ftime().
|
||||
|
||||
AC_CHECK_FUNCS(rdtscll)
|
||||
# I doubt that we'll ever reach the check for this.
|
||||
|
||||
# When compiling with Sun Studio C / C++ we need to include
|
||||
# my_timer_cycles.il, an "inline templates" separate file,
|
||||
# on the command line. It has assembly code, "rd %tick" for
|
||||
# SPARC or "rdtsc" for x86.
|
||||
RDTSC_SPARC_ASSEMBLY=""
|
||||
case $CC_VERSION in
|
||||
*Sun*C*)
|
||||
RDTSC_SPARC_ASSEMBLY="my_timer_cycles.il"
|
||||
;;
|
||||
esac
|
||||
case $CXX_VERSION in
|
||||
*Sun*C++*)
|
||||
RDTSC_SPARC_ASSEMBLY="my_timer_cycles.il"
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST([RDTSC_SPARC_ASSEMBLY])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Output results
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
if test -d "$srcdir/pstack" ; then
|
||||
AC_CONFIG_FILES(pstack/Makefile pstack/aout/Makefile)
|
||||
fi
|
||||
|
|
|
@ -1039,11 +1039,11 @@ static char *parse_text_line(char *pos)
|
|||
switch (*++pos) {
|
||||
case '\\':
|
||||
case '"':
|
||||
VOID(strmov(pos - 1, pos));
|
||||
(void) strmov(pos - 1, pos);
|
||||
break;
|
||||
case 'n':
|
||||
pos[-1]= '\n';
|
||||
VOID(strmov(pos, pos + 1));
|
||||
(void) strmov(pos, pos + 1);
|
||||
break;
|
||||
default:
|
||||
if (*pos >= '0' && *pos < '8')
|
||||
|
@ -1053,10 +1053,10 @@ static char *parse_text_line(char *pos)
|
|||
nr= nr * 8 + (*(pos++) - '0');
|
||||
pos -= i;
|
||||
pos[-1]= nr;
|
||||
VOID(strmov(pos, pos + i));
|
||||
(void) strmov(pos, pos + i);
|
||||
}
|
||||
else if (*pos)
|
||||
VOID(strmov(pos - 1, pos)); /* Remove '\' */
|
||||
(void) strmov(pos - 1, pos); /* Remove '\' */
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -311,7 +311,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
|
|||
pa->flag[pa->typelib.count]=0; /* Reset flag */
|
||||
pa->typelib.type_names[pa->typelib.count++]= (char*) (pa->str+pa->length);
|
||||
pa->typelib.type_names[pa->typelib.count]= NullS; /* Put end-mark */
|
||||
VOID(strmov((char*) pa->str + pa->length, name));
|
||||
(void) strmov((char*) pa->str + pa->length, name);
|
||||
pa->length+=length;
|
||||
DBUG_RETURN(0);
|
||||
} /* insert_pointer_name */
|
||||
|
@ -433,7 +433,7 @@ static REPLACE *init_replace(char * *from, char * *to,uint count,
|
|||
free_sets(&sets);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
VOID(make_new_set(&sets)); /* Set starting set */
|
||||
(void) make_new_set(&sets); /* Set starting set */
|
||||
make_sets_invisible(&sets); /* Hide previus sets */
|
||||
used_sets=-1;
|
||||
word_states=make_new_set(&sets); /* Start of new word */
|
||||
|
|
|
@ -30,7 +30,7 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
|
|||
m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \
|
||||
$(HEADERS_GEN_MAKE) probes_mysql.h probes_mysql_nodtrace.h
|
||||
|
||||
noinst_HEADERS = config-win.h config-netware.h my_bit.h \
|
||||
noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \
|
||||
heap.h my_bitmap.h my_uctype.h \
|
||||
myisam.h myisampack.h myisammrg.h ft_global.h\
|
||||
mysys_err.h my_base.h help_start.h help_end.h \
|
||||
|
@ -38,10 +38,11 @@ noinst_HEADERS = config-win.h config-netware.h my_bit.h \
|
|||
my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \
|
||||
thr_lock.h t_ctype.h violite.h my_md5.h base64.h \
|
||||
my_handler.h my_time.h service_versions.h \
|
||||
my_rdtsc.h \
|
||||
my_vle.h my_user.h my_atomic.h atomic/nolock.h \
|
||||
atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \
|
||||
atomic/solaris.h \
|
||||
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h
|
||||
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \
|
||||
atomic/solaris.h
|
||||
|
||||
EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp probes_mysql.d.base
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ATOMIC_RWLOCK_INCLUDED
|
||||
#define ATOMIC_RWLOCK_INCLUDED
|
||||
|
||||
/* Copyright (C) 2006 MySQL AB
|
||||
/* Copyright (C) 2006 MySQL AB, 2009 Sun Microsystems, Inc.
|
||||
|
||||
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
|
||||
|
@ -16,7 +16,6 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
|
||||
#define MY_ATOMIC_MODE_RWLOCKS 1
|
||||
|
||||
#ifdef MY_ATOMIC_MODE_DUMMY
|
||||
|
@ -27,6 +26,9 @@ typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
|
|||
implementations (another way is to run a UP build on an SMP box).
|
||||
*/
|
||||
#warning MY_ATOMIC_MODE_DUMMY and MY_ATOMIC_MODE_RWLOCKS are incompatible
|
||||
|
||||
typedef char my_atomic_rwlock_t;
|
||||
|
||||
#define my_atomic_rwlock_destroy(name)
|
||||
#define my_atomic_rwlock_init(name)
|
||||
#define my_atomic_rwlock_rdlock(name)
|
||||
|
@ -34,7 +36,12 @@ typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
|
|||
#define my_atomic_rwlock_rdunlock(name)
|
||||
#define my_atomic_rwlock_wrunlock(name)
|
||||
#define MY_ATOMIC_MODE "dummy (non-atomic)"
|
||||
#else
|
||||
#else /* not MY_ATOMIC_MODE_DUMMY */
|
||||
|
||||
typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
|
||||
|
||||
#ifndef SAFE_MUTEX
|
||||
|
||||
/*
|
||||
we're using read-write lock macros but map them to mutex locks, and they're
|
||||
faster. Still, having semantically rich API we can change the
|
||||
|
@ -46,6 +53,38 @@ typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
|
|||
#define my_atomic_rwlock_wrlock(name) pthread_mutex_lock(& (name)->rw)
|
||||
#define my_atomic_rwlock_rdunlock(name) pthread_mutex_unlock(& (name)->rw)
|
||||
#define my_atomic_rwlock_wrunlock(name) pthread_mutex_unlock(& (name)->rw)
|
||||
|
||||
#else /* SAFE_MUTEX */
|
||||
|
||||
/*
|
||||
SAFE_MUTEX pollutes the compiling name space with macros
|
||||
that alter pthread_mutex_t, pthread_mutex_init, etc.
|
||||
Atomic operations should never use the safe mutex wrappers.
|
||||
Unfortunately, there is no way to have both:
|
||||
- safe mutex macros expanding pthread_mutex_lock to safe_mutex_lock
|
||||
- my_atomic macros expanding to unmodified pthread_mutex_lock
|
||||
inlined in the same compilation unit.
|
||||
So, in case of SAFE_MUTEX, a function call is required.
|
||||
Given that SAFE_MUTEX is a debugging facility,
|
||||
this extra function call is not a performance concern for
|
||||
production builds.
|
||||
*/
|
||||
C_MODE_START
|
||||
extern void plain_pthread_mutex_init(safe_mutex_t *);
|
||||
extern void plain_pthread_mutex_destroy(safe_mutex_t *);
|
||||
extern void plain_pthread_mutex_lock(safe_mutex_t *);
|
||||
extern void plain_pthread_mutex_unlock(safe_mutex_t *);
|
||||
C_MODE_END
|
||||
|
||||
#define my_atomic_rwlock_destroy(name) plain_pthread_mutex_destroy(&(name)->rw)
|
||||
#define my_atomic_rwlock_init(name) plain_pthread_mutex_init(&(name)->rw)
|
||||
#define my_atomic_rwlock_rdlock(name) plain_pthread_mutex_lock(&(name)->rw)
|
||||
#define my_atomic_rwlock_wrlock(name) plain_pthread_mutex_lock(&(name)->rw)
|
||||
#define my_atomic_rwlock_rdunlock(name) plain_pthread_mutex_unlock(&(name)->rw)
|
||||
#define my_atomic_rwlock_wrunlock(name) plain_pthread_mutex_unlock(&(name)->rw)
|
||||
|
||||
#endif /* SAFE_MUTEX */
|
||||
|
||||
#define MY_ATOMIC_MODE "mutex"
|
||||
#ifndef MY_ATOMIC_MODE_RWLOCKS
|
||||
#define MY_ATOMIC_MODE_RWLOCKS 1
|
||||
|
|
|
@ -88,7 +88,4 @@
|
|||
#define make_atomic_store_body(S) \
|
||||
asm volatile ("; xchg %0, %1;" : "+m" (*a), "+r" (v))
|
||||
#endif
|
||||
|
||||
/* TODO test on intel whether the below helps. on AMD it makes no difference */
|
||||
//#define LF_BACKOFF ({asm volatile ("rep; nop"); 1; })
|
||||
#endif /* ATOMIC_X86_GCC_INCLUDED */
|
||||
|
|
|
@ -73,7 +73,6 @@ extern "C" {
|
|||
#undef HAVE_FINITE
|
||||
#undef HAVE_GETPWNAM
|
||||
#undef HAVE_GETPWUID
|
||||
#undef HAVE_PTHREAD_SETSCHEDPARAM
|
||||
#undef HAVE_READLINK
|
||||
#undef HAVE_STPCPY
|
||||
/* changes end */
|
||||
|
|
|
@ -145,12 +145,23 @@ typedef __int64 os_off_t;
|
|||
#ifdef _WIN64
|
||||
typedef UINT_PTR rf_SetTimer;
|
||||
#else
|
||||
#ifndef HAVE_SIZE_T
|
||||
typedef unsigned int size_t;
|
||||
#endif
|
||||
typedef uint rf_SetTimer;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SIZE_T
|
||||
#ifndef _SIZE_T_DEFINED
|
||||
typedef SIZE_T size_t;
|
||||
#define _SIZE_T_DEFINED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SSIZE_T
|
||||
#ifndef _SSIZE_T_DEFINED
|
||||
typedef SSIZE_T ssize_t;
|
||||
#define _SSIZE_T_DEFINED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define Socket_defined
|
||||
#define my_socket SOCKET
|
||||
#define SIGPIPE SIGINT
|
||||
|
|
268
include/lf.h
Normal file
268
include/lf.h
Normal file
|
@ -0,0 +1,268 @@
|
|||
/* Copyright (C) 2007-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#ifndef _lf_h
|
||||
#define _lf_h
|
||||
|
||||
#include <my_atomic.h>
|
||||
|
||||
C_MODE_START
|
||||
|
||||
/*
|
||||
Helpers to define both func() and _func(), where
|
||||
func() is a _func() protected by my_atomic_rwlock_wrlock()
|
||||
*/
|
||||
|
||||
#define lock_wrap(f, t, proto_args, args, lock) \
|
||||
t _ ## f proto_args; \
|
||||
static inline t f proto_args \
|
||||
{ \
|
||||
t ret; \
|
||||
my_atomic_rwlock_wrlock(lock); \
|
||||
ret= _ ## f args; \
|
||||
my_atomic_rwlock_wrunlock(lock); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define lock_wrap_void(f, proto_args, args, lock) \
|
||||
void _ ## f proto_args; \
|
||||
static inline void f proto_args \
|
||||
{ \
|
||||
my_atomic_rwlock_wrlock(lock); \
|
||||
_ ## f args; \
|
||||
my_atomic_rwlock_wrunlock(lock); \
|
||||
}
|
||||
|
||||
#define nolock_wrap(f, t, proto_args, args) \
|
||||
t _ ## f proto_args; \
|
||||
static inline t f proto_args \
|
||||
{ \
|
||||
return _ ## f args; \
|
||||
}
|
||||
|
||||
#define nolock_wrap_void(f, proto_args, args) \
|
||||
void _ ## f proto_args; \
|
||||
static inline void f proto_args \
|
||||
{ \
|
||||
_ ## f args; \
|
||||
}
|
||||
|
||||
/*
|
||||
wait-free dynamic array, see lf_dynarray.c
|
||||
|
||||
4 levels of 256 elements each mean 4311810304 elements in an array - it
|
||||
should be enough for a while
|
||||
*/
|
||||
#define LF_DYNARRAY_LEVEL_LENGTH 256
|
||||
#define LF_DYNARRAY_LEVELS 4
|
||||
|
||||
typedef struct {
|
||||
void * volatile level[LF_DYNARRAY_LEVELS];
|
||||
uint size_of_element;
|
||||
my_atomic_rwlock_t lock;
|
||||
} LF_DYNARRAY;
|
||||
|
||||
typedef int (*lf_dynarray_func)(void *, void *);
|
||||
|
||||
void lf_dynarray_init(LF_DYNARRAY *array, uint element_size);
|
||||
void lf_dynarray_destroy(LF_DYNARRAY *array);
|
||||
|
||||
nolock_wrap(lf_dynarray_value, void *,
|
||||
(LF_DYNARRAY *array, uint idx),
|
||||
(array, idx))
|
||||
lock_wrap(lf_dynarray_lvalue, void *,
|
||||
(LF_DYNARRAY *array, uint idx),
|
||||
(array, idx),
|
||||
&array->lock)
|
||||
nolock_wrap(lf_dynarray_iterate, int,
|
||||
(LF_DYNARRAY *array, lf_dynarray_func func, void *arg),
|
||||
(array, func, arg))
|
||||
|
||||
/*
|
||||
pin manager for memory allocator, lf_alloc-pin.c
|
||||
*/
|
||||
|
||||
#define LF_PINBOX_PINS 4
|
||||
#define LF_PURGATORY_SIZE 10
|
||||
|
||||
typedef void lf_pinbox_free_func(void *, void *, void*);
|
||||
|
||||
typedef struct {
|
||||
LF_DYNARRAY pinarray;
|
||||
lf_pinbox_free_func *free_func;
|
||||
void *free_func_arg;
|
||||
uint free_ptr_offset;
|
||||
uint32 volatile pinstack_top_ver; /* this is a versioned pointer */
|
||||
uint32 volatile pins_in_array; /* number of elements in array */
|
||||
} LF_PINBOX;
|
||||
|
||||
typedef struct {
|
||||
void * volatile pin[LF_PINBOX_PINS];
|
||||
LF_PINBOX *pinbox;
|
||||
void **stack_ends_here;
|
||||
void *purgatory;
|
||||
uint32 purgatory_count;
|
||||
uint32 volatile link;
|
||||
/* we want sizeof(LF_PINS) to be 64 to avoid false sharing */
|
||||
#if SIZEOF_INT*2+SIZEOF_CHARP*(LF_PINBOX_PINS+3) != 64
|
||||
char pad[64-sizeof(uint32)*2-sizeof(void*)*(LF_PINBOX_PINS+3)];
|
||||
#endif
|
||||
} LF_PINS;
|
||||
|
||||
/*
|
||||
shortcut macros to do an atomic_wrlock on a structure that uses pins
|
||||
(e.g. lf_hash).
|
||||
*/
|
||||
#define lf_rwlock_by_pins(PINS) \
|
||||
my_atomic_rwlock_wrlock(&(PINS)->pinbox->pinarray.lock)
|
||||
#define lf_rwunlock_by_pins(PINS) \
|
||||
my_atomic_rwlock_wrunlock(&(PINS)->pinbox->pinarray.lock)
|
||||
|
||||
/*
|
||||
compile-time assert, to require "no less than N" pins
|
||||
it's enough if it'll fail on at least one compiler, so
|
||||
we'll enable it on GCC only, which supports zero-length arrays.
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(MY_LF_EXTRA_DEBUG)
|
||||
#define LF_REQUIRE_PINS(N) \
|
||||
static const char require_pins[LF_PINBOX_PINS-N] \
|
||||
__attribute__ ((unused)); \
|
||||
static const int LF_NUM_PINS_IN_THIS_FILE= N;
|
||||
#define _lf_pin(PINS, PIN, ADDR) \
|
||||
( \
|
||||
assert(PIN < LF_NUM_PINS_IN_THIS_FILE), \
|
||||
my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)) \
|
||||
)
|
||||
#else
|
||||
#define LF_REQUIRE_PINS(N)
|
||||
#define _lf_pin(PINS, PIN, ADDR) my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR))
|
||||
#endif
|
||||
|
||||
#define _lf_unpin(PINS, PIN) _lf_pin(PINS, PIN, NULL)
|
||||
#define lf_pin(PINS, PIN, ADDR) \
|
||||
do { \
|
||||
lf_rwlock_by_pins(PINS); \
|
||||
_lf_pin(PINS, PIN, ADDR); \
|
||||
lf_rwunlock_by_pins(PINS); \
|
||||
} while (0)
|
||||
#define lf_unpin(PINS, PIN) lf_pin(PINS, PIN, NULL)
|
||||
#define _lf_assert_pin(PINS, PIN) assert((PINS)->pin[PIN] != 0)
|
||||
#define _lf_assert_unpin(PINS, PIN) assert((PINS)->pin[PIN] == 0)
|
||||
|
||||
void lf_pinbox_init(LF_PINBOX *pinbox, uint free_ptr_offset,
|
||||
lf_pinbox_free_func *free_func, void * free_func_arg);
|
||||
void lf_pinbox_destroy(LF_PINBOX *pinbox);
|
||||
|
||||
lock_wrap(lf_pinbox_get_pins, LF_PINS *,
|
||||
(LF_PINBOX *pinbox),
|
||||
(pinbox),
|
||||
&pinbox->pinarray.lock)
|
||||
lock_wrap_void(lf_pinbox_put_pins,
|
||||
(LF_PINS *pins),
|
||||
(pins),
|
||||
&pins->pinbox->pinarray.lock)
|
||||
lock_wrap_void(lf_pinbox_free,
|
||||
(LF_PINS *pins, void *addr),
|
||||
(pins, addr),
|
||||
&pins->pinbox->pinarray.lock)
|
||||
|
||||
/*
|
||||
memory allocator, lf_alloc-pin.c
|
||||
*/
|
||||
|
||||
typedef struct st_lf_allocator {
|
||||
LF_PINBOX pinbox;
|
||||
uchar * volatile top;
|
||||
uint element_size;
|
||||
uint32 volatile mallocs;
|
||||
void (*constructor)(uchar *); /* called, when an object is malloc()'ed */
|
||||
void (*destructor)(uchar *); /* called, when an object is free()'d */
|
||||
} LF_ALLOCATOR;
|
||||
|
||||
void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset);
|
||||
void lf_alloc_destroy(LF_ALLOCATOR *allocator);
|
||||
uint lf_alloc_pool_count(LF_ALLOCATOR *allocator);
|
||||
/*
|
||||
shortcut macros to access underlying pinbox functions from an LF_ALLOCATOR
|
||||
see _lf_pinbox_get_pins() and _lf_pinbox_put_pins()
|
||||
*/
|
||||
#define _lf_alloc_free(PINS, PTR) _lf_pinbox_free((PINS), (PTR))
|
||||
#define lf_alloc_free(PINS, PTR) lf_pinbox_free((PINS), (PTR))
|
||||
#define _lf_alloc_get_pins(A) _lf_pinbox_get_pins(&(A)->pinbox)
|
||||
#define lf_alloc_get_pins(A) lf_pinbox_get_pins(&(A)->pinbox)
|
||||
#define _lf_alloc_put_pins(PINS) _lf_pinbox_put_pins(PINS)
|
||||
#define lf_alloc_put_pins(PINS) lf_pinbox_put_pins(PINS)
|
||||
#define lf_alloc_direct_free(ALLOC, ADDR) my_free((uchar*)(ADDR), MYF(0))
|
||||
|
||||
lock_wrap(lf_alloc_new, void *,
|
||||
(LF_PINS *pins),
|
||||
(pins),
|
||||
&pins->pinbox->pinarray.lock)
|
||||
|
||||
C_MODE_END
|
||||
|
||||
/*
|
||||
extendible hash, lf_hash.c
|
||||
*/
|
||||
#include <hash.h>
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#define LF_HASH_UNIQUE 1
|
||||
|
||||
/* lf_hash overhead per element (that is, sizeof(LF_SLIST) */
|
||||
extern const int LF_HASH_OVERHEAD;
|
||||
|
||||
typedef struct {
|
||||
LF_DYNARRAY array; /* hash itself */
|
||||
LF_ALLOCATOR alloc; /* allocator for elements */
|
||||
my_hash_get_key get_key; /* see HASH */
|
||||
CHARSET_INFO *charset; /* see HASH */
|
||||
uint key_offset, key_length; /* see HASH */
|
||||
uint element_size; /* size of memcpy'ed area on insert */
|
||||
uint flags; /* LF_HASH_UNIQUE, etc */
|
||||
int32 volatile size; /* size of array */
|
||||
int32 volatile count; /* number of elements in the hash */
|
||||
} LF_HASH;
|
||||
|
||||
void lf_hash_init(LF_HASH *hash, uint element_size, uint flags,
|
||||
uint key_offset, uint key_length, my_hash_get_key get_key,
|
||||
CHARSET_INFO *charset);
|
||||
void lf_hash_destroy(LF_HASH *hash);
|
||||
int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data);
|
||||
void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen);
|
||||
int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen);
|
||||
/*
|
||||
shortcut macros to access underlying pinbox functions from an LF_HASH
|
||||
see _lf_pinbox_get_pins() and _lf_pinbox_put_pins()
|
||||
*/
|
||||
#define _lf_hash_get_pins(HASH) _lf_alloc_get_pins(&(HASH)->alloc)
|
||||
#define lf_hash_get_pins(HASH) lf_alloc_get_pins(&(HASH)->alloc)
|
||||
#define _lf_hash_put_pins(PINS) _lf_pinbox_put_pins(PINS)
|
||||
#define lf_hash_put_pins(PINS) lf_pinbox_put_pins(PINS)
|
||||
#define lf_hash_search_unpin(PINS) lf_unpin((PINS), 2)
|
||||
/*
|
||||
cleanup
|
||||
*/
|
||||
|
||||
#undef lock_wrap_void
|
||||
#undef lock_wrap
|
||||
#undef nolock_wrap_void
|
||||
#undef nolock_wrap
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif
|
||||
|
|
@ -33,15 +33,15 @@ extern ulong my_time_to_wait_for_lock;
|
|||
#define ALARM_INIT my_have_got_alarm=0 ; \
|
||||
alarm_old=(uint) alarm(MY_HOW_OFTEN_TO_ALARM); \
|
||||
alarm_signal=signal(SIGALRM,my_set_alarm_variable);
|
||||
#define ALARM_END VOID(signal(SIGALRM,alarm_signal)); \
|
||||
VOID(alarm(alarm_old));
|
||||
#define ALARM_END (void) signal(SIGALRM,alarm_signal); \
|
||||
(void) alarm(alarm_old);
|
||||
#define ALARM_TEST my_have_got_alarm
|
||||
#ifdef DONT_REMEMBER_SIGNAL
|
||||
#define ALARM_REINIT VOID(alarm(MY_HOW_OFTEN_TO_ALARM)); \
|
||||
VOID(signal(SIGALRM,my_set_alarm_variable));\
|
||||
#define ALARM_REINIT (void) alarm(MY_HOW_OFTEN_TO_ALARM); \
|
||||
(void) signal(SIGALRM,my_set_alarm_variable);\
|
||||
my_have_got_alarm=0;
|
||||
#else
|
||||
#define ALARM_REINIT VOID(alarm((uint) MY_HOW_OFTEN_TO_ALARM)); \
|
||||
#define ALARM_REINIT (void) alarm((uint) MY_HOW_OFTEN_TO_ALARM); \
|
||||
my_have_got_alarm=0;
|
||||
#endif /* DONT_REMEMBER_SIGNAL */
|
||||
#else
|
||||
|
|
|
@ -542,17 +542,6 @@ extern "C" int madvise(void *addr, size_t len, int behav);
|
|||
#define DONT_REMEMBER_SIGNAL
|
||||
#endif
|
||||
|
||||
/* Define void to stop lint from generating "null effekt" comments */
|
||||
#ifndef DONT_DEFINE_VOID
|
||||
#ifdef _lint
|
||||
int __void__;
|
||||
#define VOID(X) (__void__ = (int) (X))
|
||||
#else
|
||||
#undef VOID
|
||||
#define VOID(X) (X)
|
||||
#endif
|
||||
#endif /* DONT_DEFINE_VOID */
|
||||
|
||||
#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
|
||||
#define LINT_INIT(var) var=0 /* No uninitialize-warning */
|
||||
#else
|
||||
|
|
|
@ -35,7 +35,6 @@ typedef DWORD pthread_t;
|
|||
typedef struct thread_attr {
|
||||
DWORD dwStackSize ;
|
||||
DWORD dwCreatingFlag ;
|
||||
int priority ;
|
||||
} pthread_attr_t ;
|
||||
|
||||
typedef struct { int dummy; } pthread_condattr_t;
|
||||
|
@ -110,7 +109,6 @@ int pthread_cond_broadcast(pthread_cond_t *cond);
|
|||
int pthread_cond_destroy(pthread_cond_t *cond);
|
||||
int pthread_attr_init(pthread_attr_t *connect_att);
|
||||
int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
|
||||
int pthread_attr_setprio(pthread_attr_t *connect_att,int priority);
|
||||
int pthread_attr_destroy(pthread_attr_t *connect_att);
|
||||
struct tm *localtime_r(const time_t *timep,struct tm *tmp);
|
||||
struct tm *gmtime_r(const time_t *timep,struct tm *tmp);
|
||||
|
@ -141,19 +139,19 @@ int pthread_join(pthread_t thread, void **value_ptr);
|
|||
#define pthread_mutex_trylock(A) win_pthread_mutex_trylock((A))
|
||||
#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
|
||||
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
|
||||
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
|
||||
#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
|
||||
|
||||
|
||||
/* Dummy defines for easier code */
|
||||
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
|
||||
#define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B)
|
||||
#define pthread_attr_setscope(A,B)
|
||||
#define pthread_detach_this_thread()
|
||||
#define pthread_condattr_init(A)
|
||||
#define pthread_condattr_destroy(A)
|
||||
#define pthread_yield() SwitchToThread()
|
||||
|
||||
#define my_pthread_getprio(thread_id) pthread_dummy(0)
|
||||
/* per the platform's documentation */
|
||||
#define pthread_yield() Sleep(0)
|
||||
|
||||
#else /* Normal threads */
|
||||
|
||||
|
@ -181,8 +179,6 @@ void my_pthread_exit(void *status);
|
|||
#define pthread_exit(A) my_pthread_exit(A)
|
||||
#endif
|
||||
|
||||
extern int my_pthread_getprio(pthread_t thread_id);
|
||||
|
||||
#define pthread_key(T,V) pthread_key_t V
|
||||
#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,(V))
|
||||
#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,(void*) (V))
|
||||
|
@ -254,32 +250,6 @@ int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
|
|||
#define my_sigset(A,B) signal((A),(B))
|
||||
#endif
|
||||
|
||||
#ifndef my_pthread_setprio
|
||||
#if defined(HAVE_PTHREAD_SETPRIO_NP) /* FSU threads */
|
||||
#define my_pthread_setprio(A,B) pthread_setprio_np((A),(B))
|
||||
#elif defined(HAVE_PTHREAD_SETPRIO)
|
||||
#define my_pthread_setprio(A,B) pthread_setprio((A),(B))
|
||||
#elif defined(HAVE_PTHREAD_SETSCHEDPRIO) && !defined (__GNUC__)
|
||||
/*
|
||||
Workaround for bug on Solaris where pthread.h have bug in GNU
|
||||
version of pthread.h => configure says yes, header files says
|
||||
no. So not used with gcc and issue is Solaris only, so will
|
||||
be used on Solaris using SunStudio.
|
||||
*/
|
||||
#define my_pthread_setprio(A,B) pthread_setschedprio((A),(B))
|
||||
#else
|
||||
extern void my_pthread_setprio(pthread_t thread_id,int prior);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef my_pthread_attr_setprio
|
||||
#ifdef HAVE_PTHREAD_ATTR_SETPRIO
|
||||
#define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B))
|
||||
#else
|
||||
extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_PTHREAD_ATTR_SETSCOPE) || defined(HAVE_DEC_3_2_THREADS)
|
||||
#define pthread_attr_setscope(A,B)
|
||||
#undef HAVE_GETHOSTBYADDR_R /* No definition */
|
||||
|
@ -385,6 +355,17 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size);
|
|||
int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_PTHREAD_YIELD_ONE_ARG) && !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
|
||||
/* no pthread_yield() available */
|
||||
#ifdef HAVE_SCHED_YIELD
|
||||
#define pthread_yield() sched_yield()
|
||||
#elif defined(HAVE_PTHREAD_YIELD_NP) /* can be Mac OS X */
|
||||
#define pthread_yield() pthread_yield_np()
|
||||
#elif defined(HAVE_THR_YIELD)
|
||||
#define pthread_yield() thr_yield()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
The defines set_timespec and set_timespec_nsec should be used
|
||||
for calculating an absolute time at which
|
||||
|
@ -663,6 +644,7 @@ struct st_my_thread_var
|
|||
my_bool init;
|
||||
struct st_my_thread_var *next,**prev;
|
||||
void *opt_info;
|
||||
void *stack_ends_here;
|
||||
#ifndef DBUG_OFF
|
||||
void *dbug;
|
||||
char name[THREAD_NAME_SIZE+1];
|
||||
|
|
129
include/my_rdtsc.h
Normal file
129
include/my_rdtsc.h
Normal file
|
@ -0,0 +1,129 @@
|
|||
/* Copyright (C) 2008, 2009 Sun Microsystems, Inc
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/*
|
||||
rdtsc3 -- multi-platform timer code
|
||||
pgulutzan@mysql.com, 2005-08-29
|
||||
modified 2008-11-02
|
||||
*/
|
||||
|
||||
#ifndef MY_RDTSC_H
|
||||
#define MY_RDTSC_H
|
||||
|
||||
/**
|
||||
Characteristics of a timer.
|
||||
*/
|
||||
struct my_timer_unit_info
|
||||
{
|
||||
/** Routine used for the timer. */
|
||||
ulonglong routine;
|
||||
/** Overhead of the timer. */
|
||||
ulonglong overhead;
|
||||
/** Frequency of the timer. */
|
||||
ulonglong frequency;
|
||||
/** Resolution of the timer. */
|
||||
ulonglong resolution;
|
||||
};
|
||||
|
||||
/**
|
||||
Characteristics of all the supported timers.
|
||||
@sa my_timer_init().
|
||||
*/
|
||||
struct my_timer_info
|
||||
{
|
||||
/** Characteristics of the cycle timer. */
|
||||
struct my_timer_unit_info cycles;
|
||||
/** Characteristics of the nanosecond timer. */
|
||||
struct my_timer_unit_info nanoseconds;
|
||||
/** Characteristics of the microsecond timer. */
|
||||
struct my_timer_unit_info microseconds;
|
||||
/** Characteristics of the millisecond timer. */
|
||||
struct my_timer_unit_info milliseconds;
|
||||
/** Characteristics of the tick timer. */
|
||||
struct my_timer_unit_info ticks;
|
||||
};
|
||||
|
||||
typedef struct my_timer_info MY_TIMER_INFO;
|
||||
|
||||
C_MODE_START
|
||||
|
||||
/**
|
||||
A cycle timer.
|
||||
@return the current timer value, in cycles.
|
||||
*/
|
||||
ulonglong my_timer_cycles(void);
|
||||
|
||||
/**
|
||||
A namoseconds timer.
|
||||
@return the current timer value, in nanoseconds.
|
||||
*/
|
||||
ulonglong my_timer_nanoseconds(void);
|
||||
|
||||
/**
|
||||
A microseconds timer.
|
||||
@return the current timer value, in microseconds.
|
||||
*/
|
||||
ulonglong my_timer_microseconds(void);
|
||||
|
||||
/**
|
||||
A millisecond timer.
|
||||
@return the current timer value, in milliseconds.
|
||||
*/
|
||||
ulonglong my_timer_milliseconds(void);
|
||||
|
||||
/**
|
||||
A ticks timer.
|
||||
@return the current timer value, in ticks.
|
||||
*/
|
||||
ulonglong my_timer_ticks(void);
|
||||
|
||||
/**
|
||||
Timer initialization function.
|
||||
@param [out] mti the timer characteristics.
|
||||
*/
|
||||
void my_timer_init(MY_TIMER_INFO *mti);
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#define MY_TIMER_ROUTINE_ASM_X86 1
|
||||
#define MY_TIMER_ROUTINE_ASM_X86_64 2
|
||||
#define MY_TIMER_ROUTINE_RDTSCLL 3
|
||||
#define MY_TIMER_ROUTINE_ASM_X86_WIN 4
|
||||
#define MY_TIMER_ROUTINE_RDTSC 5
|
||||
#define MY_TIMER_ROUTINE_ASM_IA64 6
|
||||
#define MY_TIMER_ROUTINE_ASM_PPC 7
|
||||
#define MY_TIMER_ROUTINE_SGI_CYCLE 8
|
||||
#define MY_TIMER_ROUTINE_GETHRTIME 9
|
||||
#define MY_TIMER_ROUTINE_READ_REAL_TIME 10
|
||||
#define MY_TIMER_ROUTINE_CLOCK_GETTIME 11
|
||||
#define MY_TIMER_ROUTINE_NXGETTIME 12
|
||||
#define MY_TIMER_ROUTINE_GETTIMEOFDAY 13
|
||||
#define MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER 14
|
||||
#define MY_TIMER_ROUTINE_GETTICKCOUNT 15
|
||||
#define MY_TIMER_ROUTINE_TIME 16
|
||||
#define MY_TIMER_ROUTINE_TIMES 17
|
||||
#define MY_TIMER_ROUTINE_FTIME 18
|
||||
#define MY_TIMER_ROUTINE_ASM_PPC64 19
|
||||
#define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64 20
|
||||
#define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32 21
|
||||
#define MY_TIMER_ROUTINE_ASM_SUNPRO_I386 22
|
||||
#define MY_TIMER_ROUTINE_ASM_GCC_SPARC64 23
|
||||
#define MY_TIMER_ROUTINE_ASM_GCC_SPARC32 24
|
||||
#define MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME 25
|
||||
#define MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME 26
|
||||
#define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64 27
|
||||
|
||||
#endif
|
||||
|
|
@ -86,6 +86,7 @@ my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port);
|
|||
void vio_in_addr(Vio *vio, struct in_addr *in);
|
||||
my_bool vio_poll_read(Vio *vio, uint timeout);
|
||||
my_bool vio_is_connected(Vio *vio);
|
||||
ssize_t vio_pending(Vio *vio);
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
#include <openssl/opensslv.h>
|
||||
|
|
|
@ -556,7 +556,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename)
|
|||
if ((*options->local_infile_init)(&li_ptr, net_filename,
|
||||
options->local_infile_userdata))
|
||||
{
|
||||
VOID(my_net_write(net,(const uchar*) "",0)); /* Server needs one packet */
|
||||
(void) my_net_write(net,(const uchar*) "",0); /* Server needs one packet */
|
||||
net_flush(net);
|
||||
strmov(net->sqlstate, unknown_sqlstate);
|
||||
net->last_errno=
|
||||
|
|
|
@ -86,6 +86,26 @@ select 1;
|
|||
1
|
||||
1
|
||||
unlock tables;
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
lock table t1 read;
|
||||
drop table t2;
|
||||
ERROR HY000: Table 't2' was not locked with LOCK TABLES
|
||||
drop table t1;
|
||||
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
|
||||
unlock tables;
|
||||
drop table t1,t2;
|
||||
create table t1 (i int);
|
||||
create table t2 (i int);
|
||||
lock tables t1 read;
|
||||
lock tables t2 read;
|
||||
drop table t1;
|
||||
ERROR HY000: Table 't1' was not locked with LOCK TABLES
|
||||
drop table t1,t2;
|
||||
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
|
||||
unlock tables;
|
||||
drop table t1,t2;
|
||||
End of 5.0 tests
|
||||
create database mysql_test;
|
||||
create table mysql_test.t1(f1 int);
|
||||
|
|
|
@ -55,6 +55,42 @@ Error 1054 Unknown column 'b' in 'field list'
|
|||
INSERT INTO t1 SELECT b FROM t1;
|
||||
ERROR 42S22: Unknown column 'b' in 'field list'
|
||||
DROP TABLE t1;
|
||||
flush status;
|
||||
drop table if exists t1, t2;
|
||||
create table t1 (a int unique);
|
||||
create table t2 (a int);
|
||||
drop function if exists f1;
|
||||
Warnings:
|
||||
Note 1305 FUNCTION f1 does not exist
|
||||
drop function if exists f2;
|
||||
Warnings:
|
||||
Note 1305 FUNCTION f2 does not exist
|
||||
create function f1() returns int
|
||||
begin
|
||||
insert into t1 (a) values (1);
|
||||
insert into t1 (a) values (1);
|
||||
return 1;
|
||||
end|
|
||||
create function f2() returns int
|
||||
begin
|
||||
insert into t2 (a) values (1);
|
||||
return 2;
|
||||
end|
|
||||
flush status;
|
||||
select f1(), f2();
|
||||
ERROR 23000: Duplicate entry '1' for key 'a'
|
||||
show status like 'Com_insert';
|
||||
Variable_name Value
|
||||
Com_insert 2
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
select * from t2;
|
||||
a
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop function f1;
|
||||
drop function f2;
|
||||
SET NAMES utf8;
|
||||
SET sql_quote_show_create= _binary x'5452C39C45';
|
||||
ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'TR\xC3\x9CE'
|
||||
|
|
|
@ -107,8 +107,9 @@ SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2
|
|||
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;
|
||||
drop table t2;
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
bug_id mediumint(9) NOT NULL auto_increment,
|
||||
groupset bigint(20) DEFAULT '0' NOT NULL,
|
||||
|
|
|
@ -122,5 +122,6 @@ a b
|
|||
connection: default
|
||||
select * from t1;
|
||||
a b
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
set low_priority_updates=default;
|
||||
|
|
|
@ -48,6 +48,9 @@ unlock tables;
|
|||
lock tables t1 write, t1 as t1_alias read;
|
||||
insert into t1 select index1,nr from t1 as t1_alias;
|
||||
drop table t1,t2;
|
||||
ERROR HY000: Table 't2' was not locked with LOCK TABLES
|
||||
unlock tables;
|
||||
drop table t1,t2;
|
||||
create table t1 (c1 int);
|
||||
create table t2 (c1 int);
|
||||
create table t3 (c1 int);
|
||||
|
@ -69,6 +72,9 @@ ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
|
|||
delete t2 from t1,t2 where t1.a=t2.a;
|
||||
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
|
||||
drop table t1,t2;
|
||||
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
|
||||
unlock tables;
|
||||
drop table t2,t1;
|
||||
End of 4.1 tests.
|
||||
drop table if exists t1;
|
||||
create table t1 (a int);
|
||||
|
|
|
@ -27,6 +27,7 @@ update t1,t2 set c=a where b=d;
|
|||
select c from t2;
|
||||
c
|
||||
2
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
create table t1 (a int);
|
||||
|
@ -209,3 +210,12 @@ select @tlwa < @tlwb;
|
|||
@tlwa < @tlwb
|
||||
1
|
||||
End of 5.1 tests
|
||||
drop table if exists t1;
|
||||
create table t1 (i int);
|
||||
connection: default
|
||||
lock tables t1 write;
|
||||
connection: flush
|
||||
flush tables with read lock;;
|
||||
connection: default
|
||||
flush tables;
|
||||
drop table t1;
|
||||
|
|
|
@ -529,6 +529,7 @@ select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
|
|||
a a b
|
||||
1 1 1
|
||||
2 2 1
|
||||
unlock tables;
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (c1 varchar(250) NOT NULL);
|
||||
CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
|
||||
|
@ -542,6 +543,7 @@ INSERT INTO t2 VALUES ('test000001'), ('test000005');
|
|||
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
|
||||
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
|
||||
t1c1 t2c1
|
||||
UNLOCK TABLES;
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM;
|
||||
Got one of the listed errors
|
||||
|
|
|
@ -93,6 +93,7 @@ a
|
|||
3
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
UNLOCK TABLES;
|
||||
drop table t1;
|
||||
flush query cache;
|
||||
reset query cache;
|
||||
|
|
|
@ -1659,6 +1659,29 @@ begin
|
|||
declare continue handler for sqlstate '00000' set @x=0;
|
||||
end$$
|
||||
ERROR 42000: Bad SQLSTATE: '00000'
|
||||
drop procedure if exists proc_36510;
|
||||
create procedure proc_36510()
|
||||
begin
|
||||
declare should_be_illegal condition for sqlstate '00123';
|
||||
declare continue handler for should_be_illegal set @x=0;
|
||||
end$$
|
||||
ERROR 42000: Bad SQLSTATE: '00123'
|
||||
create procedure proc_36510()
|
||||
begin
|
||||
declare continue handler for sqlstate '00123' set @x=0;
|
||||
end$$
|
||||
ERROR 42000: Bad SQLSTATE: '00123'
|
||||
create procedure proc_36510()
|
||||
begin
|
||||
declare should_be_illegal condition for 0;
|
||||
declare continue handler for should_be_illegal set @x=0;
|
||||
end$$
|
||||
ERROR HY000: Incorrect CONDITION value: '0'
|
||||
create procedure proc_36510()
|
||||
begin
|
||||
declare continue handler for 0 set @x=0;
|
||||
end$$
|
||||
ERROR HY000: Incorrect CONDITION value: '0'
|
||||
drop procedure if exists p1;
|
||||
set @old_recursion_depth = @@max_sp_recursion_depth;
|
||||
set @@max_sp_recursion_depth = 255;
|
||||
|
|
|
@ -3321,9 +3321,43 @@ call bug11529()|
|
|||
call bug11529()|
|
||||
delete from t1|
|
||||
drop procedure bug11529|
|
||||
set character set utf8|
|
||||
drop procedure if exists bug6063|
|
||||
drop procedure if exists bug7088_1|
|
||||
drop procedure if exists bug7088_2|
|
||||
create procedure bug6063()
|
||||
begin
|
||||
lâbel: begin end;
|
||||
label: begin end;
|
||||
label1: begin end;
|
||||
end|
|
||||
create procedure bug7088_1()
|
||||
label1: begin end label1|
|
||||
create procedure bug7088_2()
|
||||
läbel1: begin end|
|
||||
call bug6063()|
|
||||
call bug7088_1()|
|
||||
call bug7088_2()|
|
||||
set character set default|
|
||||
show create procedure bug6063|
|
||||
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
|
||||
bug6063 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug6063`()
|
||||
begin
|
||||
lâbel: begin end;
|
||||
label: begin end;
|
||||
label1: begin end;
|
||||
end utf8 latin1_swedish_ci latin1_swedish_ci
|
||||
show create procedure bug7088_1|
|
||||
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
|
||||
bug7088_1 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug7088_1`()
|
||||
label1: begin end label1 utf8 latin1_swedish_ci latin1_swedish_ci
|
||||
show create procedure bug7088_2|
|
||||
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
|
||||
bug7088_2 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug7088_2`()
|
||||
läbel1: begin end utf8 latin1_swedish_ci latin1_swedish_ci
|
||||
drop procedure bug6063|
|
||||
drop procedure bug7088_1|
|
||||
drop procedure bug7088_2|
|
||||
drop procedure if exists bug9565_sub|
|
||||
drop procedure if exists bug9565|
|
||||
create procedure bug9565_sub()
|
||||
|
|
|
@ -238,5 +238,11 @@ SELECT 9;
|
|||
9
|
||||
DROP PROCEDURE p1;
|
||||
DROP FUNCTION f1;
|
||||
DROP VIEW IF EXISTS v1;
|
||||
CREATE VIEW v1 AS SELECT VARIABLE_NAME AS NAME, CONVERT(VARIABLE_VALUE, UNSIGNED) AS VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS;
|
||||
SELECT VALUE INTO @tc FROM v1 WHERE NAME = 'Threads_connected';
|
||||
SELECT NAME FROM v1 WHERE NAME = 'Threads_created' AND VALUE < @tc;
|
||||
NAME
|
||||
DROP VIEW v1;
|
||||
set @@global.concurrent_insert= @old_concurrent_insert;
|
||||
SET GLOBAL log_output = @old_log_output;
|
||||
|
|
|
@ -1104,6 +1104,9 @@ select * from t2;
|
|||
ERROR HY000: Table 't2' was not locked with LOCK TABLES
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
|
||||
unlock tables;
|
||||
drop table t1, t2;
|
||||
create table t1 (a int);
|
||||
create view v1 as select * from t1 where a < 2 with check option;
|
||||
insert into v1 values(1);
|
||||
|
|
|
@ -124,6 +124,39 @@ disconnect addconroot1;
|
|||
--source include/wait_until_disconnected.inc
|
||||
connection default;
|
||||
|
||||
#
|
||||
# Bug#25858 Some DROP TABLE under LOCK TABLES can cause deadlocks
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2;
|
||||
--enable_warnings
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
lock table t1 read;
|
||||
--error ER_TABLE_NOT_LOCKED
|
||||
drop table t2;
|
||||
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
|
||||
drop table t1;
|
||||
unlock tables;
|
||||
drop table t1,t2;
|
||||
connect (addconroot, localhost, root,,);
|
||||
connection default;
|
||||
create table t1 (i int);
|
||||
create table t2 (i int);
|
||||
lock tables t1 read;
|
||||
connection addconroot;
|
||||
lock tables t2 read;
|
||||
--error ER_TABLE_NOT_LOCKED
|
||||
drop table t1;
|
||||
connection default;
|
||||
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
|
||||
drop table t1,t2;
|
||||
disconnect addconroot;
|
||||
connection default;
|
||||
unlock tables;
|
||||
drop table t1,t2;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
||||
#
|
||||
|
|
|
@ -68,6 +68,40 @@ INSERT INTO t1 SELECT b FROM t1;
|
|||
DROP TABLE t1;
|
||||
# End of 5.0 tests
|
||||
|
||||
flush status;
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2;
|
||||
--enable_warnings
|
||||
create table t1 (a int unique);
|
||||
create table t2 (a int);
|
||||
drop function if exists f1;
|
||||
drop function if exists f2;
|
||||
|
||||
delimiter |;
|
||||
|
||||
create function f1() returns int
|
||||
begin
|
||||
insert into t1 (a) values (1);
|
||||
insert into t1 (a) values (1);
|
||||
return 1;
|
||||
end|
|
||||
create function f2() returns int
|
||||
begin
|
||||
insert into t2 (a) values (1);
|
||||
return 2;
|
||||
end|
|
||||
delimiter ;|
|
||||
|
||||
flush status;
|
||||
--error 1062
|
||||
select f1(), f2();
|
||||
show status like 'Com_insert';
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop function f1;
|
||||
drop function f2;
|
||||
#
|
||||
# testing the value encoding in the error messages of set_var
|
||||
#
|
||||
|
|
|
@ -120,8 +120,9 @@ SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2
|
|||
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;
|
||||
drop table t2;
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Test of group by bug in bugzilla
|
||||
|
|
|
@ -185,5 +185,6 @@ select * from t1;
|
|||
connection default;
|
||||
disconnect update;
|
||||
disconnect select;
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
set low_priority_updates=default;
|
||||
|
|
|
@ -58,6 +58,9 @@ insert into t1 select index1,nr from t1;
|
|||
unlock tables;
|
||||
lock tables t1 write, t1 as t1_alias read;
|
||||
insert into t1 select index1,nr from t1 as t1_alias;
|
||||
--error ER_TABLE_NOT_LOCKED
|
||||
drop table t1,t2;
|
||||
unlock tables;
|
||||
drop table t1,t2;
|
||||
|
||||
#
|
||||
|
@ -90,7 +93,10 @@ delete t1 from t1,t2 where t1.a=t2.a;
|
|||
delete from t2 using t1,t2 where t1.a=t2.a;
|
||||
--error 1099
|
||||
delete t2 from t1,t2 where t1.a=t2.a;
|
||||
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
|
||||
drop table t1,t2;
|
||||
unlock tables;
|
||||
drop table t2,t1;
|
||||
|
||||
--echo End of 4.1 tests.
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ update t1,t2 set c=a where b=d;
|
|||
connection reader;
|
||||
select c from t2;
|
||||
connection locker;
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
|
||||
|
@ -635,6 +636,41 @@ select @tlwa < @tlwb;
|
|||
|
||||
--echo End of 5.1 tests
|
||||
|
||||
#
|
||||
# Test that DROP TABLES does not wait for a impending FLUSH TABLES
|
||||
# WITH READ LOCK
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (i int);
|
||||
connect (flush,localhost,root,,test,,);
|
||||
connection default;
|
||||
--echo connection: default
|
||||
lock tables t1 write;
|
||||
connection flush;
|
||||
--echo connection: flush
|
||||
--send flush tables with read lock;
|
||||
connection default;
|
||||
--echo connection: default
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Flushing tables";
|
||||
--source include/wait_condition.inc
|
||||
flush tables;
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Flushing tables";
|
||||
--source include/wait_condition.inc
|
||||
drop table t1;
|
||||
let $wait_condition=
|
||||
select count(*) = 0 from information_schema.processlist
|
||||
where state = "Flushing tables";
|
||||
--source include/wait_condition.inc
|
||||
connection flush;
|
||||
--reap
|
||||
connection default;
|
||||
disconnect flush;
|
||||
# Wait till all disconnects are completed
|
||||
--source include/wait_until_count_sessions.inc
|
||||
|
||||
|
|
|
@ -503,6 +503,7 @@ insert into t2 values(2,0);
|
|||
disconnect root;
|
||||
connection default;
|
||||
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
|
||||
unlock tables;
|
||||
drop table t1,t2;
|
||||
#
|
||||
# Full key.
|
||||
|
@ -520,6 +521,7 @@ disconnect con1;
|
|||
connection default;
|
||||
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
|
||||
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
|
||||
UNLOCK TABLES;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
# End of 4.0 tests
|
||||
|
|
|
@ -99,6 +99,7 @@ connection root2;
|
|||
SELECT * FROM t1;
|
||||
connection root;
|
||||
SELECT * FROM t1;
|
||||
UNLOCK TABLES;
|
||||
drop table t1;
|
||||
connection default;
|
||||
disconnect root;
|
||||
|
|
|
@ -2419,6 +2419,43 @@ end$$
|
|||
|
||||
delimiter ;$$
|
||||
|
||||
#
|
||||
# Bug#36510 (Stored Procedures: mysql_error_code 0 should be illegal)
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
drop procedure if exists proc_36510;
|
||||
--enable_warnings
|
||||
|
||||
delimiter $$;
|
||||
|
||||
--error ER_SP_BAD_SQLSTATE
|
||||
create procedure proc_36510()
|
||||
begin
|
||||
declare should_be_illegal condition for sqlstate '00123';
|
||||
declare continue handler for should_be_illegal set @x=0;
|
||||
end$$
|
||||
|
||||
--error ER_SP_BAD_SQLSTATE
|
||||
create procedure proc_36510()
|
||||
begin
|
||||
declare continue handler for sqlstate '00123' set @x=0;
|
||||
end$$
|
||||
|
||||
--error ER_WRONG_VALUE
|
||||
create procedure proc_36510()
|
||||
begin
|
||||
declare should_be_illegal condition for 0;
|
||||
declare continue handler for should_be_illegal set @x=0;
|
||||
end$$
|
||||
|
||||
--error ER_WRONG_VALUE
|
||||
create procedure proc_36510()
|
||||
begin
|
||||
declare continue handler for 0 set @x=0;
|
||||
end$$
|
||||
delimiter ;$$
|
||||
|
||||
#
|
||||
# Bug#15192: "fatal errors" are caught by handlers in stored procedures
|
||||
#
|
||||
|
|
|
@ -4061,34 +4061,41 @@ drop procedure bug11529|
|
|||
# BUG#6063: Stored procedure labels are subject to restrictions (partial)
|
||||
# BUG#7088: Stored procedures: labels won't work if character set is utf8
|
||||
#
|
||||
|
||||
set character set utf8|
|
||||
|
||||
--disable_warnings
|
||||
drop procedure if exists bug6063|
|
||||
drop procedure if exists bug7088_1|
|
||||
drop procedure if exists bug7088_2|
|
||||
--enable_warnings
|
||||
|
||||
--disable_parsing # temporarily disabled until Bar fixes BUG#11986
|
||||
create procedure bug6063()
|
||||
lâbel: begin end|
|
||||
call bug6063()|
|
||||
# QQ Known bug: this will not show the label correctly.
|
||||
show create procedure bug6063|
|
||||
begin
|
||||
lâbel: begin end;
|
||||
label: begin end;
|
||||
label1: begin end;
|
||||
end|
|
||||
|
||||
set character set utf8|
|
||||
create procedure bug7088_1()
|
||||
label1: begin end label1|
|
||||
|
||||
create procedure bug7088_2()
|
||||
läbel1: begin end|
|
||||
|
||||
call bug6063()|
|
||||
call bug7088_1()|
|
||||
call bug7088_2()|
|
||||
|
||||
set character set default|
|
||||
|
||||
show create procedure bug6063|
|
||||
show create procedure bug7088_1|
|
||||
show create procedure bug7088_2|
|
||||
|
||||
drop procedure bug6063|
|
||||
drop procedure bug7088_1|
|
||||
drop procedure bug7088_2|
|
||||
--enable_parsing
|
||||
|
||||
#
|
||||
# BUG#9565: "Wrong locking in stored procedure if a sub-sequent procedure
|
||||
|
|
|
@ -353,6 +353,21 @@ DROP FUNCTION f1;
|
|||
|
||||
# End of 5.1 tests
|
||||
|
||||
#
|
||||
# Bug#17954 Threads_connected > Threads_created
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
DROP VIEW IF EXISTS v1;
|
||||
--enable_warnings
|
||||
|
||||
CREATE VIEW v1 AS SELECT VARIABLE_NAME AS NAME, CONVERT(VARIABLE_VALUE, UNSIGNED) AS VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS;
|
||||
|
||||
SELECT VALUE INTO @tc FROM v1 WHERE NAME = 'Threads_connected';
|
||||
SELECT NAME FROM v1 WHERE NAME = 'Threads_created' AND VALUE < @tc;
|
||||
|
||||
DROP VIEW v1;
|
||||
|
||||
# Restore global concurrent_insert value. Keep in the end of the test file.
|
||||
--connection default
|
||||
set @@global.concurrent_insert= @old_concurrent_insert;
|
||||
|
|
|
@ -1017,6 +1017,9 @@ select * from v1;
|
|||
-- error ER_TABLE_NOT_LOCKED
|
||||
select * from t2;
|
||||
drop view v1;
|
||||
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
|
||||
drop table t1, t2;
|
||||
unlock tables;
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2006 MySQL AB
|
||||
# Copyright (C) 2006 MySQL AB, 2009 Sun Microsystems, Inc
|
||||
#
|
||||
# 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
|
||||
|
@ -39,7 +39,10 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
|
|||
my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c
|
||||
my_winerr.c my_winfile.c my_windac.c my_winthread.c my_write.c ptr_cmp.c queues.c stacktrace.c
|
||||
rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
|
||||
thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c)
|
||||
thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c
|
||||
lf_alloc-pin.c lf_dynarray.c lf_hash.c
|
||||
my_atomic.c my_getncpus.c
|
||||
my_rdtsc.c)
|
||||
|
||||
IF(NOT SOURCE_SUBLIBS)
|
||||
ADD_LIBRARY(mysys ${MYSYS_SOURCES})
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
MYSQLDATAdir = $(localstatedir)
|
||||
MYSQLSHAREdir = $(pkgdatadir)
|
||||
MYSQLBASEdir= $(prefix)
|
||||
INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
|
||||
INCLUDES = @ZLIB_INCLUDES@ @RDTSC_SPARC_ASSEMBLY@ \
|
||||
-I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/include -I$(srcdir)
|
||||
pkglib_LIBRARIES = libmysys.a
|
||||
LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug/libdbug.a
|
||||
|
@ -30,7 +31,8 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
|
|||
mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \
|
||||
my_malloc.c my_realloc.c my_once.c mulalloc.c \
|
||||
my_alloc.c safemalloc.c my_new.cc \
|
||||
my_vle.c my_atomic.c \
|
||||
my_vle.c my_atomic.c lf_hash.c \
|
||||
lf_dynarray.c lf_alloc-pin.c \
|
||||
my_fopen.c my_fstream.c my_getsystime.c \
|
||||
my_error.c errors.c my_div.c my_messnc.c \
|
||||
mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \
|
||||
|
@ -52,7 +54,8 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
|
|||
my_gethostbyname.c rijndael.c my_aes.c sha1.c \
|
||||
my_handler.c my_netware.c my_largepage.c \
|
||||
my_memmem.c stacktrace.c \
|
||||
my_windac.c my_access.c base64.c my_libwrap.c
|
||||
my_windac.c my_access.c base64.c my_libwrap.c \
|
||||
my_rdtsc.c
|
||||
|
||||
if NEED_THREAD
|
||||
# mf_keycache is used only in the server, so it is safe to leave the file
|
||||
|
@ -64,7 +67,9 @@ endif
|
|||
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
|
||||
thr_mutex.c thr_rwlock.c \
|
||||
CMakeLists.txt mf_soundex.c \
|
||||
my_conio.c my_wincond.c my_winthread.c my_winerr.c my_winfile.c
|
||||
my_conio.c my_wincond.c my_winthread.c my_winerr.c \
|
||||
my_winfile.c \
|
||||
my_timer_cycles.il
|
||||
libmysys_a_LIBADD = @THREAD_LOBJECTS@
|
||||
# test_dir_DEPENDENCIES= $(LIBRARIES)
|
||||
# testhash_DEPENDENCIES= $(LIBRARIES)
|
||||
|
|
|
@ -104,7 +104,7 @@ void wait_for_free_space(const char *filename, int errors)
|
|||
MYF(ME_BELL | ME_NOREFRESH),
|
||||
MY_WAIT_FOR_USER_TO_FIX_PANIC,
|
||||
MY_WAIT_GIVE_USER_A_MESSAGE * MY_WAIT_FOR_USER_TO_FIX_PANIC );
|
||||
VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
|
||||
(void) sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC);
|
||||
}
|
||||
|
||||
const char **get_global_errmsgs()
|
||||
|
|
|
@ -541,7 +541,7 @@ my_bool my_hash_delete(HASH *hash, uchar *record)
|
|||
pos->next=empty_index;
|
||||
|
||||
exit:
|
||||
VOID(pop_dynamic(&hash->array));
|
||||
(void) pop_dynamic(&hash->array);
|
||||
if (hash->free)
|
||||
(*hash->free)((uchar*) record);
|
||||
DBUG_RETURN(0);
|
||||
|
|
534
mysys/lf_alloc-pin.c
Normal file
534
mysys/lf_alloc-pin.c
Normal file
|
@ -0,0 +1,534 @@
|
|||
/* QQ: TODO multi-pinbox */
|
||||
/* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/*
|
||||
wait-free concurrent allocator based on pinning addresses
|
||||
|
||||
It works as follows: every thread (strictly speaking - every CPU, but
|
||||
it's too difficult to do) has a small array of pointers. They're called
|
||||
"pins". Before using an object its address must be stored in this array
|
||||
(pinned). When an object is no longer necessary its address must be
|
||||
removed from this array (unpinned). When a thread wants to free() an
|
||||
object it scans all pins of all threads to see if somebody has this
|
||||
object pinned. If yes - the object is not freed (but stored in a
|
||||
"purgatory"). To reduce the cost of a single free() pins are not scanned
|
||||
on every free() but only added to (thread-local) purgatory. On every
|
||||
LF_PURGATORY_SIZE free() purgatory is scanned and all unpinned objects
|
||||
are freed.
|
||||
|
||||
Pins are used to solve ABA problem. To use pins one must obey
|
||||
a pinning protocol:
|
||||
|
||||
1. Let's assume that PTR is a shared pointer to an object. Shared means
|
||||
that any thread may modify it anytime to point to a different object
|
||||
and free the old object. Later the freed object may be potentially
|
||||
allocated by another thread. If we're unlucky that other thread may
|
||||
set PTR to point to this object again. This is ABA problem.
|
||||
2. Create a local pointer LOCAL_PTR.
|
||||
3. Pin the PTR in a loop:
|
||||
do
|
||||
{
|
||||
LOCAL_PTR= PTR;
|
||||
pin(PTR, PIN_NUMBER);
|
||||
} while (LOCAL_PTR != PTR)
|
||||
4. It is guaranteed that after the loop has ended, LOCAL_PTR
|
||||
points to an object (or NULL, if PTR may be NULL), that
|
||||
will never be freed. It is not guaranteed though
|
||||
that LOCAL_PTR == PTR (as PTR can change any time)
|
||||
5. When done working with the object, remove the pin:
|
||||
unpin(PIN_NUMBER)
|
||||
6. When copying pins (as in the list traversing loop:
|
||||
pin(CUR, 1);
|
||||
while ()
|
||||
{
|
||||
do // standard
|
||||
{ // pinning
|
||||
NEXT=CUR->next; // loop
|
||||
pin(NEXT, 0); // see #3
|
||||
} while (NEXT != CUR->next); // above
|
||||
...
|
||||
...
|
||||
CUR=NEXT;
|
||||
pin(CUR, 1); // copy pin[0] to pin[1]
|
||||
}
|
||||
which keeps CUR address constantly pinned), note than pins may be
|
||||
copied only upwards (!!!), that is pin[N] to pin[M], M > N.
|
||||
7. Don't keep the object pinned longer than necessary - the number of
|
||||
pins you have is limited (and small), keeping an object pinned
|
||||
prevents its reuse and cause unnecessary mallocs.
|
||||
|
||||
Explanations:
|
||||
|
||||
3. The loop is important. The following can occur:
|
||||
thread1> LOCAL_PTR= PTR
|
||||
thread2> free(PTR); PTR=0;
|
||||
thread1> pin(PTR, PIN_NUMBER);
|
||||
now thread1 cannot access LOCAL_PTR, even if it's pinned,
|
||||
because it points to a freed memory. That is, it *must*
|
||||
verify that it has indeed pinned PTR, the shared pointer.
|
||||
|
||||
6. When a thread wants to free some LOCAL_PTR, and it scans
|
||||
all lists of pins to see whether it's pinned, it does it
|
||||
upwards, from low pin numbers to high. Thus another thread
|
||||
must copy an address from one pin to another in the same
|
||||
direction - upwards, otherwise the scanning thread may
|
||||
miss it.
|
||||
|
||||
Implementation details:
|
||||
|
||||
Pins are given away from a "pinbox". Pinbox is stack-based allocator.
|
||||
It used dynarray for storing pins, new elements are allocated by dynarray
|
||||
as necessary, old are pushed in the stack for reuse. ABA is solved by
|
||||
versioning a pointer - because we use an array, a pointer to pins is 16 bit,
|
||||
upper 16 bits are used for a version.
|
||||
|
||||
It is assumed that pins belong to a THD and are not transferable
|
||||
between THD's (LF_PINS::stack_ends_here being a primary reason
|
||||
for this limitation).
|
||||
*/
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include <lf.h>
|
||||
|
||||
#define LF_PINBOX_MAX_PINS 65536
|
||||
|
||||
static void _lf_pinbox_real_free(LF_PINS *pins);
|
||||
|
||||
/*
|
||||
Initialize a pinbox. Normally called from lf_alloc_init.
|
||||
See the latter for details.
|
||||
*/
|
||||
void lf_pinbox_init(LF_PINBOX *pinbox, uint free_ptr_offset,
|
||||
lf_pinbox_free_func *free_func, void *free_func_arg)
|
||||
{
|
||||
DBUG_ASSERT(free_ptr_offset % sizeof(void *) == 0);
|
||||
compile_time_assert(sizeof(LF_PINS) == 64);
|
||||
lf_dynarray_init(&pinbox->pinarray, sizeof(LF_PINS));
|
||||
pinbox->pinstack_top_ver= 0;
|
||||
pinbox->pins_in_array= 0;
|
||||
pinbox->free_ptr_offset= free_ptr_offset;
|
||||
pinbox->free_func= free_func;
|
||||
pinbox->free_func_arg= free_func_arg;
|
||||
}
|
||||
|
||||
void lf_pinbox_destroy(LF_PINBOX *pinbox)
|
||||
{
|
||||
lf_dynarray_destroy(&pinbox->pinarray);
|
||||
}
|
||||
|
||||
/*
|
||||
Get pins from a pinbox. Usually called via lf_alloc_get_pins() or
|
||||
lf_hash_get_pins().
|
||||
|
||||
SYNOPSYS
|
||||
pinbox -
|
||||
|
||||
DESCRIPTION
|
||||
get a new LF_PINS structure from a stack of unused pins,
|
||||
or allocate a new one out of dynarray.
|
||||
|
||||
NOTE
|
||||
It is assumed that pins belong to a thread and are not transferable
|
||||
between threads.
|
||||
*/
|
||||
LF_PINS *_lf_pinbox_get_pins(LF_PINBOX *pinbox)
|
||||
{
|
||||
uint32 pins, next, top_ver;
|
||||
LF_PINS *el;
|
||||
/*
|
||||
We have an array of max. 64k elements.
|
||||
The highest index currently allocated is pinbox->pins_in_array.
|
||||
Freed elements are in a lifo stack, pinstack_top_ver.
|
||||
pinstack_top_ver is 32 bits; 16 low bits are the index in the
|
||||
array, to the first element of the list. 16 high bits are a version
|
||||
(every time the 16 low bits are updated, the 16 high bits are
|
||||
incremented). Versioniong prevents the ABA problem.
|
||||
*/
|
||||
top_ver= pinbox->pinstack_top_ver;
|
||||
do
|
||||
{
|
||||
if (!(pins= top_ver % LF_PINBOX_MAX_PINS))
|
||||
{
|
||||
/* the stack of free elements is empty */
|
||||
pins= my_atomic_add32((int32 volatile*) &pinbox->pins_in_array, 1)+1;
|
||||
if (unlikely(pins >= LF_PINBOX_MAX_PINS))
|
||||
return 0;
|
||||
/*
|
||||
note that the first allocated element has index 1 (pins==1).
|
||||
index 0 is reserved to mean "NULL pointer"
|
||||
*/
|
||||
el= (LF_PINS *)_lf_dynarray_lvalue(&pinbox->pinarray, pins);
|
||||
if (unlikely(!el))
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
el= (LF_PINS *)_lf_dynarray_value(&pinbox->pinarray, pins);
|
||||
next= el->link;
|
||||
} while (!my_atomic_cas32((int32 volatile*) &pinbox->pinstack_top_ver,
|
||||
(int32*) &top_ver,
|
||||
top_ver-pins+next+LF_PINBOX_MAX_PINS));
|
||||
/*
|
||||
set el->link to the index of el in the dynarray (el->link has two usages:
|
||||
- if element is allocated, it's its own index
|
||||
- if element is free, it's its next element in the free stack
|
||||
*/
|
||||
el->link= pins;
|
||||
el->purgatory_count= 0;
|
||||
el->pinbox= pinbox;
|
||||
el->stack_ends_here= & my_thread_var->stack_ends_here;
|
||||
return el;
|
||||
}
|
||||
|
||||
/*
|
||||
Put pins back to a pinbox. Usually called via lf_alloc_put_pins() or
|
||||
lf_hash_put_pins().
|
||||
|
||||
DESCRIPTION
|
||||
empty the purgatory (XXX deadlock warning below!),
|
||||
push LF_PINS structure to a stack
|
||||
*/
|
||||
void _lf_pinbox_put_pins(LF_PINS *pins)
|
||||
{
|
||||
LF_PINBOX *pinbox= pins->pinbox;
|
||||
uint32 top_ver, nr;
|
||||
nr= pins->link;
|
||||
#ifdef MY_LF_EXTRA_DEBUG
|
||||
{
|
||||
int i;
|
||||
for (i= 0; i < LF_PINBOX_PINS; i++)
|
||||
DBUG_ASSERT(pins->pin[i] == 0);
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
XXX this will deadlock if other threads will wait for
|
||||
the caller to do something after _lf_pinbox_put_pins(),
|
||||
and they would have pinned addresses that the caller wants to free.
|
||||
Thus: only free pins when all work is done and nobody can wait for you!!!
|
||||
*/
|
||||
while (pins->purgatory_count)
|
||||
{
|
||||
_lf_pinbox_real_free(pins);
|
||||
if (pins->purgatory_count)
|
||||
{
|
||||
my_atomic_rwlock_wrunlock(&pins->pinbox->pinarray.lock);
|
||||
pthread_yield();
|
||||
my_atomic_rwlock_wrlock(&pins->pinbox->pinarray.lock);
|
||||
}
|
||||
}
|
||||
top_ver= pinbox->pinstack_top_ver;
|
||||
do
|
||||
{
|
||||
pins->link= top_ver % LF_PINBOX_MAX_PINS;
|
||||
} while (!my_atomic_cas32((int32 volatile*) &pinbox->pinstack_top_ver,
|
||||
(int32*) &top_ver,
|
||||
top_ver-pins->link+nr+LF_PINBOX_MAX_PINS));
|
||||
return;
|
||||
}
|
||||
|
||||
static int ptr_cmp(void **a, void **b)
|
||||
{
|
||||
return *a < *b ? -1 : *a == *b ? 0 : 1;
|
||||
}
|
||||
|
||||
#define add_to_purgatory(PINS, ADDR) \
|
||||
do \
|
||||
{ \
|
||||
*(void **)((char *)(ADDR)+(PINS)->pinbox->free_ptr_offset)= \
|
||||
(PINS)->purgatory; \
|
||||
(PINS)->purgatory= (ADDR); \
|
||||
(PINS)->purgatory_count++; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
Free an object allocated via pinbox allocator
|
||||
|
||||
DESCRIPTION
|
||||
add an object to purgatory. if necessary, call _lf_pinbox_real_free()
|
||||
to actually free something.
|
||||
*/
|
||||
void _lf_pinbox_free(LF_PINS *pins, void *addr)
|
||||
{
|
||||
add_to_purgatory(pins, addr);
|
||||
if (pins->purgatory_count % LF_PURGATORY_SIZE)
|
||||
_lf_pinbox_real_free(pins);
|
||||
}
|
||||
|
||||
struct st_harvester {
|
||||
void **granary;
|
||||
int npins;
|
||||
};
|
||||
|
||||
/*
|
||||
callback for _lf_dynarray_iterate:
|
||||
scan all pins of all threads and accumulate all pins
|
||||
*/
|
||||
static int harvest_pins(LF_PINS *el, struct st_harvester *hv)
|
||||
{
|
||||
int i;
|
||||
LF_PINS *el_end= el+min(hv->npins, LF_DYNARRAY_LEVEL_LENGTH);
|
||||
for (; el < el_end; el++)
|
||||
{
|
||||
for (i= 0; i < LF_PINBOX_PINS; i++)
|
||||
{
|
||||
void *p= el->pin[i];
|
||||
if (p)
|
||||
*hv->granary++= p;
|
||||
}
|
||||
}
|
||||
/*
|
||||
hv->npins may become negative below, but it means that
|
||||
we're on the last dynarray page and harvest_pins() won't be
|
||||
called again. We don't bother to make hv->npins() correct
|
||||
(that is 0) in this case.
|
||||
*/
|
||||
hv->npins-= LF_DYNARRAY_LEVEL_LENGTH;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
callback for _lf_dynarray_iterate:
|
||||
scan all pins of all threads and see if addr is present there
|
||||
*/
|
||||
static int match_pins(LF_PINS *el, void *addr)
|
||||
{
|
||||
int i;
|
||||
LF_PINS *el_end= el+LF_DYNARRAY_LEVEL_LENGTH;
|
||||
for (; el < el_end; el++)
|
||||
for (i= 0; i < LF_PINBOX_PINS; i++)
|
||||
if (el->pin[i] == addr)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if STACK_DIRECTION < 0
|
||||
#define available_stack_size(CUR,END) (long) ((char*)(CUR) - (char*)(END))
|
||||
#else
|
||||
#define available_stack_size(CUR,END) (long) ((char*)(END) - (char*)(CUR))
|
||||
#endif
|
||||
|
||||
#define next_node(P, X) (*((uchar * volatile *)(((uchar *)(X)) + (P)->free_ptr_offset)))
|
||||
#define anext_node(X) next_node(&allocator->pinbox, (X))
|
||||
|
||||
/*
|
||||
Scan the purgatory and free everything that can be freed
|
||||
*/
|
||||
static void _lf_pinbox_real_free(LF_PINS *pins)
|
||||
{
|
||||
int npins, alloca_size;
|
||||
void *list, **addr;
|
||||
void *first, *last= NULL;
|
||||
LF_PINBOX *pinbox= pins->pinbox;
|
||||
|
||||
LINT_INIT(first);
|
||||
npins= pinbox->pins_in_array+1;
|
||||
|
||||
#ifdef HAVE_ALLOCA
|
||||
alloca_size= sizeof(void *)*LF_PINBOX_PINS*npins;
|
||||
/* create a sorted list of pinned addresses, to speed up searches */
|
||||
if (available_stack_size(&pinbox, *pins->stack_ends_here) > alloca_size)
|
||||
{
|
||||
struct st_harvester hv;
|
||||
addr= (void **) alloca(alloca_size);
|
||||
hv.granary= addr;
|
||||
hv.npins= npins;
|
||||
/* scan the dynarray and accumulate all pinned addresses */
|
||||
_lf_dynarray_iterate(&pinbox->pinarray,
|
||||
(lf_dynarray_func)harvest_pins, &hv);
|
||||
|
||||
npins= hv.granary-addr;
|
||||
/* and sort them */
|
||||
if (npins)
|
||||
qsort(addr, npins, sizeof(void *), (qsort_cmp)ptr_cmp);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
addr= 0;
|
||||
|
||||
list= pins->purgatory;
|
||||
pins->purgatory= 0;
|
||||
pins->purgatory_count= 0;
|
||||
while (list)
|
||||
{
|
||||
void *cur= list;
|
||||
list= *(void **)((char *)cur+pinbox->free_ptr_offset);
|
||||
if (npins)
|
||||
{
|
||||
if (addr) /* use binary search */
|
||||
{
|
||||
void **a, **b, **c;
|
||||
for (a= addr, b= addr+npins-1, c= a+(b-a)/2; (b-a) > 1; c= a+(b-a)/2)
|
||||
if (cur == *c)
|
||||
a= b= c;
|
||||
else if (cur > *c)
|
||||
a= c;
|
||||
else
|
||||
b= c;
|
||||
if (cur == *a || cur == *b)
|
||||
goto found;
|
||||
}
|
||||
else /* no alloca - no cookie. linear search here */
|
||||
{
|
||||
if (_lf_dynarray_iterate(&pinbox->pinarray,
|
||||
(lf_dynarray_func)match_pins, cur))
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
/* not pinned - freeing */
|
||||
if (last)
|
||||
last= next_node(pinbox, last)= (uchar *)cur;
|
||||
else
|
||||
first= last= (uchar *)cur;
|
||||
continue;
|
||||
found:
|
||||
/* pinned - keeping */
|
||||
add_to_purgatory(pins, cur);
|
||||
}
|
||||
if (last)
|
||||
pinbox->free_func(first, last, pinbox->free_func_arg);
|
||||
}
|
||||
|
||||
/* lock-free memory allocator for fixed-size objects */
|
||||
|
||||
LF_REQUIRE_PINS(1)
|
||||
|
||||
/*
|
||||
callback for _lf_pinbox_real_free to free a list of unpinned objects -
|
||||
add it back to the allocator stack
|
||||
|
||||
DESCRIPTION
|
||||
'first' and 'last' are the ends of the linked list of nodes:
|
||||
first->el->el->....->el->last. Use first==last to free only one element.
|
||||
*/
|
||||
static void alloc_free(uchar *first,
|
||||
uchar volatile *last,
|
||||
LF_ALLOCATOR *allocator)
|
||||
{
|
||||
/*
|
||||
we need a union here to access type-punned pointer reliably.
|
||||
otherwise gcc -fstrict-aliasing will not see 'tmp' changed in the loop
|
||||
*/
|
||||
union { uchar * node; void *ptr; } tmp;
|
||||
tmp.node= allocator->top;
|
||||
do
|
||||
{
|
||||
anext_node(last)= tmp.node;
|
||||
} while (!my_atomic_casptr((void **)(char *)&allocator->top,
|
||||
(void **)&tmp.ptr, first) && LF_BACKOFF);
|
||||
}
|
||||
|
||||
/*
|
||||
initialize lock-free allocator
|
||||
|
||||
SYNOPSYS
|
||||
allocator -
|
||||
size a size of an object to allocate
|
||||
free_ptr_offset an offset inside the object to a sizeof(void *)
|
||||
memory that is guaranteed to be unused after
|
||||
the object is put in the purgatory. Unused by ANY
|
||||
thread, not only the purgatory owner.
|
||||
This memory will be used to link waiting-to-be-freed
|
||||
objects in a purgatory list.
|
||||
*/
|
||||
void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset)
|
||||
{
|
||||
lf_pinbox_init(&allocator->pinbox, free_ptr_offset,
|
||||
(lf_pinbox_free_func *)alloc_free, allocator);
|
||||
allocator->top= 0;
|
||||
allocator->mallocs= 0;
|
||||
allocator->element_size= size;
|
||||
allocator->constructor= 0;
|
||||
allocator->destructor= 0;
|
||||
DBUG_ASSERT(size >= sizeof(void*) + free_ptr_offset);
|
||||
}
|
||||
|
||||
/*
|
||||
destroy the allocator, free everything that's in it
|
||||
|
||||
NOTE
|
||||
As every other init/destroy function here and elsewhere it
|
||||
is not thread safe. No, this function is no different, ensure
|
||||
that no thread needs the allocator before destroying it.
|
||||
We are not responsible for any damage that may be caused by
|
||||
accessing the allocator when it is being or has been destroyed.
|
||||
Oh yes, and don't put your cat in a microwave.
|
||||
*/
|
||||
void lf_alloc_destroy(LF_ALLOCATOR *allocator)
|
||||
{
|
||||
uchar *node= allocator->top;
|
||||
while (node)
|
||||
{
|
||||
uchar *tmp= anext_node(node);
|
||||
if (allocator->destructor)
|
||||
allocator->destructor(node);
|
||||
my_free((void *)node, MYF(0));
|
||||
node= tmp;
|
||||
}
|
||||
lf_pinbox_destroy(&allocator->pinbox);
|
||||
allocator->top= 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Allocate and return an new object.
|
||||
|
||||
DESCRIPTION
|
||||
Pop an unused object from the stack or malloc it is the stack is empty.
|
||||
pin[0] is used, it's removed on return.
|
||||
*/
|
||||
void *_lf_alloc_new(LF_PINS *pins)
|
||||
{
|
||||
LF_ALLOCATOR *allocator= (LF_ALLOCATOR *)(pins->pinbox->free_func_arg);
|
||||
uchar *node;
|
||||
for (;;)
|
||||
{
|
||||
do
|
||||
{
|
||||
node= allocator->top;
|
||||
_lf_pin(pins, 0, node);
|
||||
} while (node != allocator->top && LF_BACKOFF);
|
||||
if (!node)
|
||||
{
|
||||
node= (void *)my_malloc(allocator->element_size, MYF(MY_WME));
|
||||
if (allocator->constructor)
|
||||
allocator->constructor(node);
|
||||
#ifdef MY_LF_EXTRA_DEBUG
|
||||
if (likely(node != 0))
|
||||
my_atomic_add32(&allocator->mallocs, 1);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
if (my_atomic_casptr((void **)(char *)&allocator->top,
|
||||
(void *)&node, anext_node(node)))
|
||||
break;
|
||||
}
|
||||
_lf_unpin(pins, 0);
|
||||
return node;
|
||||
}
|
||||
|
||||
/*
|
||||
count the number of objects in a pool.
|
||||
|
||||
NOTE
|
||||
This is NOT thread-safe !!!
|
||||
*/
|
||||
uint lf_alloc_pool_count(LF_ALLOCATOR *allocator)
|
||||
{
|
||||
uint i;
|
||||
uchar *node;
|
||||
for (node= allocator->top, i= 0; node; node= anext_node(node), i++)
|
||||
/* no op */;
|
||||
return i;
|
||||
}
|
||||
|
207
mysys/lf_dynarray.c
Normal file
207
mysys/lf_dynarray.c
Normal file
|
@ -0,0 +1,207 @@
|
|||
/* Copyright (C) 2006 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/*
|
||||
Analog of DYNAMIC_ARRAY that never reallocs
|
||||
(so no pointer into the array may ever become invalid).
|
||||
|
||||
Memory is allocated in non-contiguous chunks.
|
||||
This data structure is not space efficient for sparse arrays.
|
||||
|
||||
Every element is aligned to sizeof(element) boundary
|
||||
(to avoid false sharing if element is big enough).
|
||||
|
||||
LF_DYNARRAY is a recursive structure. On the zero level
|
||||
LF_DYNARRAY::level[0] it's an array of LF_DYNARRAY_LEVEL_LENGTH elements,
|
||||
on the first level it's an array of LF_DYNARRAY_LEVEL_LENGTH pointers
|
||||
to arrays of elements, on the second level it's an array of pointers
|
||||
to arrays of pointers to arrays of elements. And so on.
|
||||
|
||||
With four levels the number of elements is limited to 4311810304
|
||||
(but as in all functions index is uint, the real limit is 2^32-1)
|
||||
|
||||
Actually, it's wait-free, not lock-free ;-)
|
||||
*/
|
||||
|
||||
#include <my_global.h>
|
||||
#include <m_string.h>
|
||||
#include <my_sys.h>
|
||||
#include <lf.h>
|
||||
|
||||
void lf_dynarray_init(LF_DYNARRAY *array, uint element_size)
|
||||
{
|
||||
bzero(array, sizeof(*array));
|
||||
array->size_of_element= element_size;
|
||||
my_atomic_rwlock_init(&array->lock);
|
||||
}
|
||||
|
||||
static void recursive_free(void **alloc, int level)
|
||||
{
|
||||
if (!alloc)
|
||||
return;
|
||||
|
||||
if (level)
|
||||
{
|
||||
int i;
|
||||
for (i= 0; i < LF_DYNARRAY_LEVEL_LENGTH; i++)
|
||||
recursive_free(alloc[i], level-1);
|
||||
my_free((void *)alloc, MYF(0));
|
||||
}
|
||||
else
|
||||
my_free(alloc[-1], MYF(0));
|
||||
}
|
||||
|
||||
void lf_dynarray_destroy(LF_DYNARRAY *array)
|
||||
{
|
||||
int i;
|
||||
for (i= 0; i < LF_DYNARRAY_LEVELS; i++)
|
||||
recursive_free(array->level[i], i);
|
||||
my_atomic_rwlock_destroy(&array->lock);
|
||||
}
|
||||
|
||||
static const ulong dynarray_idxes_in_prev_levels[LF_DYNARRAY_LEVELS]=
|
||||
{
|
||||
0, /* +1 here to to avoid -1's below */
|
||||
LF_DYNARRAY_LEVEL_LENGTH,
|
||||
LF_DYNARRAY_LEVEL_LENGTH * LF_DYNARRAY_LEVEL_LENGTH +
|
||||
LF_DYNARRAY_LEVEL_LENGTH,
|
||||
LF_DYNARRAY_LEVEL_LENGTH * LF_DYNARRAY_LEVEL_LENGTH *
|
||||
LF_DYNARRAY_LEVEL_LENGTH + LF_DYNARRAY_LEVEL_LENGTH *
|
||||
LF_DYNARRAY_LEVEL_LENGTH + LF_DYNARRAY_LEVEL_LENGTH
|
||||
};
|
||||
|
||||
static const ulong dynarray_idxes_in_prev_level[LF_DYNARRAY_LEVELS]=
|
||||
{
|
||||
0, /* +1 here to to avoid -1's below */
|
||||
LF_DYNARRAY_LEVEL_LENGTH,
|
||||
LF_DYNARRAY_LEVEL_LENGTH * LF_DYNARRAY_LEVEL_LENGTH,
|
||||
LF_DYNARRAY_LEVEL_LENGTH * LF_DYNARRAY_LEVEL_LENGTH *
|
||||
LF_DYNARRAY_LEVEL_LENGTH,
|
||||
};
|
||||
|
||||
/*
|
||||
Returns a valid lvalue pointer to the element number 'idx'.
|
||||
Allocates memory if necessary.
|
||||
*/
|
||||
void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx)
|
||||
{
|
||||
void * ptr, * volatile * ptr_ptr= 0;
|
||||
int i;
|
||||
|
||||
for (i= LF_DYNARRAY_LEVELS-1; idx < dynarray_idxes_in_prev_levels[i]; i--)
|
||||
/* no-op */;
|
||||
ptr_ptr= &array->level[i];
|
||||
idx-= dynarray_idxes_in_prev_levels[i];
|
||||
for (; i > 0; i--)
|
||||
{
|
||||
if (!(ptr= *ptr_ptr))
|
||||
{
|
||||
void *alloc= my_malloc(LF_DYNARRAY_LEVEL_LENGTH * sizeof(void *),
|
||||
MYF(MY_WME|MY_ZEROFILL));
|
||||
if (unlikely(!alloc))
|
||||
return(NULL);
|
||||
if (my_atomic_casptr(ptr_ptr, &ptr, alloc))
|
||||
ptr= alloc;
|
||||
else
|
||||
my_free(alloc, MYF(0));
|
||||
}
|
||||
ptr_ptr= ((void **)ptr) + idx / dynarray_idxes_in_prev_level[i];
|
||||
idx%= dynarray_idxes_in_prev_level[i];
|
||||
}
|
||||
if (!(ptr= *ptr_ptr))
|
||||
{
|
||||
uchar *alloc, *data;
|
||||
alloc= my_malloc(LF_DYNARRAY_LEVEL_LENGTH * array->size_of_element +
|
||||
max(array->size_of_element, sizeof(void *)),
|
||||
MYF(MY_WME|MY_ZEROFILL));
|
||||
if (unlikely(!alloc))
|
||||
return(NULL);
|
||||
/* reserve the space for free() address */
|
||||
data= alloc + sizeof(void *);
|
||||
{ /* alignment */
|
||||
intptr mod= ((intptr)data) % array->size_of_element;
|
||||
if (mod)
|
||||
data+= array->size_of_element - mod;
|
||||
}
|
||||
((void **)data)[-1]= alloc; /* free() will need the original pointer */
|
||||
if (my_atomic_casptr(ptr_ptr, &ptr, data))
|
||||
ptr= data;
|
||||
else
|
||||
my_free(alloc, MYF(0));
|
||||
}
|
||||
return ((uchar*)ptr) + array->size_of_element * idx;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns a pointer to the element number 'idx'
|
||||
or NULL if an element does not exists
|
||||
*/
|
||||
void *_lf_dynarray_value(LF_DYNARRAY *array, uint idx)
|
||||
{
|
||||
void * ptr, * volatile * ptr_ptr= 0;
|
||||
int i;
|
||||
|
||||
for (i= LF_DYNARRAY_LEVELS-1; idx < dynarray_idxes_in_prev_levels[i]; i--)
|
||||
/* no-op */;
|
||||
ptr_ptr= &array->level[i];
|
||||
idx-= dynarray_idxes_in_prev_levels[i];
|
||||
for (; i > 0; i--)
|
||||
{
|
||||
if (!(ptr= *ptr_ptr))
|
||||
return(NULL);
|
||||
ptr_ptr= ((void **)ptr) + idx / dynarray_idxes_in_prev_level[i];
|
||||
idx %= dynarray_idxes_in_prev_level[i];
|
||||
}
|
||||
if (!(ptr= *ptr_ptr))
|
||||
return(NULL);
|
||||
return ((uchar*)ptr) + array->size_of_element * idx;
|
||||
}
|
||||
|
||||
static int recursive_iterate(LF_DYNARRAY *array, void *ptr, int level,
|
||||
lf_dynarray_func func, void *arg)
|
||||
{
|
||||
int res, i;
|
||||
if (!ptr)
|
||||
return 0;
|
||||
if (!level)
|
||||
return func(ptr, arg);
|
||||
for (i= 0; i < LF_DYNARRAY_LEVEL_LENGTH; i++)
|
||||
if ((res= recursive_iterate(array, ((void **)ptr)[i], level-1, func, arg)))
|
||||
return res;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Calls func(array, arg) on every array of LF_DYNARRAY_LEVEL_LENGTH elements
|
||||
in lf_dynarray.
|
||||
|
||||
DESCRIPTION
|
||||
lf_dynarray consists of a set of arrays, LF_DYNARRAY_LEVEL_LENGTH elements
|
||||
each. _lf_dynarray_iterate() calls user-supplied function on every array
|
||||
from the set. It is the fastest way to scan the array, faster than
|
||||
for (i=0; i < N; i++) { func(_lf_dynarray_value(dynarray, i)); }
|
||||
|
||||
NOTE
|
||||
if func() returns non-zero, the scan is aborted
|
||||
*/
|
||||
int _lf_dynarray_iterate(LF_DYNARRAY *array, lf_dynarray_func func, void *arg)
|
||||
{
|
||||
int i, res;
|
||||
for (i= 0; i < LF_DYNARRAY_LEVELS; i++)
|
||||
if ((res= recursive_iterate(array, array->level[i], i, func, arg)))
|
||||
return res;
|
||||
return 0;
|
||||
}
|
||||
|
505
mysys/lf_hash.c
Normal file
505
mysys/lf_hash.c
Normal file
|
@ -0,0 +1,505 @@
|
|||
/* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/*
|
||||
extensible hash
|
||||
|
||||
TODO
|
||||
try to get rid of dummy nodes ?
|
||||
for non-unique hash, count only _distinct_ values
|
||||
(but how to do it in lf_hash_delete ?)
|
||||
*/
|
||||
#include <my_global.h>
|
||||
#include <m_string.h>
|
||||
#include <my_sys.h>
|
||||
#include <my_bit.h>
|
||||
#include <lf.h>
|
||||
|
||||
LF_REQUIRE_PINS(3)
|
||||
|
||||
/* An element of the list */
|
||||
typedef struct {
|
||||
intptr volatile link; /* a pointer to the next element in a listand a flag */
|
||||
uint32 hashnr; /* reversed hash number, for sorting */
|
||||
const uchar *key;
|
||||
size_t keylen;
|
||||
/*
|
||||
data is stored here, directly after the keylen.
|
||||
thus the pointer to data is (void*)(slist_element_ptr+1)
|
||||
*/
|
||||
} LF_SLIST;
|
||||
|
||||
const int LF_HASH_OVERHEAD= sizeof(LF_SLIST);
|
||||
|
||||
/*
|
||||
a structure to pass the context (pointers two the three successive elements
|
||||
in a list) from lfind to linsert/ldelete
|
||||
*/
|
||||
typedef struct {
|
||||
intptr volatile *prev;
|
||||
LF_SLIST *curr, *next;
|
||||
} CURSOR;
|
||||
|
||||
/*
|
||||
the last bit in LF_SLIST::link is a "deleted" flag.
|
||||
the helper macros below convert it to a pure pointer or a pure flag
|
||||
*/
|
||||
#define PTR(V) (LF_SLIST *)((V) & (~(intptr)1))
|
||||
#define DELETED(V) ((V) & 1)
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
Search for hashnr/key/keylen in the list starting from 'head' and
|
||||
position the cursor. The list is ORDER BY hashnr, key
|
||||
|
||||
RETURN
|
||||
0 - not found
|
||||
1 - found
|
||||
|
||||
NOTE
|
||||
cursor is positioned in either case
|
||||
pins[0..2] are used, they are NOT removed on return
|
||||
*/
|
||||
static int lfind(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
|
||||
const uchar *key, uint keylen, CURSOR *cursor, LF_PINS *pins)
|
||||
{
|
||||
uint32 cur_hashnr;
|
||||
const uchar *cur_key;
|
||||
uint cur_keylen;
|
||||
intptr link;
|
||||
|
||||
retry:
|
||||
cursor->prev= (intptr *)head;
|
||||
do { /* PTR() isn't necessary below, head is a dummy node */
|
||||
cursor->curr= (LF_SLIST *)(*cursor->prev);
|
||||
_lf_pin(pins, 1, cursor->curr);
|
||||
} while (*cursor->prev != (intptr)cursor->curr && LF_BACKOFF);
|
||||
for (;;)
|
||||
{
|
||||
if (unlikely(!cursor->curr))
|
||||
return 0; /* end of the list */
|
||||
do {
|
||||
/* QQ: XXX or goto retry ? */
|
||||
link= cursor->curr->link;
|
||||
cursor->next= PTR(link);
|
||||
_lf_pin(pins, 0, cursor->next);
|
||||
} while (link != cursor->curr->link && LF_BACKOFF);
|
||||
cur_hashnr= cursor->curr->hashnr;
|
||||
cur_key= cursor->curr->key;
|
||||
cur_keylen= cursor->curr->keylen;
|
||||
if (*cursor->prev != (intptr)cursor->curr)
|
||||
{
|
||||
(void)LF_BACKOFF;
|
||||
goto retry;
|
||||
}
|
||||
if (!DELETED(link))
|
||||
{
|
||||
if (cur_hashnr >= hashnr)
|
||||
{
|
||||
int r= 1;
|
||||
if (cur_hashnr > hashnr ||
|
||||
(r= my_strnncoll(cs, (uchar*) cur_key, cur_keylen, (uchar*) key,
|
||||
keylen)) >= 0)
|
||||
return !r;
|
||||
}
|
||||
cursor->prev= &(cursor->curr->link);
|
||||
_lf_pin(pins, 2, cursor->curr);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
we found a deleted node - be nice, help the other thread
|
||||
and remove this deleted node
|
||||
*/
|
||||
if (my_atomic_casptr((void **)cursor->prev,
|
||||
(void **)&cursor->curr, cursor->next))
|
||||
_lf_alloc_free(pins, cursor->curr);
|
||||
else
|
||||
{
|
||||
(void)LF_BACKOFF;
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
cursor->curr= cursor->next;
|
||||
_lf_pin(pins, 1, cursor->curr);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
insert a 'node' in the list that starts from 'head' in the correct
|
||||
position (as found by lfind)
|
||||
|
||||
RETURN
|
||||
0 - inserted
|
||||
not 0 - a pointer to a duplicate (not pinned and thus unusable)
|
||||
|
||||
NOTE
|
||||
it uses pins[0..2], on return all pins are removed.
|
||||
if there're nodes with the same key value, a new node is added before them.
|
||||
*/
|
||||
static LF_SLIST *linsert(LF_SLIST * volatile *head, CHARSET_INFO *cs,
|
||||
LF_SLIST *node, LF_PINS *pins, uint flags)
|
||||
{
|
||||
CURSOR cursor;
|
||||
int res;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (lfind(head, cs, node->hashnr, node->key, node->keylen,
|
||||
&cursor, pins) &&
|
||||
(flags & LF_HASH_UNIQUE))
|
||||
{
|
||||
res= 0; /* duplicate found */
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
node->link= (intptr)cursor.curr;
|
||||
DBUG_ASSERT(node->link != (intptr)node); /* no circular references */
|
||||
DBUG_ASSERT(cursor.prev != &node->link); /* no circular references */
|
||||
if (my_atomic_casptr((void **)cursor.prev, (void **)&cursor.curr, node))
|
||||
{
|
||||
res= 1; /* inserted ok */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_lf_unpin(pins, 0);
|
||||
_lf_unpin(pins, 1);
|
||||
_lf_unpin(pins, 2);
|
||||
/*
|
||||
Note that cursor.curr is not pinned here and the pointer is unreliable,
|
||||
the object may dissapear anytime. But if it points to a dummy node, the
|
||||
pointer is safe, because dummy nodes are never freed - initialize_bucket()
|
||||
uses this fact.
|
||||
*/
|
||||
return res ? 0 : cursor.curr;
|
||||
}
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
deletes a node as identified by hashnr/keey/keylen from the list
|
||||
that starts from 'head'
|
||||
|
||||
RETURN
|
||||
0 - ok
|
||||
1 - not found
|
||||
|
||||
NOTE
|
||||
it uses pins[0..2], on return all pins are removed.
|
||||
*/
|
||||
static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
|
||||
const uchar *key, uint keylen, LF_PINS *pins)
|
||||
{
|
||||
CURSOR cursor;
|
||||
int res;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (!lfind(head, cs, hashnr, key, keylen, &cursor, pins))
|
||||
{
|
||||
res= 1; /* not found */
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* mark the node deleted */
|
||||
if (my_atomic_casptr((void **)&(cursor.curr->link),
|
||||
(void **)&cursor.next,
|
||||
(void *)(((intptr)cursor.next) | 1)))
|
||||
{
|
||||
/* and remove it from the list */
|
||||
if (my_atomic_casptr((void **)cursor.prev,
|
||||
(void **)&cursor.curr, cursor.next))
|
||||
_lf_alloc_free(pins, cursor.curr);
|
||||
else
|
||||
{
|
||||
/*
|
||||
somebody already "helped" us and removed the node ?
|
||||
Let's check if we need to help that someone too!
|
||||
(to ensure the number of "set DELETED flag" actions
|
||||
is equal to the number of "remove from the list" actions)
|
||||
*/
|
||||
lfind(head, cs, hashnr, key, keylen, &cursor, pins);
|
||||
}
|
||||
res= 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_lf_unpin(pins, 0);
|
||||
_lf_unpin(pins, 1);
|
||||
_lf_unpin(pins, 2);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
searches for a node as identified by hashnr/keey/keylen in the list
|
||||
that starts from 'head'
|
||||
|
||||
RETURN
|
||||
0 - not found
|
||||
node - found
|
||||
|
||||
NOTE
|
||||
it uses pins[0..2], on return the pin[2] keeps the node found
|
||||
all other pins are removed.
|
||||
*/
|
||||
static LF_SLIST *lsearch(LF_SLIST * volatile *head, CHARSET_INFO *cs,
|
||||
uint32 hashnr, const uchar *key, uint keylen,
|
||||
LF_PINS *pins)
|
||||
{
|
||||
CURSOR cursor;
|
||||
int res= lfind(head, cs, hashnr, key, keylen, &cursor, pins);
|
||||
if (res)
|
||||
_lf_pin(pins, 2, cursor.curr);
|
||||
_lf_unpin(pins, 0);
|
||||
_lf_unpin(pins, 1);
|
||||
return res ? cursor.curr : 0;
|
||||
}
|
||||
|
||||
static inline const uchar* hash_key(const LF_HASH *hash,
|
||||
const uchar *record, size_t *length)
|
||||
{
|
||||
if (hash->get_key)
|
||||
return (*hash->get_key)(record, length, 0);
|
||||
*length= hash->key_length;
|
||||
return record + hash->key_offset;
|
||||
}
|
||||
|
||||
/*
|
||||
Compute the hash key value from the raw key.
|
||||
|
||||
@note, that the hash value is limited to 2^31, because we need one
|
||||
bit to distinguish between normal and dummy nodes.
|
||||
*/
|
||||
static inline uint calc_hash(LF_HASH *hash, const uchar *key, uint keylen)
|
||||
{
|
||||
ulong nr1= 1, nr2= 4;
|
||||
hash->charset->coll->hash_sort(hash->charset, (uchar*) key, keylen,
|
||||
&nr1, &nr2);
|
||||
return nr1 & INT_MAX32;
|
||||
}
|
||||
|
||||
#define MAX_LOAD 1.0 /* average number of elements in a bucket */
|
||||
|
||||
static int initialize_bucket(LF_HASH *, LF_SLIST * volatile*, uint, LF_PINS *);
|
||||
|
||||
/*
|
||||
Initializes lf_hash, the arguments are compatible with hash_init
|
||||
|
||||
@note element_size sets both the size of allocated memory block for
|
||||
lf_alloc and a size of memcpy'ed block size in lf_hash_insert. Typically
|
||||
they are the same, indeed. But LF_HASH::element_size can be decreased
|
||||
after lf_hash_init, and then lf_alloc will allocate larger block that
|
||||
lf_hash_insert will copy over. It is desireable if part of the element
|
||||
is expensive to initialize - for example if there is a mutex or
|
||||
DYNAMIC_ARRAY. In this case they should be initialize in the
|
||||
LF_ALLOCATOR::constructor, and lf_hash_insert should not overwrite them.
|
||||
See wt_init() for example.
|
||||
*/
|
||||
void lf_hash_init(LF_HASH *hash, uint element_size, uint flags,
|
||||
uint key_offset, uint key_length, my_hash_get_key get_key,
|
||||
CHARSET_INFO *charset)
|
||||
{
|
||||
lf_alloc_init(&hash->alloc, sizeof(LF_SLIST)+element_size,
|
||||
offsetof(LF_SLIST, key));
|
||||
lf_dynarray_init(&hash->array, sizeof(LF_SLIST *));
|
||||
hash->size= 1;
|
||||
hash->count= 0;
|
||||
hash->element_size= element_size;
|
||||
hash->flags= flags;
|
||||
hash->charset= charset ? charset : &my_charset_bin;
|
||||
hash->key_offset= key_offset;
|
||||
hash->key_length= key_length;
|
||||
hash->get_key= get_key;
|
||||
DBUG_ASSERT(get_key ? !key_offset && !key_length : key_length);
|
||||
}
|
||||
|
||||
void lf_hash_destroy(LF_HASH *hash)
|
||||
{
|
||||
LF_SLIST *el, **head= (LF_SLIST **)_lf_dynarray_value(&hash->array, 0);
|
||||
|
||||
if (unlikely(!head))
|
||||
return;
|
||||
el= *head;
|
||||
|
||||
while (el)
|
||||
{
|
||||
intptr next= el->link;
|
||||
if (el->hashnr & 1)
|
||||
lf_alloc_direct_free(&hash->alloc, el); /* normal node */
|
||||
else
|
||||
my_free((void *)el, MYF(0)); /* dummy node */
|
||||
el= (LF_SLIST *)next;
|
||||
}
|
||||
lf_alloc_destroy(&hash->alloc);
|
||||
lf_dynarray_destroy(&hash->array);
|
||||
}
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
inserts a new element to a hash. it will have a _copy_ of
|
||||
data, not a pointer to it.
|
||||
|
||||
RETURN
|
||||
0 - inserted
|
||||
1 - didn't (unique key conflict)
|
||||
-1 - out of memory
|
||||
|
||||
NOTE
|
||||
see linsert() for pin usage notes
|
||||
*/
|
||||
int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data)
|
||||
{
|
||||
int csize, bucket, hashnr;
|
||||
LF_SLIST *node, * volatile *el;
|
||||
|
||||
lf_rwlock_by_pins(pins);
|
||||
node= (LF_SLIST *)_lf_alloc_new(pins);
|
||||
if (unlikely(!node))
|
||||
return -1;
|
||||
memcpy(node+1, data, hash->element_size);
|
||||
node->key= hash_key(hash, (uchar *)(node+1), &node->keylen);
|
||||
hashnr= calc_hash(hash, node->key, node->keylen);
|
||||
bucket= hashnr % hash->size;
|
||||
el= _lf_dynarray_lvalue(&hash->array, bucket);
|
||||
if (unlikely(!el))
|
||||
return -1;
|
||||
if (*el == NULL && unlikely(initialize_bucket(hash, el, bucket, pins)))
|
||||
return -1;
|
||||
node->hashnr= my_reverse_bits(hashnr) | 1; /* normal node */
|
||||
if (linsert(el, hash->charset, node, pins, hash->flags))
|
||||
{
|
||||
_lf_alloc_free(pins, node);
|
||||
lf_rwunlock_by_pins(pins);
|
||||
return 1;
|
||||
}
|
||||
csize= hash->size;
|
||||
if ((my_atomic_add32(&hash->count, 1)+1.0) / csize > MAX_LOAD)
|
||||
my_atomic_cas32(&hash->size, &csize, csize*2);
|
||||
lf_rwunlock_by_pins(pins);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
deletes an element with the given key from the hash (if a hash is
|
||||
not unique and there're many elements with this key - the "first"
|
||||
matching element is deleted)
|
||||
RETURN
|
||||
0 - deleted
|
||||
1 - didn't (not found)
|
||||
-1 - out of memory
|
||||
NOTE
|
||||
see ldelete() for pin usage notes
|
||||
*/
|
||||
int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
|
||||
{
|
||||
LF_SLIST * volatile *el;
|
||||
uint bucket, hashnr= calc_hash(hash, (uchar *)key, keylen);
|
||||
|
||||
bucket= hashnr % hash->size;
|
||||
lf_rwlock_by_pins(pins);
|
||||
el= _lf_dynarray_lvalue(&hash->array, bucket);
|
||||
if (unlikely(!el))
|
||||
return -1;
|
||||
/*
|
||||
note that we still need to initialize_bucket here,
|
||||
we cannot return "node not found", because an old bucket of that
|
||||
node may've been split and the node was assigned to a new bucket
|
||||
that was never accessed before and thus is not initialized.
|
||||
*/
|
||||
if (*el == NULL && unlikely(initialize_bucket(hash, el, bucket, pins)))
|
||||
return -1;
|
||||
if (ldelete(el, hash->charset, my_reverse_bits(hashnr) | 1,
|
||||
(uchar *)key, keylen, pins))
|
||||
{
|
||||
lf_rwunlock_by_pins(pins);
|
||||
return 1;
|
||||
}
|
||||
my_atomic_add32(&hash->count, -1);
|
||||
lf_rwunlock_by_pins(pins);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
RETURN
|
||||
a pointer to an element with the given key (if a hash is not unique and
|
||||
there're many elements with this key - the "first" matching element)
|
||||
NULL if nothing is found
|
||||
MY_ERRPTR if OOM
|
||||
|
||||
NOTE
|
||||
see lsearch() for pin usage notes
|
||||
*/
|
||||
void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
|
||||
{
|
||||
LF_SLIST * volatile *el, *found;
|
||||
uint bucket, hashnr= calc_hash(hash, (uchar *)key, keylen);
|
||||
|
||||
bucket= hashnr % hash->size;
|
||||
lf_rwlock_by_pins(pins);
|
||||
el= _lf_dynarray_lvalue(&hash->array, bucket);
|
||||
if (unlikely(!el))
|
||||
return MY_ERRPTR;
|
||||
if (*el == NULL && unlikely(initialize_bucket(hash, el, bucket, pins)))
|
||||
return MY_ERRPTR;
|
||||
found= lsearch(el, hash->charset, my_reverse_bits(hashnr) | 1,
|
||||
(uchar *)key, keylen, pins);
|
||||
lf_rwunlock_by_pins(pins);
|
||||
return found ? found+1 : 0;
|
||||
}
|
||||
|
||||
static const uchar *dummy_key= (uchar*)"";
|
||||
|
||||
/*
|
||||
RETURN
|
||||
0 - ok
|
||||
-1 - out of memory
|
||||
*/
|
||||
static int initialize_bucket(LF_HASH *hash, LF_SLIST * volatile *node,
|
||||
uint bucket, LF_PINS *pins)
|
||||
{
|
||||
uint parent= my_clear_highest_bit(bucket);
|
||||
LF_SLIST *dummy= (LF_SLIST *)my_malloc(sizeof(LF_SLIST), MYF(MY_WME));
|
||||
LF_SLIST **tmp= 0, *cur;
|
||||
LF_SLIST * volatile *el= _lf_dynarray_lvalue(&hash->array, parent);
|
||||
if (unlikely(!el || !dummy))
|
||||
return -1;
|
||||
if (*el == NULL && bucket &&
|
||||
unlikely(initialize_bucket(hash, el, parent, pins)))
|
||||
return -1;
|
||||
dummy->hashnr= my_reverse_bits(bucket) | 0; /* dummy node */
|
||||
dummy->key= dummy_key;
|
||||
dummy->keylen= 0;
|
||||
if ((cur= linsert(el, hash->charset, dummy, pins, LF_HASH_UNIQUE)))
|
||||
{
|
||||
my_free((void *)dummy, MYF(0));
|
||||
dummy= cur;
|
||||
}
|
||||
my_atomic_casptr((void **)node, (void **)&tmp, dummy);
|
||||
/*
|
||||
note that if the CAS above failed (after linsert() succeeded),
|
||||
it would mean that some other thread has executed linsert() for
|
||||
the same dummy node, its linsert() failed, it picked up our
|
||||
dummy node (in "dummy= cur") and executed the same CAS as above.
|
||||
Which means that even if CAS above failed we don't need to retry,
|
||||
and we should not free(dummy) - there's no memory leak here
|
||||
*/
|
||||
return 0;
|
||||
}
|
|
@ -135,7 +135,7 @@ void my_b_seek(IO_CACHE *info,my_off_t pos)
|
|||
b) see if there is a better way to make it work
|
||||
*/
|
||||
if (info->type == SEQ_READ_APPEND)
|
||||
VOID(flush_io_cache(info));
|
||||
(void) flush_io_cache(info);
|
||||
|
||||
offset=(pos - info->pos_in_file);
|
||||
|
||||
|
@ -163,7 +163,7 @@ void my_b_seek(IO_CACHE *info,my_off_t pos)
|
|||
info->write_pos = info->write_buffer + offset;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
VOID(flush_io_cache(info));
|
||||
(void) flush_io_cache(info);
|
||||
/* Correct buffer end so that we write in increments of IO_SIZE */
|
||||
info->write_end=(info->write_buffer+info->buffer_length-
|
||||
(pos & (IO_SIZE-1)));
|
||||
|
|
|
@ -34,7 +34,7 @@ char * my_load_path(char * to, const char *path,
|
|||
|
||||
if ((path[0] == FN_HOMELIB && path[1] == FN_LIBCHAR) ||
|
||||
test_if_hard_path(path))
|
||||
VOID(strmov(buff,path));
|
||||
(void) strmov(buff,path);
|
||||
else if ((is_cur=(path[0] == FN_CURLIB && path[1] == FN_LIBCHAR)) ||
|
||||
(is_prefix(path,FN_PARENTDIR)) ||
|
||||
! own_path_prefix)
|
||||
|
@ -42,12 +42,12 @@ char * my_load_path(char * to, const char *path,
|
|||
if (is_cur)
|
||||
is_cur=2; /* Remove current dir */
|
||||
if (! my_getwd(buff,(uint) (FN_REFLEN-strlen(path)+is_cur),MYF(0)))
|
||||
VOID(strcat(buff,path+is_cur));
|
||||
(void) strcat(buff,path+is_cur);
|
||||
else
|
||||
VOID(strmov(buff,path)); /* Return org file name */
|
||||
(void) strmov(buff,path); /* Return org file name */
|
||||
}
|
||||
else
|
||||
VOID(strxmov(buff,own_path_prefix,path,NullS));
|
||||
(void) strxmov(buff,own_path_prefix,path,NullS);
|
||||
strmov(to,buff);
|
||||
DBUG_PRINT("exit",("to: %s",to));
|
||||
DBUG_RETURN(to);
|
||||
|
|
|
@ -42,7 +42,7 @@ char * my_path(char * to, const char *progname,
|
|||
((prog=getenv("_")) != 0 &&
|
||||
dirname_part(to, prog, &to_length))))
|
||||
{
|
||||
VOID(intern_filename(to,to));
|
||||
(void) intern_filename(to,to);
|
||||
if (!test_if_hard_path(to))
|
||||
{
|
||||
if (!my_getwd(curr_dir,FN_REFLEN,MYF(0)))
|
||||
|
@ -60,11 +60,11 @@ char * my_path(char * to, const char *progname,
|
|||
end= (char*) "/my/";
|
||||
#endif
|
||||
}
|
||||
VOID(intern_filename(to,end));
|
||||
(void) intern_filename(to,end);
|
||||
to=strend(to);
|
||||
if (to != start && to[-1] != FN_LIBCHAR)
|
||||
*to++ = FN_LIBCHAR;
|
||||
VOID(strmov(to,own_pathname_part));
|
||||
(void) strmov(to,own_pathname_part);
|
||||
}
|
||||
DBUG_PRINT("exit",("to: '%s'",start));
|
||||
DBUG_RETURN(start);
|
||||
|
|
|
@ -58,7 +58,7 @@ int my_append(const char *from, const char *to, myf MyFlags)
|
|||
}
|
||||
}
|
||||
err:
|
||||
if (from_file >= 0) VOID(my_close(from_file,MyFlags));
|
||||
if (to_file >= 0) VOID(my_close(to_file,MyFlags));
|
||||
if (from_file >= 0) (void) my_close(from_file,MyFlags);
|
||||
if (to_file >= 0) (void) my_close(to_file,MyFlags);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2006 MySQL AB
|
||||
/* Copyright (C) 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||
|
||||
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
|
||||
|
@ -14,7 +14,7 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_pthread.h>
|
||||
#include <my_sys.h>
|
||||
|
||||
#ifndef HAVE_INLINE
|
||||
/* the following will cause all inline functions to be instantiated */
|
||||
|
@ -43,3 +43,32 @@ int my_atomic_initialize()
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef SAFE_MUTEX
|
||||
#undef pthread_mutex_init
|
||||
#undef pthread_mutex_destroy
|
||||
#undef pthread_mutex_lock
|
||||
#undef pthread_mutex_unlock
|
||||
|
||||
void plain_pthread_mutex_init(safe_mutex_t *m)
|
||||
{
|
||||
pthread_mutex_init(& m->mutex, NULL);
|
||||
}
|
||||
|
||||
void plain_pthread_mutex_destroy(safe_mutex_t *m)
|
||||
{
|
||||
pthread_mutex_destroy(& m->mutex);
|
||||
}
|
||||
|
||||
void plain_pthread_mutex_lock(safe_mutex_t *m)
|
||||
{
|
||||
pthread_mutex_lock(& m->mutex);
|
||||
}
|
||||
|
||||
void plain_pthread_mutex_unlock(safe_mutex_t *m)
|
||||
{
|
||||
pthread_mutex_unlock(& m->mutex);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ long my_clock(void)
|
|||
{
|
||||
#if !defined(__WIN__) && !defined(__NETWARE__)
|
||||
struct tms tmsbuf;
|
||||
VOID(times(&tmsbuf));
|
||||
(void) times(&tmsbuf);
|
||||
return (tmsbuf.tms_utime + tmsbuf.tms_stime);
|
||||
#else
|
||||
return clock();
|
||||
|
|
|
@ -112,19 +112,19 @@ int my_copy(const char *from, const char *to, myf MyFlags)
|
|||
struct utimbuf timep;
|
||||
timep.actime = stat_buff.st_atime;
|
||||
timep.modtime = stat_buff.st_mtime;
|
||||
VOID(utime((char*) to, &timep)); /* last accessed and modified times */
|
||||
(void) utime((char*) to, &timep); /* last accessed and modified times */
|
||||
}
|
||||
#endif
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
err:
|
||||
if (from_file >= 0) VOID(my_close(from_file,MyFlags));
|
||||
if (from_file >= 0) (void) my_close(from_file,MyFlags);
|
||||
if (to_file >= 0)
|
||||
{
|
||||
VOID(my_close(to_file, MyFlags));
|
||||
(void) my_close(to_file, MyFlags);
|
||||
/* attempt to delete the to-file we've partially written */
|
||||
VOID(my_delete(to, MyFlags));
|
||||
(void) my_delete(to, MyFlags);
|
||||
}
|
||||
DBUG_RETURN(-1);
|
||||
} /* my_copy */
|
||||
|
|
|
@ -119,7 +119,7 @@ size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags)
|
|||
#ifdef EINTR
|
||||
if (errno == EINTR)
|
||||
{
|
||||
VOID(my_fseek(stream,seekptr,MY_SEEK_SET,MYF(0)));
|
||||
(void) my_fseek(stream,seekptr,MY_SEEK_SET,MYF(0));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
@ -133,7 +133,7 @@ size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags)
|
|||
{
|
||||
wait_for_free_space("[stream]", errors);
|
||||
errors++;
|
||||
VOID(my_fseek(stream,seekptr,MY_SEEK_SET,MYF(0)));
|
||||
(void) my_fseek(stream,seekptr,MY_SEEK_SET,MYF(0));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2006 MySQL AB
|
||||
/* Copyright (C) 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
|
||||
|
||||
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
|
||||
|
@ -16,24 +16,34 @@
|
|||
/* get the number of (online) CPUs */
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static int ncpus=0;
|
||||
|
||||
#ifdef _SC_NPROCESSORS_ONLN
|
||||
int my_getncpus()
|
||||
{
|
||||
if (!ncpus)
|
||||
{
|
||||
#ifdef _SC_NPROCESSORS_ONLN
|
||||
ncpus= sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#elif defined(__WIN__)
|
||||
SYSTEM_INFO sysinfo;
|
||||
|
||||
/*
|
||||
* We are not calling GetNativeSystemInfo here because (1) we
|
||||
* don't believe that they return different values for number
|
||||
* of processors and (2) if WOW64 limits processors for Win32
|
||||
* then we don't want to try to override that.
|
||||
*/
|
||||
GetSystemInfo(&sysinfo);
|
||||
|
||||
ncpus= sysinfo.dwNumberOfProcessors;
|
||||
#else
|
||||
/* unknown so play safe: assume SMP and forbid uniprocessor build */
|
||||
ncpus= 2;
|
||||
#endif
|
||||
}
|
||||
return ncpus;
|
||||
}
|
||||
|
||||
#else
|
||||
/* unknown */
|
||||
int my_getncpus()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ int my_getwd(char * buf, size_t size, myf MyFlags)
|
|||
(long) buf, (uint) size, MyFlags));
|
||||
|
||||
if (curr_dir[0]) /* Current pos is saved here */
|
||||
VOID(strmake(buf,&curr_dir[0],size-1));
|
||||
(void) strmake(buf,&curr_dir[0],size-1);
|
||||
else
|
||||
{
|
||||
#if defined(HAVE_GETCWD)
|
||||
|
|
|
@ -159,8 +159,8 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
|
|||
goto error;
|
||||
|
||||
bzero(finfo.mystat, sizeof(MY_STAT));
|
||||
VOID(strmov(tmp_file,dp->d_name));
|
||||
VOID(my_stat(tmp_path, finfo.mystat, MyFlags));
|
||||
(void) strmov(tmp_file,dp->d_name);
|
||||
(void) my_stat(tmp_path, finfo.mystat, MyFlags);
|
||||
if (!(finfo.mystat->st_mode & MY_S_IREAD))
|
||||
continue;
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ char * directory_file_name (char * dst, const char *src)
|
|||
/* what about when we have logical_name:???? */
|
||||
if (src[slen] == FN_DEVCHAR)
|
||||
{ /* Xlate logical name and see what we get */
|
||||
VOID(strmov(dst,src));
|
||||
(void) strmov(dst,src);
|
||||
dst[slen] = 0; /* remove colon */
|
||||
if (!(src = getenv (dst)))
|
||||
return dst; /* Can't translate */
|
||||
|
@ -282,13 +282,13 @@ char * directory_file_name (char * dst, const char *src)
|
|||
slen = strlen (src) - 1;
|
||||
if (src[slen] != FN_C_AFTER_DIR && src[slen] != FN_C_AFTER_DIR_2)
|
||||
{ /* no recursion here! */
|
||||
VOID(strmov(dst, src));
|
||||
(void) strmov(dst, src);
|
||||
return(dst);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* not a directory spec */
|
||||
VOID(strmov(dst, src));
|
||||
(void) strmov(dst, src);
|
||||
return(dst);
|
||||
}
|
||||
}
|
||||
|
@ -296,13 +296,13 @@ char * directory_file_name (char * dst, const char *src)
|
|||
bracket = src[slen]; /* End char */
|
||||
if (!(ptr = strchr (src, bracket - 2)))
|
||||
{ /* no opening bracket */
|
||||
VOID(strmov (dst, src));
|
||||
(void) strmov (dst, src);
|
||||
return dst;
|
||||
}
|
||||
if (!(rptr = strrchr (src, '.')))
|
||||
rptr = ptr;
|
||||
slen = rptr - src;
|
||||
VOID(strmake (dst, src, slen));
|
||||
(void) strmake (dst, src, slen);
|
||||
|
||||
if (*rptr == '.')
|
||||
{ /* Put bracket and add */
|
||||
|
@ -323,7 +323,7 @@ char * directory_file_name (char * dst, const char *src)
|
|||
&& (ptr[rlen] == FN_C_AFTER_DIR || ptr[rlen] == FN_C_AFTER_DIR_2)
|
||||
&& ptr[rlen - 1] == '.')
|
||||
{
|
||||
VOID(strmov(esa,ptr));
|
||||
(void) strmov(esa,ptr);
|
||||
esa[rlen - 1] = FN_C_AFTER_DIR;
|
||||
esa[rlen] = '\0';
|
||||
return (directory_file_name (dst, esa));
|
||||
|
@ -331,13 +331,13 @@ char * directory_file_name (char * dst, const char *src)
|
|||
else
|
||||
dst[slen - 1] = ':';
|
||||
}
|
||||
VOID(strmov(dst+slen,"[000000]"));
|
||||
(void) strmov(dst+slen,"[000000]");
|
||||
slen += 8;
|
||||
}
|
||||
VOID(strmov(strmov(dst+slen,rptr+1)-1,".DIR.1"));
|
||||
(void) strmov(strmov(dst+slen,rptr+1)-1,".DIR.1");
|
||||
return dst;
|
||||
}
|
||||
VOID(strmov(dst, src));
|
||||
(void) strmov(dst, src);
|
||||
if (dst[slen] == '/' && slen > 1)
|
||||
dst[slen] = 0;
|
||||
return dst;
|
||||
|
|
|
@ -59,7 +59,7 @@ uchar *my_malloc_lock(uint size,myf MyFlags)
|
|||
/* Add block in a list for munlock */
|
||||
if (!(element=(struct st_mem_list*) my_malloc(sizeof(*element),MyFlags)))
|
||||
{
|
||||
VOID(munlock((uchar*) ptr,size));
|
||||
(void) munlock((uchar*) ptr,size);
|
||||
free(ptr);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ void my_free_lock(uchar *ptr,myf Myflags __attribute__((unused)))
|
|||
element=(struct st_mem_list*) list->data;
|
||||
if (ptr == element->page)
|
||||
{ /* Found locked mem */
|
||||
VOID(munlock((uchar*) ptr,element->size));
|
||||
(void) munlock((uchar*) ptr,element->size);
|
||||
mem_list=list_delete(mem_list,list);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -31,46 +31,6 @@
|
|||
|
||||
uint thd_lib_detected= 0;
|
||||
|
||||
#ifndef my_pthread_setprio
|
||||
void my_pthread_setprio(pthread_t thread_id,int prior)
|
||||
{
|
||||
#ifdef HAVE_PTHREAD_SETSCHEDPARAM
|
||||
struct sched_param tmp_sched_param;
|
||||
bzero((char*) &tmp_sched_param,sizeof(tmp_sched_param));
|
||||
tmp_sched_param.sched_priority=prior;
|
||||
VOID(pthread_setschedparam(thread_id,SCHED_POLICY,&tmp_sched_param));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef my_pthread_getprio
|
||||
int my_pthread_getprio(pthread_t thread_id)
|
||||
{
|
||||
#ifdef HAVE_PTHREAD_SETSCHEDPARAM
|
||||
struct sched_param tmp_sched_param;
|
||||
int policy;
|
||||
if (!pthread_getschedparam(thread_id,&policy,&tmp_sched_param))
|
||||
{
|
||||
return tmp_sched_param.sched_priority;
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef my_pthread_attr_setprio
|
||||
void my_pthread_attr_setprio(pthread_attr_t *attr, int priority)
|
||||
{
|
||||
#ifdef HAVE_PTHREAD_SETSCHEDPARAM
|
||||
struct sched_param tmp_sched_param;
|
||||
bzero((char*) &tmp_sched_param,sizeof(tmp_sched_param));
|
||||
tmp_sched_param.sched_priority=priority;
|
||||
VOID(pthread_attr_setschedparam(attr,&tmp_sched_param));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* To allow use of pthread_getspecific with two arguments */
|
||||
|
||||
#ifdef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC
|
||||
|
@ -308,7 +268,7 @@ void sigwait_handle_sig(int sig)
|
|||
{
|
||||
pthread_mutex_lock(&LOCK_sigwait);
|
||||
sigaddset(&pending_set, sig);
|
||||
VOID(pthread_cond_signal(&COND_sigwait)); /* inform sigwait() about signal */
|
||||
pthread_cond_signal(&COND_sigwait); /* inform sigwait() about signal */
|
||||
pthread_mutex_unlock(&LOCK_sigwait);
|
||||
}
|
||||
|
||||
|
@ -364,9 +324,8 @@ int sigwait(sigset_t *setp, int *sigp)
|
|||
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
|
||||
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
|
||||
pthread_attr_setstacksize(&thr_attr,8196);
|
||||
my_pthread_attr_setprio(&thr_attr,100); /* Very high priority */
|
||||
VOID(pthread_create(&sigwait_thread_id,&thr_attr,sigwait_thread,setp));
|
||||
VOID(pthread_attr_destroy(&thr_attr));
|
||||
pthread_create(&sigwait_thread_id,&thr_attr,sigwait_thread,setp);
|
||||
pthread_attr_destroy(&thr_attr);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&LOCK_sigwait);
|
||||
|
@ -392,7 +351,7 @@ int sigwait(sigset_t *setp, int *sigp)
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
VOID(pthread_cond_wait(&COND_sigwait,&LOCK_sigwait));
|
||||
pthread_cond_wait(&COND_sigwait,&LOCK_sigwait);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
1004
mysys/my_rdtsc.c
Normal file
1004
mysys/my_rdtsc.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -89,7 +89,7 @@ int my_copystat(const char *from, const char *to, int MyFlags)
|
|||
}
|
||||
if ((statbuf.st_mode & S_IFMT) != S_IFREG)
|
||||
return 1;
|
||||
VOID(chmod(to, statbuf.st_mode & 07777)); /* Copy modes */
|
||||
(void) chmod(to, statbuf.st_mode & 07777); /* Copy modes */
|
||||
|
||||
#if !defined(__WIN__) && !defined(__NETWARE__)
|
||||
if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
|
||||
|
@ -107,7 +107,7 @@ int my_copystat(const char *from, const char *to, int MyFlags)
|
|||
struct utimbuf timep;
|
||||
timep.actime = statbuf.st_atime;
|
||||
timep.modtime = statbuf.st_mtime;
|
||||
VOID(utime((char*) to, &timep));/* Update last accessed and modified times */
|
||||
(void) utime((char*) to, &timep);/* Update last accessed and modified times */
|
||||
}
|
||||
#else
|
||||
if (MyFlags & MY_COPYTIME)
|
||||
|
@ -115,7 +115,7 @@ int my_copystat(const char *from, const char *to, int MyFlags)
|
|||
time_t time[2];
|
||||
time[0]= statbuf.st_atime;
|
||||
time[1]= statbuf.st_mtime;
|
||||
VOID(utime((char*) to, time));/* Update last accessed and modified times */
|
||||
(void) utime((char*) to, time);/* Update last accessed and modified times */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -284,6 +284,9 @@ my_bool my_thread_init(void)
|
|||
pthread_cond_init(&tmp->suspend, NULL);
|
||||
tmp->init= 1;
|
||||
|
||||
tmp->stack_ends_here= (char*)&tmp +
|
||||
STACK_DIRECTION * (long)my_thread_stack_size;
|
||||
|
||||
pthread_mutex_lock(&THR_LOCK_threads);
|
||||
tmp->id= ++thread_id;
|
||||
++THR_thread_count;
|
||||
|
|
38
mysys/my_timer_cycles.il
Normal file
38
mysys/my_timer_cycles.il
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* Copyright (C) 2008 Sun Microsystems, Inc
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/* Sun Studio SPARC inline templates for cycle timer */
|
||||
/* Sun Studio i386 and x86_64 inline templates for cycle timer */
|
||||
/* I didn't say ".volatile" or ".nonvolatile". */
|
||||
|
||||
.inline my_timer_cycles_il_sparc64,0
|
||||
rd %tick,%o0
|
||||
.end
|
||||
|
||||
.inline my_timer_cycles_il_sparc32,0
|
||||
rd %tick,%o2
|
||||
srlx %o2,32,%o0
|
||||
sra %o2,0,%o1
|
||||
.end
|
||||
|
||||
.inline my_timer_cycles_il_i386,0
|
||||
rdtsc
|
||||
.end
|
||||
|
||||
.inline my_timer_cycles_il_x86_64,0
|
||||
rdtsc
|
||||
shlq $32,%rdx
|
||||
orq %rdx,%rax
|
||||
.end
|
|
@ -181,7 +181,6 @@ int pthread_attr_init(pthread_attr_t *connect_att)
|
|||
{
|
||||
connect_att->dwStackSize = 0;
|
||||
connect_att->dwCreatingFlag = 0;
|
||||
connect_att->priority = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -191,12 +190,6 @@ int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int pthread_attr_setprio(pthread_attr_t *connect_att,int priority)
|
||||
{
|
||||
connect_att->priority=priority;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_attr_destroy(pthread_attr_t *connect_att)
|
||||
{
|
||||
bzero((uchar*) connect_att,sizeof(*connect_att));
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
/* Workaround for Bug#32082: VOID redefinition on Win results in compile errors*/
|
||||
#define DONT_DEFINE_VOID 1
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_stacktrace.h>
|
||||
|
||||
|
|
|
@ -97,10 +97,8 @@ void init_thr_alarm(uint max_alarms)
|
|||
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
|
||||
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
|
||||
pthread_attr_setstacksize(&thr_attr,8196);
|
||||
|
||||
my_pthread_attr_setprio(&thr_attr,100); /* Very high priority */
|
||||
VOID(pthread_create(&alarm_thread,&thr_attr,alarm_handler,NULL));
|
||||
VOID(pthread_attr_destroy(&thr_attr));
|
||||
pthread_create(&alarm_thread,&thr_attr,alarm_handler,NULL);
|
||||
pthread_attr_destroy(&thr_attr);
|
||||
}
|
||||
#elif defined(USE_ONE_SIGNAL_HAND)
|
||||
pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */
|
||||
|
@ -774,7 +772,7 @@ static void *test_thread(void *arg)
|
|||
break;
|
||||
continue;
|
||||
}
|
||||
VOID(getchar()); /* Somebody was playing */
|
||||
(void) getchar(); /* Somebody was playing */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -786,7 +784,7 @@ static void *test_thread(void *arg)
|
|||
}
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
thread_count--;
|
||||
VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */
|
||||
pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
free((uchar*) arg);
|
||||
return 0;
|
||||
|
@ -815,7 +813,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
|
|||
pthread_detach_this_thread();
|
||||
init_thr_alarm(10); /* Setup alarm handler */
|
||||
pthread_mutex_lock(&LOCK_thread_count); /* Required by bsdi */
|
||||
VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */
|
||||
pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
|
||||
sigemptyset(&set); /* Catch all signals */
|
||||
|
@ -906,7 +904,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
|
|||
#ifdef NOT_USED
|
||||
sigemptyset(&set);
|
||||
sigaddset(&set, thr_client_alarm);
|
||||
VOID(pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0));
|
||||
pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0);
|
||||
#endif
|
||||
|
||||
pthread_attr_init(&thr_attr);
|
||||
|
@ -915,10 +913,10 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
|
|||
pthread_attr_setstacksize(&thr_attr,65536L);
|
||||
|
||||
/* Start signal thread and wait for it to start */
|
||||
VOID(pthread_mutex_lock(&LOCK_thread_count));
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
pthread_create(&tid,&thr_attr,signal_hand,NULL);
|
||||
VOID(pthread_cond_wait(&COND_thread_count,&LOCK_thread_count));
|
||||
VOID(pthread_mutex_unlock(&LOCK_thread_count));
|
||||
pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
DBUG_PRINT("info",("signal thread created"));
|
||||
|
||||
thr_setconcurrency(3);
|
||||
|
@ -946,7 +944,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
|
|||
alarm_info.next_alarm_time);
|
||||
while (thread_count)
|
||||
{
|
||||
VOID(pthread_cond_wait(&COND_thread_count,&LOCK_thread_count));
|
||||
pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
|
||||
if (thread_count == 1)
|
||||
{
|
||||
printf("Calling end_thr_alarm. This should cancel the last thread\n");
|
||||
|
|
|
@ -316,7 +316,7 @@ void thr_lock_init(THR_LOCK *lock)
|
|||
{
|
||||
DBUG_ENTER("thr_lock_init");
|
||||
bzero((char*) lock,sizeof(*lock));
|
||||
VOID(pthread_mutex_init(&lock->mutex,MY_MUTEX_INIT_FAST));
|
||||
pthread_mutex_init(&lock->mutex,MY_MUTEX_INIT_FAST);
|
||||
lock->read.last= &lock->read.data;
|
||||
lock->read_wait.last= &lock->read_wait.data;
|
||||
lock->write_wait.last= &lock->write_wait.data;
|
||||
|
@ -522,7 +522,7 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner,
|
|||
data->cond=0; /* safety */
|
||||
data->type=lock_type;
|
||||
data->owner= owner; /* Must be reset ! */
|
||||
VOID(pthread_mutex_lock(&lock->mutex));
|
||||
pthread_mutex_lock(&lock->mutex);
|
||||
DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx type: %d",
|
||||
(long) data, data->owner->info->thread_id,
|
||||
(long) lock, (int) lock_type));
|
||||
|
@ -794,7 +794,7 @@ static inline void free_all_read_locks(THR_LOCK *lock,
|
|||
data->owner->info->thread_id));
|
||||
/* purecov: end */
|
||||
data->cond=0; /* Mark thread free */
|
||||
VOID(pthread_cond_signal(cond));
|
||||
pthread_cond_signal(cond);
|
||||
} while ((data=data->next));
|
||||
*lock->read_wait.last=0;
|
||||
if (!lock->read_wait.data)
|
||||
|
@ -904,7 +904,7 @@ static void wake_up_waiters(THR_LOCK *lock)
|
|||
{
|
||||
pthread_cond_t *cond=data->cond;
|
||||
data->cond=0; /* Mark thread free */
|
||||
VOID(pthread_cond_signal(cond)); /* Start waiting thread */
|
||||
pthread_cond_signal(cond); /* Start waiting thread */
|
||||
}
|
||||
if (data->type != TL_WRITE_ALLOW_WRITE ||
|
||||
!lock->write_wait.data ||
|
||||
|
@ -955,7 +955,7 @@ static void wake_up_waiters(THR_LOCK *lock)
|
|||
lock->write.last= &data->next;
|
||||
data->next=0; /* Only one write lock */
|
||||
data->cond=0; /* Mark thread free */
|
||||
VOID(pthread_cond_signal(cond)); /* Start waiting thread */
|
||||
pthread_cond_signal(cond); /* Start waiting thread */
|
||||
} while (lock_type == TL_WRITE_ALLOW_WRITE &&
|
||||
(data=lock->write_wait.data) &&
|
||||
data->type == TL_WRITE_ALLOW_WRITE);
|
||||
|
@ -1526,7 +1526,7 @@ void thr_print_locks(void)
|
|||
list= list_rest(list))
|
||||
{
|
||||
THR_LOCK *lock=(THR_LOCK*) list->data;
|
||||
VOID(pthread_mutex_lock(&lock->mutex));
|
||||
pthread_mutex_lock(&lock->mutex);
|
||||
printf("lock: 0x%lx:",(ulong) lock);
|
||||
if ((lock->write_wait.data || lock->read_wait.data) &&
|
||||
(! lock->read.data && ! lock->write.data))
|
||||
|
@ -1544,7 +1544,7 @@ void thr_print_locks(void)
|
|||
thr_print_lock("write_wait",&lock->write_wait);
|
||||
thr_print_lock("read",&lock->read);
|
||||
thr_print_lock("read_wait",&lock->read_wait);
|
||||
VOID(pthread_mutex_unlock(&lock->mutex));
|
||||
pthread_mutex_unlock(&lock->mutex);
|
||||
puts("");
|
||||
}
|
||||
fflush(stdout);
|
||||
|
@ -1684,7 +1684,7 @@ static void *test_thread(void *arg)
|
|||
thr_print_locks();
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
thread_count--;
|
||||
VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */
|
||||
pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
free((uchar*) arg);
|
||||
return 0;
|
||||
|
@ -1745,7 +1745,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
|
|||
}
|
||||
#endif
|
||||
#ifdef HAVE_THR_SETCONCURRENCY
|
||||
VOID(thr_setconcurrency(2));
|
||||
(void) thr_setconcurrency(2);
|
||||
#endif
|
||||
for (i=0 ; i < (int) array_elements(lock_counts) ; i++)
|
||||
{
|
||||
|
|
|
@ -143,7 +143,7 @@ Error message file '%s' had only %d error messages,\n\
|
|||
but it should contain at least %d error messages.\n\
|
||||
Check that the above file is the right version for this program!",
|
||||
name,count,error_messages);
|
||||
VOID(my_close(file,MYF(MY_WME)));
|
||||
(void) my_close(file,MYF(MY_WME));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ Check that the above file is the right version for this program!",
|
|||
{
|
||||
point[i]= *point +uint2korr(head+10+i+i);
|
||||
}
|
||||
VOID(my_close(file,MYF(0)));
|
||||
(void) my_close(file,MYF(0));
|
||||
DBUG_RETURN(0);
|
||||
|
||||
err:
|
||||
|
@ -187,7 +187,7 @@ err:
|
|||
}
|
||||
sql_print_error(errmsg, name);
|
||||
if (file != FERR)
|
||||
VOID(my_close(file,MYF(MY_WME)));
|
||||
(void) my_close(file,MYF(MY_WME));
|
||||
DBUG_RETURN(1);
|
||||
} /* read_texts */
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ load_des_key_file(const char *file_name)
|
|||
DBUG_ENTER("load_des_key_file");
|
||||
DBUG_PRINT("enter",("name: %s",file_name));
|
||||
|
||||
VOID(pthread_mutex_lock(&LOCK_des_key_file));
|
||||
pthread_mutex_lock(&LOCK_des_key_file);
|
||||
if ((file=my_open(file_name,O_RDONLY | O_BINARY ,MYF(MY_WME))) < 0 ||
|
||||
init_io_cache(&io, file, IO_SIZE*2, READ_CACHE, 0, 0, MYF(MY_WME)))
|
||||
goto error;
|
||||
|
@ -96,7 +96,7 @@ error:
|
|||
my_close(file,MYF(0));
|
||||
end_io_cache(&io);
|
||||
}
|
||||
VOID(pthread_mutex_unlock(&LOCK_des_key_file));
|
||||
pthread_mutex_unlock(&LOCK_des_key_file);
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
|
|
@ -82,7 +82,7 @@ int readfrm(const char *name, uchar **frmdata, size_t *len)
|
|||
|
||||
err:
|
||||
if (file > 0)
|
||||
VOID(my_close(file,MYF(MY_WME)));
|
||||
(void) my_close(file,MYF(MY_WME));
|
||||
|
||||
err_end: /* Here when no file */
|
||||
DBUG_RETURN (error);
|
||||
|
@ -118,7 +118,7 @@ int writefrm(const char *name, const uchar *frmdata, size_t len)
|
|||
{
|
||||
if (my_write(file, frmdata, len,MYF(MY_WME | MY_NABP)))
|
||||
error= 2;
|
||||
VOID(my_close(file,MYF(0)));
|
||||
(void) my_close(file,MYF(0));
|
||||
}
|
||||
DBUG_RETURN(error);
|
||||
} /* writefrm */
|
||||
|
|
|
@ -4200,7 +4200,7 @@ String *Field_float::val_str(String *val_buffer,
|
|||
char buff[70],*pos=buff;
|
||||
int decpt,sign,tmp_dec=dec;
|
||||
|
||||
VOID(sfconvert(&nr,tmp_dec,&decpt,&sign,buff));
|
||||
(void) sfconvert(&nr,tmp_dec,&decpt,&sign,buff);
|
||||
if (sign)
|
||||
{
|
||||
*to++='-';
|
||||
|
@ -4559,7 +4559,7 @@ String *Field_double::val_str(String *val_buffer,
|
|||
char *pos= buff;
|
||||
int decpt,sign,tmp_dec=dec;
|
||||
|
||||
VOID(fconvert(nr,tmp_dec,&decpt,&sign,buff));
|
||||
(void) fconvert(nr,tmp_dec,&decpt,&sign,buff);
|
||||
if (sign)
|
||||
{
|
||||
*to++='-';
|
||||
|
|
|
@ -1318,7 +1318,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
|
|||
if (!(error= (int) read_to_buffer(from_file,buffpek,
|
||||
rec_length)))
|
||||
{
|
||||
VOID(queue_remove(&queue,0));
|
||||
(void) queue_remove(&queue,0);
|
||||
reuse_freed_buff(&queue, buffpek, rec_length);
|
||||
break; /* One buffer have been removed */
|
||||
}
|
||||
|
|
|
@ -6904,7 +6904,7 @@ int ndbcluster_drop_database_impl(const char *path)
|
|||
while ((tabname=it++))
|
||||
{
|
||||
tablename_to_filename(tabname, tmp, FN_REFLEN - (tmp - full_path)-1);
|
||||
VOID(pthread_mutex_lock(&LOCK_open));
|
||||
pthread_mutex_lock(&LOCK_open);
|
||||
if (ha_ndbcluster::delete_table(0, ndb, full_path, dbname, tabname))
|
||||
{
|
||||
const NdbError err= dict->getNdbError();
|
||||
|
@ -6914,7 +6914,7 @@ int ndbcluster_drop_database_impl(const char *path)
|
|||
ret= ndb_to_mysql_error(&err);
|
||||
}
|
||||
}
|
||||
VOID(pthread_mutex_unlock(&LOCK_open));
|
||||
pthread_mutex_unlock(&LOCK_open);
|
||||
}
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
|
|
@ -641,7 +641,7 @@ int ha_partition::drop_partitions(const char *path)
|
|||
part_elem->part_state= PART_IS_DROPPED;
|
||||
}
|
||||
} while (++i < num_parts);
|
||||
VOID(sync_ddl_log());
|
||||
(void) sync_ddl_log();
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -739,7 +739,7 @@ int ha_partition::rename_partitions(const char *path)
|
|||
part_elem->log_entry= NULL; /* Indicate success */
|
||||
}
|
||||
} while (++i < temp_partitions);
|
||||
VOID(sync_ddl_log());
|
||||
(void) sync_ddl_log();
|
||||
}
|
||||
i= 0;
|
||||
do
|
||||
|
@ -791,7 +791,7 @@ int ha_partition::rename_partitions(const char *path)
|
|||
error= ret_error;
|
||||
else if (deactivate_ddl_log_entry(sub_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
VOID(sync_ddl_log());
|
||||
(void) sync_ddl_log();
|
||||
}
|
||||
file= m_new_file[part];
|
||||
create_subpartition_name(part_name_buff, path,
|
||||
|
@ -822,7 +822,7 @@ int ha_partition::rename_partitions(const char *path)
|
|||
error= ret_error;
|
||||
else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
VOID(sync_ddl_log());
|
||||
(void) sync_ddl_log();
|
||||
}
|
||||
file= m_new_file[i];
|
||||
create_partition_name(part_name_buff, path,
|
||||
|
@ -840,7 +840,7 @@ int ha_partition::rename_partitions(const char *path)
|
|||
}
|
||||
}
|
||||
} while (++i < num_parts);
|
||||
VOID(sync_ddl_log());
|
||||
(void) sync_ddl_log();
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -1295,7 +1295,7 @@ int ha_partition::prepare_new_partition(TABLE *tbl,
|
|||
DBUG_RETURN(0);
|
||||
error:
|
||||
if (create_flag)
|
||||
VOID(file->ha_delete_table(part_name));
|
||||
(void) file->ha_delete_table(part_name);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -2210,7 +2210,7 @@ bool ha_partition::create_handler_file(const char *name)
|
|||
{
|
||||
result= my_write(file, (uchar *) file_buffer, tot_len_byte,
|
||||
MYF(MY_WME | MY_NABP)) != 0;
|
||||
VOID(my_close(file, MYF(0)));
|
||||
(void) my_close(file, MYF(0));
|
||||
}
|
||||
else
|
||||
result= TRUE;
|
||||
|
@ -2396,7 +2396,7 @@ bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root)
|
|||
len_bytes= 4 * len_words;
|
||||
if (!(file_buffer= (char*) my_malloc(len_bytes, MYF(0))))
|
||||
goto err1;
|
||||
VOID(my_seek(file, 0, MY_SEEK_SET, MYF(0)));
|
||||
my_seek(file, 0, MY_SEEK_SET, MYF(0));
|
||||
if (my_read(file, (uchar *) file_buffer, len_bytes, MYF(MY_NABP)))
|
||||
goto err2;
|
||||
|
||||
|
@ -2418,7 +2418,7 @@ bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root)
|
|||
if (len_words != (tot_partition_words + tot_name_words + 4))
|
||||
goto err3;
|
||||
name_buffer_ptr= file_buffer + 16 + 4 * tot_partition_words;
|
||||
VOID(my_close(file, MYF(0)));
|
||||
(void) my_close(file, MYF(0));
|
||||
m_file_buffer= file_buffer; // Will be freed in clear_handler_file()
|
||||
m_name_buffer_ptr= name_buffer_ptr;
|
||||
|
||||
|
@ -2443,7 +2443,7 @@ err3:
|
|||
err2:
|
||||
my_free(file_buffer, MYF(0));
|
||||
err1:
|
||||
VOID(my_close(file, MYF(0)));
|
||||
(void) my_close(file, MYF(0));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
|
@ -5844,9 +5844,9 @@ void ha_partition::late_extra_cache(uint partition_id)
|
|||
DBUG_VOID_RETURN;
|
||||
file= m_file[partition_id];
|
||||
if (m_extra_cache_size == 0)
|
||||
VOID(file->extra(HA_EXTRA_CACHE));
|
||||
(void) file->extra(HA_EXTRA_CACHE);
|
||||
else
|
||||
VOID(file->extra_opt(HA_EXTRA_CACHE, m_extra_cache_size));
|
||||
(void) file->extra_opt(HA_EXTRA_CACHE, m_extra_cache_size);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -5870,7 +5870,7 @@ void ha_partition::late_extra_no_cache(uint partition_id)
|
|||
if (!m_extra_cache)
|
||||
DBUG_VOID_RETURN;
|
||||
file= m_file[partition_id];
|
||||
VOID(file->extra(HA_EXTRA_NO_CACHE));
|
||||
(void) file->extra(HA_EXTRA_NO_CACHE);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -6675,7 +6675,7 @@ static PARTITION_SHARE *get_share(const char *table_name, TABLE *table)
|
|||
if (!partition_init)
|
||||
{
|
||||
partition_init++;
|
||||
VOID(pthread_mutex_init(&partition_mutex, MY_MUTEX_INIT_FAST));
|
||||
pthread_mutex_init(&partition_mutex, MY_MUTEX_INIT_FAST);
|
||||
(void) hash_init(&partition_open_tables, system_charset_info, 32, 0, 0,
|
||||
(hash_get_key) partition_get_key, 0, 0);
|
||||
}
|
||||
|
|
|
@ -992,7 +992,7 @@ int ha_prepare(THD *thd)
|
|||
THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt;
|
||||
Ha_trx_info *ha_info= trans->ha_list;
|
||||
DBUG_ENTER("ha_prepare");
|
||||
#ifdef USING_TRANSACTIONS
|
||||
|
||||
if (ha_info)
|
||||
{
|
||||
for (; ha_info; ha_info= ha_info->next())
|
||||
|
@ -1018,7 +1018,7 @@ int ha_prepare(THD *thd)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* USING_TRANSACTIONS */
|
||||
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -1146,7 +1146,7 @@ int ha_commit_trans(THD *thd, bool all)
|
|||
my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
|
||||
DBUG_RETURN(2);
|
||||
}
|
||||
#ifdef USING_TRANSACTIONS
|
||||
|
||||
if (ha_info)
|
||||
{
|
||||
uint rw_ha_count;
|
||||
|
@ -1227,7 +1227,6 @@ end:
|
|||
/* Free resources and perform other cleanup even for 'empty' transactions. */
|
||||
else if (is_real_trans)
|
||||
thd->transaction.cleanup();
|
||||
#endif /* USING_TRANSACTIONS */
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -1249,7 +1248,7 @@ int ha_commit_one_phase(THD *thd, bool all)
|
|||
bool is_real_trans=all || thd->transaction.all.ha_list == 0;
|
||||
Ha_trx_info *ha_info= trans->ha_list, *ha_info_next;
|
||||
DBUG_ENTER("ha_commit_one_phase");
|
||||
#ifdef USING_TRANSACTIONS
|
||||
|
||||
if (ha_info)
|
||||
{
|
||||
for (; ha_info; ha_info= ha_info_next)
|
||||
|
@ -1279,7 +1278,7 @@ int ha_commit_one_phase(THD *thd, bool all)
|
|||
/* Free resources and perform other cleanup even for 'empty' transactions. */
|
||||
if (is_real_trans)
|
||||
thd->transaction.cleanup();
|
||||
#endif /* USING_TRANSACTIONS */
|
||||
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -1319,7 +1318,7 @@ int ha_rollback_trans(THD *thd, bool all)
|
|||
my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
#ifdef USING_TRANSACTIONS
|
||||
|
||||
if (ha_info)
|
||||
{
|
||||
/* Close all cursors that can not survive ROLLBACK */
|
||||
|
@ -1350,7 +1349,6 @@ int ha_rollback_trans(THD *thd, bool all)
|
|||
/* Always cleanup. Even if there nht==0. There may be savepoints. */
|
||||
if (is_real_trans)
|
||||
thd->transaction.cleanup();
|
||||
#endif /* USING_TRANSACTIONS */
|
||||
if (all)
|
||||
thd->transaction_rollback_request= FALSE;
|
||||
|
||||
|
@ -1386,7 +1384,7 @@ int ha_rollback_trans(THD *thd, bool all)
|
|||
int ha_autocommit_or_rollback(THD *thd, int error)
|
||||
{
|
||||
DBUG_ENTER("ha_autocommit_or_rollback");
|
||||
#ifdef USING_TRANSACTIONS
|
||||
|
||||
if (thd->transaction.stmt.ha_list)
|
||||
{
|
||||
if (!error)
|
||||
|
@ -1404,7 +1402,6 @@ int ha_autocommit_or_rollback(THD *thd, int error)
|
|||
thd->variables.tx_isolation=thd->session_tx_isolation;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (!error)
|
||||
RUN_HOOK(transaction, after_commit, (thd, FALSE));
|
||||
|
@ -1812,7 +1809,7 @@ int ha_savepoint(THD *thd, SAVEPOINT *sv)
|
|||
&thd->transaction.all);
|
||||
Ha_trx_info *ha_info= trans->ha_list;
|
||||
DBUG_ENTER("ha_savepoint");
|
||||
#ifdef USING_TRANSACTIONS
|
||||
|
||||
for (; ha_info; ha_info= ha_info->next())
|
||||
{
|
||||
int err;
|
||||
|
@ -1836,7 +1833,7 @@ int ha_savepoint(THD *thd, SAVEPOINT *sv)
|
|||
engines are prepended to the beginning of the list.
|
||||
*/
|
||||
sv->ha_list= trans->ha_list;
|
||||
#endif /* USING_TRANSACTIONS */
|
||||
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -3017,7 +3014,7 @@ static bool update_frm_version(TABLE *table)
|
|||
}
|
||||
err:
|
||||
if (file >= 0)
|
||||
VOID(my_close(file,MYF(MY_WME)));
|
||||
(void) my_close(file,MYF(MY_WME));
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
|
@ -3650,7 +3647,7 @@ int ha_create_table(THD *thd, const char *path,
|
|||
name= get_canonical_filename(table.file, share.path.str, name_buff);
|
||||
|
||||
error= table.file->ha_create(name, &table, create_info);
|
||||
VOID(closefrm(&table, 0));
|
||||
(void) closefrm(&table, 0);
|
||||
if (error)
|
||||
{
|
||||
strxmov(name_buff, db, ".", table_name, NullS);
|
||||
|
@ -3721,7 +3718,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name)
|
|||
|
||||
get_canonical_filename(table.file, path, path);
|
||||
error=table.file->ha_create(path, &table, &create_info);
|
||||
VOID(closefrm(&table, 1));
|
||||
(void) closefrm(&table, 1);
|
||||
|
||||
DBUG_RETURN(error != 0);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
#define NO_HASH /* Not yet implemented */
|
||||
#endif
|
||||
|
||||
#define USING_TRANSACTIONS
|
||||
|
||||
// the following is for checking tables
|
||||
|
||||
#define HA_ADMIN_ALREADY_DONE 1
|
||||
|
|
|
@ -87,7 +87,7 @@ static void add_hostname(struct in_addr *in,const char *name)
|
|||
{
|
||||
if (!(specialflag & SPECIAL_NO_HOST_CACHE))
|
||||
{
|
||||
VOID(pthread_mutex_lock(&hostname_cache->lock));
|
||||
pthread_mutex_lock(&hostname_cache->lock);
|
||||
host_entry *entry;
|
||||
if (!(entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0)))
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ static void add_hostname(struct in_addr *in,const char *name)
|
|||
(void) hostname_cache->add(entry);
|
||||
}
|
||||
}
|
||||
VOID(pthread_mutex_unlock(&hostname_cache->lock));
|
||||
pthread_mutex_unlock(&hostname_cache->lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,20 +118,20 @@ inline void add_wrong_ip(struct in_addr *in)
|
|||
|
||||
void inc_host_errors(struct in_addr *in)
|
||||
{
|
||||
VOID(pthread_mutex_lock(&hostname_cache->lock));
|
||||
pthread_mutex_lock(&hostname_cache->lock);
|
||||
host_entry *entry;
|
||||
if ((entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0)))
|
||||
entry->errors++;
|
||||
VOID(pthread_mutex_unlock(&hostname_cache->lock));
|
||||
pthread_mutex_unlock(&hostname_cache->lock);
|
||||
}
|
||||
|
||||
void reset_host_errors(struct in_addr *in)
|
||||
{
|
||||
VOID(pthread_mutex_lock(&hostname_cache->lock));
|
||||
pthread_mutex_lock(&hostname_cache->lock);
|
||||
host_entry *entry;
|
||||
if ((entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0)))
|
||||
entry->errors=0;
|
||||
VOID(pthread_mutex_unlock(&hostname_cache->lock));
|
||||
pthread_mutex_unlock(&hostname_cache->lock);
|
||||
}
|
||||
|
||||
/* Deal with systems that don't defined INADDR_LOOPBACK */
|
||||
|
@ -153,7 +153,7 @@ char * ip_to_hostname(struct in_addr *in, uint *errors)
|
|||
/* Check first if we have name in cache */
|
||||
if (!(specialflag & SPECIAL_NO_HOST_CACHE))
|
||||
{
|
||||
VOID(pthread_mutex_lock(&hostname_cache->lock));
|
||||
pthread_mutex_lock(&hostname_cache->lock);
|
||||
if ((entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0)))
|
||||
{
|
||||
char *name;
|
||||
|
@ -162,10 +162,10 @@ char * ip_to_hostname(struct in_addr *in, uint *errors)
|
|||
else
|
||||
name=my_strdup(entry->hostname,MYF(0));
|
||||
*errors= entry->errors;
|
||||
VOID(pthread_mutex_unlock(&hostname_cache->lock));
|
||||
pthread_mutex_unlock(&hostname_cache->lock);
|
||||
DBUG_RETURN(name);
|
||||
}
|
||||
VOID(pthread_mutex_unlock(&hostname_cache->lock));
|
||||
pthread_mutex_unlock(&hostname_cache->lock);
|
||||
}
|
||||
|
||||
struct hostent *hp, *check;
|
||||
|
@ -214,10 +214,10 @@ char * ip_to_hostname(struct in_addr *in, uint *errors)
|
|||
}
|
||||
my_gethostbyname_r_free();
|
||||
#else
|
||||
VOID(pthread_mutex_lock(&LOCK_hostname));
|
||||
pthread_mutex_lock(&LOCK_hostname);
|
||||
if (!(hp=gethostbyaddr((char*) in,sizeof(*in), AF_INET)))
|
||||
{
|
||||
VOID(pthread_mutex_unlock(&LOCK_hostname));
|
||||
pthread_mutex_unlock(&LOCK_hostname);
|
||||
DBUG_PRINT("error",("gethostbyaddr returned %d",errno));
|
||||
|
||||
if (errno == HOST_NOT_FOUND || errno == NO_DATA)
|
||||
|
@ -227,17 +227,17 @@ char * ip_to_hostname(struct in_addr *in, uint *errors)
|
|||
}
|
||||
if (!hp->h_name[0]) // Don't allow empty hostnames
|
||||
{
|
||||
VOID(pthread_mutex_unlock(&LOCK_hostname));
|
||||
pthread_mutex_unlock(&LOCK_hostname);
|
||||
DBUG_PRINT("error",("Got an empty hostname"));
|
||||
goto add_wrong_ip_and_return;
|
||||
}
|
||||
if (!(name=my_strdup(hp->h_name,MYF(0))))
|
||||
{
|
||||
VOID(pthread_mutex_unlock(&LOCK_hostname));
|
||||
pthread_mutex_unlock(&LOCK_hostname);
|
||||
DBUG_RETURN(0); // out of memory
|
||||
}
|
||||
check=gethostbyname(name);
|
||||
VOID(pthread_mutex_unlock(&LOCK_hostname));
|
||||
pthread_mutex_unlock(&LOCK_hostname);
|
||||
if (!check)
|
||||
{
|
||||
DBUG_PRINT("error",("gethostbyname returned %d",errno));
|
||||
|
|
|
@ -40,7 +40,7 @@ void unireg_init(ulong options)
|
|||
my_abort_hook=unireg_abort; /* Abort with close of databases */
|
||||
#endif
|
||||
|
||||
VOID(strmov(reg_ext,".frm"));
|
||||
(void) strmov(reg_ext,".frm");
|
||||
reg_ext_length= 4;
|
||||
specialflag=SPECIAL_SAME_DB_NAME | options; /* Set options from argv */
|
||||
DBUG_VOID_RETURN;
|
||||
|
|
|
@ -1196,7 +1196,7 @@ void Item_case_expr::print(String *str, enum_query_type)
|
|||
{
|
||||
if (str->reserve(MAX_INT_WIDTH + sizeof("case_expr@")))
|
||||
return; /* purecov: inspected */
|
||||
VOID(str->append(STRING_WITH_LEN("case_expr@")));
|
||||
(void) str->append(STRING_WITH_LEN("case_expr@"));
|
||||
str->qs_append(m_case_expr_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -4187,7 +4187,7 @@ void Item_cond::neg_arguments(THD *thd)
|
|||
if (!(new_item= new Item_func_not(item)))
|
||||
return; // Fatal OEM error
|
||||
}
|
||||
VOID(li.replace(new_item));
|
||||
(void) li.replace(new_item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -465,18 +465,18 @@ String *Item_func_des_encrypt::val_str(String *str)
|
|||
if (arg_count == 1)
|
||||
{
|
||||
/* Protect against someone doing FLUSH DES_KEY_FILE */
|
||||
VOID(pthread_mutex_lock(&LOCK_des_key_file));
|
||||
pthread_mutex_lock(&LOCK_des_key_file);
|
||||
keyschedule= des_keyschedule[key_number=des_default_key];
|
||||
VOID(pthread_mutex_unlock(&LOCK_des_key_file));
|
||||
pthread_mutex_unlock(&LOCK_des_key_file);
|
||||
}
|
||||
else if (args[1]->result_type() == INT_RESULT)
|
||||
{
|
||||
key_number= (uint) args[1]->val_int();
|
||||
if (key_number > 9)
|
||||
goto error;
|
||||
VOID(pthread_mutex_lock(&LOCK_des_key_file));
|
||||
pthread_mutex_lock(&LOCK_des_key_file);
|
||||
keyschedule= des_keyschedule[key_number];
|
||||
VOID(pthread_mutex_unlock(&LOCK_des_key_file));
|
||||
pthread_mutex_unlock(&LOCK_des_key_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -566,9 +566,9 @@ String *Item_func_des_decrypt::val_str(String *str)
|
|||
key_number > 9)
|
||||
goto error;
|
||||
|
||||
VOID(pthread_mutex_lock(&LOCK_des_key_file));
|
||||
pthread_mutex_lock(&LOCK_des_key_file);
|
||||
keyschedule= des_keyschedule[key_number];
|
||||
VOID(pthread_mutex_unlock(&LOCK_des_key_file));
|
||||
pthread_mutex_unlock(&LOCK_des_key_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
173
sql/lock.cc
173
sql/lock.cc
|
@ -90,7 +90,6 @@ extern HASH open_cache;
|
|||
|
||||
static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table,uint count,
|
||||
uint flags, TABLE **write_locked);
|
||||
static void reset_lock_data(MYSQL_LOCK *sql_lock);
|
||||
static int lock_external(THD *thd, TABLE **table,uint count);
|
||||
static int unlock_external(THD *thd, TABLE **table,uint count);
|
||||
static void print_lock_error(int error, const char *);
|
||||
|
@ -194,6 +193,60 @@ int mysql_lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags)
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reset lock type in lock data and free.
|
||||
|
||||
@param mysql_lock Lock structures to reset.
|
||||
|
||||
@note After a locking error we want to quit the locking of the table(s).
|
||||
The test case in the bug report for Bug #18544 has the following
|
||||
cases: 1. Locking error in lock_external() due to InnoDB timeout.
|
||||
2. Locking error in get_lock_data() due to missing write permission.
|
||||
3. Locking error in wait_if_global_read_lock() due to lock conflict.
|
||||
|
||||
@note In all these cases we have already set the lock type into the lock
|
||||
data of the open table(s). If the table(s) are in the open table
|
||||
cache, they could be reused with the non-zero lock type set. This
|
||||
could lead to ignoring a different lock type with the next lock.
|
||||
|
||||
@note Clear the lock type of all lock data. This ensures that the next
|
||||
lock request will set its lock type properly.
|
||||
*/
|
||||
|
||||
|
||||
static void reset_lock_data(MYSQL_LOCK *sql_lock)
|
||||
{
|
||||
THR_LOCK_DATA **ldata, **ldata_end;
|
||||
DBUG_ENTER("reset_lock_data");
|
||||
|
||||
/* Clear the lock type of all lock data to avoid reusage. */
|
||||
for (ldata= sql_lock->locks, ldata_end= ldata + sql_lock->lock_count;
|
||||
ldata < ldata_end;
|
||||
ldata++)
|
||||
{
|
||||
/* Reset lock type. */
|
||||
(*ldata)->type= TL_UNLOCK;
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reset lock type in lock data and free.
|
||||
|
||||
@param mysql_lock Lock structures to reset.
|
||||
|
||||
*/
|
||||
|
||||
static void reset_lock_data_and_free(MYSQL_LOCK **mysql_lock)
|
||||
{
|
||||
reset_lock_data(*mysql_lock);
|
||||
my_free(*mysql_lock, MYF(0));
|
||||
*mysql_lock= 0;
|
||||
}
|
||||
|
||||
|
||||
MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
|
||||
uint flags, bool *need_reopen)
|
||||
{
|
||||
|
@ -224,16 +277,13 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
|
|||
if (wait_if_global_read_lock(thd, 1, 1))
|
||||
{
|
||||
/* Clear the lock type of all lock data to avoid reusage. */
|
||||
reset_lock_data(sql_lock);
|
||||
my_free((uchar*) sql_lock,MYF(0));
|
||||
sql_lock=0;
|
||||
reset_lock_data_and_free(&sql_lock);
|
||||
break;
|
||||
}
|
||||
if (thd->version != refresh_version)
|
||||
{
|
||||
/* Clear the lock type of all lock data to avoid reusage. */
|
||||
reset_lock_data(sql_lock);
|
||||
my_free((uchar*) sql_lock,MYF(0));
|
||||
reset_lock_data_and_free(&sql_lock);
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
|
@ -248,9 +298,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
|
|||
Someone has issued SET GLOBAL READ_ONLY=1 and we want a write lock.
|
||||
We do not wait for READ_ONLY=0, and fail.
|
||||
*/
|
||||
reset_lock_data(sql_lock);
|
||||
my_free((uchar*) sql_lock, MYF(0));
|
||||
sql_lock=0;
|
||||
reset_lock_data_and_free(&sql_lock);
|
||||
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
|
||||
break;
|
||||
}
|
||||
|
@ -261,14 +309,11 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
|
|||
sql_lock->table_count))
|
||||
{
|
||||
/* Clear the lock type of all lock data to avoid reusage. */
|
||||
reset_lock_data(sql_lock);
|
||||
my_free((uchar*) sql_lock,MYF(0));
|
||||
sql_lock=0;
|
||||
reset_lock_data_and_free(&sql_lock);
|
||||
break;
|
||||
}
|
||||
thd_proc_info(thd, "Table lock");
|
||||
DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info));
|
||||
thd->locked=1;
|
||||
thd_proc_info(thd, "Locked");
|
||||
/* Copy the lock data array. thr_multi_lock() reorders its contens. */
|
||||
memcpy(sql_lock->locks + sql_lock->lock_count, sql_lock->locks,
|
||||
sql_lock->lock_count * sizeof(*sql_lock->locks));
|
||||
|
@ -280,23 +325,16 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
|
|||
if (rc > 1) /* a timeout or a deadlock */
|
||||
{
|
||||
if (sql_lock->table_count)
|
||||
VOID(unlock_external(thd, sql_lock->table, sql_lock->table_count));
|
||||
(void) unlock_external(thd, sql_lock->table, sql_lock->table_count);
|
||||
reset_lock_data_and_free(&sql_lock);
|
||||
my_error(rc, MYF(0));
|
||||
my_free((uchar*) sql_lock,MYF(0));
|
||||
sql_lock= 0;
|
||||
break;
|
||||
}
|
||||
else if (rc == 1) /* aborted */
|
||||
{
|
||||
/*
|
||||
reset_lock_data is required here. If thr_multi_lock fails it
|
||||
resets lock type for tables, which were locked before (and
|
||||
including) one that caused error. Lock type for other tables
|
||||
preserved.
|
||||
*/
|
||||
reset_lock_data(sql_lock);
|
||||
thd->some_tables_deleted=1; // Try again
|
||||
sql_lock->lock_count= 0; // Locks are already freed
|
||||
// Fall through: unlock, reset lock data, free and retry
|
||||
}
|
||||
else if (!thd->some_tables_deleted || (flags & MYSQL_LOCK_IGNORE_FLUSH))
|
||||
{
|
||||
|
@ -304,23 +342,30 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
|
|||
Thread was killed or lock aborted. Let upper level close all
|
||||
used tables and retry or give error.
|
||||
*/
|
||||
thd->locked=0;
|
||||
break;
|
||||
}
|
||||
else if (!thd->open_tables)
|
||||
{
|
||||
// Only using temporary tables, no need to unlock
|
||||
thd->some_tables_deleted=0;
|
||||
thd->locked=0;
|
||||
break;
|
||||
}
|
||||
thd_proc_info(thd, 0);
|
||||
|
||||
/* some table was altered or deleted. reopen tables marked deleted */
|
||||
mysql_unlock_tables(thd,sql_lock);
|
||||
thd->locked=0;
|
||||
/* going to retry, unlock all tables */
|
||||
if (sql_lock->lock_count)
|
||||
thr_multi_unlock(sql_lock->locks, sql_lock->lock_count);
|
||||
|
||||
if (sql_lock->table_count)
|
||||
(void) unlock_external(thd, sql_lock->table, sql_lock->table_count);
|
||||
|
||||
/*
|
||||
If thr_multi_lock fails it resets lock type for tables, which
|
||||
were locked before (and including) one that caused error. Lock
|
||||
type for other tables preserved.
|
||||
*/
|
||||
reset_lock_data_and_free(&sql_lock);
|
||||
retry:
|
||||
sql_lock=0;
|
||||
if (flags & MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN)
|
||||
{
|
||||
*need_reopen= TRUE;
|
||||
|
@ -388,7 +433,7 @@ void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock)
|
|||
if (sql_lock->lock_count)
|
||||
thr_multi_unlock(sql_lock->locks,sql_lock->lock_count);
|
||||
if (sql_lock->table_count)
|
||||
VOID(unlock_external(thd,sql_lock->table,sql_lock->table_count));
|
||||
(void) unlock_external(thd,sql_lock->table,sql_lock->table_count);
|
||||
my_free((uchar*) sql_lock,MYF(0));
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
@ -452,7 +497,7 @@ void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock)
|
|||
/* Unlock all read locked tables */
|
||||
if (i != found)
|
||||
{
|
||||
VOID(unlock_external(thd,table,i-found));
|
||||
(void) unlock_external(thd,table,i-found);
|
||||
sql_lock->table_count=found;
|
||||
}
|
||||
/* Fix the lock positions in TABLE */
|
||||
|
@ -863,8 +908,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
|
|||
my_error(ER_OPEN_AS_READONLY,MYF(0),table->alias);
|
||||
/* Clear the lock type of the lock data that are stored already. */
|
||||
sql_lock->lock_count= (uint) (locks - sql_lock->locks);
|
||||
reset_lock_data(sql_lock);
|
||||
my_free((uchar*) sql_lock,MYF(0));
|
||||
reset_lock_data_and_free(&sql_lock);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
}
|
||||
|
@ -905,42 +949,6 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
Reset lock type in lock data.
|
||||
|
||||
After a locking error we want to quit the locking of the table(s).
|
||||
The test case in the bug report for Bug #18544 has the following
|
||||
cases:
|
||||
-# Locking error in lock_external() due to InnoDB timeout.
|
||||
-# Locking error in get_lock_data() due to missing write permission.
|
||||
-# Locking error in wait_if_global_read_lock() due to lock conflict.
|
||||
|
||||
In all these cases we have already set the lock type into the lock
|
||||
data of the open table(s). If the table(s) are in the open table
|
||||
cache, they could be reused with the non-zero lock type set. This
|
||||
could lead to ignoring a different lock type with the next lock.
|
||||
|
||||
Clear the lock type of all lock data. This ensures that the next
|
||||
lock request will set its lock type properly.
|
||||
|
||||
@param sql_lock The MySQL lock.
|
||||
*/
|
||||
|
||||
static void reset_lock_data(MYSQL_LOCK *sql_lock)
|
||||
{
|
||||
THR_LOCK_DATA **ldata;
|
||||
THR_LOCK_DATA **ldata_end;
|
||||
|
||||
for (ldata= sql_lock->locks, ldata_end= ldata + sql_lock->lock_count;
|
||||
ldata < ldata_end;
|
||||
ldata++)
|
||||
{
|
||||
/* Reset lock type. */
|
||||
(*ldata)->type= TL_UNLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
Lock table based on the name.
|
||||
This is used when we need total access to a closed, not open table
|
||||
|
@ -970,7 +978,7 @@ int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list)
|
|||
|
||||
if (wait_if_global_read_lock(thd, 0, 1))
|
||||
DBUG_RETURN(1);
|
||||
VOID(pthread_mutex_lock(&LOCK_open));
|
||||
pthread_mutex_lock(&LOCK_open);
|
||||
if ((lock_retcode = lock_table_name(thd, table_list, TRUE)) < 0)
|
||||
goto end;
|
||||
if (lock_retcode && wait_for_locked_table_names(thd, table_list))
|
||||
|
@ -1020,6 +1028,7 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use)
|
|||
char key[MAX_DBKEY_LENGTH];
|
||||
char *db= table_list->db;
|
||||
uint key_length;
|
||||
bool found_locked_table= FALSE;
|
||||
HASH_SEARCH_STATE state;
|
||||
DBUG_ENTER("lock_table_name");
|
||||
DBUG_PRINT("enter",("db: %s name: %s", db, table_list->table_name));
|
||||
|
@ -1035,6 +1044,13 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use)
|
|||
table = (TABLE*) my_hash_next(&open_cache,(uchar*) key,
|
||||
key_length, &state))
|
||||
{
|
||||
if (table->reginfo.lock_type < TL_WRITE)
|
||||
{
|
||||
if (table->in_use == thd)
|
||||
found_locked_table= TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (table->in_use == thd)
|
||||
{
|
||||
DBUG_PRINT("info", ("Table is in use"));
|
||||
|
@ -1045,6 +1061,17 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use)
|
|||
}
|
||||
}
|
||||
|
||||
if (thd->locked_tables && thd->locked_tables->table_count &&
|
||||
! find_temporary_table(thd, table_list->db, table_list->table_name))
|
||||
{
|
||||
if (found_locked_table)
|
||||
my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE, MYF(0), table_list->alias);
|
||||
else
|
||||
my_error(ER_TABLE_NOT_LOCKED, MYF(0), table_list->alias);
|
||||
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
if (!(table= table_cache_insert_placeholder(thd, key, key_length)))
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
|
@ -1595,8 +1622,8 @@ bool make_global_read_lock_block_commit(THD *thd)
|
|||
|
||||
void broadcast_refresh(void)
|
||||
{
|
||||
VOID(pthread_cond_broadcast(&COND_refresh));
|
||||
VOID(pthread_cond_broadcast(&COND_global_read_lock));
|
||||
pthread_cond_broadcast(&COND_refresh);
|
||||
pthread_cond_broadcast(&COND_global_read_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
23
sql/log.cc
23
sql/log.cc
|
@ -2909,7 +2909,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
|
|||
thread. If the transaction involved MyISAM tables, it should go
|
||||
into binlog even on rollback.
|
||||
*/
|
||||
VOID(pthread_mutex_lock(&LOCK_thread_count));
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
|
||||
/* Save variables so that we can reopen the log */
|
||||
save_name=name;
|
||||
|
@ -2989,7 +2989,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
|
|||
my_free((uchar*) save_name, MYF(0));
|
||||
|
||||
err:
|
||||
VOID(pthread_mutex_unlock(&LOCK_thread_count));
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
pthread_mutex_unlock(&LOCK_index);
|
||||
pthread_mutex_unlock(&LOCK_log);
|
||||
DBUG_RETURN(error);
|
||||
|
@ -4084,12 +4084,11 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
|
|||
if ((thd && !(thd->options & OPTION_BIN_LOG)) ||
|
||||
(!binlog_filter->db_ok(local_db)))
|
||||
{
|
||||
VOID(pthread_mutex_unlock(&LOCK_log));
|
||||
pthread_mutex_unlock(&LOCK_log);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
#endif /* HAVE_REPLICATION */
|
||||
|
||||
#if defined(USING_TRANSACTIONS)
|
||||
/*
|
||||
Should we write to the binlog cache or to the binlog on disk?
|
||||
Write to the binlog cache if:
|
||||
|
@ -4124,7 +4123,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
|
|||
LOCK_log.
|
||||
*/
|
||||
}
|
||||
#endif /* USING_TRANSACTIONS */
|
||||
|
||||
DBUG_PRINT("info",("event type: %d",event_info->get_type_code()));
|
||||
|
||||
/*
|
||||
|
@ -4547,7 +4546,7 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event,
|
|||
bool incident)
|
||||
{
|
||||
DBUG_ENTER("MYSQL_BIN_LOG::write(THD *, IO_CACHE *, Log_event *)");
|
||||
VOID(pthread_mutex_lock(&LOCK_log));
|
||||
pthread_mutex_lock(&LOCK_log);
|
||||
|
||||
/* NULL would represent nothing to replicate after ROLLBACK */
|
||||
DBUG_ASSERT(commit_event != NULL);
|
||||
|
@ -4636,7 +4635,7 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event,
|
|||
else
|
||||
rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
|
||||
}
|
||||
VOID(pthread_mutex_unlock(&LOCK_log));
|
||||
pthread_mutex_unlock(&LOCK_log);
|
||||
|
||||
DBUG_RETURN(0);
|
||||
|
||||
|
@ -4646,7 +4645,7 @@ err:
|
|||
write_error= 1;
|
||||
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
|
||||
}
|
||||
VOID(pthread_mutex_unlock(&LOCK_log));
|
||||
pthread_mutex_unlock(&LOCK_log);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
|
@ -4866,7 +4865,7 @@ bool flush_error_log()
|
|||
char err_renamed[FN_REFLEN], *end;
|
||||
end= strmake(err_renamed,log_error_file,FN_REFLEN-4);
|
||||
strmov(end, "-old");
|
||||
VOID(pthread_mutex_lock(&LOCK_error_log));
|
||||
pthread_mutex_lock(&LOCK_error_log);
|
||||
#ifdef __WIN__
|
||||
char err_temp[FN_REFLEN+4];
|
||||
/*
|
||||
|
@ -4913,7 +4912,7 @@ bool flush_error_log()
|
|||
else
|
||||
result= 1;
|
||||
#endif
|
||||
VOID(pthread_mutex_unlock(&LOCK_error_log));
|
||||
pthread_mutex_unlock(&LOCK_error_log);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -4988,7 +4987,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer)
|
|||
DBUG_ENTER("print_buffer_to_file");
|
||||
DBUG_PRINT("enter",("buffer: %s", buffer));
|
||||
|
||||
VOID(pthread_mutex_lock(&LOCK_error_log));
|
||||
pthread_mutex_lock(&LOCK_error_log);
|
||||
|
||||
skr= my_time(0);
|
||||
localtime_r(&skr, &tm_tmp);
|
||||
|
@ -5007,7 +5006,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer)
|
|||
|
||||
fflush(stderr);
|
||||
|
||||
VOID(pthread_mutex_unlock(&LOCK_error_log));
|
||||
pthread_mutex_unlock(&LOCK_error_log);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
|
|
@ -3892,7 +3892,6 @@ int Format_description_log_event::do_apply_event(Relay_log_info const *rli)
|
|||
int ret= 0;
|
||||
DBUG_ENTER("Format_description_log_event::do_apply_event");
|
||||
|
||||
#ifdef USING_TRANSACTIONS
|
||||
/*
|
||||
As a transaction NEVER spans on 2 or more binlogs:
|
||||
if we have an active transaction at this point, the master died
|
||||
|
@ -3914,7 +3913,7 @@ int Format_description_log_event::do_apply_event(Relay_log_info const *rli)
|
|||
"its binary log, thus rolled back too.");
|
||||
const_cast<Relay_log_info*>(rli)->cleanup_context(thd, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
If this event comes from ourselves, there is no cleaning task to
|
||||
perform, we don't call Start_log_event_v3::do_apply_event()
|
||||
|
@ -4578,7 +4577,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
|
|||
if (rpl_filter->db_ok(thd->db))
|
||||
{
|
||||
thd->set_time((time_t)when);
|
||||
thd->query_id = next_query_id();
|
||||
thd->set_query_id(next_query_id());
|
||||
thd->warning_info->opt_clear_warning_info(thd->query_id);
|
||||
|
||||
TABLE_LIST tables;
|
||||
|
|
|
@ -478,17 +478,7 @@ protected:
|
|||
#if defined(__WIN__)
|
||||
#undef FLUSH_TIME
|
||||
#define FLUSH_TIME 1800 /**< Flush every half hour */
|
||||
|
||||
#define INTERRUPT_PRIOR -2
|
||||
#define CONNECT_PRIOR -1
|
||||
#define WAIT_PRIOR 0
|
||||
#define QUERY_PRIOR 2
|
||||
#else
|
||||
#define INTERRUPT_PRIOR 10
|
||||
#define CONNECT_PRIOR 9
|
||||
#define WAIT_PRIOR 8
|
||||
#define QUERY_PRIOR 6
|
||||
#endif /* __WIN92__ */
|
||||
#endif /* __WIN__ */
|
||||
|
||||
/* Bits from testflag */
|
||||
#define TEST_PRINT_CACHED_TABLES 1
|
||||
|
|
|
@ -48,10 +48,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_SKIP_THREAD_PRIORITY
|
||||
#define DEFAULT_SKIP_THREAD_PRIORITY 0
|
||||
#endif
|
||||
|
||||
#include <thr_alarm.h>
|
||||
#include <ft_global.h>
|
||||
#include <errmsg.h>
|
||||
|
@ -1046,14 +1042,14 @@ static void close_server_sock()
|
|||
{
|
||||
ip_sock=INVALID_SOCKET;
|
||||
DBUG_PRINT("info",("calling shutdown on TCP/IP socket"));
|
||||
VOID(shutdown(tmp_sock, SHUT_RDWR));
|
||||
(void) shutdown(tmp_sock, SHUT_RDWR);
|
||||
#if defined(__NETWARE__)
|
||||
/*
|
||||
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));
|
||||
(void) closesocket(tmp_sock);
|
||||
#endif
|
||||
}
|
||||
tmp_sock=unix_sock;
|
||||
|
@ -1061,16 +1057,16 @@ static void close_server_sock()
|
|||
{
|
||||
unix_sock=INVALID_SOCKET;
|
||||
DBUG_PRINT("info",("calling shutdown on unix socket"));
|
||||
VOID(shutdown(tmp_sock, SHUT_RDWR));
|
||||
(void) shutdown(tmp_sock, SHUT_RDWR);
|
||||
#if defined(__NETWARE__)
|
||||
/*
|
||||
The following code is disabled for normal systems as it may cause MySQL
|
||||
to hang on AIX 4.3 during shutdown
|
||||
*/
|
||||
DBUG_PRINT("info",("calling closesocket on unix/IP socket"));
|
||||
VOID(closesocket(tmp_sock));
|
||||
(void) closesocket(tmp_sock);
|
||||
#endif
|
||||
VOID(unlink(mysqld_unix_port));
|
||||
(void) unlink(mysqld_unix_port);
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
#endif
|
||||
|
@ -2476,7 +2472,8 @@ and this may fail.\n\n");
|
|||
fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
|
||||
fprintf(stderr, "max_used_connections=%lu\n", max_used_connections);
|
||||
fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads);
|
||||
fprintf(stderr, "threads_connected=%u\n", thread_count);
|
||||
fprintf(stderr, "thread_count=%u\n", thread_count);
|
||||
fprintf(stderr, "connection_count=%u\n", connection_count);
|
||||
fprintf(stderr, "It is possible that mysqld could use up to \n\
|
||||
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = %lu K\n\
|
||||
bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size +
|
||||
|
@ -2685,8 +2682,6 @@ static void start_signal_handler(void)
|
|||
#if !defined(HAVE_DEC_3_2_THREADS)
|
||||
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM);
|
||||
(void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_attr_setprio(&thr_attr,INTERRUPT_PRIOR);
|
||||
#if defined(__ia64__) || defined(__ia64)
|
||||
/*
|
||||
Peculiar things with ia64 platforms - it seems we only have half the
|
||||
|
@ -2806,8 +2801,6 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
|
|||
abort_loop=1; // mark abort for threads
|
||||
#ifdef USE_ONE_SIGNAL_HAND
|
||||
pthread_t tmp;
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_attr_setprio(&connection_attrib,INTERRUPT_PRIOR);
|
||||
if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
|
||||
(void*) &sig))
|
||||
sql_print_error("Can't create thread to kill server");
|
||||
|
@ -3633,8 +3626,6 @@ static int init_thread_environment()
|
|||
(void) pthread_attr_setdetachstate(&connection_attrib,
|
||||
PTHREAD_CREATE_DETACHED);
|
||||
pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR);
|
||||
|
||||
if (pthread_key_create(&THR_THD,NULL) ||
|
||||
pthread_key_create(&THR_MALLOC,NULL))
|
||||
|
@ -4342,8 +4333,6 @@ int main(int argc, char **argv)
|
|||
unireg_abort(1); // Will do exit
|
||||
|
||||
init_signals();
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_setprio(pthread_self(),CONNECT_PRIOR);
|
||||
#if defined(__ia64__) || defined(__ia64)
|
||||
/*
|
||||
Peculiar things with ia64 platforms - it seems we only have half the
|
||||
|
@ -5033,8 +5022,6 @@ void handle_connections_sockets()
|
|||
|
||||
LINT_INIT(new_sock);
|
||||
|
||||
(void) my_pthread_getprio(pthread_self()); // For debugging
|
||||
|
||||
FD_ZERO(&clientFDs);
|
||||
if (ip_sock != INVALID_SOCKET)
|
||||
{
|
||||
|
@ -5193,7 +5180,7 @@ void handle_connections_sockets()
|
|||
if (!(thd= new THD))
|
||||
{
|
||||
(void) shutdown(new_sock, SHUT_RDWR);
|
||||
VOID(closesocket(new_sock));
|
||||
(void) closesocket(new_sock);
|
||||
continue;
|
||||
}
|
||||
if (!(vio_tmp=vio_new(new_sock,
|
||||
|
@ -6457,8 +6444,9 @@ Can't be set to 1 if --log-slave-updates is used.",
|
|||
{"skip-symlink", OPT_SKIP_SYMLINKS, "Don't allow symlinking of tables. Deprecated option. Use --skip-symbolic-links instead.",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"skip-thread-priority", OPT_SKIP_PRIOR,
|
||||
"Don't give threads different priorities. Deprecated option.", 0, 0, 0, GET_NO_ARG, NO_ARG,
|
||||
DEFAULT_SKIP_THREAD_PRIORITY, 0, 0, 0, 0, 0},
|
||||
"Don't give threads different priorities. This option is deprecated "
|
||||
"because it has no effect; the implied behavior is already the default.",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
#ifdef HAVE_REPLICATION
|
||||
{"slave-load-tmpdir", OPT_SLAVE_LOAD_TMPDIR,
|
||||
"The location where the slave should put its temporary files when \
|
||||
|
@ -7629,7 +7617,7 @@ SHOW_VAR status_vars[]= {
|
|||
{"Tc_log_page_waits", (char*) &tc_log_page_waits, SHOW_LONG},
|
||||
#endif
|
||||
{"Threads_cached", (char*) &cached_thread_count, SHOW_LONG_NOFLUSH},
|
||||
{"Threads_connected", (char*) &thread_count, SHOW_INT},
|
||||
{"Threads_connected", (char*) &connection_count, SHOW_INT},
|
||||
{"Threads_created", (char*) &thread_created, SHOW_LONG_NOFLUSH},
|
||||
{"Threads_running", (char*) &thread_running, SHOW_INT},
|
||||
{"Uptime", (char*) &show_starttime, SHOW_FUNC},
|
||||
|
@ -7928,9 +7916,6 @@ static int mysql_init_variables(void)
|
|||
#ifdef HAVE_SMEM
|
||||
shared_memory_base_name= default_shared_memory_base_name;
|
||||
#endif
|
||||
#if !defined(my_pthread_setprio) && !defined(HAVE_PTHREAD_SETSCHEDPARAM)
|
||||
opt_specialflag |= SPECIAL_NO_PRIOR;
|
||||
#endif
|
||||
|
||||
#if defined(__WIN__) || defined(__NETWARE__)
|
||||
/* Allow Win32 and NetWare users to move MySQL anywhere */
|
||||
|
@ -8214,8 +8199,8 @@ mysqld_get_one_option(int optid,
|
|||
case (int) OPT_SKIP_PRIOR:
|
||||
opt_specialflag|= SPECIAL_NO_PRIOR;
|
||||
sql_print_warning("The --skip-thread-priority startup option is deprecated "
|
||||
"and will be removed in MySQL 7.0. MySQL 6.0 and up do not "
|
||||
"give threads different priorities.");
|
||||
"and will be removed in MySQL 7.0. This option has no effect "
|
||||
"as the implied behavior is already the default.");
|
||||
break;
|
||||
case (int) OPT_SKIP_LOCK:
|
||||
opt_external_locking=0;
|
||||
|
|
|
@ -730,7 +730,7 @@ class SQL_SELECT :public Sql_alloc {
|
|||
class FT_SELECT: public QUICK_RANGE_SELECT {
|
||||
public:
|
||||
FT_SELECT(THD *thd, TABLE *table, uint key) :
|
||||
QUICK_RANGE_SELECT (thd, table, key, 1) { VOID(init()); }
|
||||
QUICK_RANGE_SELECT (thd, table, key, 1) { (void) init(); }
|
||||
~FT_SELECT() { file->ft_end(); }
|
||||
int init() { return error=file->ft_init(); }
|
||||
int reset() { return 0; }
|
||||
|
|
|
@ -247,6 +247,7 @@ net_send_ok(THD *thd,
|
|||
if (!error)
|
||||
error= net_flush(net);
|
||||
|
||||
|
||||
thd->stmt_da->can_overwrite_status= FALSE;
|
||||
DBUG_PRINT("info", ("OK sent, so no more error sending allowed"));
|
||||
|
||||
|
@ -406,6 +407,7 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err,
|
|||
buff[2]= '#';
|
||||
pos= (uchar*) strmov((char*) buff+3, sqlstate);
|
||||
}
|
||||
|
||||
converted_err_len= convert_error_message((char*)converted_err,
|
||||
sizeof(converted_err),
|
||||
thd->variables.character_set_results,
|
||||
|
@ -414,6 +416,7 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err,
|
|||
length= (uint) (strmake((char*) pos, (char*)converted_err, MYSQL_ERRMSG_SIZE) -
|
||||
(char*) buff);
|
||||
err= (char*) buff;
|
||||
|
||||
DBUG_RETURN(net_write_command(net,(uchar) 255, (uchar*) "", 0, (uchar*) err,
|
||||
length));
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
|
|||
|
||||
if (table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE &&
|
||||
!table->sort.addon_field)
|
||||
VOID(table->file->extra(HA_EXTRA_MMAP));
|
||||
(void) table->file->extra(HA_EXTRA_MMAP);
|
||||
|
||||
if (table->sort.addon_field)
|
||||
{
|
||||
|
@ -266,8 +266,8 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
|
|||
!(table->s->db_options_in_use & HA_OPTION_PACK_RECORD) ||
|
||||
(use_record_cache < 0 &&
|
||||
!(table->file->ha_table_flags() & HA_NOT_DELETE_WITH_CACHE))))
|
||||
VOID(table->file->extra_opt(HA_EXTRA_CACHE,
|
||||
thd->variables.read_buff_size));
|
||||
(void) table->file->extra_opt(HA_EXTRA_CACHE,
|
||||
thd->variables.read_buff_size);
|
||||
}
|
||||
/* Condition pushdown to storage engine */
|
||||
if (thd->variables.engine_condition_pushdown &&
|
||||
|
|
|
@ -1395,12 +1395,10 @@ static void fix_thd_mem_root(THD *thd, enum_var_type type)
|
|||
|
||||
static void fix_trans_mem_root(THD *thd, enum_var_type type)
|
||||
{
|
||||
#ifdef USING_TRANSACTIONS
|
||||
if (type != OPT_GLOBAL)
|
||||
reset_root_defaults(&thd->transaction.mem_root,
|
||||
thd->variables.trans_alloc_block_size,
|
||||
thd->variables.trans_prealloc_size);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -612,8 +612,7 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
|
|||
pthread_cond_t *start_cond,
|
||||
volatile uint *slave_running,
|
||||
volatile ulong *slave_run_id,
|
||||
Master_info* mi,
|
||||
bool high_priority)
|
||||
Master_info* mi)
|
||||
{
|
||||
pthread_t th;
|
||||
ulong start_id;
|
||||
|
@ -643,8 +642,6 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
|
|||
}
|
||||
start_id= *slave_run_id;
|
||||
DBUG_PRINT("info",("Creating new slave thread"));
|
||||
if (high_priority)
|
||||
my_pthread_attr_setprio(&connection_attrib,CONNECT_PRIOR);
|
||||
if (pthread_create(&th, &connection_attrib, h_func, (void*)mi))
|
||||
{
|
||||
if (start_lock)
|
||||
|
@ -707,13 +704,13 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
|
|||
error=start_slave_thread(handle_slave_io,lock_io,lock_cond_io,
|
||||
cond_io,
|
||||
&mi->slave_running, &mi->slave_run_id,
|
||||
mi, 1); //high priority, to read the most possible
|
||||
mi);
|
||||
if (!error && (thread_mask & SLAVE_SQL))
|
||||
{
|
||||
error=start_slave_thread(handle_slave_sql,lock_sql,lock_cond_sql,
|
||||
cond_sql,
|
||||
&mi->rli.slave_running, &mi->rli.slave_run_id,
|
||||
mi, 0);
|
||||
mi);
|
||||
if (error)
|
||||
terminate_slave_threads(mi, thread_mask & SLAVE_IO, !need_slave_mutex);
|
||||
}
|
||||
|
|
|
@ -164,8 +164,7 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t* start_lock,
|
|||
pthread_cond_t* start_cond,
|
||||
volatile uint *slave_running,
|
||||
volatile ulong *slave_run_id,
|
||||
Master_info* mi,
|
||||
bool high_priority);
|
||||
Master_info* mi);
|
||||
|
||||
/* If fd is -1, dump to NET */
|
||||
int mysql_table_dump(THD* thd, const char* db,
|
||||
|
|
|
@ -1769,9 +1769,9 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount,
|
|||
as one select and not resetting THD::user_var_events before
|
||||
each invocation.
|
||||
*/
|
||||
VOID(pthread_mutex_lock(&LOCK_thread_count));
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
q= global_query_id;
|
||||
VOID(pthread_mutex_unlock(&LOCK_thread_count));
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
mysql_bin_log.start_union_events(thd, q + 1);
|
||||
binlog_save_options= thd->options;
|
||||
thd->options&= ~OPTION_BIN_LOG;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue