summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Kuruvila <arun.kuruvila@oracle.com>2015-06-30 10:27:12 +0530
committerArun Kuruvila <arun.kuruvila@oracle.com>2015-06-30 10:27:12 +0530
commit7c5d18e2271ce4fcd9294511860841dbb4fec31a (patch)
tree94914c21097ad1759f8a40396a8d0db6cae45c33
parent9068238b1984100dc2251f742a994b18fafaa841 (diff)
downloadmariadb-git-7c5d18e2271ce4fcd9294511860841dbb4fec31a.tar.gz
Bug #20772273 : MYSQLIMPORT --USE-THREADS DOESN'T USE
MULTIPLE THREADS Description:- The utility "mysqlimport" does not use multiple threads for the execution with option "--use-threads". "mysqlimport" while importing multiple files and multiple tables, uses a single thread even if the number of threads are specified with "--use-threads" option. Analysis:- This utility uses ifdef HAVE_LIBPTHREAD to check for libpthread library and if defined uses libpthread library for mutlithreaing. Since HAVE_LIBPTHREAD is not defined anywhere in the source, "--use-threads" option is silently ignored. Fix:- "-DTHREADS" is set to the COMPILE_FLAGS which will enable pthreads. HAVE_LIBPTHREAD macro is removed.
-rw-r--r--client/CMakeLists.txt3
-rw-r--r--client/mysqlimport.c11
-rw-r--r--mysql-test/r/mysqldump.result28
-rw-r--r--mysql-test/t/mysqldump.test29
4 files changed, 60 insertions, 11 deletions
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 0d67cf2e0d4..21b1e084409 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
#
# 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
@@ -51,6 +51,7 @@ MYSQL_ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c)
TARGET_LINK_LIBRARIES(mysqldump mysqlclient)
MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c)
+SET_SOURCE_FILES_PROPERTIES(mysqlimport.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient)
MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c)
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 2045c94619b..813c1baf793 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
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
@@ -24,19 +24,14 @@
#include "client_priv.h"
#include "mysql_version.h"
-#ifdef HAVE_LIBPTHREAD
-#include <my_pthread.h>
-#endif
#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
/* Global Thread counter */
uint counter;
-#ifdef HAVE_LIBPTHREAD
pthread_mutex_t counter_mutex;
pthread_cond_t count_threshhold;
-#endif
static void db_error_with_table(MYSQL *mysql, char *table);
static void db_error(MYSQL *mysql);
@@ -548,7 +543,6 @@ static char *field_escape(char *to,const char *from,uint length)
int exitcode= 0;
-#ifdef HAVE_LIBPTHREAD
pthread_handler_t worker_thread(void *arg)
{
int error;
@@ -588,7 +582,6 @@ error:
return 0;
}
-#endif
int main(int argc, char **argv)
@@ -607,7 +600,6 @@ int main(int argc, char **argv)
return(1);
}
-#ifdef HAVE_LIBPTHREAD
if (opt_use_threads && !lock_tables)
{
pthread_t mainthread; /* Thread descriptor */
@@ -661,7 +653,6 @@ int main(int argc, char **argv)
pthread_attr_destroy(&attr);
}
else
-#endif
{
MYSQL *mysql= 0;
if (!(mysql= db_connect(current_host,current_db,current_user,opt_password)))
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index a31516d10d2..c578f9e8df6 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -5255,3 +5255,31 @@ SET @@global.general_log= @old_general_log_state;
#
# End of 5.1 tests
#
+#
+# Bug #20772273 : MYSQLIMPORT --USE-THREADS DOESN'T USE MULTIPLE THREADS
+#
+CREATE DATABASE db_20772273;
+USE db_20772273;
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (2);
+CREATE TABLE t2(a INT);
+INSERT INTO t2 VALUES (3), (4);
+SELECT * FROM t1;
+a
+1
+2
+SELECT * FROM t2;
+a
+3
+4
+SELECT * FROM t1;
+a
+1
+2
+SELECT * FROM t2;
+a
+3
+4
+DROP TABLE t1;
+DROP TABLE t2;
+DROP DATABASE db_20772273;
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index 478d8fb2863..54780b95627 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -2401,3 +2401,32 @@ SET @@global.general_log= @old_general_log_state;
--echo #
--echo # End of 5.1 tests
--echo #
+
+--echo #
+--echo # Bug #20772273 : MYSQLIMPORT --USE-THREADS DOESN'T USE MULTIPLE THREADS
+--echo #
+
+CREATE DATABASE db_20772273;
+USE db_20772273;
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (2);
+CREATE TABLE t2(a INT);
+INSERT INTO t2 VALUES (3), (4);
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ db_20772273
+--exec $MYSQL db_20772273 < $MYSQLTEST_VARDIR/tmp/t1.sql
+--exec $MYSQL db_20772273 < $MYSQLTEST_VARDIR/tmp/t2.sql
+
+# Test mysqlimport with multiple threads
+--exec $MYSQL_IMPORT --silent --use-threads=2 db_20772273 $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+#Cleanup
+DROP TABLE t1;
+DROP TABLE t2;
+DROP DATABASE db_20772273;