Skip to content

Commit 38a0def

Browse files
author
Nirbhay Choubey
committed
Merge tag 'mariadb-5.5.51' into 5.5-galera
2 parents 44e3046 + 5ad0206 commit 38a0def

File tree

91 files changed

+1645
-390
lines changed

Some content is hidden

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

91 files changed

+1645
-390
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
MYSQL_VERSION_MAJOR=5
22
MYSQL_VERSION_MINOR=5
3-
MYSQL_VERSION_PATCH=50
3+
MYSQL_VERSION_PATCH=51
44
MYSQL_VERSION_EXTRA=

client/mysqlcheck.c

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static int process_selected_tables(char *db, char **table_names, int tables);
232232
static int process_all_tables_in_db(char *database);
233233
static int process_one_db(char *database);
234234
static int use_db(char *database);
235-
static int handle_request_for_tables(char *tables, size_t length, my_bool view);
235+
static int handle_request_for_tables(char *, size_t, my_bool, my_bool);
236236
static int dbConnect(char *host, char *user,char *passwd);
237237
static void dbDisconnect(char *host);
238238
static void DBerror(MYSQL *mysql, const char *when);
@@ -566,7 +566,7 @@ static int process_selected_tables(char *db, char **table_names, int tables)
566566
}
567567
*--end = 0;
568568
handle_request_for_tables(table_names_comma_sep + 1, tot_length - 1,
569-
opt_do_views != 0);
569+
opt_do_views != 0, opt_all_in_1);
570570
my_free(table_names_comma_sep);
571571
}
572572
else
@@ -577,7 +577,7 @@ static int process_selected_tables(char *db, char **table_names, int tables)
577577
view= is_view(table);
578578
if (view < 0)
579579
continue;
580-
handle_request_for_tables(table, table_len, (view == 1));
580+
handle_request_for_tables(table, table_len, view == 1, opt_all_in_1);
581581
}
582582
DBUG_RETURN(0);
583583
} /* process_selected_tables */
@@ -605,13 +605,9 @@ static char *fix_table_name(char *dest, char *src)
605605
*dest++= '`';
606606
for (; *src; src++)
607607
{
608-
switch (*src) {
609-
case '`': /* escape backtick character */
608+
if (*src == '`')
610609
*dest++= '`';
611-
/* fall through */
612-
default:
613-
*dest++= *src;
614-
}
610+
*dest++= *src;
615611
}
616612
*dest++= '`';
617613

@@ -700,9 +696,9 @@ static int process_all_tables_in_db(char *database)
700696
*--end = 0;
701697
*--views_end = 0;
702698
if (tot_length)
703-
handle_request_for_tables(tables + 1, tot_length - 1, FALSE);
699+
handle_request_for_tables(tables + 1, tot_length - 1, FALSE, opt_all_in_1);
704700
if (tot_views_length)
705-
handle_request_for_tables(views + 1, tot_views_length - 1, TRUE);
701+
handle_request_for_tables(views + 1, tot_views_length - 1, TRUE, opt_all_in_1);
706702
my_free(tables);
707703
my_free(views);
708704
}
@@ -728,7 +724,7 @@ static int process_all_tables_in_db(char *database)
728724
!strcmp(row[0], "slow_log")))
729725
continue; /* Skip logging tables */
730726

731-
handle_request_for_tables(row[0], fixed_name_length(row[0]), view);
727+
handle_request_for_tables(row[0], fixed_name_length(row[0]), view, opt_all_in_1);
732728
}
733729
}
734730
mysql_free_result(res);
@@ -756,7 +752,7 @@ static int fix_table_storage_name(const char *name)
756752

