]> granicus.if.org Git - php/commitdiff
Fixing host info for TCP/IP and aligning mysqlnd and libmysql
authorUlf Wendel <uw@php.net>
Mon, 19 Oct 2009 12:09:48 +0000 (12:09 +0000)
committerUlf Wendel <uw@php.net>
Mon, 19 Oct 2009 12:09:48 +0000 (12:09 +0000)
ext/mysqli/tests/mysqli_get_host_info.phpt
ext/mysqlnd/mysqlnd.c

index 63fdad28b471b3e1b6819a5b4ec62457cb63b2d8..b3db9be8dc7b64361606d8acdfadbf0d49b06dee 100644 (file)
@@ -20,6 +20,11 @@ require_once('skipifconnectfailure.inc');
        if (!is_string($info = mysqli_get_host_info($link)) || ('' === $info))
                printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info);
 
+       if ($IS_MYSQLND && $host != 'localhost' && $host != '127.0.0.1' && $port != '' && $host != "" && strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+               /* this should be a TCP/IP connection and not a Unix Socket (or SHM or Named Pipe) */
+               if (!stristr($info, "TCP/IP"))
+                       printf("[004] Should be a TCP/IP connection but mysqlnd says '%s'\n", $info);   
+       }
        print "done!";
 ?>
 --CLEAN--
index e2108461d28c9e37bad6f983a324767e9aa71492..c5e3350cbb5cc6cc439e92b0026064b35633c550 100644 (file)
@@ -728,11 +728,12 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
                conn->user                              = pestrdup(user, conn->persistent);
                conn->passwd                    = pestrndup(passwd, passwd_len, conn->persistent);
                conn->port                              = port;
-               if (host && !socket) {
+
+               if (!unix_socket) {
                        char *p;
 
                        conn->host = pestrdup(host, conn->persistent);
-                       spprintf(&p, 0, "MySQL host info: %s via TCP/IP", conn->host);
+                       spprintf(&p, 0, "%s via TCP/IP", conn->host);
                        if (conn->persistent) {
                                conn->host_info = pestrdup(p, 1);
                                mnd_efree(p);
@@ -741,7 +742,7 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn,
                        }
                } else {
                        conn->unix_socket       = pestrdup(socket, conn->persistent);
-                       conn->host_info         = pestrdup("MySQL host info: Localhost via UNIX socket", conn->persistent);
+                       conn->host_info         = pestrdup("Localhost via UNIX socket", conn->persistent);
                }
                conn->client_flag               = auth_packet->client_flags;
                conn->max_packet_size   = auth_packet->max_packet_size;