Skip to content

Commit a69f4c7

Browse files
committed
Merge branch 'bb-10.0-serg' into 10.0
2 parents fa10a65 + 61a880d commit a69f4c7

File tree

547 files changed

+22098
-10054
lines changed

Some content is hidden

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

547 files changed

+22098
-10054
lines changed

client/mysqladmin.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,6 @@ my_bool
235235
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
236236
char *argument)
237237
{
238-
int error = 0;
239-
240238
switch(optid) {
241239
case 'c':
242240
opt_count_iterations= 1;
@@ -284,8 +282,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
284282
break;
285283
case '?':
286284
case 'I': /* Info */
287-
error++;
288-
break;
285+
usage();
286+
exit(0);
289287
case OPT_CHARSETS_DIR:
290288
#if MYSQL_VERSION_ID > 32300
291289
charsets_dir = argument;
@@ -296,11 +294,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
296294
opt->name);
297295
break;
298296
}
299-
if (error)
300-
{
301-
usage();
302-
exit(1);
303-
}
304297
return 0;
305298
}
306299

client/mysqlcheck.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static void dbDisconnect(char *host);
246246
static void DBerror(MYSQL *mysql, const char *when);
247247
static void safe_exit(int error);
248248
static void print_result();
249-
static uint fixed_name_length(const char *name);
249+
static size_t fixed_name_length(const char *name);
250250
static char *fix_table_name(char *dest, char *src);
251251
int what_to_do = 0;
252252

@@ -594,18 +594,18 @@ static int process_selected_tables(char *db, char **table_names, int tables)
594594
} /* process_selected_tables */
595595

596596

597-
static uint fixed_name_length(const char *name)
597+
static size_t fixed_name_length(const char *name)
598598
{
599599
const char *p;
600-
uint extra_length= 2; /* count the first/last backticks */
600+
size_t extra_length= 2; /* count the first/last backticks */
601601
DBUG_ENTER("fixed_name_length");
602602

603603
for (p= name; *p; p++)
604604
{
605605
if (*p == '`')
606606
extra_length++;
607607
}
608-
DBUG_RETURN((uint) ((p - name) + extra_length));
608+
DBUG_RETURN((size_t) ((p - name) + extra_length));
609609
}
610610

611611

@@ -664,7 +664,7 @@ static int process_all_tables_in_db(char *database)
664664
*/
665665

666666
char *tables, *end;
667-
uint tot_length = 0;
667+
size_t tot_length = 0;
668668

669669
char *views, *views_end;
670670
uint tot_views_length = 0;
@@ -769,7 +769,9 @@ static int fix_table_storage_name(const char *name)
769769

770770
if (strncmp(name, "#mysql50#", 9))
771771
DBUG_RETURN(1);
772-
sprintf(qbuf, "RENAME TABLE `%s` TO `%s`", name, name + 9);
772+
my_snprintf(qbuf, sizeof(qbuf), "RENAME TABLE %`s TO %`s",
773+
name, name + 9);
774+
773775
rc= run_query(qbuf, 1);
774776
if (verbose)
775777
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
@@ -784,7 +786,8 @@ static int fix_database_storage_name(const char *name)
784786

