Below is the list of changes that have just been committed into a local
5.0 repository of tnurnberg. When tnurnberg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-08-21 20:17:34+02:00, tnurnberg@stripped +30 -0
Bug #15327: configure: --with-tcp-port option being partially ignored
make sure that if builder configured with a non-standard (!= 3306)
default TCP port that value actually gets used throughout. if they
didn't configure a value, assume "use a sensible default", which
will be read from /etc/services or, failing that, from the factory
default. That makes the order of preference
- command-line option
- my.cnf, where applicable
- $MYSQL_TCP_PORT environment variable
- /etc/services (unless configured --with-tcp-port)
- default port (--with-tcp-port=... or factory default)
client/mysql.cc@stripped, 2007-08-21 20:17:26+02:00, tnurnberg@stripped +6 -3
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysql_upgrade.c@stripped, 2007-08-21 20:17:26+02:00, tnurnberg@stripped +5 -2
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqladmin.cc@stripped, 2007-08-21 20:17:26+02:00, tnurnberg@stripped +5 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlbinlog.cc@stripped, 2007-08-21 20:17:26+02:00, tnurnberg@stripped +6 -3
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlcheck.c@stripped, 2007-08-21 20:17:26+02:00, tnurnberg@stripped +5 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqldump.c@stripped, 2007-08-21 20:17:26+02:00, tnurnberg@stripped +5 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlimport.c@stripped, 2007-08-21 20:17:26+02:00, tnurnberg@stripped +5 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlmanagerc.c@stripped, 2007-08-21 20:17:26+02:00, tnurnberg@stripped +5 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqlshow.c@stripped, 2007-08-21 20:17:26+02:00, tnurnberg@stripped +5 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
client/mysqltest.c@stripped, 2007-08-21 20:17:26+02:00, tnurnberg@stripped +5 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
configure.in@stripped, 2007-08-21 20:17:25+02:00, tnurnberg@stripped +28 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
If MYSQL_TCP_PORT defaulted in configure (factory default 3306
at the time of this writing), set MYSQL_TCP_PORT to factory
default, then clear factory default after. That way, we lose no
information, and we can distinguish between "defaulted" and the
pathological case "builder specifically configured a port that
coincides with factory default." This can in theory happen if
builder configures and builds several servers from a script
(--with-tcp-port=3306, --with-tcp-port=3316, --with-tcp-port=3326).
Not all that probable, but much preferable to having more "magic"
happen in the server when we can solve this without any guesswork.
include/mysql_version.h.in@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +1 -0
Bug #15327: configure: --with-tcp-port option being partially ignored
make factory default for TCP port available as MYSQL_PORT_DEFAULT
if build-time configured with a different default. (0 if unchanged)
libmysql/libmysql.c@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +17 -4
Bug #15327: configure: --with-tcp-port option being partially ignored
initialize default tcp port for client, like so:
- if user configured --with-tcp-port, use that value as default
- otherwise assume "use a good default": search mysqld/tcp in
/etc/services; if that doesn't exist, use factory default (3306)
- environment variable MYSQL_TCP_PORT overrides this default
- command-line option overrides all of the above
mysql-test/Makefile.am@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +1 -0
Bug #15327: configure: --with-tcp-port option being partially ignored
make factory default for TCP port available as MYSQL_TCP_PORT_DEFAULT
if build-time configured with a different default. (0 if unchanged)
mysql-test/mysql-test-run-shell.sh@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +10 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
set up MYSQL_TCP_PORT if not already set in environment:
- if user configured --with-tcp-port, use that value as default
- otherwise assume "use a good default": search mysqld/tcp in
/etc/services; if that doesn't exist, use factory default (3306)
netware/mysql_test_run.c@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +2 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
netware/mysqld_safe.c@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +1 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
scripts/Makefile.am@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +1 -0
Bug #15327: configure: --with-tcp-port option being partially ignored
make factory default for TCP port available as MYSQL_TCP_PORT_DEFAULT
if build-time configured with a different default. (0 if unchanged)
scripts/mysql_config.sh@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +11 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
set up MYSQL_TCP_PORT if not already set in environment:
- if user configured --with-tcp-port, use that value as default
- otherwise assume "use a good default": search mysqld/tcp in
/etc/services; if that doesn't exist, use factory default (3306)
scripts/mysql_convert_table_format.sh@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +20 -0
Bug #15327: configure: --with-tcp-port option being partially ignored
if --port not given on command line and $MYSQL_TCP_PORT unset,
use --with-tcp-port value if exists. failing that, query
/etc/services; fall back on factory default (3306).
scripts/mysql_fix_privilege_tables.sh@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +1 -0
Bug #15327: configure: --with-tcp-port option being partially ignored
clarifying notice only
scripts/mysql_setpermission.sh@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +19 -0
Bug #15327: configure: --with-tcp-port option being partially ignored
if --port not given on command line and $MYSQL_TCP_PORT unset,
use --with-tcp-port value if exists. failing that, query
/etc/services; fall back on factory default (3306).
scripts/mysql_tableinfo.sh@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +19 -0
Bug #15327: configure: --with-tcp-port option being partially ignored
if --port not given on command line and $MYSQL_TCP_PORT unset,
use --with-tcp-port value if exists. failing that, query
/etc/services; fall back on factory default (3306).
scripts/mysqld_safe-watch.sh@stripped, 2007-08-21 20:17:27+02:00, tnurnberg@stripped +1 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
scripts/mysqlhotcopy.sh@stripped, 2007-08-21 20:17:28+02:00, tnurnberg@stripped +20 -0
Bug #15327: configure: --with-tcp-port option being partially ignored
if --port not given on command line and $MYSQL_TCP_PORT unset,
use --with-tcp-port value if exists. failing that, query
/etc/services; fall back on factory default (3306).
server-tools/instance-manager/priv.h@stripped, 2007-08-21 20:17:28+02:00, tnurnberg@stripped +1 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
sql/mysqld.cc@stripped, 2007-08-21 20:17:28+02:00, tnurnberg@stripped +13 -0
Bug #15327: configure: --with-tcp-port option being partially ignored
if builder specifically requested a default port, use that
(even if it coincides with our factory default).
only if they didn't do we check /etc/services (and, failing
on that, fall back to the factory default of 3306).
either default can be overridden by the environment variable
MYSQL_TCP_PORT, which in turn can be overridden with command
line options.
tests/mysql_client_test.c@stripped, 2007-08-21 20:17:28+02:00, tnurnberg@stripped +5 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
tests/ssl_test.c@stripped, 2007-08-21 20:17:28+02:00, tnurnberg@stripped +1 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
account for non-standard default port-no. configured at build-time
tests/thread_test.c@stripped, 2007-08-21 20:17:28+02:00, tnurnberg@stripped +5 -1
Bug #15327: configure: --with-tcp-port option being partially ignored
make help on --port a little more clear
diff -Nrup a/client/mysql.cc b/client/mysql.cc
--- a/client/mysql.cc 2007-04-23 16:21:59 +02:00
+++ b/client/mysql.cc 2007-08-21 20:17:26 +02:00
@@ -673,9 +673,12 @@ static struct my_option my_long_options[
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
- {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
- (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
- 0},
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", (gptr*) &opt_mysql_port,
+ (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"prompt", OPT_PROMPT, "Set the mysql prompt to this value.",
(gptr*) ¤t_prompt, (gptr*) ¤t_prompt, 0, GET_STR_ALLOC,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
diff -Nrup a/client/mysql_upgrade.c b/client/mysql_upgrade.c
--- a/client/mysql_upgrade.c 2007-04-23 13:27:54 +02:00
+++ b/client/mysql_upgrade.c 2007-08-21 20:17:26 +02:00
@@ -88,8 +88,11 @@ static struct my_option my_long_options[
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
- {"port", 'P', "Port number to use for connection.", 0,
- 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", 0, 0, 0, GET_STR, 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},
diff -Nrup a/client/mysqladmin.cc b/client/mysqladmin.cc
--- a/client/mysqladmin.cc 2006-12-30 21:02:04 +01:00
+++ b/client/mysqladmin.cc 2007-08-21 20:17:26 +02:00
@@ -159,7 +159,11 @@ static struct my_option my_long_options[
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
- {"port", 'P', "Port number to use for connection.", (gptr*) &tcp_port,
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", (gptr*) &tcp_port,
(gptr*) &tcp_port, 0, GET_UINT, 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},
diff -Nrup a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
--- a/client/mysqlbinlog.cc 2007-04-10 15:26:33 +02:00
+++ b/client/mysqlbinlog.cc 2007-08-21 20:17:26 +02:00
@@ -687,9 +687,12 @@ static struct my_option my_long_options[
0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', "Password to connect to remote server.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"port", 'P', "Use port to connect to the remote server.",
- (gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0,
- 0, 0, 0},
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", (gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0},
{"position", 'j', "Deprecated. Use --start-position instead.",
(gptr*) &start_position, (gptr*) &start_position, 0, GET_ULL,
REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE,
diff -Nrup a/client/mysqlcheck.c b/client/mysqlcheck.c
--- a/client/mysqlcheck.c 2006-12-23 20:04:04 +01:00
+++ b/client/mysqlcheck.c 2007-08-21 20:17:26 +02:00
@@ -123,7 +123,11 @@ static struct my_option my_long_options[
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
- {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", (gptr*) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
diff -Nrup a/client/mysqldump.c b/client/mysqldump.c
--- a/client/mysqldump.c 2007-06-28 11:23:58 +02:00
+++ b/client/mysqldump.c 2007-08-21 20:17:26 +02:00
@@ -361,7 +361,11 @@ static struct my_option my_long_options[
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
- {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", (gptr*) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
diff -Nrup a/client/mysqlimport.c b/client/mysqlimport.c
--- a/client/mysqlimport.c 2006-12-30 21:02:04 +01:00
+++ b/client/mysqlimport.c 2007-08-21 20:17:26 +02:00
@@ -119,7 +119,11 @@ static struct my_option my_long_options[
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
- {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", (gptr*) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
diff -Nrup a/client/mysqlmanagerc.c b/client/mysqlmanagerc.c
--- a/client/mysqlmanagerc.c 2006-12-23 20:04:04 +01:00
+++ b/client/mysqlmanagerc.c 2007-08-21 20:17:26 +02:00
@@ -49,7 +49,11 @@ static struct my_option my_long_options[
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p', "Password to use when connecting to server.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"port", 'P', "Port number to use for connection.", (gptr*) &port,
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", (gptr*) &port,
(gptr*) &port, 0, GET_UINT, REQUIRED_ARG, MYSQL_MANAGER_PORT, 0, 0, 0, 0,
0},
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG,
diff -Nrup a/client/mysqlshow.c b/client/mysqlshow.c
--- a/client/mysqlshow.c 2006-12-30 21:02:04 +01:00
+++ b/client/mysqlshow.c 2007-08-21 20:17:26 +02:00
@@ -188,7 +188,11 @@ static struct my_option my_long_options[
{"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", (gptr*) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0},
#ifdef __WIN__
diff -Nrup a/client/mysqltest.c b/client/mysqltest.c
--- a/client/mysqltest.c 2007-07-13 07:55:02 +02:00
+++ b/client/mysqltest.c 2007-08-21 20:17:26 +02:00
@@ -4512,7 +4512,11 @@ static struct my_option my_long_options[
GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0},
{"password", 'p', "Password to use when connecting to server.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"port", 'P', "Port number to use for connection.", (gptr*) &opt_port,
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", (gptr*) &opt_port,
(gptr*) &opt_port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"ps-protocol", OPT_PS_PROTOCOL, "Use prepared statements protocol for communication",
(gptr*) &ps_protocol, (gptr*) &ps_protocol, 0,
diff -Nrup a/configure.in b/configure.in
--- a/configure.in 2007-07-16 12:42:05 +02:00
+++ b/configure.in 2007-08-21 20:17:25 +02:00
@@ -710,7 +710,34 @@ AC_ARG_WITH(tcp-port,
[ --with-tcp-port=port-number
Which port to use for MySQL services (default 3306)],
[ MYSQL_TCP_PORT=$withval ],
- [ MYSQL_TCP_PORT=$MYSQL_TCP_PORT_DEFAULT ]
+ [ MYSQL_TCP_PORT=$MYSQL_TCP_PORT_DEFAULT
+ # if we actually defaulted (as opposed to the pathological case of
+ # --with-tcp-port=<MYSQL_TCP_PORT_DEFAULT> which might in theory
+ # happen if whole batch of servers was built from a script), set
+ # the default to zero to indicate that; we don't lose information
+ # that way, because 0 obviously indicates that we can get the
+ # default value from MYSQL_TCP_PORT. this seems really evil, but
+ # testing for MYSQL_TCP_PORT==MYSQL_TCP_PORT_DEFAULT would make a
+ # a port of MYSQL_TCP_PORT_DEFAULT magic even if the builder did not
+ # intend it to mean "use the default, in fact, look up a good default
+ # from /etc/services if you can", but really, really meant 3306 when
+ # they passed in 3306. When they pass in a specific value, let them
+ # have it; don't second guess user and think we know better, this will
+ # just make people cross. this makes the the logic work like this
+ # (which is complicated enough):
+ #
+ # - if a port was set during build, use that as a default.
+ #
+ # - otherwise, try to look up a port in /etc/services; if that fails,
+ # use MYSQL_TCP_PORT_DEFAULT (at the time of this writing 3306)
+ #
+ # - allow the MYSQL_TCP_PORT environment variable to override that.
+ #
+ # - allow command-line parameters to override all of the above.
+ #
+ # the top-most MYSQL_TCP_PORT_DEFAULT is read from win/configure.js,
+ # so don't mess with that.
+ MYSQL_TCP_PORT_DEFAULT=0 ]
)
AC_SUBST(MYSQL_TCP_PORT)
# We might want to document the assigned port in the manual.
diff -Nrup a/include/mysql_version.h.in b/include/mysql_version.h.in
--- a/include/mysql_version.h.in 2004-05-25 01:32:12 +02:00
+++ b/include/mysql_version.h.in 2007-08-21 20:17:27 +02:00
@@ -15,6 +15,7 @@
#define FRM_VER @DOT_FRM_VERSION@
#define MYSQL_VERSION_ID @MYSQL_VERSION_ID@
#define MYSQL_PORT @MYSQL_TCP_PORT@
+#define MYSQL_PORT_DEFAULT @MYSQL_TCP_PORT_DEFAULT@
#define MYSQL_UNIX_ADDR "@MYSQL_UNIX_ADDR@"
#define MYSQL_CONFIG_NAME "my"
#define MYSQL_COMPILATION_COMMENT "@COMPILATION_COMMENT@"
diff -Nrup a/libmysql/libmysql.c b/libmysql/libmysql.c
--- a/libmysql/libmysql.c 2007-07-06 08:34:06 +02:00
+++ b/libmysql/libmysql.c 2007-08-21 20:17:27 +02:00
@@ -133,10 +133,23 @@ int STDCALL mysql_server_init(int argc _
{
struct servent *serv_ptr;
char *env;
- if ((serv_ptr = getservbyname("mysql", "tcp")))
- mysql_port = (uint) ntohs((ushort) serv_ptr->s_port);
- if ((env = getenv("MYSQL_TCP_PORT")))
- mysql_port =(uint) atoi(env);
+
+ /*
+ if builder specifically requested a default port, use that
+ (even if it coincides with our factory default).
+ only if they didn't do we check /etc/services (and, failing
+ on that, fall back to the factory default of 3306).
+ either default can be overridden by the environment variable
+ MYSQL_TCP_PORT, which in turn can be overridden with command
+ line options.
+ */
+
+#if MYSQL_PORT_DEFAULT == 0
+ if ((serv_ptr = getservbyname("mysql", "tcp")))
+ mysql_port = (uint) ntohs((ushort) serv_ptr->s_port);
+#endif
+ if ((env = getenv("MYSQL_TCP_PORT")))
+ mysql_port =(uint) atoi(env);
}
#endif
}
diff -Nrup a/mysql-test/Makefile.am b/mysql-test/Makefile.am
--- a/mysql-test/Makefile.am 2007-06-08 11:51:17 +02:00
+++ b/mysql-test/Makefile.am 2007-08-21 20:17:27 +02:00
@@ -147,6 +147,7 @@ SUFFIXES = .sh
-e 's!@''PERL''@!@PERL@!' \
-e 's!@''VERSION''@!@VERSION@!' \
-e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \
+ -e 's!@''MYSQL_TCP_PORT_DEFAULT''@!@MYSQL_TCP_PORT_DEFAULT@!' \
-e 's!@''MYSQL_BASE_VERSION''@!@MYSQL_BASE_VERSION@!' \
-e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \
-e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \
diff -Nrup a/mysql-test/mysql-test-run-shell.sh b/mysql-test/mysql-test-run-shell.sh
--- a/mysql-test/mysql-test-run-shell.sh 2006-11-28 21:11:42 +01:00
+++ b/mysql-test/mysql-test-run-shell.sh 2007-08-21 20:17:27 +02:00
@@ -17,7 +17,16 @@ USE_MANAGER=0
MY_TZ=GMT-3
TZ=$MY_TZ; export TZ # for UNIX_TIMESTAMP tests to work
LOCAL_SOCKET=@MYSQL_UNIX_ADDR@
-MYSQL_TCP_PORT=@MYSQL_TCP_PORT@
+
+if [ -z "$MYSQL_TCP_PORT" ]; then
+ MYSQL_TCP_PORT=@MYSQL_TCP_PORT@
+ if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then
+ ESP=`getent services mysql/tcp`
+ if [ $? -eq 0 ]; then
+ MYSQL_TCP_PORT=`echo "$ESP"|sed -e's-^[a-z]*[ ]*\([0-9]*\)/[a-z]*$-\1-g'`
+ fi
+ fi
+fi
umask 022
diff -Nrup a/netware/mysql_test_run.c b/netware/mysql_test_run.c
--- a/netware/mysql_test_run.c 2005-12-04 19:57:28 +01:00
+++ b/netware/mysql_test_run.c 2007-08-21 20:17:27 +02:00
@@ -1170,7 +1170,8 @@ void setup(char *file)
setenv("MYSQL_BINLOG", file_path, 1);
setenv("MASTER_MYPORT", "9306", 1);
setenv("SLAVE_MYPORT", "9307", 1);
- setenv("MYSQL_TCP_PORT", "3306", 1);
+ snprintf(file_path, PATH_MAX*2, "%d", MYSQL_PORT);
+ setenv("MYSQL_TCP_PORT", file_path, 1);
snprintf(file_path, PATH_MAX*2, "%s/mysql_client_test --no-defaults --testcase--user=root --port=%u ", bin_dir, master_port);
setenv("MYSQL_CLIENT_TEST",file_path,1);
snprintf(file_path, PATH_MAX*2, "%s/mysql --no-defaults --user=root --port=%u ", bin_dir, master_port);
diff -Nrup a/netware/mysqld_safe.c b/netware/mysqld_safe.c
--- a/netware/mysqld_safe.c 2006-01-12 19:07:03 +01:00
+++ b/netware/mysqld_safe.c 2007-08-21 20:17:27 +02:00
@@ -189,7 +189,7 @@ void start_defaults(int argc, char *argv
snprintf(address, PATH_MAX, "0.0.0.0");
// port
- snprintf(port, PATH_MAX, "3306");
+ snprintf(port, PATH_MAX, "%d", MYSQL_PORT);
// default option
default_option[0]= NULL;
diff -Nrup a/scripts/Makefile.am b/scripts/Makefile.am
--- a/scripts/Makefile.am 2007-05-03 15:50:59 +02:00
+++ b/scripts/Makefile.am 2007-08-21 20:17:27 +02:00
@@ -174,6 +174,7 @@ SUFFIXES = .sh
-e 's!@''MYSQLD_DEFAULT_SWITCHES''@!@MYSQLD_DEFAULT_SWITCHES@!' \
-e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \
-e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \
+ -e 's!@''MYSQL_TCP_PORT_DEFAULT''@!@MYSQL_TCP_PORT_DEFAULT@!' \
-e 's!@''TARGET_LINUX''@!@TARGET_LINUX@!' \
-e "s!@""CONF_COMMAND""@!@CONF_COMMAND@!" \
-e 's!@''MYSQLD_USER''@!@MYSQLD_USER@!' \
diff -Nrup a/scripts/mysql_config.sh b/scripts/mysql_config.sh
--- a/scripts/mysql_config.sh 2006-12-30 21:02:05 +01:00
+++ b/scripts/mysql_config.sh 2007-08-21 20:17:27 +02:00
@@ -92,8 +92,18 @@ fix_path pkgincludedir include/mysql inc
version='@VERSION@'
socket='@MYSQL_UNIX_ADDR@'
-port='@MYSQL_TCP_PORT@'
ldflags='@LDFLAGS@'
+
+if [ -z "$MYSQL_TCP_PORT" ]; then
+ MYSQL_TCP_PORT=@MYSQL_TCP_PORT@
+ if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then
+ ESP=`getent services mysql/tcp`
+ if [ $? -eq 0 ]; then
+ MYSQL_TCP_PORT=`echo "$ESP"|sed -e's-^[a-z]*[ ]*\([0-9]*\)/[a-z]*$-\1-g'`
+ fi
+ fi
+fi
+port=$MYSQL_TCP_PORT
# Create options
# We intentionally add a space to the beginning and end of lib strings, simplifies replace later
diff -Nrup a/scripts/mysql_convert_table_format.sh b/scripts/mysql_convert_table_format.sh
--- a/scripts/mysql_convert_table_format.sh 2006-12-30 23:47:38 +01:00
+++ b/scripts/mysql_convert_table_format.sh 2007-08-21 20:17:27 +02:00
@@ -39,10 +39,30 @@ if (uc($opt_type) eq "HEAP")
}
$connect_opt="";
+
+if ($opt_port == 0)
+{
+ # whether to try socket or TCP depends on value for "host", so always
+ # passing in a default port is safe.
+ $opt_port=$ENV{"MYSQL_TCP_PORT"};
+ if (length($opt_port) == 0)
+ {
+ $opt_port=@MYSQL_TCP_PORT@;
+ if (@MYSQL_TCP_PORT_DEFAULT@ == 0)
+ {
+ my $esp=getservbyname("mysql","tcp");
+ if (length($esp))
+ {
+ $opt_port=$esp;
+ }
+ }
+ }
+}
if ($opt_port)
{
$connect_opt.= ";port=$opt_port";
}
+
if (length($opt_socket))
{
$connect_opt.=";mysql_socket=$opt_socket";
diff -Nrup a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh
--- a/scripts/mysql_fix_privilege_tables.sh 2007-02-26 11:49:23 +01:00
+++ b/scripts/mysql_fix_privilege_tables.sh 2007-08-21 20:17:27 +02:00
@@ -25,6 +25,7 @@ sql_only=0
basedir="@prefix@"
verbose=0
args=""
+# no elaborate fallback here; with no argument, it will happen in "mysql"
port=""
socket=""
database="mysql"
diff -Nrup a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh
--- a/scripts/mysql_setpermission.sh 2003-04-25 21:58:23 +02:00
+++ b/scripts/mysql_setpermission.sh 2007-08-21 20:17:27 +02:00
@@ -54,6 +54,25 @@ else
$sqlhost = $opt_host;
}
+if ($opt_port == 0)
+{
+ # whether to try socket or TCP depends on value for "host", so always
+ # passing in a default port is safe.
+ $opt_port=$ENV{"MYSQL_TCP_PORT"};
+ if (length($opt_port) == 0)
+ {
+ $opt_port=@MYSQL_TCP_PORT@;
+ if (@MYSQL_TCP_PORT_DEFAULT@ == 0)
+ {
+ my $esp=getservbyname("mysql","tcp");
+ if (length($esp))
+ {
+ $opt_port=$esp;
+ }
+ }
+ }
+}
+
# ask for a password if no password is set already
if ($opt_password eq '')
{
diff -Nrup a/scripts/mysql_tableinfo.sh b/scripts/mysql_tableinfo.sh
--- a/scripts/mysql_tableinfo.sh 2005-04-24 22:35:56 +02:00
+++ b/scripts/mysql_tableinfo.sh 2007-08-21 20:17:27 +02:00
@@ -106,6 +106,25 @@ my $info_idx="`".$opt{'prefix'}."idx`";
# --- connect to the database ---
+if ($opt{'port'} == 0)
+{
+ # whether to try socket or TCP depends on value for "host", so always
+ # passing in a default port is safe.
+ $opt{'port'}=$ENV{"MYSQL_TCP_PORT"};
+ if (length($opt{'port'}) == 0)
+ {
+ $opt{'port'}=@MYSQL_TCP_PORT@;
+ if (@MYSQL_TCP_PORT_DEFAULT@ == 0)
+ {
+ my $esp=getservbyname("mysql","tcp");
+ if (length($esp))
+ {
+ $opt{'port'}=$esp;
+ }
+ }
+ }
+}
+
my $dsn = ";host=$opt{'host'}";
$dsn .= ";port=$opt{'port'}" if $opt{'port'};
$dsn .= ";mysql_socket=$opt{'socket'}" if $opt{'socket'};
diff -Nrup a/scripts/mysqld_safe-watch.sh b/scripts/mysqld_safe-watch.sh
--- a/scripts/mysqld_safe-watch.sh 2006-06-28 00:07:20 +02:00
+++ b/scripts/mysqld_safe-watch.sh 2007-08-21 20:17:27 +02:00
@@ -66,7 +66,7 @@ fi
echo "Starting mysqld demon with databases from $DATADIR"
#Default communication ports
-#MYSQL_TCP_PORT=3306
+#MYSQL_TCP_PORT=@MYSQL_TCP_PORT@
if test -z "$MYSQL_UNIX_PORT"
then
MYSQL_UNIX_PORT="/tmp/mysql.sock"
diff -Nrup a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh
--- a/scripts/mysqlhotcopy.sh 2006-10-03 09:05:31 +02:00
+++ b/scripts/mysqlhotcopy.sh 2007-08-21 20:17:28 +02:00
@@ -167,6 +167,26 @@ $opt{quiet} = 0 if $opt{debug};
$opt{allowold} = 1 if $opt{keepold};
# --- connect to the database ---
+
+if (!defined($opt{'port'}) || ($opt{'port'} == 0))
+{
+ # whether to try socket or TCP depends on value for "host", so always
+ # passing in a default port is safe.
+ $opt{'port'}=$ENV{"MYSQL_TCP_PORT"};
+ if (!defined($opt{'port'}))
+ {
+ $opt{'port'}=@MYSQL_TCP_PORT@;
+ if (@MYSQL_TCP_PORT_DEFAULT@ == 0)
+ {
+ my $esp=getservbyname("mysql","tcp");
+ if (length($esp))
+ {
+ $opt{'port'}=$esp;
+ }
+ }
+ }
+}
+
my $dsn;
$dsn = ";host=" . (defined($opt{host}) ? $opt{host} : "localhost");
$dsn .= ";port=$opt{port}" if $opt{port};
diff -Nrup a/server-tools/instance-manager/priv.h b/server-tools/instance-manager/priv.h
--- a/server-tools/instance-manager/priv.h 2006-12-30 21:02:06 +01:00
+++ b/server-tools/instance-manager/priv.h 2007-08-21 20:17:28 +02:00
@@ -25,7 +25,7 @@
#include "my_pthread.h"
/* IM-wide platform-independent defines */
-#define SERVER_DEFAULT_PORT 3306
+#define SERVER_DEFAULT_PORT MYSQL_PORT
#define DEFAULT_MONITORING_INTERVAL 20
#define DEFAULT_PORT 2273
/* three-week timeout should be enough */
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc 2007-07-05 12:34:10 +02:00
+++ b/sql/mysqld.cc 2007-08-21 20:17:28 +02:00
@@ -1300,8 +1300,21 @@ static void set_ports()
{ // Get port if not from commandline
struct servent *serv_ptr;
mysqld_port= MYSQL_PORT;
+
+ /*
+ if builder specifically requested a default port, use that
+ (even if it coincides with our factory default).
+ only if they didn't do we check /etc/services (and, failing
+ on that, fall back to the factory default of 3306).
+ either default can be overridden by the environment variable
+ MYSQL_TCP_PORT, which in turn can be overridden with command
+ line options.
+ */
+
+#if MYSQL_PORT_DEFAULT == 0
if ((serv_ptr= getservbyname("mysql", "tcp")))
mysqld_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */
+#endif
if ((env = getenv("MYSQL_TCP_PORT")))
mysqld_port= (uint) atoi(env); /* purecov: inspected */
}
diff -Nrup a/tests/mysql_client_test.c b/tests/mysql_client_test.c
--- a/tests/mysql_client_test.c 2007-06-29 15:37:15 +02:00
+++ b/tests/mysql_client_test.c 2007-08-21 20:17:28 +02:00
@@ -15759,7 +15759,11 @@ static struct my_option client_test_long
{"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
- {"port", 'P', "Port number to use for connection", (char **) &opt_port,
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", (char **) &opt_port,
(char **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"server-arg", 'A', "Send embedded server this as a parameter.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
diff -Nrup a/tests/ssl_test.c b/tests/ssl_test.c
--- a/tests/ssl_test.c 2006-12-23 20:04:31 +01:00
+++ b/tests/ssl_test.c 2007-08-21 20:17:28 +02:00
@@ -44,7 +44,7 @@ int main(int argc, char **argv)
"../SSL/MySQL-client-cert.pem",
"../SSL/MySQL-ca-cert.pem", 0, 0);
#endif
- if (!(sock = mysql_real_connect(&mysql,"127.0.0.1",0,0,argv[1],3306,NULL,0)))
+ if (!(sock = mysql_real_connect(&mysql,"127.0.0.1",0,0,argv[1],MYSQL_PORT,NULL,0)))
{
fprintf(stderr,"Couldn't connect to engine!\n%s\n\n",mysql_error(&mysql));
perror("");
diff -Nrup a/tests/thread_test.c b/tests/thread_test.c
--- a/tests/thread_test.c 2006-12-23 20:04:31 +01:00
+++ b/tests/thread_test.c 2007-08-21 20:17:28 +02:00
@@ -103,7 +103,11 @@ static struct my_option my_long_options[
(gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"query", 'Q', "Query to execute in each threads", (gptr*) &query,
(gptr*) &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"port", 'P', "Port number to use for connection", (gptr*) &tcp_port,
+ {"port", 'P', "Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, "
+#if MYSQL_PORT_DEFAULT == 0
+ "/etc/services, "
+#endif
+ "built-in default.", (gptr*) &tcp_port,
(gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection", (gptr*) &unix_socket,
(gptr*) &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},