Skip to content

Commit bf66a08

Browse files
author
Akhila Maddukuri
committed
Merge from WL#6735
2 parents f5a8fba + 619e8b1 commit bf66a08

File tree

736 files changed

+57912
-24088
lines changed

Some content is hidden

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

736 files changed

+57912
-24088
lines changed

README

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ For the avoidance of doubt, this particular copy of the software
55
is released under the version 2 of the GNU General Public License.
66
MySQL is brought to you by Oracle.
77

8-
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
8+
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
99

1010
License information can be found in the COPYING file.
1111

client/client_priv.h

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ enum options_client
9898
OPT_MYSQLBINLOG_EXCLUDE_GTIDS,
9999
OPT_REMOTE_PROTO,
100100
OPT_CONFIG_ALL,
101+
OPT_REWRITE_DB,
101102
OPT_SERVER_PUBLIC_KEY,
102103
OPT_ENABLE_CLEARTEXT_PLUGIN,
103104
OPT_MAX_CLIENT_OPTION

client/mysql.cc

+5-2
Original file line numberDiff line numberDiff line change
@@ -2624,14 +2624,17 @@ static bool add_line(String &buffer, char *line, ulong line_length,
26242624
{
26252625
uint length=(uint) (out-line);
26262626

2627-
if (!truncated && !is_delimiter_command(line, length))
2627+
if (!truncated && (!is_delimiter_command(line, length) ||
2628+
(*in_string || *ml_comment)))
26282629
{
26292630
/*
26302631
Don't add a new line in case there's a DELIMITER command to be
26312632
added to the glob buffer (e.g. on processing a line like
26322633
"<command>;DELIMITER <non-eof>") : similar to how a new line is
26332634
not added in the case when the DELIMITER is the first command
2634-
entered with an empty glob buffer.
2635+
entered with an empty glob buffer. However, if the delimiter is
2636+
part of a string or a comment, the new line should be added. (e.g.
2637+
SELECT '\ndelimiter\n';\n)
26352638
*/
26362639
*out++='\n';
26372640
length++;

client/mysql_config_editor.cc

+57-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2012, 2013, 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
@@ -50,14 +50,14 @@ static int g_fd;
5050
*/
5151
static size_t file_size;
5252
static char *opt_user= NULL, *opt_password= NULL, *opt_host=NULL,
53-
*opt_login_path= NULL;
53+
*opt_login_path= NULL, *opt_socket= NULL, *opt_port= NULL;
5454

5555
static char my_login_file[FN_REFLEN];
5656
static char my_key[LOGIN_KEY_LEN];
5757

5858
static my_bool opt_verbose, opt_all, tty_password= 0, opt_warn,
5959
opt_remove_host, opt_remove_pass, opt_remove_user,
60-
login_path_specified= FALSE;
60+
opt_remove_socket, opt_remove_port, login_path_specified= FALSE;
6161

6262
static int execute_commands(int command);
6363
static int set_command(void);
@@ -141,6 +141,10 @@ static struct my_option my_set_command_options[]=
141141
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
142142
{"user", 'u', "User name to be entered into the login file.", &opt_user,
143143
&opt_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
144+
{"socket", 'S', "Socket path to be entered into login file.", &opt_socket,
145+
&opt_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
146+
{"port", 'P', "Port number to be entered into login file.", &opt_port,
147+
&opt_port, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
144148
{"warn", 'w', "Warn and ask for confirmation if set command attempts to "
145149
"overwrite an existing login path (enabled by default).",
146150
&opt_warn, &opt_warn, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
@@ -157,8 +161,9 @@ static struct my_option my_remove_command_options[]=
157161
0, 0, 0},
158162
{"login-path", 'G', "Name of the login path from which options to "
159163
"be removed (entire path would be removed if none of user, password, "
160-
"or host options are specified). (Default : client)", &opt_login_path,
161-
&opt_login_path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
164+
"host, socket, or port options are specified). (Default : client)",
165+
&opt_login_path, &opt_login_path, 0, GET_STR, REQUIRED_ARG,
166+
0, 0, 0, 0, 0, 0},
162167
{"password", 'p', "Remove password from the login path.",
163168
&opt_remove_pass, &opt_remove_pass, 0, GET_BOOL, NO_ARG, 0, 0, 0,
164169
0, 0, 0},
@@ -168,6 +173,10 @@ static struct my_option my_remove_command_options[]=
168173
"to remove the default login path (client) if no login path is specified "
169174
"(enabled by default).", &opt_warn, &opt_warn, 0, GET_BOOL, NO_ARG, 1,
170175
0, 0, 0, 0, 0},
176+
{"socket", 'S', "Remove socket path from the login path.", &opt_remove_socket,
177+
&opt_remove_socket, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
178+
{"port", 'P', "Remove port number from the login path.", &opt_remove_port,
179+
&opt_remove_port, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
171180
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
172181
};
173182

@@ -229,6 +238,13 @@ my_set_command_get_one_option(int optid,
229238
tty_password= 1;
230239
break;
231240
case 'G':
241+
if (login_path_specified)
242+
{
243+
/* Error, we do not support multiple login paths. */
244+
my_perror("Error: Use of multiple login paths is not supported. "
245+
"Exiting..");
246+
return 1;
247+
}
232248
login_path_specified= TRUE;
233249
break;
234250
case '?':
@@ -246,6 +262,13 @@ my_remove_command_get_one_option(int optid,
246262
{
247263
switch(optid) {
248264
case 'G':
265+
if (login_path_specified)
266+
{
267+
/* Error, we do not support multiple login paths. */
268+
my_perror("Error: Use of multiple login paths is not supported. "
269+
"Exiting..");
270+
return 1;
271+
}
249272
login_path_specified= TRUE;
250273
break;
251274
case '?':
@@ -263,6 +286,13 @@ my_print_command_get_one_option(int optid,
263286
{
264287
switch(optid) {
265288
case 'G':
289+
if (login_path_specified)
290+
{
291+
/* Error, we do not support multiple login paths. */
292+
my_perror("Error: Use of multiple login paths is not supported. "
293+
"Exiting..");
294+
return 1;
295+
}
266296
login_path_specified= TRUE;
267297
break;
268298
case '?':
@@ -537,6 +567,18 @@ static int set_command(void)
537567
dynstr_append(&path_buf, opt_host);
538568
}
539569

570+
if (opt_socket)
571+
{
572+
dynstr_append(&path_buf, "\nsocket = ");
573+
dynstr_append(&path_buf, opt_socket);
574+
}
575+
576+
if (opt_port)
577+
{
578+
dynstr_append(&path_buf, "\nport = ");
579+
dynstr_append(&path_buf, opt_port);
580+
}
581+
540582
dynstr_append(&path_buf, "\n");
541583

542584
/* Warn if login path already exists */
@@ -901,7 +943,8 @@ static void mask_password_and_print(char *buf)
901943
static void remove_options(DYNAMIC_STRING *file_buf, const char *path_name)
902944
{
903945
/* If nope of the options are specified remove the entire path. */
904-
if (!opt_remove_host && !opt_remove_pass && !opt_remove_user)
946+
if (!opt_remove_host && !opt_remove_pass && !opt_remove_user
947+
&& !opt_remove_socket && !opt_remove_port)
905948
{
906949
remove_login_path(file_buf, path_name);
907950
return;
@@ -915,6 +958,12 @@ static void remove_options(DYNAMIC_STRING *file_buf, const char *path_name)
915958

916959
if (opt_remove_host)
917960
remove_option(file_buf, path_name, "host");
961+
962+
if (opt_remove_socket)
963+
remove_option(file_buf, path_name, "socket");
964+
965+
if (opt_remove_port)
966+
remove_option(file_buf, path_name, "port");
918967
}
919968

920969

@@ -1423,8 +1472,8 @@ static void usage_program(void)
14231472
my_print_help(my_program_long_options);
14241473
my_print_variables(my_program_long_options);
14251474
puts("\nWhere command can be any one of the following :\n\
1426-
set [command options] Sets user name/password/host name for a\n\
1427-
given login path (section).\n\
1475+
set [command options] Sets user name/password/host name/socket/port\n\
1476+
for a given login path (section).\n\
14281477
remove [command options] Remove a login path from the login file.\n\
14291478
print [command options] Print all the options for a specified\n\
14301479
login path.\n\

client/mysqlbinlog.cc

+79-9
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, 2013, 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
@@ -65,6 +65,11 @@ using std::max;
6565
#define INTVAR_DYNAMIC_INIT 16
6666
#define INTVAR_DYNAMIC_INCR 1
6767

68+
/*
69+
The character set used should be equal to the one used in mysqld.cc for
70+
server rewrite-db
71+
*/
72+
#define mysqld_charset &my_charset_latin1
6873

6974
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
7075

@@ -119,6 +124,7 @@ static enum enum_remote_proto {
119124
static char *opt_remote_proto_str= 0;
120125
static char *database= 0;
121126
static char *output_file= 0;
127+
static char *rewrite= 0;
122128
static my_bool force_opt= 0, short_form= 0, idempotent_mode= 0;
123129
static my_bool debug_info_flag, debug_check_flag;
124130
static my_bool force_if_open_opt= 1, raw_mode= 0;
@@ -159,6 +165,18 @@ Checkable_rwlock *global_sid_lock= NULL;
159165
Gtid_set *gtid_set_included= NULL;
160166
Gtid_set *gtid_set_excluded= NULL;
161167

168+
/**
169+
Function to add a new member in the binlog_rewrite_db list
170+
in the form of from_db, to_db pair
171+
172+
@param from_db database to be rewritten.
173+
@param to_db new database name to replace from_db.
174+
*/
175+
void add_binlog_db_rewrite(const char* from_db, const char* to_db)
176+
{
177+
i_string_pair *db_pair = new i_string_pair(from_db, to_db);
178+
binlog_rewrite_db.push_back(db_pair);
179+
}
162180

163181
/**
164182
Pointer to the Format_description_log_event of the currently active binlog.
@@ -1134,10 +1152,12 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
11341152
event was not skipped).
11351153
*/
11361154
if (skip_event)
1137-
/* Flush head,body and footer cache to result_file */
1138-
if ((copy_event_cache_to_file_and_reinit(&print_event_info->head_cache, result_file) ||
1139-
copy_event_cache_to_file_and_reinit(&print_event_info->body_cache, result_file) ||
1140-
copy_event_cache_to_file_and_reinit(&print_event_info->footer_cache, result_file)))
1155+
if ((copy_event_cache_to_file_and_reinit(&print_event_info->head_cache,
1156+
result_file, stop_never /* flush result_file */) ||
1157+
copy_event_cache_to_file_and_reinit(&print_event_info->body_cache,
1158+
result_file, stop_never /* flush result_file */) ||
1159+
copy_event_cache_to_file_and_reinit(&print_event_info->footer_cache,
1160+
result_file, stop_never /* flush result_file */)))
11411161
goto err;
11421162
}
11431163

@@ -1179,9 +1199,12 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
11791199
if (stmt_end)
11801200
{
11811201
print_event_info->have_unflushed_events= FALSE;
1182-
if (copy_event_cache_to_file_and_reinit(&print_event_info->head_cache, result_file) ||
1183-
copy_event_cache_to_file_and_reinit(&print_event_info->body_cache, result_file) ||
1184-
copy_event_cache_to_file_and_reinit(&print_event_info->footer_cache, result_file))
1202+
if (copy_event_cache_to_file_and_reinit(&print_event_info->head_cache,
1203+
result_file, stop_never /* flush result file */) ||
1204+
copy_event_cache_to_file_and_reinit(&print_event_info->body_cache,
1205+
result_file, stop_never /* flush result file */) ||
1206+
copy_event_cache_to_file_and_reinit(&print_event_info->footer_cache,
1207+
result_file, stop_never /* flush result file */))
11851208
goto err;
11861209
goto end;
11871210
}
@@ -1221,7 +1244,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
12211244
}
12221245
/* Flush head cache to result_file for every event */
12231246
if (copy_event_cache_to_file_and_reinit(&print_event_info->head_cache,
1224-
result_file))
1247+
result_file, stop_never /* flush result_file */))
12251248
goto err;
12261249
}
12271250

@@ -1276,6 +1299,9 @@ static struct my_option my_long_options[] =
12761299
{"database", 'd', "List entries for just this database (local log only).",
12771300
&database, &database, 0, GET_STR_ALLOC, REQUIRED_ARG,
12781301
0, 0, 0, 0, 0, 0},
1302+
{"rewrite-db", OPT_REWRITE_DB, "Rewrite the row event to point so that "
1303+
"it can be applied to a new database", &rewrite, &rewrite, 0,
1304+
GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
12791305
#ifndef DBUG_OFF
12801306
{"debug", '#', "Output debug log.", &default_dbug_option,
12811307
&default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
@@ -1611,6 +1637,35 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
16111637
case 'd':
16121638
one_database = 1;
16131639
break;
1640+
case OPT_REWRITE_DB:
1641+
{
1642+
char *from_db= argument, *p, *to_db;
1643+
if (!(p= strstr(argument, "->")))
1644+
{
1645+
sql_print_error("Bad syntax in mysqlbinlog-rewrite-db - missing '->'!\n");
1646+
return 1;
1647+
}
1648+
to_db= p + 2;
1649+
while(p > argument && my_isspace(mysqld_charset, p[-1]))
1650+
p--;
1651+
*p= 0;
1652+
if (!*from_db)
1653+
{
1654+
sql_print_error("Bad syntax in mysqlbinlog-rewrite-db - empty FROM db!\n");
1655+
return 1;
1656+
}
1657+
while (*to_db && my_isspace(mysqld_charset, *to_db))
1658+
to_db++;
1659+
if (!*to_db)
1660+
{
1661+
sql_print_error("Bad syntax in mysqlbinlog-rewrite-db - empty TO db!\n");
1662+
return 1;
1663+
}
1664+
option_rewrite_set= TRUE;
1665+
add_binlog_db_rewrite(from_db, to_db); //add the new from_db, to_db pair in
1666+
// I_List ie. binlog_rewrite_db.
1667+
break;
1668+
}
16141669
case 'p':
16151670
if (argument == disabled_my_option)
16161671
argument= (char*) ""; // Don't require password
@@ -2055,6 +2110,21 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
20552110
*/
20562111

20572112
type= (Log_event_type) net->read_pos[1 + EVENT_TYPE_OFFSET];
2113+
2114+
/*
2115+
Ignore HEARBEAT events. They can show up if mysqlbinlog is
2116+
running with:
2117+
2118+
--read-from-remote-server
2119+
--read-from-remote-master=BINLOG-DUMP-GTIDS'
2120+
--stop-never
2121+
--stop-never-slave-server-id
2122+
2123+
i.e., acting as a fake slave.
2124+
*/
2125+
if (type == HEARTBEAT_LOG_EVENT)
2126+
continue;
2127+
20582128
if (!raw_mode || (type == ROTATE_EVENT) || (type == FORMAT_DESCRIPTION_EVENT))
20592129
{
20602130
if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,

0 commit comments

Comments
 (0)