757753
if (strncmp(name, "#mysql50#", 9))
758754
DBUG_RETURN(1);
759-
my_snprintf(qbuf, sizeof(qbuf), "RENAME TABLE `%s` TO `%s`",
755+
my_snprintf(qbuf, sizeof(qbuf), "RENAME TABLE %`s TO %`s",
760756
name, name + 9);
761757

762758
rc= run_query(qbuf);
@@ -773,7 +769,7 @@ static int fix_database_storage_name(const char *name)
773769

774770
if (strncmp(name, "#mysql50#", 9))
775771
DBUG_RETURN(1);
776-
my_snprintf(qbuf, sizeof(qbuf), "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY "
772+
my_snprintf(qbuf, sizeof(qbuf), "ALTER DATABASE %`s UPGRADE DATA DIRECTORY "
777773
"NAME", name);
778774
rc= run_query(qbuf);
779775
if (verbose)
@@ -787,13 +783,11 @@ static int rebuild_table(char *name)
787783
int rc= 0;
788784
DBUG_ENTER("rebuild_table");
789785

790-
query= (char*)my_malloc(sizeof(char) * (12 + fixed_name_length(name) + 6 + 1),
786+
query= (char*)my_malloc(sizeof(char) * (12 + strlen(name) + 6 + 1),
791787
MYF(MY_WME));
792788
if (!query)
793789
DBUG_RETURN(1);
794-
ptr= strmov(query, "ALTER TABLE ");
795-
ptr= fix_table_name(ptr, name);
796-
ptr= strxmov(ptr, " FORCE", NullS);
790+
ptr= strxmov(query, "ALTER TABLE ", name, " FORCE", NullS);
797791
if (mysql_real_query(sock, query, (ulong)(ptr - query)))
798792
{
799793
fprintf(stderr, "Failed to %s\n", query);
@@ -855,7 +849,8 @@ static int disable_binlog()
855849
return run_query(stmt);
856850
}
857851

858-
static int handle_request_for_tables(char *tables, size_t length, my_bool view)
852+
static int handle_request_for_tables(char *tables, size_t length,
853+
my_bool view, my_bool dont_quote)
859854
{
860855
char *query, *end, options[100], message[100];
861856
char table_name_buff[NAME_CHAR_LEN*2*2+1], *table_name;
@@ -913,7 +908,7 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
913908

914909
if (!(query =(char *) my_malloc(query_size, MYF(MY_WME))))
915910
DBUG_RETURN(1);
916-
if (opt_all_in_1)
911+
if (dont_quote)
917912
{
918913
DBUG_ASSERT(strlen(op)+strlen(tables)+strlen(options)+8+1 <= query_size);
919914

@@ -956,23 +951,27 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
956951
DBUG_RETURN(0);
957952
}
958953

954+
static void insert_table_name(DYNAMIC_ARRAY *arr, char *in, size_t dblen)
955+
{
956+
char buf[NAME_LEN*2+2];
957+
in[dblen]= 0;
958+
my_snprintf(buf, sizeof(buf), "%`s.%`s", in, in + dblen + 1);
959+
insert_dynamic(arr, (uchar*) buf);
960+
}
959961

960962
static void print_result()
961963
{
962964
MYSQL_RES *res;
963965
MYSQL_ROW row;
964966
char prev[(NAME_LEN+9)*3+2];
965967
char prev_alter[MAX_ALTER_STR_SIZE];
966-
char *db_name;
967-
uint length_of_db;
968+
size_t length_of_db= strlen(sock->db);
968969
uint i;
969970
my_bool found_error=0, table_rebuild=0;
970971
DYNAMIC_ARRAY *array4repair= &tables4repair;
971972
DBUG_ENTER("print_result");
972973

973974
res = mysql_use_result(sock);
974-
db_name= sock->db;
975-
length_of_db= strlen(db_name);
976975

977976
prev[0] = '\0';
978977
prev_alter[0]= 0;
@@ -996,16 +995,10 @@ static void print_result()
996995
if (prev_alter[0])
997996
insert_dynamic(&alter_table_cmds, (uchar*) prev_alter);
998997
else
999-
{
1000-
char *table_name= prev + (length_of_db+1);
1001-
insert_dynamic(&tables4rebuild, (uchar*) table_name);
1002-
}
998+
insert_table_name(&tables4rebuild, prev, length_of_db);
1003999
}
10041000
else
1005-
{
1006-
char *table_name= prev + (length_of_db+1);
1007-
insert_dynamic(array4repair, (uchar*) table_name);
1008-
}
1001+
insert_table_name(array4repair, prev, length_of_db);
10091002
}
10101003
array4repair= &tables4repair;
10111004
found_error=0;
@@ -1072,16 +1065,10 @@ static void print_result()
10721065
if (prev_alter[0])
10731066
insert_dynamic(&alter_table_cmds, (uchar*) prev_alter);
10741067
else
1075-
{
1076-
char *table_name= prev + (length_of_db+1);
1077-
insert_dynamic(&tables4rebuild, (uchar*) table_name);
1078-
}
1068+
insert_table_name(&tables4rebuild, prev, length_of_db);
10791069
}
10801070
else
1081-
{
1082-
char *table_name= prev + (length_of_db+1);
1083-
insert_dynamic(array4repair, (uchar*) table_name);
1084-
}
1071+
insert_table_name(array4repair, prev, length_of_db);
10851072
}
10861073
mysql_free_result(res);
10871074
DBUG_VOID_RETURN;
@@ -1215,7 +1202,7 @@ int main(int argc, char **argv)
12151202
for (i = 0; i < tables4repair.elements ; i++)
12161203
{
12171204
char *name= (char*) dynamic_array_ptr(&tables4repair, i);
1218-
handle_request_for_tables(name, fixed_name_length(name), FALSE);
1205+
handle_request_for_tables(name, fixed_name_length(name), FALSE, TRUE);
12191206
}
12201207
for (i = 0; i < tables4rebuild.elements ; i++)
12211208
rebuild_table((char*) dynamic_array_ptr(&tables4rebuild, i));
@@ -1226,7 +1213,7 @@ int main(int argc, char **argv)
12261213
for (i = 0; i < views4repair.elements ; i++)
12271214
{
12281215
char *name= (char*) dynamic_array_ptr(&views4repair, i);
1229-
handle_request_for_tables(name, fixed_name_length(name), TRUE);
1216+
handle_request_for_tables(name, fixed_name_length(name), TRUE, TRUE);
12301217
}
12311218
}
12321219
ret= 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)
@@ -605,7 +617,7 @@ pthread_handler_t worker_thread(void *arg)
605617
pthread_cond_signal(&count_threshhold);
606618
pthread_mutex_unlock(&counter_mutex);
607619
mysql_thread_end();
608-
620+
pthread_exit(0);
609621
return 0;
610622
}
611623

