Skip to content

Commit 6b1863b

Browse files
committed
Merge branch '10.0' into 10.1
2 parents ea91bb6 + 5bbe929 commit 6b1863b

File tree

381 files changed

+5154
-3894
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

381 files changed

+5154
-3894
lines changed

CREDITS

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
MariaDB is brought to you by the MariaDB Foundation, a non profit
22
organization registered in the USA.
33

4-
The current main members and sponsors of the MariaDB Foundation are:
5-
6-
MariaDB Corporation http://www.mariadb.com (2013 - 2016)
7-
Booking.com http://www.booking.com (2013 - 2016)
8-
Parallels http://www.parallels.com/products/plesk (2013 - 2016)
9-
Automattic http://automattic.com (2014 - 2016)
10-
Verkkokauppa.com http://verkkokauppa.com (2015 - 2016)
11-
Visma http://visma.com/ (2015 - 2016)
12-
Webyog http://webyog.com (2015 - 2016)
13-
Wikimedia Foundation http://wikimedia.org (2015 - 2016)
14-
Acronis http://acronis.com (2016)
15-
16-
For a full list of supporters and sponsors see
4+
The current main sponsors of the MariaDB Foundation are:
5+
6+
Booking.com http://www.booking.com (2013 - 2016)
7+
Development Bank of Singapore http://dbs.com (2016)
8+
MariaDB Corporation https://www.mariadb.com (2013 - 2016)
9+
Visma http://visma.com (2015 - 2016)
10+
Acronis http://acronis.com (2016)
11+
Nexedi https://www.nexedi.com (2016)
12+
Automattic https://automattic.com (2014 - 2016)
13+
Verkkokauppa.com https://www.verkkokauppa.com (2015 - 2016)
14+
Virtuozzo https://virtuozzo.com (2016)
15+
16+
For a full list of sponsors, see
1717
https://mariadb.org/about/supporters/
18+
and for individual contributors, see
19+
https://mariadb.org/donate/individual-sponsors/
1820

19-
You can also do this by running SHOW CONTRIBUTORS.
21+
You can also get the list of sponsors by running SHOW CONTRIBUTORS.
2022

21-
For all corporate memberships and sponsorships please contact the
23+
For all corporate sponsorships please contact the
2224
MariaDB Foundation Board via foundation@mariadb.org.
2325

2426
The MariaDB Foundation is responsible for the MariaDB source
@@ -38,7 +40,7 @@ following services to the MariaDB community:
3840
To be able to do the above we need help from corporations and individuals!
3941

4042
You can help support MariaDB by becoming a MariaDB developer or a
41-
member or sponsor of the MariaDB Foundation. To donate or sponsor,
43+
sponsor of the MariaDB Foundation. To donate or sponsor,
4244
go to https://mariadb.org/donate/
4345

4446
You can get a list of all the main authors of MariaDB / MySQL by running

client/mysqlcheck.c

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static int process_selected_tables(char *db, char **table_names, int tables);
240240
static int process_all_tables_in_db(char *database);
241241
static int process_one_db(char *database);
242242
static int use_db(char *database);
243-
static int handle_request_for_tables(char *tables, size_t length, my_bool view);
243+
static int handle_request_for_tables(char *, size_t, my_bool, my_bool);
244244
static int dbConnect(char *host, char *user,char *passwd);
245245
static void dbDisconnect(char *host);
246246
static void DBerror(MYSQL *mysql, const char *when);
@@ -577,7 +577,7 @@ static int process_selected_tables(char *db, char **table_names, int tables)
577577
}
578578
*--end = 0;
579579
handle_request_for_tables(table_names_comma_sep + 1, tot_length - 1,
580-
opt_do_views != 0);
580+
opt_do_views != 0, opt_all_in_1);
581581
my_free(table_names_comma_sep);
582582
}
583583
else
@@ -588,7 +588,7 @@ static int process_selected_tables(char *db, char **table_names, int tables)
588588
view= is_view(table);
589589
if (view < 0)
590590
continue;
591-
handle_request_for_tables(table, table_len, (view == 1));
591+
handle_request_for_tables(table, table_len, view == 1, opt_all_in_1);
592592
}
593593
DBUG_RETURN(0);
594594
} /* process_selected_tables */
@@ -616,13 +616,9 @@ static char *fix_table_name(char *dest, char *src)
616616
*dest++= '`';
617617
for (; *src; src++)
618618
{
619-
switch (*src) {
620-
case '`': /* escape backtick character */
619+
if (*src == '`')
621620
*dest++= '`';
622-
/* fall through */
623-
default:
624-
*dest++= *src;
625-
}
621+
*dest++= *src;
626622
}
627623
*dest++= '`';
628624

