Skip to content

mysqlnd: detect mysql unix socket path with mysql_config #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ext/mysqlnd/config9.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ dnl $Id$
dnl config.m4 for mysqlnd driver

PHP_ARG_ENABLE(mysqlnd, whether to enable mysqlnd,
[ --enable-mysqlnd Enable mysqlnd explicitly, will be done implicitly
when required by other extensions], no, yes)
[ --enable-mysqlnd=FILE Enable mysqlnd explicitly, will be done implicitly
when required by other extensions. FILE is the path
to mysql_config.], no, yes)

PHP_ARG_ENABLE(mysqlnd_compression_support, whether to disable compressed protocol support in mysqlnd,
[ --disable-mysqlnd-compression-support
Expand All @@ -17,6 +18,8 @@ fi

dnl If some extension uses mysqlnd it will get compiled in PHP core
if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
MYSQL_CONFIG=$PHP_MYSQLND

mysqlnd_ps_sources="mysqlnd_ps.c mysqlnd_ps_codec.c"
mysqlnd_base_sources="mysqlnd.c mysqlnd_alloc.c mysqlnd_bt.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
mysqlnd_loaddata.c mysqlnd_reverse_api.c mysqlnd_net.c \
Expand Down Expand Up @@ -44,6 +47,11 @@ if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, $ext_shared)
PHP_ADD_BUILD_DIR([ext/mysqlnd], 1)
PHP_INSTALL_HEADERS([ext/mysqlnd/])

if test -x "$MYSQL_CONFIG"; then
MYSQLND_SOCKET=`$MYSQL_CONFIG --socket`
AC_DEFINE_UNQUOTED(MYSQLND_UNIX_SOCK_ADDR, "$MYSQLND_SOCKET", [ ])
fi
fi

if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes" || test "$PHP_MYSQLI" != "no"; then
Expand Down
4 changes: 4 additions & 0 deletions ext/mysqlnd/mysqlnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,11 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn,
if (host_len == sizeof("localhost") - 1 && !strncasecmp(host, "localhost", host_len)) {
DBG_INF_FMT("socket=%s", socket_or_pipe? socket_or_pipe:"n/a");
if (!socket_or_pipe) {
#ifdef MYSQLND_UNIX_SOCK_ADDR
socket_or_pipe = MYSQLND_UNIX_SOCK_ADDR;
#else
socket_or_pipe = "/tmp/mysql.sock";
#endif
}
transport_len = mnd_sprintf(&transport, 0, "unix://%s", socket_or_pipe);
unix_socket = TRUE;
Expand Down
10 changes: 7 additions & 3 deletions ext/pdo_mysql/pdo_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ ZEND_DECLARE_MODULE_GLOBALS(pdo_mysql)
# ifdef PHP_MYSQL_UNIX_SOCK_ADDR
# define PDO_MYSQL_UNIX_ADDR PHP_MYSQL_UNIX_SOCK_ADDR
# else
# if !PHP_WIN32
# define PDO_MYSQL_UNIX_ADDR "/tmp/mysql.sock"
# ifdef MYSQLND_UNIX_SOCK_ADDR
# define PDO_MYSQL_UNIX_ADDR MYSQLND_UNIX_SOCK_ADDR
# else
# define PDO_MYSQL_UNIX_ADDR NULL
# if !PHP_WIN32
# define PDO_MYSQL_UNIX_ADDR "/tmp/mysql.sock"
# else
# define PDO_MYSQL_UNIX_ADDR NULL
# endif
# endif
# endif
#endif
Expand Down