@@ -629,15 +641,31 @@ int main(int argc, char **argv)
629641

630642
if (opt_use_threads && !lock_tables)
631643
{
632-
pthread_t mainthread; /* Thread descriptor */
633-
pthread_attr_t attr; /* Thread attributes */
644+
char **save_argv;
645+
uint worker_thread_count= 0, table_count= 0, i= 0;
646+
pthread_t *worker_threads; /* Thread descriptor */
647+
pthread_attr_t attr; /* Thread attributes */
634648
pthread_attr_init(&attr);
635649
pthread_attr_setdetachstate(&attr,
636-
PTHREAD_CREATE_DETACHED);
650+
PTHREAD_CREATE_JOINABLE);
637651

652+
pthread_mutex_init(&init_mutex, NULL);
638653
pthread_mutex_init(&counter_mutex, NULL);
639654
pthread_cond_init(&count_threshhold, NULL);
640655

656+
/* Count the number of tables. This number denotes the total number
657+
of threads spawn.
658+
*/
659+
save_argv= argv;
660+
for (table_count= 0; *argv != NULL; argv++)
661+
table_count++;
662+
argv= save_argv;
663+
664+
if (!(worker_threads= (pthread_t*) my_malloc(table_count *
665+
sizeof(*worker_threads),
666+
MYF(0))))
667+
return -2;
668+
641669
for (counter= 0; *argv != NULL; argv++) /* Loop through tables */
642670
{
643671
pthread_mutex_lock(&counter_mutex);
@@ -652,15 +680,16 @@ int main(int argc, char **argv)
652680
counter++;
653681
pthread_mutex_unlock(&counter_mutex);
654682
/* now create the thread */
655-
if (pthread_create(&mainthread, &attr, worker_thread,
656-
(void *)*argv) != 0)
683+
if (pthread_create(&worker_threads[worker_thread_count], &attr,
684+
worker_thread, (void *)*argv) != 0)
657685
{
658686
pthread_mutex_lock(&counter_mutex);
659687
counter--;
660688
pthread_mutex_unlock(&counter_mutex);
661-
fprintf(stderr,"%s: Could not create thread\n",
662-
my_progname);
689+
fprintf(stderr,"%s: Could not create thread\n", my_progname);
690+
continue;
663691
}
692+
worker_thread_count++;
664693
}
665694