@@ -711,9 +707,9 @@ static int process_all_tables_in_db(char *database)
711707
*--end = 0;
712708
*--views_end = 0;
713709
if (tot_length)
714-
handle_request_for_tables(tables + 1, tot_length - 1, FALSE);
710+
handle_request_for_tables(tables + 1, tot_length - 1, FALSE, opt_all_in_1);
715711
if (tot_views_length)
716-
handle_request_for_tables(views + 1, tot_views_length - 1, TRUE);
712+
handle_request_for_tables(views + 1, tot_views_length - 1, TRUE, opt_all_in_1);
717713
my_free(tables);
718714
my_free(views);
719715
}
@@ -739,7 +735,7 @@ static int process_all_tables_in_db(char *database)
739735
!strcmp(row[0], "slow_log")))
740736
continue; /* Skip logging tables */
741737

742-
handle_request_for_tables(row[0], fixed_name_length(row[0]), view);
738+
handle_request_for_tables(row[0], fixed_name_length(row[0]), view, opt_all_in_1);
743739
}
744740
}
745741
mysql_free_result(res);
@@ -800,13 +796,11 @@ static int rebuild_table(char *name)
800796
int rc= 0;
801797
DBUG_ENTER("rebuild_table");
802798

803-
query= (char*)my_malloc(sizeof(char) * (12 + fixed_name_length(name) + 6 + 1),
799+
query= (char*)my_malloc(sizeof(char) * (12 + strlen(name) + 6 + 1),
804800
MYF(MY_WME));
805801
if (!query)
806802
DBUG_RETURN(1);
807-
ptr= strmov(query, "ALTER TABLE ");
808-
ptr= fix_table_name(ptr, name);
809-
ptr= strxmov(ptr, " FORCE", NullS);
803+
ptr= strxmov(query, "ALTER TABLE ", name, " FORCE", NullS);
810804
if (verbose >= 3)
811805
puts(query);
812806
if (mysql_real_query(sock, query, (ulong)(ptr - query)))
@@ -870,7 +864,8 @@ static int disable_binlog()
870864
return run_query("SET SQL_LOG_BIN=0", 0);
871865
}
872866

873-
static int handle_request_for_tables(char *tables, size_t length, my_bool view)
867+
static int handle_request_for_tables(char *tables, size_t length,
868+
my_bool view, my_bool dont_quote)
874869
{
875870
char *query, *end, options[100], message[100];
876871
char table_name_buff[NAME_CHAR_LEN*2*2+1], *table_name;
@@ -929,7 +924,7 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
929924

930925
if (!(query =(char *) my_malloc(query_size, MYF(MY_WME))))
931926
DBUG_RETURN(1);
932-
if (opt_all_in_1)
927+
if (dont_quote)
933928
{
934929
DBUG_ASSERT(strlen(op)+strlen(tables)+strlen(options)+8+1 <= query_size);
935930

@@ -974,23 +969,27 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
974969
DBUG_RETURN(0);
975970
}
976971

972+
static void insert_table_name(DYNAMIC_ARRAY *arr, char *in, size_t dblen)
973+
{
974+
char buf[NAME_LEN*2+2];
975+
in[dblen]= 0;
976+
my_snprintf(buf, sizeof(buf), "%`s.%`s", in, in + dblen + 1);
977+
insert_dynamic(arr, (uchar*) buf);
978+
}
977979

978980
static void print_result()
979981
{
980982
MYSQL_RES *res;
981983
MYSQL_ROW row;
982984
char prev[(NAME_LEN+9)*3+2];
983985
char prev_alter[MAX_ALTER_STR_SIZE];
984-
char *db_name;
985-
uint length_of_db;
986+
size_t length_of_db= strlen(sock->db);
986987
uint i;
987988
my_bool found_error=0, table_rebuild=0;
988989
DYNAMIC_ARRAY *array4repair= &tables4repair;
989990
DBUG_ENTER("print_result");
990991

991992
res = mysql_use_result(sock);
992-
db_name= sock->db;
993-
length_of_db= strlen(db_name);
994993

995994
prev[0] = '\0';
996995
prev_alter[0]= 0;
@@ -1014,16 +1013,10 @@ static void print_result()
10141013
if (prev_alter[0])
10151014
insert_dynamic(&alter_table_cmds, (uchar*) prev_alter);
10161015
else
1017-
{
1018-
char *table_name= prev + (length_of_db+1);
1019-
insert_dynamic(&tables4rebuild, (uchar*) table_name);
1020-
}
1016+
insert_table_name(&tables4rebuild, prev, length_of_db);
10211017
}
10221018
else
1023-
{
1024-
char *table_name= prev + (length_of_db+1);
1025-
insert_dynamic(array4repair, table_name);
1026-
}
1019+
insert_table_name(array4repair, prev, length_of_db);
10271020
}
10281021
array4repair= &tables4repair;
10291022
found_error=0;
@@ -1068,16 +1061,10 @@ static void print_result()
10681061
if (prev_alter[0])
10691062
insert_dynamic(&alter_table_cmds, prev_alter);
10701063
else
1071-
{
1072-
char *table_name= prev + (length_of_db+1);
1073-
insert_dynamic(&tables4rebuild, table_name);
1074-
}
1064+
insert_table_name(&tables4rebuild, prev, length_of_db);
10751065
}
10761066
else
1077-
{
1078-
char *table_name= prev + (length_of_db+1);
1079-
insert_dynamic(array4repair, table_name);
1080-
}
1067+
insert_table_name(array4repair, prev, length_of_db);
10811068
}
10821069
mysql_free_result(res);
10831070
DBUG_VOID_RETURN;
@@ -1222,7 +1209,7 @@ int main(int argc, char **argv)
12221209
for (i = 0; i < tables4repair.elements ; i++)
12231210
{
12241211
char *name= (char*) dynamic_array_ptr(&tables4repair, i);
1225-
handle_request_for_tables(name, fixed_name_length(name), FALSE);
1212+
handle_request_for_tables(name, fixed_name_length(name), FALSE, TRUE);
12261213
}
12271214
for (i = 0; i < tables4rebuild.elements ; i++)
12281215
rebuild_table((char*) dynamic_array_ptr(&tables4rebuild, i));
@@ -1233,7 +1220,7 @@ int main(int argc, char **argv)
12331220
for (i = 0; i < views4repair.elements ; i++)
12341221
{
12351222
char *name= (char*) dynamic_array_ptr(&views4repair, i);
1236-
handle_request_for_tables(name, fixed_name_length(name), TRUE);
1223+
handle_request_for_tables(name, fixed_name_length(name), TRUE, TRUE);
12371224
}
12381225
}
12391226
ret= MY_TEST(first_error);

client/mysqlimport.c

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
/* Global Thread counter */
3939
uint counter= 0;
40+
pthread_mutex_t init_mutex;
4041
pthread_mutex_t counter_mutex;
4142
pthread_cond_t count_threshhold;
4243

