Commit 3c0aca02 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into  chilla.local:/home/mydev/mysql-5.0-axmrg


sql/item_func.cc:
  Auto merged
parents 9bb750f5 d03d2987
***************
*** 39,46 ****
c_warnings="$global_warnings -Wunused"
cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor"
! alpha_cflags="-mcpu=ev6 -Wa,-mev6" # Not used yet
! pentium_cflags="-mcpu=pentiumpro"
sparc_cflags=""
# be as fast as we can be without losing our ability to backtrace
--- 39,46 ----
c_warnings="$global_warnings -Wunused"
cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor"
! #alpha_cflags="-mcpu=ev6 -Wa,-mev6" # Not used yet
! #pentium_cflags="-mcpu=pentiumpro"
sparc_cflags=""
# be as fast as we can be without losing our ability to backtrace
...@@ -123,6 +123,7 @@ tags: ...@@ -123,6 +123,7 @@ tags:
# making sure each user use different ports. # making sure each user use different ports.
test-ps: test-ps:
cd mysql-test ; \
@PERL@ ./mysql-test-run.pl $(force) --ps-protocol @PERL@ ./mysql-test-run.pl $(force) --ps-protocol
test-ns: test-ns:
......
***************
*** 388,402 ****
if expr "$target_os" : "[[Ll]]inux.*" > /dev/null
then
MYSQLD_DEFAULT_SWITCHES="--skip-locking"
! IS_LINUX="true"
AC_MSG_RESULT("yes");
else
MYSQLD_DEFAULT_SWITCHES=""
! IS_LINUX="false"
AC_MSG_RESULT("no");
fi
AC_SUBST(MYSQLD_DEFAULT_SWITCHES)
! AC_SUBST(IS_LINUX)
dnl Find paths to some shell programs
AC_PATH_PROG(LN, ln, ln)
--- 388,403 ----
if expr "$target_os" : "[[Ll]]inux.*" > /dev/null
then
MYSQLD_DEFAULT_SWITCHES="--skip-locking"
! TARGET_LINUX="true"
AC_MSG_RESULT("yes");
+ AC_DEFINE([TARGET_OS_LINUX], [1], [Whether we build for Linux])
else
MYSQLD_DEFAULT_SWITCHES=""
! TARGET_LINUX="false"
AC_MSG_RESULT("no");
fi
AC_SUBST(MYSQLD_DEFAULT_SWITCHES)
! AC_SUBST(TARGET_LINUX)
dnl Find paths to some shell programs
AC_PATH_PROG(LN, ln, ln)
***************
*** 576,582 ****
# (this is true on the MySQL build machines to avoid NSS problems)
#
! if test "$IS_LINUX" = "true" -a "$static_nss" = ""
then
tmp=`nm /usr/lib/libc.a | grep _nss_files_getaliasent_r`
if test -n "$tmp"
--- 577,583 ----
# (this is true on the MySQL build machines to avoid NSS problems)
#
! if test "$TARGET_LINUX" = "true" -a "$static_nss" = ""
then
tmp=`nm /usr/lib/libc.a | grep _nss_files_getaliasent_r`
if test -n "$tmp"
***************
*** 827,833 ****
])
AC_SUBST(WRAPLIBS)
! if test "$IS_LINUX" = "true"; then
AC_MSG_CHECKING([for atomic operations])
AC_LANG_SAVE
--- 828,834 ----
])
AC_SUBST(WRAPLIBS)
! if test "$TARGET_LINUX" = "true"; then
AC_MSG_CHECKING([for atomic operations])
AC_LANG_SAVE
***************
*** 870,876 ****
[ USE_PSTACK=no ])
pstack_libs=
pstack_dirs=
! if test "$USE_PSTACK" = yes -a "$IS_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386" -a "$with_mit_threads" = "no"
then
have_libiberty= have_libbfd=
my_save_LIBS="$LIBS"
--- 871,877 ----
[ USE_PSTACK=no ])
pstack_libs=
pstack_dirs=
! if test "$USE_PSTACK" = yes -a "$TARGET_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386" -a "$with_mit_threads" = "no"
then
have_libiberty= have_libbfd=
my_save_LIBS="$LIBS"
***************
*** 1239,1301 ****
# Hack for DEC-UNIX (OSF1)
if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
then
! # Look for LinuxThreads.
! AC_MSG_CHECKING("LinuxThreads")
! grepres=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l`
! getconfres=`which getconf >/dev/null && getconf GNU_LIBPTHREAD_VERSION | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ |grep LINUXTHREADS | wc -l || echo 0`
! if test "$grepres" -gt 0 -o "$getconfres" -gt 0
then
! AC_MSG_RESULT("Found")
! AC_DEFINE(HAVE_LINUXTHREADS)
! # Linux 2.0 sanity check
! AC_TRY_COMPILE([#include <sched.h>], [int a = sched_get_priority_min(1);], ,
! AC_MSG_ERROR([Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file. See the Installation chapter in the Reference Manual]))
! # RedHat 5.0 does not work with dynamic linking of this. -static also
! # gives a speed increase in linux so it does not hurt on other systems.
! with_named_thread="-lpthread"
! else
! AC_MSG_RESULT("Not found")
! # If this is a linux machine we should barf
! AC_MSG_CHECKING("NPTL")
! if test "$IS_LINUX" = "true"
! then
! getconfres=`which getconf >/dev/null && getconf GNU_LIBPTHREAD_VERSION | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ |grep NPTL | wc -l || echo 0`
! if test "$getconfres" -gt 0
then
! AC_DEFINE(HAVE_LINUXTHREADS) dnl All this code predates NPTL, so "have linuxthreads" is a poor name.
! with_named_thread="-lpthread"
else
! AC_MSG_ERROR([This is a Linux system and neither Linuxthreads nor NPTL were
! found. Please install Linuxthreads or a new glibc and try
! again. See the Installation chapter in the Reference Manual for
! more information.])
fi
! else
! AC_MSG_CHECKING("DEC threads")
! if test -f /usr/shlib/libpthread.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a
! then
! with_named_thread="-lpthread -lmach -lexc"
! CFLAGS="$CFLAGS -D_REENTRANT"
! CXXFLAGS="$CXXFLAGS -D_REENTRANT"
! AC_DEFINE(HAVE_DEC_THREADS)
! AC_MSG_RESULT("yes")
! else
! AC_MSG_RESULT("no")
! AC_MSG_CHECKING("DEC 3.2 threads")
! if test -f /usr/shlib/libpthreads.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a
! then
! with_named_thread="-lpthreads -lmach -lc_r"
! AC_DEFINE(HAVE_DEC_THREADS)
! AC_DEFINE(HAVE_DEC_3_2_THREADS)
! with_osf32_threads="yes"
! MYSQLD_DEFAULT_SWITCHES="--skip-thread-priority"
! AC_MSG_RESULT("yes")
! else
! AC_MSG_RESULT("no")
! fi
! fi
! fi
! fi
fi
--- 1240,1337 ----
# Hack for DEC-UNIX (OSF1)
if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
then
! AC_MSG_CHECKING("Linux threads")
! if test "$TARGET_LINUX" = "true"
then
! AC_MSG_RESULT("starting")
! # use getconf to check glibc contents
! AC_MSG_CHECKING("getconf GNU_LIBPTHREAD_VERSION")
! case `getconf GNU_LIBPTHREAD_VERSION | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` in
! NPTL* )
! AC_MSG_RESULT("NPTL")
! AC_DEFINE([HAVE_NPTL], [1], [NPTL threads implementation])
! with_named_thread="-lpthread"
! ;;
! LINUXTHREADS* )
! AC_MSG_RESULT("Linuxthreads")
! AC_DEFINE([HAVE_LINUXTHREADS], [1],
! [Whether we are using Xavier Leroy's LinuxThreads])
! with_named_thread="-lpthread"
! ;;
! * )
! AC_MSG_RESULT("unknown")
! ;;
! esac
! if test "$with_named_thread" = "no"
then
! # old method, check headers
! # Look for LinuxThreads.
! AC_MSG_CHECKING("LinuxThreads in header file comment")
! res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l`
! if test "$res" -gt 0
! then
! AC_MSG_RESULT("Found")
! AC_DEFINE([HAVE_LINUXTHREADS], [1],
! [Whether we are using Xavier Leroy's LinuxThreads])
! # Linux 2.0 sanity check
! AC_TRY_COMPILE([#include <sched.h>], [int a = sched_get_priority_min(1);], ,
! AC_MSG_ERROR([Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file. See the Installation chapter in the Reference Manual]))
! # RedHat 5.0 does not work with dynamic linking of this. -static also
! # gives a speed increase in linux so it does not hurt on other systems.
! with_named_thread="-lpthread"
! else
! AC_MSG_RESULT("Not found")
! # If this is a linux machine we should barf
! AC_MSG_ERROR([This is a Linux system without a working getconf,
! and Linuxthreads was not found. Please install it (or a new glibc) and try again.
! See the Installation chapter in the Reference Manual for more information.])
! fi
else
! AC_MSG_RESULT("no need to check headers")
fi
! AC_MSG_CHECKING("for pthread_create in -lpthread");
! ac_save_LIBS="$LIBS"
! LIBS="$LIBS -lpthread"
! AC_TRY_LINK( [#include <pthread.h>],
! [ (void) pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0); ],
! AC_MSG_RESULT("yes"),
! [ AC_MSG_RESULT("no")
! AC_MSG_ERROR([
! This is a Linux system claiming to support threads, either Linuxthreads or NPTL, but linking a test program failed.
! Please install one of these (or a new glibc) and try again.
! See the Installation chapter in the Reference Manual for more information.]) ]
! )
! LIBS="$ac_save_LIBS"
! else
! AC_MSG_RESULT("no")
! fi # "$TARGET_LINUX"
! fi # "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
!
! if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
! then
! AC_MSG_CHECKING("DEC threads")
! if test -f /usr/shlib/libpthread.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a
! then
! with_named_thread="-lpthread -lmach -lexc"
! CFLAGS="$CFLAGS -D_REENTRANT"
! CXXFLAGS="$CXXFLAGS -D_REENTRANT"
! AC_DEFINE(HAVE_DEC_THREADS)
! AC_MSG_RESULT("yes")
! else
! AC_MSG_RESULT("no")
! AC_MSG_CHECKING("DEC 3.2 threads")
! if test -f /usr/shlib/libpthreads.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a
! then
! with_named_thread="-lpthreads -lmach -lc_r"
! AC_DEFINE(HAVE_DEC_THREADS)
! AC_DEFINE(HAVE_DEC_3_2_THREADS)
! with_osf32_threads="yes"
! MYSQLD_DEFAULT_SWITCHES="--skip-thread-priority"
! AC_MSG_RESULT("yes")
! else
! AC_MSG_RESULT("no")
! fi
! fi
fi
***************
*** 1720,1726 ****
AC_SUBST(COMPILATION_COMMENT)
AC_MSG_CHECKING("need of special linking flags")
! if test "$IS_LINUX" = "true" -a "$ac_cv_prog_gcc" = "yes" -a "$all_is_static" != "yes"
then
LDFLAGS="$LDFLAGS -rdynamic"
AC_MSG_RESULT("-rdynamic")
--- 1756,1762 ----
AC_SUBST(COMPILATION_COMMENT)
AC_MSG_CHECKING("need of special linking flags")
! if test "$TARGET_LINUX" = "true" -a "$ac_cv_prog_gcc" = "yes" -a "$all_is_static" != "yes"
then
LDFLAGS="$LDFLAGS -rdynamic"
AC_MSG_RESULT("-rdynamic")
***************
*** 1873,1878 ****
tell atod memcpy memmove \
setupterm strcasecmp sighold vidattr lrand48 localtime_r \
sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \
pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \
pthread_attr_getstacksize pthread_key_delete \
--- 1909,1915 ----
tell atod memcpy memmove \
setupterm strcasecmp sighold vidattr lrand48 localtime_r \
sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \
+ sigaction sigemptyset sigaddset \
pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \
pthread_attr_getstacksize pthread_key_delete \
***************
*** 1884,1890 ****
# Sanity check: We chould not have any fseeko symbol unless
# large_file_support=yes
AC_CHECK_FUNCS(fseeko,
! [if test "$large_file_support" = no -a "$IS_LINUX" = "true";
then
AC_MSG_ERROR("Found fseeko symbol but large_file_support is not enabled!");
fi]
--- 1921,1927 ----
# Sanity check: We chould not have any fseeko symbol unless
# large_file_support=yes
AC_CHECK_FUNCS(fseeko,
! [if test "$large_file_support" = no -a "$TARGET_LINUX" = "true";
then
AC_MSG_ERROR("Found fseeko symbol but large_file_support is not enabled!");
fi]
***************
*** 97,103 ****
/* Fix problem with S_ISLNK() on Linux */
! #if defined(HAVE_LINUXTHREADS)
#undef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
--- 97,103 ----
/* Fix problem with S_ISLNK() on Linux */
! #if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
#undef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
...@@ -49,7 +49,6 @@ extern "C" { ...@@ -49,7 +49,6 @@ extern "C" {
#define NPTL_PTHREAD_EXIT_BUG 1 #define NPTL_PTHREAD_EXIT_BUG 1
#endif #endif
#if defined(__WIN__) || defined(OS2) #if defined(__WIN__) || defined(OS2)
#ifdef OS2 #ifdef OS2
...@@ -764,6 +763,15 @@ extern uint my_thread_end_wait_time; ...@@ -764,6 +763,15 @@ extern uint my_thread_end_wait_time;
Keep track of shutdown,signal, and main threads so that my_end() will not Keep track of shutdown,signal, and main threads so that my_end() will not
report errors with them report errors with them
*/ */
/* Which kind of thread library is in use */
#define THD_LIB_OTHER 1
#define THD_LIB_NPTL 2
#define THD_LIB_LT 4
extern uint thd_lib_detected;
/* statistics_xxx functions are for not essential statistic */ /* statistics_xxx functions are for not essential statistic */
#ifndef thread_safe_increment #ifndef thread_safe_increment
......
***************
*** 286,293 ****
#undef HAVE_PTHREAD_RWLOCK_RDLOCK
#undef HAVE_SNPRINTF
! #define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
! #define signal(A,B) pthread_signal((A),(void (*)(int)) (B))
#define my_pthread_attr_setprio(A,B)
#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */
--- 294,301 ----
#undef HAVE_PTHREAD_RWLOCK_RDLOCK
#undef HAVE_SNPRINTF
! #define my_sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
! #define my_signal(A,B) pthread_signal((A),(void (*)(int)) (B))
#define my_pthread_attr_setprio(A,B)
#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */
***************
*** 324,337 ****
#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
#endif
! #if !defined(HAVE_SIGSET) && !defined(HAVE_mit_thread) && !defined(sigset)
! #define sigset(A,B) do { struct sigaction s; sigset_t set; \
! sigemptyset(&set); \
! s.sa_handler = (B); \
! s.sa_mask = set; \
! s.sa_flags = 0; \
! sigaction((A), &s, (struct sigaction *) NULL); \
} while (0)
#endif
#ifndef my_pthread_setprio
--- 332,358 ----
#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
#endif
!
! /*
! We define my_sigset() and use that instead of the system sigset() so that
! we can favor an implementation based on sigaction(). On some systems, such
! as Mac OS X, sigset() results in flags such as SA_RESTART being set, and
! we want to make sure that no such flags are set.
! */
! #if defined(HAVE_SIGACTION) && !defined(my_sigset)
! #define my_sigset(A,B) do { struct sigaction s; sigset_t set; int rc; \
! DBUG_ASSERT((A) != 0); \
! sigemptyset(&set); \
! s.sa_handler = (B); \
! s.sa_mask = set; \
! s.sa_flags = 0; \
! rc= sigaction((A), &s, (struct sigaction *) NULL); \
! DBUG_ASSERT(rc == 0); \
} while (0)
+ #elif defined(HAVE_SIGSET) && !defined(my_sigset)
+ #define my_sigset(A,B) sigset((A),(B))
+ #elif !defined(my_sigset)
+ #define my_sigset(A,B) signal((A),(B))
#endif
#ifndef my_pthread_setprio
***************
*** 416,422 ****
#undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); }
#undef sigset
! #define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
#endif
#if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER)
--- 437,443 ----
#undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); }
#undef sigset
! #define my_sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
#endif
#if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER)
...@@ -24,11 +24,6 @@ extern "C" { ...@@ -24,11 +24,6 @@ extern "C" {
#ifndef USE_ALARM_THREAD #ifndef USE_ALARM_THREAD
#define USE_ONE_SIGNAL_HAND /* One must call process_alarm */ #define USE_ONE_SIGNAL_HAND /* One must call process_alarm */
#endif #endif
#ifdef HAVE_LINUXTHREADS
#define THR_CLIENT_ALARM SIGALRM
#else
#define THR_CLIENT_ALARM SIGUSR1
#endif
#ifdef HAVE_rts_threads #ifdef HAVE_rts_threads
#undef USE_ONE_SIGNAL_HAND #undef USE_ONE_SIGNAL_HAND
#define USE_ALARM_THREAD #define USE_ALARM_THREAD
...@@ -97,6 +92,9 @@ typedef struct st_alarm { ...@@ -97,6 +92,9 @@ typedef struct st_alarm {
my_bool malloced; my_bool malloced;
} ALARM; } ALARM;
extern uint thr_client_alarm;
extern pthread_t alarm_thread;
#define thr_alarm_init(A) (*(A))=0 #define thr_alarm_init(A) (*(A))=0
#define thr_alarm_in_use(A) (*(A)!= 0) #define thr_alarm_in_use(A) (*(A)!= 0)
void init_thr_alarm(uint max_alarm); void init_thr_alarm(uint max_alarm);
......
...@@ -772,7 +772,7 @@ CREATE TABLE t1(a INT); ...@@ -772,7 +772,7 @@ CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(2),(1); INSERT INTO t1 VALUES(2),(1);
CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1);
SELECT * FROM t2 WHERE a=2; SELECT * FROM t2 WHERE a=2;
ERROR HY000: Got error 124 from storage engine ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE t1, t2; DROP TABLE t1, t2;
CREATE TABLE t1(a INT) ENGINE=MEMORY; CREATE TABLE t1(a INT) ENGINE=MEMORY;
CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1); CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1);
...@@ -783,6 +783,26 @@ CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3); ...@@ -783,6 +783,26 @@ CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3);
SELECT * FROM t2; SELECT * FROM t2;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t1(a INT, b TEXT);
CREATE TABLE tm1(a TEXT, b INT) ENGINE=MERGE UNION=(t1);
SELECT * FROM tm1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE t1, tm1;
CREATE TABLE t1(a SMALLINT, b SMALLINT);
CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1);
SELECT * FROM tm1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE t1, tm1;
CREATE TABLE t1(a SMALLINT, b SMALLINT, KEY(a, b));
CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1);
SELECT * FROM tm1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE t1, tm1;
CREATE TABLE t1(a SMALLINT, b SMALLINT, KEY(b));
CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1);
SELECT * FROM tm1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE t1, tm1;
create table t1 (b bit(1)); create table t1 (b bit(1));
create table t2 (b bit(1)); create table t2 (b bit(1));
create table tm (b bit(1)) engine = merge union = (t1,t2); create table tm (b bit(1)) engine = merge union = (t1,t2);
......
...@@ -385,7 +385,7 @@ drop table t1, t2, t3; ...@@ -385,7 +385,7 @@ drop table t1, t2, t3;
CREATE TABLE t1(a INT); CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(2),(1); INSERT INTO t1 VALUES(2),(1);
CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1);
--error 1030 --error 1168
SELECT * FROM t2 WHERE a=2; SELECT * FROM t2 WHERE a=2;
DROP TABLE t1, t2; DROP TABLE t1, t2;
...@@ -403,6 +403,33 @@ CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3); ...@@ -403,6 +403,33 @@ CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3);
SELECT * FROM t2; SELECT * FROM t2;
DROP TABLE t2; DROP TABLE t2;
#
# Underlying table definition conformance tests.
#
CREATE TABLE t1(a INT, b TEXT);
CREATE TABLE tm1(a TEXT, b INT) ENGINE=MERGE UNION=(t1);
--error 1168
SELECT * FROM tm1;
DROP TABLE t1, tm1;
CREATE TABLE t1(a SMALLINT, b SMALLINT);
CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1);
--error 1168
SELECT * FROM tm1;
DROP TABLE t1, tm1;
CREATE TABLE t1(a SMALLINT, b SMALLINT, KEY(a, b));
CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1);
--error 1168
SELECT * FROM tm1;
DROP TABLE t1, tm1;
CREATE TABLE t1(a SMALLINT, b SMALLINT, KEY(b));
CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1);
--error 1168
SELECT * FROM tm1;
DROP TABLE t1, tm1;
# End of 4.1 tests # End of 4.1 tests
# #
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#define SCHED_POLICY SCHED_OTHER #define SCHED_POLICY SCHED_OTHER
#endif #endif
uint thd_lib_detected;
#ifndef my_pthread_setprio #ifndef my_pthread_setprio
void my_pthread_setprio(pthread_t thread_id,int prior) void my_pthread_setprio(pthread_t thread_id,int prior)
{ {
...@@ -315,8 +317,6 @@ void sigwait_handle_sig(int sig) ...@@ -315,8 +317,6 @@ void sigwait_handle_sig(int sig)
pthread_mutex_unlock(&LOCK_sigwait); pthread_mutex_unlock(&LOCK_sigwait);
} }
extern pthread_t alarm_thread;
void *sigwait_thread(void *set_arg) void *sigwait_thread(void *set_arg)
{ {
sigset_t *set=(sigset_t*) set_arg; sigset_t *set=(sigset_t*) set_arg;
...@@ -335,7 +335,9 @@ void *sigwait_thread(void *set_arg) ...@@ -335,7 +335,9 @@ void *sigwait_thread(void *set_arg)
sigaction(i, &sact, (struct sigaction*) 0); sigaction(i, &sact, (struct sigaction*) 0);
} }
} }
sigaddset(set,THR_CLIENT_ALARM); /* Ensure that init_thr_alarm() is called */
DBUG_ASSERT(thr_client_alarm);
sigaddset(set, thr_client_alarm);
pthread_sigmask(SIG_UNBLOCK,(sigset_t*) set,(sigset_t*) 0); pthread_sigmask(SIG_UNBLOCK,(sigset_t*) set,(sigset_t*) 0);
alarm_thread=pthread_self(); /* For thr_alarm */ alarm_thread=pthread_self(); /* For thr_alarm */
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "mysys_priv.h" #include "mysys_priv.h"
#include <m_string.h> #include <m_string.h>
#include <signal.h>
#ifdef THREAD #ifdef THREAD
#ifdef USE_TLS #ifdef USE_TLS
...@@ -63,6 +64,8 @@ pthread_handler_t nptl_pthread_exit_hack_handler(void *arg) ...@@ -63,6 +64,8 @@ pthread_handler_t nptl_pthread_exit_hack_handler(void *arg)
#endif #endif
static uint get_thread_lib(void);
/* /*
initialize thread environment initialize thread environment
...@@ -76,6 +79,8 @@ pthread_handler_t nptl_pthread_exit_hack_handler(void *arg) ...@@ -76,6 +79,8 @@ pthread_handler_t nptl_pthread_exit_hack_handler(void *arg)
my_bool my_thread_global_init(void) my_bool my_thread_global_init(void)
{ {
thd_lib_detected= get_thread_lib();
if (pthread_key_create(&THR_KEY_mysys,0)) if (pthread_key_create(&THR_KEY_mysys,0))
{ {
fprintf(stderr,"Can't initialize threads: error %d\n",errno); fprintf(stderr,"Can't initialize threads: error %d\n",errno);
...@@ -392,4 +397,20 @@ const char *my_thread_name(void) ...@@ -392,4 +397,20 @@ const char *my_thread_name(void)
} }
#endif /* DBUG_OFF */ #endif /* DBUG_OFF */
static uint get_thread_lib(void)
{
char buff[64];
#ifdef _CS_GNU_LIBPTHREAD_VERSION
confstr(_CS_GNU_LIBPTHREAD_VERSION, buff, sizeof(buff));
if (!strncasecmp(buff, "NPTL", 4))
return THD_LIB_NPTL;
if (!strncasecmp(buff, "linuxthreads", 12))
return THD_LIB_LT;
#endif
return THD_LIB_OTHER;
}
#endif /* THREAD */ #endif /* THREAD */
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#define ETIME ETIMEDOUT #define ETIME ETIMEDOUT
#endif #endif
uint thr_client_alarm;
static int alarm_aborted=1; /* No alarm thread */ static int alarm_aborted=1; /* No alarm thread */
my_bool thr_alarm_inited= 0; my_bool thr_alarm_inited= 0;
volatile my_bool alarm_thread_running= 0; volatile my_bool alarm_thread_running= 0;
...@@ -57,9 +58,7 @@ static void *alarm_handler(void *arg); ...@@ -57,9 +58,7 @@ static void *alarm_handler(void *arg);
#define reschedule_alarms() pthread_kill(alarm_thread,THR_SERVER_ALARM) #define reschedule_alarms() pthread_kill(alarm_thread,THR_SERVER_ALARM)
#endif #endif
#if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
static sig_handler thread_alarm(int sig __attribute__((unused))); static sig_handler thread_alarm(int sig __attribute__((unused)));
#endif
static int compare_ulong(void *not_used __attribute__((unused)), static int compare_ulong(void *not_used __attribute__((unused)),
byte *a_ptr,byte* b_ptr) byte *a_ptr,byte* b_ptr)
...@@ -78,9 +77,16 @@ void init_thr_alarm(uint max_alarms) ...@@ -78,9 +77,16 @@ void init_thr_alarm(uint max_alarms)
sigfillset(&full_signal_set); /* Neaded to block signals */ sigfillset(&full_signal_set); /* Neaded to block signals */
pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST); pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_alarm,NULL); pthread_cond_init(&COND_alarm,NULL);
#if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD) if (thd_lib_detected == THD_LIB_LT)
my_sigset(THR_CLIENT_ALARM,thread_alarm); thr_client_alarm= SIGALRM;
else
thr_client_alarm= SIGUSR1;
#ifndef USE_ALARM_THREAD
if (thd_lib_detected != THD_LIB_LT)
#endif #endif
{
my_sigset(thr_client_alarm, thread_alarm);
}
sigemptyset(&s); sigemptyset(&s);
sigaddset(&s, THR_SERVER_ALARM); sigaddset(&s, THR_SERVER_ALARM);
alarm_thread=pthread_self(); alarm_thread=pthread_self();
...@@ -98,10 +104,11 @@ void init_thr_alarm(uint max_alarms) ...@@ -98,10 +104,11 @@ void init_thr_alarm(uint max_alarms)
} }
#elif defined(USE_ONE_SIGNAL_HAND) #elif defined(USE_ONE_SIGNAL_HAND)
pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */ pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */
#if THR_SERVER_ALARM == THR_CLIENT_ALARM if (thd_lib_detected == THD_LIB_LT)
my_sigset(THR_CLIENT_ALARM,process_alarm); /* Linuxthreads */ {
pthread_sigmask(SIG_UNBLOCK, &s, NULL); my_sigset(thr_client_alarm, process_alarm); /* Linuxthreads */
#endif pthread_sigmask(SIG_UNBLOCK, &s, NULL);
}
#else #else
my_sigset(THR_SERVER_ALARM, process_alarm); my_sigset(THR_SERVER_ALARM, process_alarm);
pthread_sigmask(SIG_UNBLOCK, &s, NULL); pthread_sigmask(SIG_UNBLOCK, &s, NULL);
...@@ -152,7 +159,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data) ...@@ -152,7 +159,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)
now=(ulong) time((time_t*) 0); now=(ulong) time((time_t*) 0);
pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask); pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask);
pthread_mutex_lock(&LOCK_alarm); /* Lock from threads & alarms */ pthread_mutex_lock(&LOCK_alarm); /* Lock from threads & alarms */
if (alarm_aborted > 0) if (alarm_aborted > 0)
{ /* No signal thread */ { /* No signal thread */
DBUG_PRINT("info", ("alarm aborted")); DBUG_PRINT("info", ("alarm aborted"));
...@@ -272,18 +279,17 @@ sig_handler process_alarm(int sig __attribute__((unused))) ...@@ -272,18 +279,17 @@ sig_handler process_alarm(int sig __attribute__((unused)))
This must be first as we can't call DBUG inside an alarm for a normal thread This must be first as we can't call DBUG inside an alarm for a normal thread
*/ */
#if THR_SERVER_ALARM == THR_CLIENT_ALARM if (thd_lib_detected == THD_LIB_LT &&
if (!pthread_equal(pthread_self(),alarm_thread)) !pthread_equal(pthread_self(),alarm_thread))
{ {
#if defined(MAIN) && !defined(__bsdi__) #if defined(MAIN) && !defined(__bsdi__)
printf("thread_alarm\n"); fflush(stdout); printf("thread_alarm in process_alarm\n"); fflush(stdout);
#endif #endif
#ifdef DONT_REMEMBER_SIGNAL #ifdef DONT_REMEMBER_SIGNAL
my_sigset(THR_CLIENT_ALARM,process_alarm); /* int. thread system calls */ my_sigset(thr_client_alarm, process_alarm); /* int. thread system calls */
#endif #endif
return; return;
} }
#endif
/* /*
We have to do do the handling of the alarm in a sub function, We have to do do the handling of the alarm in a sub function,
...@@ -327,7 +333,7 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused))) ...@@ -327,7 +333,7 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused)))
alarm_data=(ALARM*) queue_element(&alarm_queue,i); alarm_data=(ALARM*) queue_element(&alarm_queue,i);
alarm_data->alarmed=1; /* Info to thread */ alarm_data->alarmed=1; /* Info to thread */
if (pthread_equal(alarm_data->thread,alarm_thread) || if (pthread_equal(alarm_data->thread,alarm_thread) ||
pthread_kill(alarm_data->thread, THR_CLIENT_ALARM)) pthread_kill(alarm_data->thread, thr_client_alarm))
{ {
#ifdef MAIN #ifdef MAIN
printf("Warning: pthread_kill couldn't find thread!!!\n"); printf("Warning: pthread_kill couldn't find thread!!!\n");
...@@ -351,7 +357,7 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused))) ...@@ -351,7 +357,7 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused)))
alarm_data->alarmed=1; /* Info to thread */ alarm_data->alarmed=1; /* Info to thread */
DBUG_PRINT("info",("sending signal to waiting thread")); DBUG_PRINT("info",("sending signal to waiting thread"));
if (pthread_equal(alarm_data->thread,alarm_thread) || if (pthread_equal(alarm_data->thread,alarm_thread) ||
pthread_kill(alarm_data->thread, THR_CLIENT_ALARM)) pthread_kill(alarm_data->thread, thr_client_alarm))
{ {
#ifdef MAIN #ifdef MAIN
printf("Warning: pthread_kill couldn't find thread!!!\n"); printf("Warning: pthread_kill couldn't find thread!!!\n");
...@@ -488,7 +494,7 @@ void thr_alarm_info(ALARM_INFO *info) ...@@ -488,7 +494,7 @@ void thr_alarm_info(ALARM_INFO *info)
ARGSUSED ARGSUSED
*/ */
#if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
static sig_handler thread_alarm(int sig) static sig_handler thread_alarm(int sig)
{ {
#ifdef MAIN #ifdef MAIN
...@@ -498,7 +504,6 @@ static sig_handler thread_alarm(int sig) ...@@ -498,7 +504,6 @@ static sig_handler thread_alarm(int sig)
my_sigset(sig,thread_alarm); /* int. thread system calls */ my_sigset(sig,thread_alarm); /* int. thread system calls */
#endif #endif
} }
#endif
#ifdef HAVE_TIMESPEC_TS_SEC #ifdef HAVE_TIMESPEC_TS_SEC
...@@ -926,9 +931,7 @@ static void *signal_hand(void *arg __attribute__((unused))) ...@@ -926,9 +931,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
sigaddset(&set,SIGINT); sigaddset(&set,SIGINT);
sigaddset(&set,SIGQUIT); sigaddset(&set,SIGQUIT);
sigaddset(&set,SIGTERM); sigaddset(&set,SIGTERM);
#if THR_CLIENT_ALARM != SIGHUP
sigaddset(&set,SIGHUP); sigaddset(&set,SIGHUP);
#endif
#ifdef SIGTSTP #ifdef SIGTSTP
sigaddset(&set,SIGTSTP); sigaddset(&set,SIGTSTP);
#endif #endif
...@@ -940,7 +943,7 @@ static void *signal_hand(void *arg __attribute__((unused))) ...@@ -940,7 +943,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
#endif #endif
#endif /* OS2 */ #endif /* OS2 */
printf("server alarm: %d thread alarm: %d\n", printf("server alarm: %d thread alarm: %d\n",
THR_SERVER_ALARM,THR_CLIENT_ALARM); THR_SERVER_ALARM, thr_client_alarm);
DBUG_PRINT("info",("Starting signal and alarm handling thread")); DBUG_PRINT("info",("Starting signal and alarm handling thread"));
for(;;) for(;;)
{ {
...@@ -1012,11 +1015,11 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) ...@@ -1012,11 +1015,11 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
sigaddset(&set,SIGTSTP); sigaddset(&set,SIGTSTP);
#endif #endif
sigaddset(&set,THR_SERVER_ALARM); sigaddset(&set,THR_SERVER_ALARM);
sigdelset(&set,THR_CLIENT_ALARM); sigdelset(&set, thr_client_alarm);
(void) pthread_sigmask(SIG_SETMASK,&set,NULL); (void) pthread_sigmask(SIG_SETMASK,&set,NULL);
#ifdef NOT_USED #ifdef NOT_USED
sigemptyset(&set); sigemptyset(&set);
sigaddset(&set,THR_CLIENT_ALARM); sigaddset(&set, thr_client_alarm);
VOID(pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0)); VOID(pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0));
#endif #endif
#endif /* OS2 */ #endif /* OS2 */
...@@ -1066,8 +1069,8 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused))) ...@@ -1066,8 +1069,8 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
} }
} }
pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_thread_count);
end_thr_alarm(1);
thr_alarm_info(&alarm_info); thr_alarm_info(&alarm_info);
end_thr_alarm(1);
printf("Main_thread: Alarms: %u max_alarms: %u next_alarm_time: %lu\n", printf("Main_thread: Alarms: %u max_alarms: %u next_alarm_time: %lu\n",
alarm_info.active_alarms, alarm_info.max_used_alarms, alarm_info.active_alarms, alarm_info.max_used_alarms,
alarm_info.next_alarm_time); alarm_info.next_alarm_time);
......
***************
*** 76,96 ****
alarm_aborted=0;
init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0,
compare_ulong,NullS);
! sigfillset(&full_signal_set); /* Neaded to block signals */
pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_alarm,NULL);
! #if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
! #if defined(HAVE_mit_thread)
! sigset(THR_CLIENT_ALARM,thread_alarm); /* int. thread system calls */
! #else
{
! struct sigaction sact;
! sact.sa_flags = 0;
! sact.sa_handler = thread_alarm;
! sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0);
}
- #endif
- #endif
sigemptyset(&s);
sigaddset(&s, THR_SERVER_ALARM);
alarm_thread=pthread_self();
--- 74,89 ----
alarm_aborted=0;
init_queue(&alarm_queue,max_alarms+1,offsetof(ALARM,expire_time),0,
compare_ulong,NullS);
! sigfillset(&full_signal_set); /* Needed to block signals */
pthread_mutex_init(&LOCK_alarm,MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_alarm,NULL);
! #ifndef USE_ALARM_THREAD
! if (thd_lib_detected != THD_LIB_LT)
! #endif
{
! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
! thread_alarm);
}
sigemptyset(&s);
sigaddset(&s, THR_SERVER_ALARM);
alarm_thread=pthread_self();
***************
*** 108,120 ****
}
#elif defined(USE_ONE_SIGNAL_HAND)
pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */
! #if THR_SERVER_ALARM == THR_CLIENT_ALARM
! sigset(THR_CLIENT_ALARM,process_alarm); /* Linuxthreads */
! pthread_sigmask(SIG_UNBLOCK, &s, NULL);
! #endif
#else
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
- sigset(THR_SERVER_ALARM,process_alarm);
#endif
DBUG_VOID_RETURN;
}
--- 101,115 ----
}
#elif defined(USE_ONE_SIGNAL_HAND)
pthread_sigmask(SIG_BLOCK, &s, NULL); /* used with sigwait() */
! if (thd_lib_detected == THD_LIB_LT)
! {
! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
! process_alarm); /* Linuxthreads */
! pthread_sigmask(SIG_UNBLOCK, &s, NULL);
! }
#else
+ my_sigset(THR_SERVER_ALARM, process_alarm);
pthread_sigmask(SIG_UNBLOCK, &s, NULL);
#endif
DBUG_VOID_RETURN;
}
***************
*** 240,246 ****
if (alarm_data->malloced)
my_free((gptr) alarm_data,MYF(0));
found++;
! #ifndef DBUG_OFF
break;
#endif
}
--- 235,241 ----
if (alarm_data->malloced)
my_free((gptr) alarm_data,MYF(0));
found++;
! #ifdef DBUG_OFF
break;
#endif
}
***************
*** 249,258 ****
if (!found)
{
if (*alarmed)
! fprintf(stderr,"Warning: Didn't find alarm %lx in queue of %d alarms\n",
! (long) *alarmed, alarm_queue.elements);
! DBUG_PRINT("warning",("Didn't find alarm %lx in queue\n",
! (long) *alarmed));
}
pthread_mutex_unlock(&LOCK_alarm);
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
--- 244,254 ----
if (!found)
{
if (*alarmed)
! fprintf(stderr,
! "Warning: Didn't find alarm 0x%lx in queue of %d alarms\n",
! (long) *alarmed, alarm_queue.elements);
! DBUG_PRINT("warning",("Didn't find alarm 0x%lx in queue\n",
! (long) *alarmed));
}
pthread_mutex_unlock(&LOCK_alarm);
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
***************
*** 274,291 ****
This must be first as we can't call DBUG inside an alarm for a normal thread
*/
! #if THR_SERVER_ALARM == THR_CLIENT_ALARM
! if (!pthread_equal(pthread_self(),alarm_thread))
{
#if defined(MAIN) && !defined(__bsdi__)
! printf("thread_alarm\n"); fflush(stdout);
#endif
#ifdef DONT_REMEMBER_SIGNAL
! sigset(THR_CLIENT_ALARM,process_alarm); /* int. thread system calls */
#endif
return;
}
- #endif
/*
We have to do do the handling of the alarm in a sub function,
--- 270,287 ----
This must be first as we can't call DBUG inside an alarm for a normal thread
*/
! if (thd_lib_detected == THD_LIB_LT &&
! !pthread_equal(pthread_self(),alarm_thread))
{
#if defined(MAIN) && !defined(__bsdi__)
! printf("thread_alarm in process_alarm\n"); fflush(stdout);
#endif
#ifdef DONT_REMEMBER_SIGNAL
! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1,
! process_alarm); /* int. thread system calls */
#endif
return;
}
/*
We have to do do the handling of the alarm in a sub function,
***************
*** 301,307 ****
process_alarm_part2(sig);
#ifndef USE_ALARM_THREAD
#if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
! sigset(THR_SERVER_ALARM,process_alarm);
#endif
pthread_mutex_unlock(&LOCK_alarm);
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
--- 297,303 ----
process_alarm_part2(sig);
#ifndef USE_ALARM_THREAD
#if defined(DONT_REMEMBER_SIGNAL) && !defined(USE_ONE_SIGNAL_HAND)
! my_sigset(THR_SERVER_ALARM, process_alarm);
#endif
pthread_mutex_unlock(&LOCK_alarm);
pthread_sigmask(SIG_SETMASK,&old_mask,NULL);
***************
*** 504,520 ****
ARGSUSED
*/
- #if THR_CLIENT_ALARM != SIGALRM || defined(USE_ALARM_THREAD)
static sig_handler thread_alarm(int sig)
{
#ifdef MAIN
printf("thread_alarm\n"); fflush(stdout);
#endif
#ifdef DONT_REMEMBER_SIGNAL
! sigset(sig,thread_alarm); /* int. thread system calls */
#endif
}
- #endif
#ifdef HAVE_TIMESPEC_TS_SEC
--- 499,513 ----
ARGSUSED
*/
static sig_handler thread_alarm(int sig)
{
#ifdef MAIN
printf("thread_alarm\n"); fflush(stdout);
#endif
#ifdef DONT_REMEMBER_SIGNAL
! my_sigset(sig, thread_alarm); /* int. thread system calls */
#endif
}
#ifdef HAVE_TIMESPEC_TS_SEC
***************
*** 915,921 ****
printf("Warning: Got signal %d from thread %s\n",sig,my_thread_name());
fflush(stdout);
#ifdef DONT_REMEMBER_SIGNAL
! sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
#ifndef OS2
if (sig == SIGALRM)
--- 908,914 ----
printf("Warning: Got signal %d from thread %s\n",sig,my_thread_name());
fflush(stdout);
#ifdef DONT_REMEMBER_SIGNAL
! my_sigset(sig, print_signal_warning); /* int. thread system calls */
#endif
#ifndef OS2
if (sig == SIGALRM)
...@@ -120,6 +120,305 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, ...@@ -120,6 +120,305 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
return; return;
} }
/*
Convert TABLE object to MyISAM key and column definition
SYNOPSIS
table2myisam()
table_arg in TABLE object.
keydef_out out MyISAM key definition.
recinfo_out out MyISAM column definition.
records_out out Number of fields.
DESCRIPTION
This function will allocate and initialize MyISAM key and column
definition for further use in mi_create or for a check for underlying
table conformance in merge engine.
RETURN VALUE
0 OK
!0 error code
*/
int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
MI_COLUMNDEF **recinfo_out, uint *records_out)
{
uint i, j, recpos, minpos, fieldpos, temp_length, length;
enum ha_base_keytype type= HA_KEYTYPE_BINARY;
KEY *pos;
MI_KEYDEF *keydef;
MI_COLUMNDEF *recinfo, *recinfo_pos;
HA_KEYSEG *keyseg;
TABLE_SHARE *share= table_arg->s;
uint options= share->db_options_in_use;
DBUG_ENTER("table2myisam");
if (!(my_multi_malloc(MYF(MY_WME),
recinfo_out, (share->fields * 2 + 2) * sizeof(MI_COLUMNDEF),
keydef_out, share->keys * sizeof(MI_KEYDEF),
&keyseg,
(share->key_parts + share->keys) * sizeof(HA_KEYSEG),
NullS)))
DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* purecov: inspected */
keydef= *keydef_out;
recinfo= *recinfo_out;
pos= table_arg->key_info;
for (i= 0; i < share->keys; i++, pos++)
{
keydef[i].flag= (pos->flags & (HA_NOSAME | HA_FULLTEXT | HA_SPATIAL));
keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ?
(pos->flags & HA_SPATIAL ? HA_KEY_ALG_RTREE : HA_KEY_ALG_BTREE) :
pos->algorithm;
keydef[i].seg= keyseg;
keydef[i].keysegs= pos->key_parts;
for (j= 0; j < pos->key_parts; j++)
{
Field *field= pos->key_part[j].field;
type= field->key_type();
keydef[i].seg[j].flag= pos->key_part[j].key_part_flag;
if (options & HA_OPTION_PACK_KEYS ||
(pos->flags & (HA_PACK_KEY | HA_BINARY_PACK_KEY |
HA_SPACE_PACK_USED)))
{
if (pos->key_part[j].length > 8 &&
(type == HA_KEYTYPE_TEXT ||
type == HA_KEYTYPE_NUM ||
(type == HA_KEYTYPE_BINARY && !field->zero_pack())))
{
/* No blobs here */
if (j == 0)
keydef[i].flag|= HA_PACK_KEY;
if (!(field->flags & ZEROFILL_FLAG) &&
(field->type() == MYSQL_TYPE_STRING ||
field->type() == MYSQL_TYPE_VAR_STRING ||
((int) (pos->key_part[j].length - field->decimals())) >= 4))
keydef[i].seg[j].flag|= HA_SPACE_PACK;
}
else if (j == 0 && (!(pos->flags & HA_NOSAME) || pos->key_length > 16))
keydef[i].flag|= HA_BINARY_PACK_KEY;
}
keydef[i].seg[j].type= (int) type;
keydef[i].seg[j].start= pos->key_part[j].offset;
keydef[i].seg[j].length= pos->key_part[j].length;
keydef[i].seg[j].bit_start= keydef[i].seg[j].bit_end=
keydef[i].seg[j].bit_length= 0;
keydef[i].seg[j].bit_pos= 0;
keydef[i].seg[j].language= field->charset()->number;
if (field->null_ptr)
{
keydef[i].seg[j].null_bit= field->null_bit;
keydef[i].seg[j].null_pos= (uint) (field->null_ptr-
(uchar*) table_arg->record[0]);
}
else
{
keydef[i].seg[j].null_bit= 0;
keydef[i].seg[j].null_pos= 0;
}
if (field->type() == FIELD_TYPE_BLOB ||
field->type() == FIELD_TYPE_GEOMETRY)
{
keydef[i].seg[j].flag|= HA_BLOB_PART;
/* save number of bytes used to pack length */
keydef[i].seg[j].bit_start= (uint) (field->pack_length() -
share->blob_ptr_size);
}
else if (field->type() == FIELD_TYPE_BIT)
{
keydef[i].seg[j].bit_length= ((Field_bit *) field)->bit_len;
keydef[i].seg[j].bit_start= ((Field_bit *) field)->bit_ofs;
keydef[i].seg[j].bit_pos= (uint) (((Field_bit *) field)->bit_ptr -
(uchar*) table_arg->record[0]);
}
}
keyseg+= pos->key_parts;
}
if (table_arg->found_next_number_field)
keydef[share->next_number_index].flag|= HA_AUTO_KEY;
recpos= 0;
recinfo_pos= recinfo;
while (recpos < (uint) share->reclength)
{
Field **field, *found= 0;
minpos= share->reclength;
length= 0;
for (field= table_arg->field; *field; field++)
{
if ((fieldpos= (*field)->offset()) >= recpos &&
fieldpos <= minpos)
{
/* skip null fields */
if (!(temp_length= (*field)->pack_length_in_rec()))
continue; /* Skip null-fields */
if (! found || fieldpos < minpos ||
(fieldpos == minpos && temp_length < length))
{
minpos= fieldpos;
found= *field;
length= temp_length;
}
}
}
DBUG_PRINT("loop", ("found: 0x%lx recpos: %d minpos: %d length: %d",
(long) found, recpos, minpos, length));
if (recpos != minpos)
{ // Reserved space (Null bits?)
bzero((char*) recinfo_pos, sizeof(*recinfo_pos));
recinfo_pos->type= (int) FIELD_NORMAL;
recinfo_pos++->length= (uint16) (minpos - recpos);
}
if (!found)
break;
if (found->flags & BLOB_FLAG)
recinfo_pos->type= (int) FIELD_BLOB;
else if (found->type() == MYSQL_TYPE_VARCHAR)
recinfo_pos->type= FIELD_VARCHAR;
else if (!(options & HA_OPTION_PACK_RECORD))
recinfo_pos->type= (int) FIELD_NORMAL;
else if (found->zero_pack())
recinfo_pos->type= (int) FIELD_SKIP_ZERO;
else
recinfo_pos->type= (int) ((length <= 3 ||
(found->flags & ZEROFILL_FLAG)) ?
FIELD_NORMAL :
found->type() == MYSQL_TYPE_STRING ||
found->type() == MYSQL_TYPE_VAR_STRING ?
FIELD_SKIP_ENDSPACE :
FIELD_SKIP_PRESPACE);
if (found->null_ptr)
{
recinfo_pos->null_bit= found->null_bit;
recinfo_pos->null_pos= (uint) (found->null_ptr -
(uchar*) table_arg->record[0]);
}
else
{
recinfo_pos->null_bit= 0;
recinfo_pos->null_pos= 0;
}
(recinfo_pos++)->length= (uint16) length;
recpos= minpos + length;
DBUG_PRINT("loop", ("length: %d type: %d",
recinfo_pos[-1].length,recinfo_pos[-1].type));
}
*records_out= (uint) (recinfo_pos - recinfo);
DBUG_RETURN(0);
}
/*
Check for underlying table conformance
SYNOPSIS
check_definition()
t1_keyinfo in First table key definition
t1_recinfo in First table record definition
t1_keys in Number of keys in first table
t1_recs in Number of records in first table
t2_keyinfo in Second table key definition
t2_recinfo in Second table record definition
t2_keys in Number of keys in second table
t2_recs in Number of records in second table
strict in Strict check switch
DESCRIPTION
This function compares two MyISAM definitions. By intention it was done
to compare merge table definition against underlying table definition.
It may also be used to compare dot-frm and MYI definitions of MyISAM
table as well to compare different MyISAM table definitions.
For merge table it is not required that number of keys in merge table
must exactly match number of keys in underlying table. When calling this
function for underlying table conformance check, 'strict' flag must be
set to false, and converted merge definition must be passed as t1_*.
Otherwise 'strict' flag must be set to 1 and it is not required to pass
converted dot-frm definition as t1_*.
RETURN VALUE
0 - Equal definitions.
1 - Different definitions.
*/
int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
uint t1_keys, uint t1_recs,
MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo,
uint t2_keys, uint t2_recs, bool strict)
{
uint i, j;
DBUG_ENTER("check_definition");
if ((strict ? t1_keys != t2_keys : t1_keys > t2_keys))
{
DBUG_PRINT("error", ("Number of keys differs: t1_keys=%u, t2_keys=%u",
t1_keys, t2_keys));
DBUG_RETURN(1);
}
if (t1_recs != t2_recs)
{
DBUG_PRINT("error", ("Number of recs differs: t1_recs=%u, t2_recs=%u",
t1_recs, t2_recs));
DBUG_RETURN(1);
}
for (i= 0; i < t1_keys; i++)
{
HA_KEYSEG *t1_keysegs= t1_keyinfo[i].seg;
HA_KEYSEG *t2_keysegs= t2_keyinfo[i].seg;
if (t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs ||
t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg)
{
DBUG_PRINT("error", ("Key %d has different definition", i));
DBUG_PRINT("error", ("t1_keysegs=%d, t1_key_alg=%d",
t1_keyinfo[i].keysegs, t1_keyinfo[i].key_alg));
DBUG_PRINT("error", ("t2_keysegs=%d, t2_key_alg=%d",
t2_keyinfo[i].keysegs, t2_keyinfo[i].key_alg));
DBUG_RETURN(1);
}
for (j= t1_keyinfo[i].keysegs; j--;)
{
if (t1_keysegs[j].type != t2_keysegs[j].type ||
t1_keysegs[j].language != t2_keysegs[j].language ||
t1_keysegs[j].null_bit != t2_keysegs[j].null_bit ||
t1_keysegs[j].length != t2_keysegs[j].length)
{
DBUG_PRINT("error", ("Key segment %d (key %d) has different "
"definition", j, i));
DBUG_PRINT("error", ("t1_type=%d, t1_language=%d, t1_null_bit=%d, "
"t1_length=%d",
t1_keysegs[j].type, t1_keysegs[j].language,
t1_keysegs[j].null_bit, t1_keysegs[j].length));
DBUG_PRINT("error", ("t2_type=%d, t2_language=%d, t2_null_bit=%d, "
"t2_length=%d",
t2_keysegs[j].type, t2_keysegs[j].language,
t2_keysegs[j].null_bit, t2_keysegs[j].length));
DBUG_RETURN(1);
}
}
}
for (i= 0; i < t1_recs; i++)
{
MI_COLUMNDEF *t1_rec= &t1_recinfo[i];
MI_COLUMNDEF *t2_rec= &t2_recinfo[i];
if (t1_rec->type != t2_rec->type ||
t1_rec->length != t2_rec->length ||
t1_rec->null_bit != t2_rec->null_bit)
{
DBUG_PRINT("error", ("Field %d has different definition", i));
DBUG_PRINT("error", ("t1_type=%d, t1_length=%d, t1_null_bit=%d",
t1_rec->type, t1_rec->length, t1_rec->null_bit));
DBUG_PRINT("error", ("t2_type=%d, t2_length=%d, t2_null_bit=%d",
t2_rec->type, t2_rec->length, t2_rec->null_bit));
DBUG_RETURN(1);
}
}
DBUG_RETURN(0);
}
extern "C" { extern "C" {
volatile int *killed_ptr(MI_CHECK *param) volatile int *killed_ptr(MI_CHECK *param)
...@@ -1429,192 +1728,31 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, ...@@ -1429,192 +1728,31 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
HA_CREATE_INFO *info) HA_CREATE_INFO *info)
{ {
int error; int error;
uint i,j,recpos,minpos,fieldpos,temp_length,length, create_flags= 0; uint create_flags= 0, records;
bool found_real_auto_increment=0;
enum ha_base_keytype type;
char buff[FN_REFLEN]; char buff[FN_REFLEN];
KEY *pos;
MI_KEYDEF *keydef; MI_KEYDEF *keydef;
MI_COLUMNDEF *recinfo,*recinfo_pos; MI_COLUMNDEF *recinfo;
HA_KEYSEG *keyseg; MI_CREATE_INFO create_info;
TABLE_SHARE *share= table->s; TABLE_SHARE *share= table->s;
uint options= share->db_options_in_use; uint options= share->db_options_in_use;
DBUG_ENTER("ha_myisam::create"); DBUG_ENTER("ha_myisam::create");
if ((error= table2myisam(table_arg, &keydef, &recinfo, &records)))
type=HA_KEYTYPE_BINARY; // Keep compiler happy DBUG_RETURN(error); /* purecov: inspected */
if (!(my_multi_malloc(MYF(MY_WME), bzero((char*) &create_info, sizeof(create_info));
&recinfo,(share->fields*2+2)*
sizeof(MI_COLUMNDEF),
&keydef, share->keys*sizeof(MI_KEYDEF),
&keyseg,
((share->key_parts + share->keys) *
sizeof(HA_KEYSEG)),
NullS)))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
pos=table_arg->key_info;
for (i=0; i < share->keys ; i++, pos++)
{
keydef[i].flag= (pos->flags & (HA_NOSAME | HA_FULLTEXT | HA_SPATIAL));
keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ?
(pos->flags & HA_SPATIAL ? HA_KEY_ALG_RTREE : HA_KEY_ALG_BTREE) :
pos->algorithm;
keydef[i].seg=keyseg;
keydef[i].keysegs=pos->key_parts;
for (j=0 ; j < pos->key_parts ; j++)
{
Field *field=pos->key_part[j].field;
type=field->key_type();
keydef[i].seg[j].flag=pos->key_part[j].key_part_flag;
if (options & HA_OPTION_PACK_KEYS ||
(pos->flags & (HA_PACK_KEY | HA_BINARY_PACK_KEY |
HA_SPACE_PACK_USED)))
{
if (pos->key_part[j].length > 8 &&
(type == HA_KEYTYPE_TEXT ||
type == HA_KEYTYPE_NUM ||
(type == HA_KEYTYPE_BINARY && !field->zero_pack())))
{
/* No blobs here */
if (j == 0)
keydef[i].flag|=HA_PACK_KEY;
if (!(field->flags & ZEROFILL_FLAG) &&
(field->type() == MYSQL_TYPE_STRING ||
field->type() == MYSQL_TYPE_VAR_STRING ||
((int) (pos->key_part[j].length - field->decimals()))
>= 4))
keydef[i].seg[j].flag|=HA_SPACE_PACK;
}
else if (j == 0 && (!(pos->flags & HA_NOSAME) || pos->key_length > 16))
keydef[i].flag|= HA_BINARY_PACK_KEY;
}
keydef[i].seg[j].type= (int) type;
keydef[i].seg[j].start= pos->key_part[j].offset;
keydef[i].seg[j].length= pos->key_part[j].length;
keydef[i].seg[j].bit_start= keydef[i].seg[j].bit_end=
keydef[i].seg[j].bit_length= 0;
keydef[i].seg[j].bit_pos= 0;
keydef[i].seg[j].language= field->charset()->number;
if (field->null_ptr)
{
keydef[i].seg[j].null_bit=field->null_bit;
keydef[i].seg[j].null_pos= (uint) (field->null_ptr-
(uchar*) table_arg->record[0]);
}
else
{
keydef[i].seg[j].null_bit=0;
keydef[i].seg[j].null_pos=0;
}
if (field->type() == FIELD_TYPE_BLOB ||
field->type() == FIELD_TYPE_GEOMETRY)
{
keydef[i].seg[j].flag|=HA_BLOB_PART;
/* save number of bytes used to pack length */
keydef[i].seg[j].bit_start= (uint) (field->pack_length() -
share->blob_ptr_size);
}
else if (field->type() == FIELD_TYPE_BIT)
{
keydef[i].seg[j].bit_length= ((Field_bit *) field)->bit_len;
keydef[i].seg[j].bit_start= ((Field_bit *) field)->bit_ofs;
keydef[i].seg[j].bit_pos= (uint) (((Field_bit *) field)->bit_ptr -
(uchar*) table_arg->record[0]);
}
}
keyseg+=pos->key_parts;
}
if (table_arg->found_next_number_field)
{
keydef[share->next_number_index].flag|= HA_AUTO_KEY;
found_real_auto_increment= share->next_number_key_offset == 0;
}
recpos=0; recinfo_pos=recinfo;
while (recpos < (uint) share->reclength)
{
Field **field,*found=0;
minpos= share->reclength;
length=0;
for (field=table_arg->field ; *field ; field++)
{
if ((fieldpos=(*field)->offset()) >= recpos &&
fieldpos <= minpos)
{
/* skip null fields */
if (!(temp_length= (*field)->pack_length_in_rec()))
continue; /* Skip null-fields */
if (! found || fieldpos < minpos ||
(fieldpos == minpos && temp_length < length))
{
minpos=fieldpos; found= *field; length=temp_length;
}
}
}
DBUG_PRINT("loop",("found: 0x%lx recpos: %d minpos: %d length: %d",
(long) found, recpos, minpos, length));
if (recpos != minpos)
{ // Reserved space (Null bits?)
bzero((char*) recinfo_pos,sizeof(*recinfo_pos));
recinfo_pos->type=(int) FIELD_NORMAL;
recinfo_pos++->length= (uint16) (minpos-recpos);
}
if (! found)
break;
if (found->flags & BLOB_FLAG)
recinfo_pos->type= (int) FIELD_BLOB;
else if (found->type() == MYSQL_TYPE_VARCHAR)
recinfo_pos->type= FIELD_VARCHAR;
else if (!(options & HA_OPTION_PACK_RECORD))
recinfo_pos->type= (int) FIELD_NORMAL;
else if (found->zero_pack())
recinfo_pos->type= (int) FIELD_SKIP_ZERO;
else
recinfo_pos->type= (int) ((length <= 3 ||
(found->flags & ZEROFILL_FLAG)) ?
FIELD_NORMAL :
found->type() == MYSQL_TYPE_STRING ||
found->type() == MYSQL_TYPE_VAR_STRING ?
FIELD_SKIP_ENDSPACE :
FIELD_SKIP_PRESPACE);
if (found->null_ptr)
{
recinfo_pos->null_bit=found->null_bit;
recinfo_pos->null_pos= (uint) (found->null_ptr-
(uchar*) table_arg->record[0]);
}
else
{
recinfo_pos->null_bit=0;
recinfo_pos->null_pos=0;
}
(recinfo_pos++)->length= (uint16) length;
recpos=minpos+length;
DBUG_PRINT("loop",("length: %d type: %d",
recinfo_pos[-1].length,recinfo_pos[-1].type));
}
MI_CREATE_INFO create_info;
bzero((char*) &create_info,sizeof(create_info));
create_info.max_rows= share->max_rows; create_info.max_rows= share->max_rows;
create_info.reloc_rows= share->min_rows; create_info.reloc_rows= share->min_rows;
create_info.with_auto_increment=found_real_auto_increment; create_info.with_auto_increment= share->next_number_key_offset == 0;
create_info.auto_increment=(info->auto_increment_value ? create_info.auto_increment= (info->auto_increment_value ?
info->auto_increment_value -1 : info->auto_increment_value -1 :
(ulonglong) 0); (ulonglong) 0);
create_info.data_file_length= ((ulonglong) share->max_rows * create_info.data_file_length= ((ulonglong) share->max_rows *
share->avg_row_length); share->avg_row_length);
create_info.raid_type=info->raid_type; create_info.raid_type= info->raid_type;
create_info.raid_chunks= (info->raid_chunks ? info->raid_chunks : create_info.raid_chunks= (info->raid_chunks ? info->raid_chunks :
RAID_DEFAULT_CHUNKS); RAID_DEFAULT_CHUNKS);
create_info.raid_chunksize= (info->raid_chunksize ? info->raid_chunksize : create_info.raid_chunksize= (info->raid_chunksize ? info->raid_chunksize :
RAID_DEFAULT_CHUNKSIZE); RAID_DEFAULT_CHUNKSIZE);
create_info.data_file_name= info->data_file_name; create_info.data_file_name= info->data_file_name;
create_info.index_file_name= info->index_file_name; create_info.index_file_name= info->index_file_name;
if (info->options & HA_LEX_CREATE_TMP_TABLE) if (info->options & HA_LEX_CREATE_TMP_TABLE)
...@@ -1627,13 +1765,13 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, ...@@ -1627,13 +1765,13 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
create_flags|= HA_CREATE_DELAY_KEY_WRITE; create_flags|= HA_CREATE_DELAY_KEY_WRITE;
/* TODO: Check that the following fn_format is really needed */ /* TODO: Check that the following fn_format is really needed */
error=mi_create(fn_format(buff,name,"","",2+4), error= mi_create(fn_format(buff, name, "", "",
share->keys,keydef, MY_UNPACK_FILENAME|MY_REPLACE_EXT),
(uint) (recinfo_pos-recinfo), recinfo, share->keys, keydef,
0, (MI_UNIQUEDEF*) 0, records, recinfo,
&create_info, create_flags); 0, (MI_UNIQUEDEF*) 0,
&create_info, create_flags);
my_free((gptr) recinfo,MYF(0)); my_free((gptr) recinfo, MYF(0));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
...@@ -66,6 +66,12 @@ static const char *ha_myisammrg_exts[] = { ...@@ -66,6 +66,12 @@ static const char *ha_myisammrg_exts[] = {
".MRG", ".MRG",
NullS NullS
}; };
extern int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
MI_COLUMNDEF **recinfo_out, uint *records_out);
extern int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
uint t1_keys, uint t1_recs,
MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo,
uint t2_keys, uint t2_recs, bool strict);
const char **ha_myisammrg::bas_ext() const const char **ha_myisammrg::bas_ext() const
{ {
...@@ -87,6 +93,12 @@ const char *ha_myisammrg::index_type(uint key_number) ...@@ -87,6 +93,12 @@ const char *ha_myisammrg::index_type(uint key_number)
int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
{ {
MI_KEYDEF *keyinfo;
MI_COLUMNDEF *recinfo;
MYRG_TABLE *u_table;
uint recs;
uint keys= table->s->keys;
int error;
char name_buff[FN_REFLEN]; char name_buff[FN_REFLEN];
DBUG_PRINT("info", ("ha_myisammrg::open")); DBUG_PRINT("info", ("ha_myisammrg::open"));
...@@ -109,18 +121,43 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) ...@@ -109,18 +121,43 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
{ {
DBUG_PRINT("error",("reclength: %lu mean_rec_length: %lu", DBUG_PRINT("error",("reclength: %lu mean_rec_length: %lu",
table->s->reclength, mean_rec_length)); table->s->reclength, mean_rec_length));
error= HA_ERR_WRONG_MRG_TABLE_DEF;
goto err; goto err;
} }
if ((error= table2myisam(table, &keyinfo, &recinfo, &recs)))
{
/* purecov: begin inspected */
DBUG_PRINT("error", ("Failed to convert TABLE object to MyISAM "
"key and column definition"));
goto err;
/* purecov: end */
}
for (u_table= file->open_tables; u_table < file->end_table; u_table++)
{
if (check_definition(keyinfo, recinfo, keys, recs,
u_table->table->s->keyinfo, u_table->table->s->rec,
u_table->table->s->base.keys,
u_table->table->s->base.fields, false))
{
my_free((gptr) recinfo, MYF(0));
error= HA_ERR_WRONG_MRG_TABLE_DEF;
goto err;
}
}
my_free((gptr) recinfo, MYF(0));
#if !defined(BIG_TABLES) || SIZEOF_OFF_T == 4 #if !defined(BIG_TABLES) || SIZEOF_OFF_T == 4
/* Merge table has more than 2G rows */ /* Merge table has more than 2G rows */
if (table->s->crashed) if (table->s->crashed)
{
error= HA_ERR_WRONG_MRG_TABLE_DEF;
goto err; goto err;
}
#endif #endif
return (0); return (0);
err: err:
myrg_close(file); myrg_close(file);
file=0; file=0;
return (my_errno= HA_ERR_WRONG_MRG_TABLE_DEF); return (my_errno= error);
} }
int ha_myisammrg::close(void) int ha_myisammrg::close(void)
......
...@@ -198,12 +198,6 @@ inline void reset_floating_point_exceptions() ...@@ -198,12 +198,6 @@ inline void reset_floating_point_exceptions()
} /* cplusplus */ } /* cplusplus */
#if defined(HAVE_LINUXTHREADS)
#define THR_KILL_SIGNAL SIGINT
#else
#define THR_KILL_SIGNAL SIGUSR2 // Can't use this with LinuxThreads
#endif
#define MYSQL_KILL_SIGNAL SIGTERM #define MYSQL_KILL_SIGNAL SIGTERM
#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R #ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
...@@ -523,6 +517,7 @@ rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; ...@@ -523,6 +517,7 @@ rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
pthread_cond_t COND_refresh,COND_thread_count, COND_global_read_lock; pthread_cond_t COND_refresh,COND_thread_count, COND_global_read_lock;
pthread_t signal_thread; pthread_t signal_thread;
pthread_attr_t connection_attrib; pthread_attr_t connection_attrib;
static uint thr_kill_signal;
File_parser_dummy_hook file_parser_dummy_hook; File_parser_dummy_hook file_parser_dummy_hook;
...@@ -698,7 +693,7 @@ static void close_connections(void) ...@@ -698,7 +693,7 @@ static void close_connections(void)
DBUG_PRINT("info",("Waiting for select thread")); DBUG_PRINT("info",("Waiting for select thread"));
#ifndef DONT_USE_THR_ALARM #ifndef DONT_USE_THR_ALARM
if (pthread_kill(select_thread,THR_CLIENT_ALARM)) if (pthread_kill(select_thread, thr_client_alarm))
break; // allready dead break; // allready dead
#endif #endif
set_timespec(abstime, 2); set_timespec(abstime, 2);
...@@ -2154,7 +2149,9 @@ static void init_signals(void) ...@@ -2154,7 +2149,9 @@ static void init_signals(void)
DBUG_ENTER("init_signals"); DBUG_ENTER("init_signals");
if (test_flags & TEST_SIGINT) if (test_flags & TEST_SIGINT)
my_sigset(THR_KILL_SIGNAL,end_thread_signal); {
my_sigset(thr_kill_signal, end_thread_signal);
}
my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called! my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL)) if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
...@@ -2211,8 +2208,12 @@ static void init_signals(void) ...@@ -2211,8 +2208,12 @@ static void init_signals(void)
#endif #endif
sigaddset(&set,THR_SERVER_ALARM); sigaddset(&set,THR_SERVER_ALARM);
if (test_flags & TEST_SIGINT) if (test_flags & TEST_SIGINT)
sigdelset(&set,THR_KILL_SIGNAL); // May be SIGINT {
sigdelset(&set,THR_CLIENT_ALARM); // For alarms // May be SIGINT
sigdelset(&set, thr_kill_signal);
}
// For alarms
sigdelset(&set, thr_client_alarm);
sigprocmask(SIG_SETMASK,&set,NULL); sigprocmask(SIG_SETMASK,&set,NULL);
pthread_sigmask(SIG_SETMASK,&set,NULL); pthread_sigmask(SIG_SETMASK,&set,NULL);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -2276,23 +2277,19 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) ...@@ -2276,23 +2277,19 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
*/ */
init_thr_alarm(max_connections + init_thr_alarm(max_connections +
global_system_variables.max_insert_delayed_threads + 10); global_system_variables.max_insert_delayed_threads + 10);
#if SIGINT != THR_KILL_SIGNAL if (thd_lib_detected != THD_LIB_LT && (test_flags & TEST_SIGINT))
if (test_flags & TEST_SIGINT)
{ {
(void) sigemptyset(&set); // Setup up SIGINT for debug (void) sigemptyset(&set); // Setup up SIGINT for debug
(void) sigaddset(&set,SIGINT); // For debugging (void) sigaddset(&set,SIGINT); // For debugging
(void) pthread_sigmask(SIG_UNBLOCK,&set,NULL); (void) pthread_sigmask(SIG_UNBLOCK,&set,NULL);
} }
#endif
(void) sigemptyset(&set); // Setup up SIGINT for debug (void) sigemptyset(&set); // Setup up SIGINT for debug
#ifdef USE_ONE_SIGNAL_HAND #ifdef USE_ONE_SIGNAL_HAND
(void) sigaddset(&set,THR_SERVER_ALARM); // For alarms (void) sigaddset(&set,THR_SERVER_ALARM); // For alarms
#endif #endif
#ifndef IGNORE_SIGHUP_SIGQUIT #ifndef IGNORE_SIGHUP_SIGQUIT
(void) sigaddset(&set,SIGQUIT); (void) sigaddset(&set,SIGQUIT);
#if THR_CLIENT_ALARM != SIGHUP
(void) sigaddset(&set,SIGHUP); (void) sigaddset(&set,SIGHUP);
#endif
#endif #endif
(void) sigaddset(&set,SIGTERM); (void) sigaddset(&set,SIGTERM);
(void) sigaddset(&set,SIGTSTP); (void) sigaddset(&set,SIGTSTP);
...@@ -3351,6 +3348,9 @@ int main(int argc, char **argv) ...@@ -3351,6 +3348,9 @@ int main(int argc, char **argv)
DEBUGGER_OFF; DEBUGGER_OFF;
/* Set signal used to kill MySQL */
thr_kill_signal= thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2;
#ifdef _CUSTOMSTARTUPCONFIG_ #ifdef _CUSTOMSTARTUPCONFIG_
if (_cust_check_startup()) if (_cust_check_startup())
{ {
......
***************
*** 177,188 ****
} /* cplusplus */
- #if defined(HAVE_LINUXTHREADS)
- #define THR_KILL_SIGNAL SIGINT
- #else
- #define THR_KILL_SIGNAL SIGUSR2 // Can't use this with LinuxThreads
- #endif
-
#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
#include <sys/types.h>
#else
--- 177,182 ----
} /* cplusplus */
#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
#include <sys/types.h>
#else
***************
*** 505,510 ****
static void clean_up_mutexes(void);
static int test_if_case_insensitive(const char *dir_name);
static void create_pid_file();
/****************************************************************************
** Code to end mysqld
--- 499,505 ----
static void clean_up_mutexes(void);
static int test_if_case_insensitive(const char *dir_name);
static void create_pid_file();
+ static uint get_thread_lib(void);
/****************************************************************************
** Code to end mysqld
***************
*** 544,550 ****
DBUG_PRINT("info",("Waiting for select_thread"));
#ifndef DONT_USE_THR_ALARM
! if (pthread_kill(select_thread,THR_CLIENT_ALARM))
break; // allready dead
#endif
set_timespec(abstime, 2);
--- 539,546 ----
DBUG_PRINT("info",("Waiting for select_thread"));
#ifndef DONT_USE_THR_ALARM
! if (pthread_kill(select_thread,
! thd_lib_detected == THD_LIB_LT ? SIGALRM : SIGUSR1))
break; // allready dead
#endif
set_timespec(abstime, 2);
***************
*** 844,850 ****
sig,my_thread_id());
}
#ifdef DONT_REMEMBER_SIGNAL
! sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
if (sig == SIGALRM)
--- 840,846 ----
sig,my_thread_id());
}
#ifdef DONT_REMEMBER_SIGNAL
! my_sigset(sig, print_signal_warning); /* int. thread system calls */
#endif
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
if (sig == SIGALRM)
***************
*** 1841,1848 ****
DBUG_ENTER("init_signals");
if (test_flags & TEST_SIGINT)
! sigset(THR_KILL_SIGNAL,end_thread_signal);
! sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
{
--- 1837,1847 ----
DBUG_ENTER("init_signals");
if (test_flags & TEST_SIGINT)
! {
! my_sigset(thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2,
! end_thread_signal);
! }
! my_sigset(THR_SERVER_ALARM, print_signal_warning); // Should never be called!
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
{
***************
*** 1877,1883 ****
#endif
(void) sigemptyset(&set);
#ifdef THREAD_SPECIFIC_SIGPIPE
! sigset(SIGPIPE,abort_thread);
sigaddset(&set,SIGPIPE);
#else
(void) signal(SIGPIPE,SIG_IGN); // Can't know which thread
--- 1876,1882 ----
#endif
(void) sigemptyset(&set);
#ifdef THREAD_SPECIFIC_SIGPIPE
! my_sigset(SIGPIPE, abort_thread);
sigaddset(&set,SIGPIPE);
#else
(void) signal(SIGPIPE,SIG_IGN); // Can't know which thread
***************
*** 2237,2244 ****
MY_INIT(argv[0]); // init my_sys library & pthreads
tzset(); // Set tzname
start_time=time((time_t*) 0);
-
#ifdef OS2
{
// fix timezone for daylight saving
--- 2236,2243 ----
MY_INIT(argv[0]); // init my_sys library & pthreads
tzset(); // Set tzname
+ thd_lib_detected= get_thread_lib();
start_time=time((time_t*) 0);
#ifdef OS2
{
// fix timezone for daylight saving
***************
*** 5547,5552 ****
(void) my_write(file, (byte*) buff, (uint) (end-buff),MYF(MY_WME));
(void) my_close(file, MYF(0));
}
}
--- 5546,5567 ----
(void) my_write(file, (byte*) buff, (uint) (end-buff),MYF(MY_WME));
(void) my_close(file, MYF(0));
}
+ }
+
+
+ static uint get_thread_lib(void)
+ {
+ char buff[64];
+
+ #ifdef _CS_GNU_LIBPTHREAD_VERSION
+ confstr(_CS_GNU_LIBPTHREAD_VERSION, buff, sizeof(buff));
+
+ if (!strncasecmp(buff, "NPTL", 4))
+ return THD_LIB_NPTL;
+ else if (!strncasecmp(buff, "linuxthreads", 12))
+ return THD_LIB_LT;
+ #endif
+ return THD_LIB_OTHER;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment