summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysql.cc2
-rw-r--r--client/mysqlbinlog.cc22
-rw-r--r--mysql-test/r/rpl_until.result6
-rw-r--r--mysql-test/t/rpl_until.test6
-rw-r--r--sql/mysqld.cc77
-rw-r--r--vio/viosocket.c4
6 files changed, 76 insertions, 41 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 9062b58d09b..42088d107ed 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -709,7 +709,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
}
break;
}
- break;
+ break;
case 'A':
rehash= 0;
break;
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index f870c92cb6d..35f0db76ad6 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -34,6 +34,7 @@ ulong server_id = 0;
ulong bytes_sent = 0L, bytes_received = 0L;
ulong mysqld_net_retry_count = 10L;
uint test_flags = 0;
+static uint opt_protocol= 0;
static FILE *result_file;
@@ -233,6 +234,10 @@ static struct my_option my_long_options[] =
{"position", 'j', "Start reading the binlog at position N.",
(gptr*) &position, (gptr*) &position, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0,
0, 0},
+ {"protocol", OPT_MYSQL_PROTOCOL,
+ "The protocol of connection (tcp,socket,pipe,memory).",
+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+
{"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"read-from-remote-server", 'R', "Read binary logs from a MySQL server",
@@ -285,7 +290,7 @@ static void die(const char* fmt, ...)
static void print_version()
{
- printf("%s Ver 2.4 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
+ printf("%s Ver 2.5 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
}
@@ -369,6 +374,17 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'R':
remote_opt= 1;
break;
+ case OPT_MYSQL_PROTOCOL:
+ {
+ if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) ==
+ ~(ulong) 0)
+ {
+ fprintf(stderr, "Unknown option to protocol: %s\n", argument);
+ exit(1);
+ }
+ break;
+ }
+ break;
case 'V':
print_version();
exit(0);
@@ -398,9 +414,11 @@ static int parse_args(int *argc, char*** argv)
static MYSQL* safe_connect()
{
MYSQL *local_mysql = mysql_init(NULL);
- if(!local_mysql)
+ if (!local_mysql)
die("Failed on mysql_init");
+ if (opt_protocol)
+ mysql_options(local_mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);
if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0))
die("failed on connect: %s", mysql_error(local_mysql));
diff --git a/mysql-test/r/rpl_until.result b/mysql-test/r/rpl_until.result
index 4e03b47fe57..c179351551d 100644
--- a/mysql-test/r/rpl_until.result
+++ b/mysql-test/r/rpl_until.result
@@ -41,7 +41,7 @@ n
4
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 244 649 Master master-no-such-bin.000001 291 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 244 # Master master-no-such-bin.000001 291 No #
start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537;
select * from t2;
n
@@ -49,13 +49,13 @@ n
2
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 449 649 Relay slave-relay-bin.000002 537 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 449 # Relay slave-relay-bin.000002 537 No #
start slave;
stop slave;
start slave until master_log_file='master-bin.000001', master_log_pos=561;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
-# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 561 693 Master master-bin.000001 561 No #
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 561 # Master master-bin.000001 561 No #
start slave until master_log_file='master-bin', master_log_pos=561;
ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_until.test
index 18c1162ed8d..9bc4ea4e7b1 100644
--- a/mysql-test/t/rpl_until.test
+++ b/mysql-test/t/rpl_until.test
@@ -38,7 +38,7 @@ start slave until master_log_file='master-no-such-bin.000001', master_log_pos=29
select * from t1;
sleep 2;
--replace_result $MASTER_MYPORT MASTER_MYPORT
---replace_column 1 # 9 # 33 #
+--replace_column 1 # 9 # 23 # 33 #
show slave status;
# try replicate all until second insert to t2;
@@ -46,7 +46,7 @@ start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537;
sleep 2;
select * from t2;
--replace_result $MASTER_MYPORT MASTER_MYPORT
---replace_column 1 # 9 # 33 #
+--replace_column 1 # 9 # 23 # 33 #
show slave status;
# clean up
@@ -62,7 +62,7 @@ start slave until master_log_file='master-bin.000001', master_log_pos=561;
sleep 2;
# here the sql slave thread should be stopped
--replace_result $MASTER_MYPORT MASTER_MYPORT
---replace_column 1 # 9 # 33 #
+--replace_column 1 # 9 # 23 # 33 #
show slave status;
#testing various error conditions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 9b31e35f90c..99ab926c479 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -5785,63 +5785,80 @@ static void fix_paths(void)
*/
#ifdef SET_RLIMIT_NOFILE
+
+#ifndef RLIM_INFINITY
+#define RLIM_INFINITY ((uint) 0xffffffff)
+#endif
+
static uint set_maximum_open_files(uint max_file_limit)
{
struct rlimit rlimit;
- ulong old_cur;
+ uint old_cur;
+ DBUG_ENTER("set_maximum_open_files");
+ DBUG_PRINT("enter",("files: %u", max_file_limit));
if (!getrlimit(RLIMIT_NOFILE,&rlimit))
{
- old_cur=rlimit.rlim_cur;
- if (rlimit.rlim_cur >= max_file_limit) // Nothing to do
- return rlimit.rlim_cur; /* purecov: inspected */
- rlimit.rlim_cur=rlimit.rlim_max=max_file_limit;
+ old_cur= (uint) rlimit.rlim_cur;
+ DBUG_PRINT("info", ("rlim_cur: %u rlim_max: %u",
+ (uint) rlimit.rlim_cur,
+ (uint) rlimit.rlim_max));
+ if (rlimit.rlim_cur >= max_file_limit ||
+ rlimit.rlim_cur == RLIM_INFINITY)
+ DBUG_RETURN(rlimit.rlim_cur); /* purecov: inspected */
+ rlimit.rlim_cur= rlimit.rlim_max= max_file_limit;
if (setrlimit(RLIMIT_NOFILE,&rlimit))
{
if (global_system_variables.log_warnings)
- sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %lu (request: %u)",
+ sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %u (request: %u)",
old_cur, max_file_limit); /* purecov: inspected */
- max_file_limit=old_cur;
+ max_file_limit= old_cur;
}
else
{
+ rlimit.rlim_cur= 0; // Safety if next call fails
(void) getrlimit(RLIMIT_NOFILE,&rlimit);
- if ((uint) rlimit.rlim_cur != max_file_limit &&
+ DBUG_PRINT("info", ("rlim_cur: %u", (uint) rlimit.rlim_cur));
+ if ((uint) rlimit.rlim_cur < max_file_limit &&
global_system_variables.log_warnings)
- sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %ld (request: %u)",
- (ulong) rlimit.rlim_cur,
+ sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %u (request: %u)",
+ (uint) rlimit.rlim_cur,
max_file_limit); /* purecov: inspected */
- max_file_limit=rlimit.rlim_cur;
+ max_file_limit= (uint) rlimit.rlim_cur;
}
}
- return max_file_limit;
+ DBUG_PRINT("exit",("max_file_limit: %u", max_file_limit));
+ DBUG_RETURN(max_file_limit);
}
#endif
+
#ifdef OS2
static uint set_maximum_open_files(uint max_file_limit)
{
- LONG cbReqCount;
- ULONG cbCurMaxFH, cbCurMaxFH0;
- APIRET ulrc;
-
- // get current limit
- cbReqCount = 0;
- DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH0);
-
- // set new limit
- cbReqCount = max_file_limit - cbCurMaxFH0;
- ulrc = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH);
- if (ulrc) {
- sql_print_error("Warning: DosSetRelMaxFH couldn't increase number of open files to more than %d",
- cbCurMaxFH0);
- cbCurMaxFH = cbCurMaxFH0;
- }
-
- return cbCurMaxFH;
+ LONG cbReqCount;
+ ULONG cbCurMaxFH, cbCurMaxFH0;
+ APIRET ulrc;
+ DBUG_ENTER("set_maximum_open_files");
+
+ // get current limit
+ cbReqCount = 0;
+ DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH0);
+
+ // set new limit
+ cbReqCount = max_file_limit - cbCurMaxFH0;
+ ulrc = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH);
+ if (ulrc) {
+ sql_print_error("Warning: DosSetRelMaxFH couldn't increase number of open files to more than %d",
+ cbCurMaxFH0);
+ cbCurMaxFH = cbCurMaxFH0;
+ }
+
+ DBUG_RETURN(cbCurMaxFH);
}
#endif
+
/*
Return a bitfield from a string of substrings separated by ','
returns ~(ulong) 0 on error.
diff --git a/vio/viosocket.c b/vio/viosocket.c
index 31941a64102..9d5c7c0d890 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -249,8 +249,8 @@ my_bool vio_peer_addr(Vio * vio, char *buf, uint16 *port)
}
else
{
- size_socket addrLen = sizeof(struct sockaddr);
- if (getpeername(vio->sd, (struct sockaddr *) (& (vio->remote)),
+ size_socket addrLen = sizeof(vio->remote);
+ if (getpeername(vio->sd, (struct sockaddr *) (&vio->remote),
&addrLen) != 0)
{
DBUG_PRINT("exit", ("getpeername gave error: %d", socket_errno));