785787
if (strncmp(name, "#mysql50#", 9))
786788
DBUG_RETURN(1);
787-
sprintf(qbuf, "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY NAME", name);
789+
my_snprintf(qbuf, sizeof(qbuf), "ALTER DATABASE %`s UPGRADE DATA DIRECTORY "
790+
"NAME", name);
788791
rc= run_query(qbuf, 1);
789792
if (verbose)
790793
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
@@ -806,7 +809,7 @@ static int rebuild_table(char *name)
806809
ptr= strxmov(ptr, " FORCE", NullS);
807810
if (verbose >= 3)
808811
puts(query);
809-
if (mysql_real_query(sock, query, (uint)(ptr - query)))
812+
if (mysql_real_query(sock, query, (ulong)(ptr - query)))
810813
{
811814
fprintf(stderr, "Failed to %s\n", query);
812815
fprintf(stderr, "Error: %s\n", mysql_error(sock));
@@ -870,7 +873,7 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
870873
{
871874
char *query, *end, options[100], message[100];
872875
char table_name_buff[NAME_CHAR_LEN*2*2+1], *table_name;
873-
uint query_length= 0;
876+
size_t query_length= 0, query_size= sizeof(char)*(length+110);
874877
const char *op = 0;
875878
const char *tab_view;
876879
DBUG_ENTER("handle_request_for_tables");
@@ -923,10 +926,12 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
923926
DBUG_RETURN(fix_table_storage_name(tables));
924927
}
925928

926-
if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME))))
929+
if (!(query =(char *) my_malloc(query_size, MYF(MY_WME))))
927930
DBUG_RETURN(1);
928931
if (opt_all_in_1)
929932
{
933+
DBUG_ASSERT(strlen(op)+strlen(tables)+strlen(options)+8+1 <= query_size);
934+
930935
/* No backticks here as we added them before */
931936
query_length= sprintf(query, "%s%s%s %s", op,
932937
tab_view, tables, options);
@@ -942,7 +947,7 @@ static int handle_request_for_tables(char *tables, size_t length, my_bool view)
942947
(int) (ptr - org)));
943948
table_name= table_name_buff;
944949
ptr= strxmov(ptr, " ", options, NullS);
945-
query_length= (uint) (ptr - query);
950+
query_length= (size_t) (ptr - query);
946951
}
947952
if (verbose >= 3)
948953
puts(query);
@@ -1208,7 +1213,7 @@ int main(int argc, char **argv)
12081213
process_databases(argv);
12091214
if (opt_auto_repair)
12101215
{
1211-
uint i;
1216+
size_t i;
12121217

12131218
if (!opt_silent && (tables4repair.elements || tables4rebuild.elements))
12141219
puts("\nRepairing tables");

client/mysqldump.c

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292

9393
static void add_load_option(DYNAMIC_STRING *str, const char *option,
9494
const char *option_value);
95-
static ulong find_set(TYPELIB *lib, const char *x, uint length,
95+
static ulong find_set(TYPELIB *lib, const char *x, size_t length,
9696
char **err_pos, uint *err_len);
9797
static char *alloc_query_str(ulong size);
9898

@@ -890,7 +890,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
890890
opt_set_charset= 0;
891891
opt_compatible_mode_str= argument;
892892
opt_compatible_mode= find_set(&compatible_mode_typelib,
893-
argument, (uint) strlen(argument),
893+
argument, strlen(argument),
894894
&err_ptr, &err_len);
895895
if (err_len)
896896
{
@@ -900,7 +900,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
900900
}
901901
#if !defined(DBUG_OFF)
902902
{
903-
uint size_for_sql_mode= 0;
903+
size_t size_for_sql_mode= 0;
904904
const char **ptr;
905905
for (ptr= compatible_mode_names; *ptr; ptr++)
906906
size_for_sql_mode+= strlen(*ptr);
@@ -1171,8 +1171,8 @@ static int fetch_db_collation(const char *db_name,
11711171
break;
11721172
}
11731173

1174-
strncpy(db_cl_name, db_cl_row[0], db_cl_size);
1175-
db_cl_name[db_cl_size - 1]= 0; /* just in case. */
1174+
strncpy(db_cl_name, db_cl_row[0], db_cl_size-1);
1175+
db_cl_name[db_cl_size - 1]= 0;
11761176

11771177
} while (FALSE);
11781178

@@ -1305,7 +1305,7 @@ get_gtid_pos(char *out_gtid_pos, int master)
13051305

13061306

13071307
static char *my_case_str(const char *str,
1308-
uint str_len,
1308+
size_t str_len,
13091309
const char *token,
13101310
uint token_len)
13111311
{
@@ -1521,7 +1521,7 @@ static int switch_character_set_results(MYSQL *mysql, const char *cs_name)
15211521
*/
15221522

15231523
static char *cover_definer_clause(const char *stmt_str,
1524-
uint stmt_length,
1524+
size_t stmt_length,
15251525
const char *definer_version_str,
15261526
uint definer_version_length,
15271527
const char *stmt_version_str,
@@ -1721,14 +1721,14 @@ static void dbDisconnect(char *host)
17211721
} /* dbDisconnect */
17221722

17231723

1724-
static void unescape(FILE *file,char *pos,uint length)
1724+
static void unescape(FILE *file,char *pos, size_t length)
17251725
{
17261726
char *tmp;
17271727
DBUG_ENTER("unescape");
17281728
if (!(tmp=(char*) my_malloc(length*2+1, MYF(MY_WME))))
17291729
die(EX_MYSQLERR, "Couldn't allocate memory");
17301730

1731-
mysql_real_escape_string(&mysql_connection, tmp, pos, length);
1731+
mysql_real_escape_string(&mysql_connection, tmp, pos, (ulong)length);
17321732
fputc('\'', file);
17331733
fputs(tmp, file);
17341734
fputc('\'', file);
@@ -1842,7 +1842,7 @@ static char *quote_for_like(const char *name, char *buff)
18421842
Quote '<' '>' '&' '\"' chars and print a string to the xml_file.
18431843
*/
18441844

1845-
static void print_quoted_xml(FILE *xml_file, const char *str, ulong len,
1845+
static void print_quoted_xml(FILE *xml_file, const char *str, size_t len,
18461846
my_bool is_attribute_name)
18471847
{
18481848
const char *end;
@@ -2103,7 +2103,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
21032103
squeezed to a single hyphen.
21042104
*/
21052105

2106-
static void print_xml_comment(FILE *xml_file, ulong len,
2106+
static void print_xml_comment(FILE *xml_file, size_t len,
21072107
const char *comment_string)
21082108
{
21092109
const char* end;
@@ -2220,7 +2220,7 @@ static uint dump_events_for_db(char *db)
22202220
DBUG_ENTER("dump_events_for_db");
22212221
DBUG_PRINT("enter", ("db: '%s'", db));
22222222

2223-
mysql_real_escape_string(mysql, db_name_buff, db, strlen(db));
2223+
mysql_real_escape_string(mysql, db_name_buff, db, (ulong)strlen(db));
22242224

22252225
/* nice comments */
22262226
print_comment(sql_file, 0,
@@ -2340,7 +2340,6 @@ static uint dump_events_for_db(char *db)
23402340
(const char *) delimiter);
23412341

23422342
my_free(query_str);
2343-
23442343
restore_time_zone(sql_file, delimiter);
23452344
restore_sql_mode(sql_file, delimiter);
23462345

@@ -2433,7 +2432,7 @@ static uint dump_routines_for_db(char *db)
24332432
DBUG_ENTER("dump_routines_for_db");
24342433
DBUG_PRINT("enter", ("db: '%s'", db));
24352434

2436-
mysql_real_escape_string(mysql, db_name_buff, db, strlen(db));
2435+
mysql_real_escape_string(mysql, db_name_buff, db, (ulong)strlen(db));
24372436

24382437
/* nice comments */
24392438
print_comment(sql_file, 0,
@@ -2491,9 +2490,9 @@ static uint dump_routines_for_db(char *db)
24912490
if the user has EXECUTE privilege he see routine names, but NOT the
24922491
routine body of other routines that are not the creator of!
24932492
*/
2494-
DBUG_PRINT("info",("length of body for %s row[2] '%s' is %d",
2493+
DBUG_PRINT("info",("length of body for %s row[2] '%s' is %zu",
24952494
routine_name, row[2] ? row[2] : "(null)",
2496-
row[2] ? (int) strlen(row[2]) : 0));
2495+
row[2] ? strlen(row[2]) : 0));
24972496
if (row[2] == NULL)
24982497
{
24992498
print_comment(sql_file, 1, "\n-- insufficient privileges to %s\n",
@@ -4076,7 +4075,7 @@ static int dump_tablespaces_for_tables(char *db, char **table_names, int tables)
40764075
int i;
40774076
char name_buff[NAME_LEN*2+3];
40784077

4079-
mysql_real_escape_string(mysql, name_buff, db, strlen(db));
4078+
mysql_real_escape_string(mysql, name_buff, db, (ulong)strlen(db));
40804079

40814080
init_dynamic_string_checked(&dynamic_where, " AND TABLESPACE_NAME IN ("
40824081
"SELECT DISTINCT TABLESPACE_NAME FROM"
@@ -4089,7 +4088,7 @@ static int dump_tablespaces_for_tables(char *db, char **table_names, int tables)
40894088
for (i=0 ; i<tables ; i++)
40904089
{
40914090
mysql_real_escape_string(mysql, name_buff,
4092-
table_names[i], strlen(table_names[i]));
4091+
table_names[i], (ulong)strlen(table_names[i]));
40934092

40944093
dynstr_append_checked(&dynamic_where, "'");
40954094
dynstr_append_checked(&dynamic_where, name_buff);
@@ -4119,7 +4118,7 @@ static int dump_tablespaces_for_databases(char** databases)
41194118
{
41204119
char db_name_buff[NAME_LEN*2+3];
41214120
mysql_real_escape_string(mysql, db_name_buff,
4122-
databases[i], strlen(databases[i]));
4121+
databases[i], (ulong)strlen(databases[i]));
41234122
dynstr_append_checked(&dynamic_where, "'");
41244123
dynstr_append_checked(&dynamic_where, db_name_buff);
41254124
dynstr_append_checked(&dynamic_where, "',");
@@ -5320,7 +5319,7 @@ static int start_transaction(MYSQL *mysql_con)
53205319
}
53215320

53225321

5323-
static ulong find_set(TYPELIB *lib, const char *x, uint length,
5322+
static ulong find_set(TYPELIB *lib, const char *x, size_t length,
53245323
char **err_pos, uint *err_len)
53255324
{
53265325
const char *end= x + length;
@@ -5378,7 +5377,7 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
53785377
fputc(' ',file);
53795378
fputs(prefix, file);
53805379
if (string_value)
5381-
unescape(file,row[0],(uint) strlen(row[0]));
5380+
unescape(file,row[0], strlen(row[0]));
53825381
else
53835382
fputs(row[0], file);
53845383
check_io(file);
@@ -5632,8 +5631,8 @@ static my_bool get_view_structure(char *table, char* db)
56325631
verbose_msg("-- Retrieving view structure for table %s...\n", table);
56335632

56345633
#ifdef NOT_REALLY_USED_YET
5635-
sprintf(insert_pat, "SET SQL_QUOTE_SHOW_CREATE=%d",
5636-
(opt_quoted || opt_keywords));
5634+
dynstr_append_checked(&insert_pat, "SET SQL_QUOTE_SHOW_CREATE=");
5635+
dynstr_append_checked(&insert_pat, (opt_quoted || opt_keywords)? "1":"0");
56375636
#endif
56385637

56395638
result_table= quote_name(table, table_buff, 1);

0 commit comments

Comments
 (0)