Skip to content

Commit 7c5d18e

Browse files
author
Arun Kuruvila
committed
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.
1 parent 9068238 commit 7c5d18e

File tree

4 files changed

+60
-11
lines changed

4 files changed

+60
-11
lines changed

client/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# 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)
5151
TARGET_LINK_LIBRARIES(mysqldump mysqlclient)
5252

5353
MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c)
54+
SET_SOURCE_FILES_PROPERTIES(mysqlimport.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
5455
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient)
5556

5657
MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c)

client/mysqlimport.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -24,19 +24,14 @@
2424

2525
#include "client_priv.h"
2626
#include "mysql_version.h"
27-
#ifdef HAVE_LIBPTHREAD
28-
#include <my_pthread.h>
29-
#endif
3027

3128
#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
3229

3330

3431
/* Global Thread counter */
3532
uint counter;
36-
#ifdef HAVE_LIBPTHREAD
3733
pthread_mutex_t counter_mutex;
3834
pthread_cond_t count_threshhold;
39-
#endif
4035

4136
static void db_error_with_table(MYSQL *mysql, char *table);
4237
static void db_error(MYSQL *mysql);
@@ -548,7 +543,6 @@ static char *field_escape(char *to,const char *from,uint length)
548543

549544
int exitcode= 0;
550545

551-
#ifdef HAVE_LIBPTHREAD
552546
pthread_handler_t worker_thread(void *arg)
553547
{
554548
int error;
@@ -588,7 +582,6 @@ pthread_handler_t worker_thread(void *arg)
588582

589583
return 0;
590584
}
591-
#endif
592585

593586

594587
int main(int argc, char **argv)
@@ -607,7 +600,6 @@ int main(int argc, char **argv)
607600
return(1);
608601
}
609602

610-
#ifdef HAVE_LIBPTHREAD
611603
if (opt_use_threads && !lock_tables)
612604
{
613605
pthread_t mainthread; /* Thread descriptor */
@@ -661,7 +653,6 @@ int main(int argc, char **argv)
661653
pthread_attr_destroy(&attr);
662654
}
663655
else
664-
#endif
665656
{
666657
MYSQL *mysql= 0;
667658
if (!(mysql= db_connect(current_host,current_db,current_user,opt_password)))

mysql-test/r/mysqldump.result

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5255,3 +5255,31 @@ SET @@global.general_log= @old_general_log_state;
52555255
#
52565256
# End of 5.1 tests
52575257
#
5258+
#
5259+
# Bug #20772273 : MYSQLIMPORT --USE-THREADS DOESN'T USE MULTIPLE THREADS
5260+
#
5261+
CREATE DATABASE db_20772273;
5262+
USE db_20772273;
5263+
CREATE TABLE t1(a INT);
5264+
INSERT INTO t1 VALUES (1), (2);
5265+
CREATE TABLE t2(a INT);
5266+
INSERT INTO t2 VALUES (3), (4);
5267+
SELECT * FROM t1;
5268+
a
5269+
1
5270+
2
5271+
SELECT * FROM t2;
5272+
a
5273+
3
5274+
4
5275+
SELECT * FROM t1;
5276+
a
5277+
1
5278+
2
5279+
SELECT * FROM t2;
5280+
a
5281+
3
5282+
4
5283+
DROP TABLE t1;
5284+
DROP TABLE t2;
5285+
DROP DATABASE db_20772273;

mysql-test/t/mysqldump.test

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,3 +2401,32 @@ SET @@global.general_log= @old_general_log_state;
24012401
--echo #
24022402
--echo # End of 5.1 tests
24032403
--echo #
2404+
2405+
--echo #
2406+
--echo # Bug #20772273 : MYSQLIMPORT --USE-THREADS DOESN'T USE MULTIPLE THREADS
2407+
--echo #
2408+
2409+
CREATE DATABASE db_20772273;
2410+
USE db_20772273;
2411+
CREATE TABLE t1(a INT);
2412+
INSERT INTO t1 VALUES (1), (2);
2413+
CREATE TABLE t2(a INT);
2414+
INSERT INTO t2 VALUES (3), (4);
2415+
2416+
SELECT * FROM t1;
2417+
SELECT * FROM t2;
2418+
2419+
--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ db_20772273
2420+
--exec $MYSQL db_20772273 < $MYSQLTEST_VARDIR/tmp/t1.sql
2421+
--exec $MYSQL db_20772273 < $MYSQLTEST_VARDIR/tmp/t2.sql
2422+
2423+
# Test mysqlimport with multiple threads
2424+
--exec $MYSQL_IMPORT --silent --use-threads=2 db_20772273 $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt
2425+
2426+
SELECT * FROM t1;
2427+
SELECT * FROM t2;
2428+
2429+
#Cleanup
2430+
DROP TABLE t1;
2431+
DROP TABLE t2;
2432+
DROP DATABASE db_20772273;

0 commit comments

Comments
 (0)