summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <brian@zim.tangent.org>2006-02-19 09:41:59 -0800
committerunknown <brian@zim.tangent.org>2006-02-19 09:41:59 -0800
commit99502158b7dca8bc5be4a52ecf30a671739a6b84 (patch)
treed05f774b368556fbf12cea7bddef5d6e079d6fd2 /client
parent309f51cd28625316f2eb2ad34ba0f95b0d986264 (diff)
downloadmariadb-git-99502158b7dca8bc5be4a52ecf30a671739a6b84.tar.gz
Fixed some threading issues that Guilhem found (and its what I get for copy and pasting from elsewhere without thinking about it). Added depracted messages to BACKUP, RESTORE, and LOAD TABLE FROM MASTER (which doesn't work well).
client/Makefile.am: Added threaded libary. client/mysqlimport.c: Updated logic to use threaded libmysql correctly. client/mysqlslap.c: Modified how threads were working. mysql-test/r/backup.result: Added deprecated messages. sql/sql_yacc.yy: Added deprecated messages to RESTORE, BACKUP, and LOAD TABLE FROM MASTER
Diffstat (limited to 'client')
-rw-r--r--client/Makefile.am12
-rw-r--r--client/mysqlimport.c11
-rw-r--r--client/mysqlslap.c51
3 files changed, 51 insertions, 23 deletions
diff --git a/client/Makefile.am b/client/Makefile.am
index 14ebadbfacb..0f702d90c4d 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -48,15 +48,19 @@ mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c \
$(top_srcdir)/mysys/my_vle.c \
$(top_srcdir)/mysys/base64.c
mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS)
-mysqlslap_LDADD = $(LDADD) $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS)
-mysqlimport_LDADD = $(LDADD) $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
+mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
+ @CLIENT_EXTRA_LDFLAGS@ \
+ $(top_builddir)/libmysql_r/libmysqlclient_r.la \
+ $(top_builddir)/mysys/libmysys.a
+mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
+ @CLIENT_EXTRA_LDFLAGS@ \
+ $(top_builddir)/libmysql_r/libmysqlclient_r.la \
$(top_builddir)/mysys/libmysys.a
mysqltestmanager_pwgen_SOURCES = mysqlmanager-pwgen.c
mysqltestmanagerc_SOURCES= mysqlmanagerc.c $(yassl_dummy_link_fix)
mysqlcheck_SOURCES= mysqlcheck.c $(yassl_dummy_link_fix)
mysqlshow_SOURCES= mysqlshow.c $(yassl_dummy_link_fix)
-mysqlslap_SOURCES= mysqlslap.c $(top_srcdir)/mysys/my_lock.c \
- $(top_srcdir)/mysys/my_alarm.c \
+mysqlslap_SOURCES= mysqlslap.c \
$(yassl_dummy_link_fix)
mysqldump_SOURCES= mysqldump.c my_user.c $(yassl_dummy_link_fix)
mysqlimport_SOURCES= mysqlimport.c \
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index df36a9f0c00..4296ab327dd 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -516,7 +516,11 @@ pthread_handler_t worker_thread(void *arg)
{
int error;
char *raw_table_name= (char *)arg;
- MYSQL *mysql;
+ MYSQL *mysql= 0;
+
+ if (mysql_thread_init())
+ goto error;
+
if (!(mysql= db_connect(current_host,current_db,current_user,opt_password)))
{
goto error;
@@ -528,6 +532,9 @@ pthread_handler_t worker_thread(void *arg)
goto error;
}
+ /*
+ We are not currently catching the error here.
+ */
if((error= write_to_table(raw_table_name, mysql)))
if (exitcode == 0)
exitcode= error;
@@ -539,6 +546,8 @@ error:
pthread_mutex_lock(&counter_mutex);
counter--;
pthread_mutex_unlock(&counter_mutex);
+ my_thread_end();
+
return 0;
}
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index c0986c2d867..44b2d1b5afb 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -76,6 +76,7 @@ TODO:
#define RAND_STRING_SIZE 126
#include "client_priv.h"
+#include <my_pthread.h>
#include <my_sys.h>
#include <m_string.h>
#include <mysql.h>
@@ -89,7 +90,6 @@ TODO:
#include <sys/wait.h>
#endif
#include <ctype.h>
-#include <my_pthread.h>
#define MYSLAPLOCK "/myslaplock.lck"
#define MYSLAPLOCK_DIR "/tmp"
@@ -170,6 +170,7 @@ typedef struct thread_context thread_context;
struct thread_context {
statement *stmt;
ulonglong limit;
+ bool thread;
};
typedef struct conclusions conclusions;
@@ -974,6 +975,7 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
con.stmt= stmts;
con.limit= limit;
+ con.thread= opt_use_threads ? 1 :0;
lock_file= my_open(lock_file_str, O_CREAT|O_WRONLY|O_TRUNC, MYF(0));
@@ -1096,8 +1098,8 @@ int
run_task(thread_context *con)
{
ulonglong counter= 0, queries;
- File lock_file;
- MYSQL mysql;
+ File lock_file= -1;
+ MYSQL *mysql;
MYSQL_RES *result;
MYSQL_ROW row;
statement *ptr;
@@ -1105,19 +1107,25 @@ run_task(thread_context *con)
DBUG_ENTER("run_task");
DBUG_PRINT("info", ("task script \"%s\"", con->stmt->string));
- mysql_init(&mysql);
+ if (!(mysql= mysql_init(NULL)))
+ goto end;
+
+ if (con->thread && mysql_thread_init())
+ goto end;
DBUG_PRINT("info", ("trying to connect to host %s as user %s", host, user));
lock_file= my_open(lock_file_str, O_RDWR, MYF(0));
my_lock(lock_file, F_RDLCK, 0, F_TO_EOF, MYF(0));
if (!opt_only_print)
{
- if (!(mysql_real_connect(&mysql, host, user, opt_password,
- "mysqlslap", opt_mysql_port, opt_mysql_unix_port,
- 0)))
+ if (!(mysql= mysql_real_connect(NULL, host, user, opt_password,
+ create_schema_string,
+ opt_mysql_port,
+ opt_mysql_unix_port,
+ 0)))
{
- fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql));
- exit(1);
+ fprintf(stderr,"%s: %s\n",my_progname,mysql_error(mysql));
+ goto end;
}
}
DBUG_PRINT("info", ("connected."));
@@ -1133,15 +1141,15 @@ limit_not_met:
}
else
{
- if (mysql_real_query(&mysql, ptr->string, ptr->length))
+ if (mysql_real_query(mysql, ptr->string, ptr->length))
{
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
- my_progname, (uint)ptr->length, ptr->string, mysql_error(&mysql));
- exit(1);
+ my_progname, (uint)ptr->length, ptr->string, mysql_error(mysql));
+ goto end;
}
- if (mysql_field_count(&mysql))
+ if (mysql_field_count(mysql))
{
- result= mysql_store_result(&mysql);
+ result= mysql_store_result(mysql);
while ((row = mysql_fetch_row(result)))
counter++;
mysql_free_result(result);
@@ -1150,18 +1158,25 @@ limit_not_met:
queries++;
if (con->limit && queries == con->limit)
- DBUG_RETURN(0);
+ goto end;
}
if (con->limit && queries < con->limit)
goto limit_not_met;
- my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
- my_close(lock_file, MYF(0));
+end:
+
+ if (lock_file != -1)
+ {
+ my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
+ my_close(lock_file, MYF(0));
+ }
if (!opt_only_print)
- mysql_close(&mysql);
+ mysql_close(mysql);
+ if (con->thread)
+ my_thread_end();
DBUG_RETURN(0);
}