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

Fixed locking problem when using bulk insert

Fixed array overrun when using drop_db
Portability fixes
parent 29510745
......@@ -402,3 +402,11 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
libmysqld/examples/completion_hash.cc
libmysqld/examples/completion_hash.h
libmysqld/examples/my_readline.h
libmysqld/examples/mysql.cc
libmysqld/examples/mysqltest.c
libmysqld/examples/readline.cc
libmysqld/examples/sql_string.cc
libmysqld/examples/sql_string.h
......@@ -1071,42 +1071,42 @@ AC_DEFUN([MYSQL_CHECK_INNODB], [
dnl Some libs are listed several times, in order for gcc to sort out
dnl circular references.
innodb_libs="\
$(top_builddir)/innobase/usr/libusr.a\
$(top_builddir)/innobase/odbc/libodbc.a\
$(top_builddir)/innobase/srv/libsrv.a\
$(top_builddir)/innobase/que/libque.a\
$(top_builddir)/innobase/srv/libsrv.a\
$(top_builddir)/innobase/dict/libdict.a\
$(top_builddir)/innobase/ibuf/libibuf.a\
$(top_builddir)/innobase/row/librow.a\
$(top_builddir)/innobase/pars/libpars.a\
$(top_builddir)/innobase/btr/libbtr.a\
$(top_builddir)/innobase/trx/libtrx.a\
$(top_builddir)/innobase/read/libread.a\
$(top_builddir)/innobase/usr/libusr.a\
$(top_builddir)/innobase/buf/libbuf.a\
$(top_builddir)/innobase/ibuf/libibuf.a\
$(top_builddir)/innobase/eval/libeval.a\
$(top_builddir)/innobase/log/liblog.a\
$(top_builddir)/innobase/fsp/libfsp.a\
$(top_builddir)/innobase/fut/libfut.a\
$(top_builddir)/innobase/fil/libfil.a\
$(top_builddir)/innobase/lock/liblock.a\
$(top_builddir)/innobase/mtr/libmtr.a\
$(top_builddir)/innobase/page/libpage.a\
$(top_builddir)/innobase/rem/librem.a\
$(top_builddir)/innobase/thr/libthr.a\
$(top_builddir)/innobase/com/libcom.a\
$(top_builddir)/innobase/sync/libsync.a\
$(top_builddir)/innobase/data/libdata.a\
$(top_builddir)/innobase/mach/libmach.a\
$(top_builddir)/innobase/ha/libha.a\
$(top_builddir)/innobase/dyn/libdyn.a\
$(top_builddir)/innobase/mem/libmem.a\
$(top_builddir)/innobase/sync/libsync.a\
$(top_builddir)/innobase/ut/libut.a\
$(top_builddir)/innobase/os/libos.a\
$(top_builddir)/innobase/ut/libut.a"
\$(top_builddir)/innobase/usr/libusr.a\
\$(top_builddir)/innobase/odbc/libodbc.a\
\$(top_builddir)/innobase/srv/libsrv.a\
\$(top_builddir)/innobase/que/libque.a\
\$(top_builddir)/innobase/srv/libsrv.a\
\$(top_builddir)/innobase/dict/libdict.a\
\$(top_builddir)/innobase/ibuf/libibuf.a\
\$(top_builddir)/innobase/row/librow.a\
\$(top_builddir)/innobase/pars/libpars.a\
\$(top_builddir)/innobase/btr/libbtr.a\
\$(top_builddir)/innobase/trx/libtrx.a\
\$(top_builddir)/innobase/read/libread.a\
\$(top_builddir)/innobase/usr/libusr.a\
\$(top_builddir)/innobase/buf/libbuf.a\
\$(top_builddir)/innobase/ibuf/libibuf.a\
\$(top_builddir)/innobase/eval/libeval.a\
\$(top_builddir)/innobase/log/liblog.a\
\$(top_builddir)/innobase/fsp/libfsp.a\
\$(top_builddir)/innobase/fut/libfut.a\
\$(top_builddir)/innobase/fil/libfil.a\
\$(top_builddir)/innobase/lock/liblock.a\
\$(top_builddir)/innobase/mtr/libmtr.a\
\$(top_builddir)/innobase/page/libpage.a\
\$(top_builddir)/innobase/rem/librem.a\
\$(top_builddir)/innobase/thr/libthr.a\
\$(top_builddir)/innobase/com/libcom.a\
\$(top_builddir)/innobase/sync/libsync.a\
\$(top_builddir)/innobase/data/libdata.a\
\$(top_builddir)/innobase/mach/libmach.a\
\$(top_builddir)/innobase/ha/libha.a\
\$(top_builddir)/innobase/dyn/libdyn.a\
\$(top_builddir)/innobase/mem/libmem.a\
\$(top_builddir)/innobase/sync/libsync.a\
\$(top_builddir)/innobase/ut/libut.a\
\$(top_builddir)/innobase/os/libos.a\
\$(top_builddir)/innobase/ut/libut.a"
AC_CHECK_LIB(rt, aio_read, [innodb_libs="$innodb_libs -lrt"])
;;
......
......@@ -44,11 +44,12 @@ int _mi_ck_write_btree(register MI_INFO *info, uint keynr, uchar *key,
int mi_write(MI_INFO *info, byte *record)
{
MYISAM_SHARE *share=info->s;
uint i;
int save_errno;
my_off_t filepos;
uchar *buff;
MYISAM_SHARE *share=info->s;
my_bool lock_tree= share->concurrent_insert;
DBUG_ENTER("mi_write");
DBUG_PRINT("enter",("isam: %d data: %d",info->s->kfile,info->dfile));
......@@ -99,7 +100,10 @@ int mi_write(MI_INFO *info, byte *record)
{
if (((ulonglong) 1 << i) & share->state.key_map)
{
if (share->concurrent_insert && ! info->bulk_insert)
bool local_lock_tree= (lock_tree &&
!(info->bulk_insert &&
is_tree_inited(& info->bulk_insert[i])));
if (local_lock_tree)
{
rw_wrlock(&share->key_root_lock[i]);
share->keyinfo[i].version++;
......@@ -108,7 +112,7 @@ int mi_write(MI_INFO *info, byte *record)
{
if (_mi_ft_add(info,i,(char*) buff,record,filepos))
{
if (share->concurrent_insert)
if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]);
DBUG_PRINT("error",("Got error: %d on write",my_errno));
goto err;
......@@ -119,13 +123,13 @@ int mi_write(MI_INFO *info, byte *record)
uint key_length=_mi_make_key(info,i,buff,record,filepos);
if (_mi_ck_write(info,i,buff,key_length))
{
if (share->concurrent_insert && ! info->bulk_insert)
if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]);
DBUG_PRINT("error",("Got error: %d on write",my_errno));
goto err;
}
}
if (share->concurrent_insert)
if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]);
}
}
......@@ -157,13 +161,16 @@ int mi_write(MI_INFO *info, byte *record)
{
if (((ulonglong) 1 << i) & share->state.key_map)
{
if (share->concurrent_insert)
bool local_lock_tree= (lock_tree &&
!(info->bulk_insert &&
is_tree_inited(& info->bulk_insert[i])));
if (local_lock_tree)
rw_wrlock(&share->key_root_lock[i]);
if (share->keyinfo[i].flag & HA_FULLTEXT)
{
if (_mi_ft_del(info,i,(char*) buff,record,filepos))
{
if (share->concurrent_insert)
if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]);
break;
}
......@@ -173,12 +180,12 @@ int mi_write(MI_INFO *info, byte *record)
uint key_length=_mi_make_key(info,i,buff,record,filepos);
if (_mi_ck_delete(info,i,buff,key_length))
{
if (share->concurrent_insert)
if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]);
break;
}
}
if (share->concurrent_insert)
if (local_lock_tree)
rw_unlock(&share->key_root_lock[i]);
}
}
......@@ -212,6 +219,7 @@ int _mi_ck_write(MI_INFO *info, uint keynr, uchar *key, uint key_length)
}
} /* _mi_ck_write */
/**********************************************************************
* Normal insert code *
**********************************************************************/
......@@ -724,6 +732,7 @@ int _mi_ck_write_tree(register MI_INFO *info, uint keynr, uchar *key,
DBUG_RETURN(error);
} /* _mi_ck_write_tree */
/* typeof(_mi_keys_compare)=qsort_cmp2 */
static int keys_compare(bulk_insert_param *param, uchar *key1, uchar *key2)
{
......@@ -732,6 +741,7 @@ static int keys_compare(bulk_insert_param *param, uchar *key1, uchar *key2)
key1, key2, USE_WHOLE_KEY, SEARCH_SAME, &not_used);
}
static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
{
/* probably I can use info->lastkey here, but I'm not sure,
......
......@@ -246,7 +246,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
/* Drop the table nicely */
*fn_ext(file->name)=0; // Remove extension
TABLE_LIST *table_list=(TABLE_LIST*)
thd->calloc(sizeof(*table_list)+ strlen(db)+strlen(file->name)+1);
thd->calloc(sizeof(*table_list)+ strlen(db)+strlen(file->name)+2);
if (!table_list)
{
my_dirend(dirp);
......
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