Commit 89f89787 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Fixed some bugs after last merge

Added semaphore support to MIT-pthreads.
parent a3538124
......@@ -27362,6 +27362,10 @@ MySQL will, by default, use sockets.)
If you connect using TCP/IP from another computer over a 100M Ethernet,
things will be 8-11 % slower.
@item
When running our benchmark with secure connections (all data encrypted
with internal ssl support) things where 55 % slower.
@item
If you compile with @code{--with-debug=full}, then you will loose 20 %
for most queries, but some queries may take substantially longer (The
......@@ -524,6 +524,13 @@ AC_ARG_WITH(mit-threads,
if test "$with_mit_threads" = "yes"
then
enable_largefile="no" # Will not work on Linux.
if test "$GXX" = "yes"
then
# Needed for gcc 3.0
CCLD=g++
export CCLD
AC_SUBST(CCLD)
fi
fi
# Set flags if we want to force to use pthreads
......@@ -1596,13 +1603,17 @@ ac_save_CXXFLAGS="$CXXFLAGS"
AC_CACHE_CHECK([style of gethost* routines], mysql_cv_gethost_style,
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
# Do not treat warnings as errors if we are linking agaist other libc
# Do not treat warnings as errors if we are linking against other libc
# this is to work around gcc not being permissive on non-system includes
# with respect to ANSI C++
if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no"
# We also remove the -fbranch-probabilities option as this will give warnings
# about not profiled code, which confuses configure
if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no"
then
CXXFLAGS="$CXXFLAGS -Werror"
CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed 's/-fbranch-probabilities//'`
fi
AC_TRY_COMPILE(
[#undef inline
#if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
......
......@@ -31,21 +31,22 @@
#ifndef _my_semaphore_h_
#define _my_semaphore_h_
C_MODE_START
#ifndef __WIN__
#include <semaphore.h>
#else
C_MODE_START
typedef HANDLE sem_t;
int sem_init (sem_t * sem, int pshared, unsigned int value);
int sem_destroy (sem_t * sem);
int sem_trywait (sem_t * sem);
int sem_wait (sem_t * sem);
int sem_post (sem_t * sem);
int sem_post_multiple (sem_t * sem,int count);
int sem_getvalue (sem_t * sem, int * sval);
int sem_init(sem_t * sem, int pshared, unsigned int value);
int sem_destroy(sem_t * sem);
int sem_trywait(sem_t * sem);
int sem_wait(sem_t * sem);
int sem_post(sem_t * sem);
int sem_post_multiple(sem_t * sem,int count);
int sem_getvalue(sem_t * sem, int * sval);
C_MODE_END
#endif /* __WIN__ */
C_MODE_END
#endif /* !_my_semaphore_h_ */
Changes done to this distrubtion (pthreads-1_60_beta6) by Monty (monty@mysql.com)
Changes done to this distrubtion (pthreads-1_60_beta6) by Monty
(monty@mysql.com)
02.06.20
- Added support for semaphores.
02.05.07
- Hacked some files to get it to compile (not work) with glibc 2.2
......
......@@ -7,7 +7,7 @@
FILES= cond.h copyright.h fd.h fd_pipe.h kernel.h mutex.h posix.h \
pthread.h pthread_attr.h queue.h util.h
pthread.h pthread_attr.h queue.h util.h semaphore.h
# Machine dependent header file
MFILE= ${.CURDIR}/arch/${MACHINE}/machdep.h
......
......@@ -6,5 +6,7 @@
#define pthread_ssize_t int
#define pthread_time_t long
#define pthread_off_t long
#define pthread_va_list void *
#ifdef NOT_USED /* Removed by monty becasue of conflicts on Linux */
#define pthread_va_list char *
#endif
#endif
/*
This is written by Sergei Golubchik for MySQL AB and is in public domain.
Simple implementation of semaphores, needed to compile MySQL with
MIT-pthreads.
*/
typedef struct {
pthread_mutex_t mutex;
pthread_cond_t cond;
uint count;
} sem_t;
int sem_init(sem_t * sem, int pshared, uint value);
int sem_destroy(sem_t * sem);
int sem_wait(sem_t * sem);
int sem_trywait(sem_t * sem);
int sem_post (sem_t * sem);
int sem_post_multiple(sem_t * sem, uint count);
int sem_getvalue (sem_t * sem, uint *sval);
......@@ -9,7 +9,7 @@ SRCS:= cleanup.c cond.c fd.c fd_kern.c fd_pipe.c fd_sysv.c file.c globals.c \
specific.c process.c wait.c errno.c schedparam.c _exit.c prio_queue.c \
pthread_init.c init.cc sig.c info.c mutexattr.c select.c wrapper.c \
dump_state.c pthread_kill.c stat.c readv.c writev.c condattr.c \
pthread_cancel.c panic.c $(SRCS)
pthread_cancel.c panic.c semaphore.c $(SRCS)
ifeq ($(HAVE_SYSCALL_TEMPLATE),yes)
SYSCALL_FILTER_RULE= for s in $(AVAILABLE_SYSCALLS) ; do \
......
......@@ -8,7 +8,8 @@ SRCS+= cleanup.c cond.c fd.c fd_kern.c fd_pipe.c file.c globals.c malloc.c \
pthread_join.c pthread_detach.c pthread_once.c sleep.c specific.c \
process.c wait.c errno.c schedparam.c _exit.c prio_queue.c \
pthread_init.c init.cc sig.c info.c mutexattr.c select.c wrapper.c \
dump_state.c pthread_kill.c condattr.c pthread_cancel.c panic.c
dump_state.c pthread_kill.c condattr.c pthread_cancel.c panic.c \
semaphore.c
.if $(HAVE_SYSCALL_TEMPLATE) == yes
OBJS+= syscalls.o
......
/*
This is written by Sergei Golubchik for MySQL AB and is in public domain.
Simple implementation of semaphores, needed to compile MySQL with
MIT-pthreads.
*/
#include <pthread.h>
#include <errno.h>
#include <semaphore.h>
int sem_init(sem_t * sem, int pshared, uint value)
{
sem->count=value;
pthread_cond_init(&sem->cond, 0);
pthread_mutex_init(&sem->mutex, 0);
return 0;
}
int sem_destroy(sem_t * sem)
{
int err1,err2;
err1=pthread_cond_destroy(&sem->cond);
err2=pthread_mutex_destroy(&sem->mutex);
if (err1 || err2)
{
errno=err1 ? err1 : err2;
return -1;
}
return 0;
}
int sem_wait(sem_t * sem)
{
while ((errno=pthread_mutex_lock(&sem->mutex)) || !sem->count)
pthread_cond_wait(&sem->cond, &sem->mutex);
if (errno)
return -1;
sem->count--; /* mutex is locked here */
pthread_mutex_unlock(&sem->mutex);
return 0;
}
int sem_trywait(sem_t * sem)
{
if ((errno=pthread_mutex_lock(&sem->mutex)))
return -1;
if (sem->count)
sem->count--;
else
errno=EAGAIN;
pthread_mutex_unlock(&sem->mutex);
return errno ? -1 : 0;
}
int sem_post(sem_t * sem)
{
if ((errno=pthread_mutex_lock(&sem->mutex)))
return -1;
sem->count++;
pthread_mutex_unlock(&sem->mutex); /* does it really matter what to do */
pthread_cond_signal(&sem->cond); /* first: x_unlock or x_signal ? */
return 0;
}
int sem_post_multiple(sem_t * sem, uint count)
{
if ((errno=pthread_mutex_lock(&sem->mutex)))
return -1;
sem->count+=count;
pthread_mutex_unlock(&sem->mutex); /* does it really matter what to do */
pthread_cond_broadcast(&sem->cond); /* first: x_unlock or x_broadcast ? */
return 0;
}
int sem_getvalue(sem_t * sem, uint *sval)
{
if ((errno=pthread_mutex_lock(&sem->mutex)))
return -1;
*sval=sem->count;
pthread_mutex_unlock(&sem->mutex);
return 0;
}
......@@ -217,7 +217,7 @@ static int vxprintf(func,arg,format,ap)
void (*func)(char*,int,void*);
void *arg;
const char *format;
va_list ap;
pthread_va_list ap;
{
register const char *fmt; /* The format string. */
register int c; /* Next character in the format string */
......@@ -673,7 +673,7 @@ int xprintf(
const char *format,
...
){
va_list ap;
pthread_va_list ap;
va_start(ap,format);
return vxprintf(func,arg,format,ap);
}
......@@ -715,7 +715,7 @@ static void sout(txt,amt,arg)
int sprintf(char *buf, const char *fmt, ...){
int rc;
va_list ap;
pthread_va_list ap;
struct s_strargument arg;
va_start(ap,fmt);
......@@ -725,7 +725,7 @@ int sprintf(char *buf, const char *fmt, ...){
rc = vxprintf(sout,&arg,fmt,ap);
va_end(ap);
}
int vsprintf(char *buf,const char *fmt,va_list ap){
int vsprintf(char *buf,const char *fmt, pthread_va_list ap){
struct s_strargument arg;
arg.next = buf;
arg.last = 0;
......@@ -734,7 +734,7 @@ int vsprintf(char *buf,const char *fmt,va_list ap){
}
int snprintf(char *buf, size_t n, const char *fmt, ...){
int rc;
va_list ap;
pthread_va_list ap;
struct s_strargument arg;
va_start(ap,fmt);
......@@ -744,7 +744,7 @@ int snprintf(char *buf, size_t n, const char *fmt, ...){
rc = vxprintf(sout,&arg,fmt,ap);
va_end(ap);
}
int vsnprintf(char *buf, size_t n, const char *fmt, va_list ap){
int vsnprintf(char *buf, size_t n, const char *fmt, pthread_va_list ap){
struct s_strargument arg;
arg.next = buf;
arg.last = &buf[n-1];
......@@ -798,7 +798,7 @@ static void mout(zNewText,nNewChar,arg)
** routine naming conventions.
*/
char *mprintf(const char *zFormat, ...){
va_list ap;
pthread_va_list ap;
struct sgMprintf sMprintf;
char *zNew;
char zBuf[200];
......@@ -825,7 +825,7 @@ char *mprintf(const char *zFormat, ...){
** The name is changed to TclVMPrintf() to conform with Tcl naming
** conventions.
*/
char *vmprintf(const char *zFormat,va_list ap){
char *vmprintf(const char *zFormat,pthread_va_list ap){
struct sgMprintf sMprintf;
char zBuf[200];
sMprintf.nChar = 0;
......@@ -858,7 +858,7 @@ static void fout(zNewText,nNewChar,arg)
/* The public interface routines */
int fprintf(FILE *pOut, const char *zFormat, ...){
va_list ap;
pthread_va_list ap;
int retc;
va_start(ap,zFormat);
......@@ -866,11 +866,11 @@ int fprintf(FILE *pOut, const char *zFormat, ...){
va_end(ap);
return retc;
}
int vfprintf(FILE *pOut, const char *zFormat, va_list ap){
int vfprintf(FILE *pOut, const char *zFormat, pthread_va_list ap){
return vxprintf(fout,pOut,zFormat,ap);
}
int printf(const char *zFormat, ...){
va_list ap;
pthread_va_list ap;
int retc;
va_start(ap,zFormat);
......@@ -878,6 +878,6 @@ int printf(const char *zFormat, ...){
va_end(ap);
return retc;
}
int vprintf(const char *zFormat, va_list ap){
int vprintf(const char *zFormat, pthread_va_list ap){
return vxprintf(fout,stdout,zFormat,ap);
}
slave stop;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
use test;
drop database if exists d1;
create database d1;
create table d1.t1 ( n int);
alter table d1.t1 add m int;
insert into d1.t1 values (1,2);
create table d1.t2 (n int);
insert into d1.t2 values (45);
rename table d1.t2 to d1.t3, d1.t1 to d1.t2;
select * from d1.t2;
n m
1 2
select * from d1.t3;
n
45
drop database d1;
......@@ -51,6 +51,8 @@ int ha_isam::open(const char *name, int mode, uint test_if_locked)
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED))
(void) nisam_extra(file,HA_EXTRA_WAIT_LOCK);
if (!table->db_record_offset)
int_table_flags|=HA_REC_NOT_IN_SEQ;
return (0);
}
......
......@@ -26,20 +26,21 @@
class ha_isam: public handler
{
N_INFO *file;
/* We need this as table_flags() may change after open() */
ulong int_table_flags;
public:
ha_isam(TABLE *table): handler(table), file(0)
ha_isam(TABLE *table)
:handler(table), file(0),
int_table_flags(HA_READ_RND_SAME | HA_KEYPOS_TO_RNDPOS | HA_LASTKEY_ORDER |
HA_KEY_READ_WRONG_STR | HA_DUPP_POS |
HA_NOT_DELETE_WITH_CACHE)
{}
~ha_isam() {}
const char *table_type() const { return "ISAM"; }
const char *index_type(uint key_number) { return "BTREE"; }
const char **bas_ext() const;
ulong table_flags() const
{
return (HA_READ_RND_SAME | HA_KEYPOS_TO_RNDPOS | HA_LASTKEY_ORDER |
HA_KEY_READ_WRONG_STR | HA_DUPP_POS | HA_NOT_DELETE_WITH_CACHE |
((table->db_record_offset) ? 0 : HA_REC_NOT_IN_SEQ));
}
ulong table_flags() const { return int_table_flags; }
uint max_record_length() const { return HA_MAX_REC_LENGTH; }
uint max_keys() const { return N_MAXKEY; }
uint max_key_parts() const { return N_MAXKEY_SEG; }
......
......@@ -27,13 +27,12 @@
#define net_write_timeout net_write_timeout1
#endif
#if defined(__WIN__)
#include <winsock.h>
#include <odbcinst.h> /* QQ: Is this really needed ? */
#define DONT_USE_THR_ALARM
#endif
#include <my_global.h>
/* my_pthread must be included early to be able to fix things */
#if defined(THREAD)
#include <my_pthread.h> /* because of signal() */
#endif
#include <thr_alarm.h>
#include <mysql_embed.h>
#include <mysql_com.h>
#include <violite.h>
......@@ -75,10 +74,6 @@ extern "C" { // Because of SCO 3.2V4.2
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
#if defined(THREAD)
#include <my_pthread.h> /* because of signal() */
#endif
#include <thr_alarm.h>
#ifndef INADDR_NONE
#define INADDR_NONE -1
#endif
......
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