@@ -421,8 +422,19 @@ static MYSQL *db_connect(char *host, char *database,
421422
MYSQL *mysql;
422423
if (verbose)
423424
fprintf(stdout, "Connecting to %s\n", host ? host : "localhost");
424-
if (!(mysql= mysql_init(NULL)))
425-
return 0;
425+
if (opt_use_threads && !lock_tables)
426+
{
427+
pthread_mutex_lock(&init_mutex);
428+
if (!(mysql= mysql_init(NULL)))
429+
{
430+
pthread_mutex_unlock(&init_mutex);
431+
return 0;
432+
}
433+
pthread_mutex_unlock(&init_mutex);
434+
}
435+
else
436+
if (!(mysql= mysql_init(NULL)))
437+
return 0;
426438
if (opt_compress)
427439
mysql_options(mysql,MYSQL_OPT_COMPRESS,NullS);
428440
if (opt_local_file)
@@ -614,7 +626,7 @@ pthread_handler_t worker_thread(void *arg)
614626
pthread_cond_signal(&count_threshhold);
615627
pthread_mutex_unlock(&counter_mutex);
616628
mysql_thread_end();
617-
629+
pthread_exit(0);
618630
return 0;
619631
}
620632

@@ -638,15 +650,31 @@ int main(int argc, char **argv)
638650

639651
if (opt_use_threads && !lock_tables)
640652
{
641-
pthread_t mainthread; /* Thread descriptor */
642-
pthread_attr_t attr; /* Thread attributes */
653+
char **save_argv;
654+
uint worker_thread_count= 0, table_count= 0, i= 0;
655+
pthread_t *worker_threads; /* Thread descriptor */
656+
pthread_attr_t attr; /* Thread attributes */
643657
pthread_attr_init(&attr);
644658
pthread_attr_setdetachstate(&attr,
645-
PTHREAD_CREATE_DETACHED);
659+
PTHREAD_CREATE_JOINABLE);
646660

661+
pthread_mutex_init(&init_mutex, NULL);
647662
pthread_mutex_init(&counter_mutex, NULL);
648663
pthread_cond_init(&count_threshhold, NULL);
649664

665+
/* Count the number of tables. This number denotes the total number
666+
of threads spawn.
667+
*/
668+
save_argv= argv;
669+
for (table_count= 0; *argv != NULL; argv++)
670+
table_count++;
671+
argv= save_argv;
672+
673+
if (!(worker_threads= (pthread_t*) my_malloc(table_count *
674+
sizeof(*worker_threads),
675+
MYF(0))))
676+
return -2;
677+
650678
for (counter= 0; *argv != NULL; argv++) /* Loop through tables */
651679
{
652680
pthread_mutex_lock(&counter_mutex);
@@ -661,15 +689,16 @@ int main(int argc, char **argv)
661689
counter++;
662690
pthread_mutex_unlock(&counter_mutex);
663691
/* now create the thread */
664-
if (pthread_create(&mainthread, &attr, worker_thread,
665-
(void *)*argv) != 0)
692+
if (pthread_create(&worker_threads[worker_thread_count], &attr,
693+
worker_thread, (void *)*argv) != 0)
666694
{
667695
pthread_mutex_lock(&counter_mutex);
668696
counter--;
669697
pthread_mutex_unlock(&counter_mutex);
670-
fprintf(stderr,"%s: Could not create thread\n",
671-
my_progname);
698+
fprintf(stderr,"%s: Could not create thread\n", my_progname);
699+
continue;
672700
}
701+
worker_thread_count++;
673702
}
674703

675704
/*
@@ -684,9 +713,18 @@ int main(int argc, char **argv)
684713
pthread_cond_timedwait(&count_threshhold, &counter_mutex, &abstime);
685714
}
686715
pthread_mutex_unlock(&counter_mutex);
716+
pthread_mutex_destroy(&init_mutex);
687717
pthread_mutex_destroy(&counter_mutex);
688718
pthread_cond_destroy(&count_threshhold);
689719
pthread_attr_destroy(&attr);
720+
721+
for(i= 0; i < worker_thread_count; i++)
722+
{
723+
if (pthread_join(worker_threads[i], NULL))
724+
fprintf(stderr,"%s: Could not join worker thread.\n", my_progname);
725+
}
726+
727+
my_free(worker_threads);
690728
}
691729
else
692730
{

0 commit comments

Comments
 (0)