666695
/*
@@ -675,9 +704,18 @@ int main(int argc, char **argv)
675704
pthread_cond_timedwait(&count_threshhold, &counter_mutex, &abstime);
676705
}
677706
pthread_mutex_unlock(&counter_mutex);
707+
pthread_mutex_destroy(&init_mutex);
678708
pthread_mutex_destroy(&counter_mutex);
679709
pthread_cond_destroy(&count_threshhold);
680710
pthread_attr_destroy(&attr);
711+
712+
for(i= 0; i < worker_thread_count; i++)
713+
{
714+
if (pthread_join(worker_threads[i], NULL))
715+
fprintf(stderr,"%s: Could not join worker thread.\n", my_progname);
716+
}
717+
718+
my_free(worker_threads);
681719
}
682720
else
683721
{

libmysqld/lib_sql.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,12 @@ static int emb_stmt_execute(MYSQL_STMT *stmt)
341341
THD *thd;
342342
my_bool res;
343343

344+
if (stmt->param_count && !stmt->bind_param_done)
345+
{
346+
set_stmt_error(stmt, CR_PARAMS_NOT_BOUND, unknown_sqlstate, NULL);
347+
DBUG_RETURN(1);
348+
}
349+
344350
int4store(header, stmt->stmt_id);
345351
header[4]= (uchar) stmt->flags;
346352
thd= (THD*)stmt->mysql->thd;

mysql-test/include/report-features.test

Lines changed: 0 additions & 12 deletions
This file was deleted.

mysql-test/mysql-test-run.pl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ END
280280
my $build_thread= 0;
281281

282282
my $opt_record;
283-
my $opt_report_features;
284283

285284
our $opt_resfile= $ENV{'MTR_RESULT_FILE'} || 0;
286285

@@ -426,21 +425,6 @@ sub main {
426425
my $tests= collect_test_cases($opt_reorder, $opt_suites, \@opt_cases, \@opt_skip_test_list);
427426
mark_time_used('collect');
428427

429-
if ( $opt_report_features ) {
430-
# Put "report features" as the first test to run
431-
my $tinfo = My::Test->new
432-
(
433-
name => 'report_features',
434-
# No result_file => Prints result
435-
path => 'include/report-features.test',
436-
template_path => "include/default_my.cnf",
437-
master_opt => [],
438-
slave_opt => [],
439-
suite => 'main',
440-
);
441-
unshift(@$tests, $tinfo);
442-
}
443-
444428
#######################################################################
445429
my $num_tests= @$tests;
446430
if ( $opt_parallel eq "auto" ) {
@@ -1207,7 +1191,6 @@ sub command_line_setup {
12071191
'client-libdir=s' => \$path_client_libdir,
12081192

12091193
# Misc
1210-
'report-features' => \$opt_report_features,
12111194
'comment=s' => \$opt_comment,
12121195
'fast' => \$opt_fast,
12131196
'force-restart' => \$opt_force_restart,
@@ -6573,7 +6556,6 @@ ($)
65736556
gprof Collect profiling information using gprof.
65746557
experimental=<file> Refer to list of tests considered experimental;
65756558
failures will be marked exp-fail instead of fail.
6576-
report-features First run a "test" that reports mysql features
65776559
timestamp Print timestamp before each test report line
65786560
timediff With --timestamp, also print time passed since
65796561
*previous* test started

0 commit comments

Comments
 (0)