diff options
| author | Ondřej Surý <ondrej@sury.org> | 2010-03-09 11:57:54 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2010-03-09 11:57:54 +0100 |
| commit | 855a09f4eded707941180c9d90acd17c25e29447 (patch) | |
| tree | a40947efaa9876f31b6ee3956c3f3775768143bb /ext/mysql | |
| parent | c852c28a88fccf6e34a2cb091fdfa72bce2b59c7 (diff) | |
| download | php-upstream/5.3.2.tar.gz | |
Imported Upstream version 5.3.2upstream/5.3.2
Diffstat (limited to 'ext/mysql')
| -rw-r--r-- | ext/mysql/config.m4 | 25 | ||||
| -rw-r--r-- | ext/mysql/php_mysql.c | 54 | ||||
| -rw-r--r-- | ext/mysql/php_mysql.h | 4 | ||||
| -rw-r--r-- | ext/mysql/php_mysql_structs.h | 9 | ||||
| -rwxr-xr-x | ext/mysql/tests/connect.inc | 48 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_connect.phpt | 20 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_pconn_disable.phpt | 16 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_pconn_max_links.phpt | 13 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_phpinfo.phpt | 7 | ||||
| -rw-r--r-- | ext/mysql/tests/mysql_query_load_data_openbasedir.phpt | 11 |
10 files changed, 97 insertions, 110 deletions
diff --git a/ext/mysql/config.m4 b/ext/mysql/config.m4 index 47e9083fc..61e24461f 100644 --- a/ext/mysql/config.m4 +++ b/ext/mysql/config.m4 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4 263087 2008-07-21 12:58:51Z andrey $ +dnl $Id: config.m4 291501 2009-11-30 15:11:29Z jani $ dnl AC_DEFUN([MYSQL_LIB_CHK], [ @@ -58,18 +58,6 @@ if test "$PHP_MYSQL" = "mysqlnd"; then PHP_MYSQLND_ENABLED=yes elif test "$PHP_MYSQL" != "no"; then - - AC_MSG_CHECKING([for MySQL UNIX socket location]) - if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then - MYSQL_SOCK=$PHP_MYSQL_SOCK - AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ]) - AC_MSG_RESULT([$MYSQL_SOCK]) - elif test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL_SOCK" = "yes"; then - PHP_MYSQL_SOCKET_SEARCH - else - AC_MSG_RESULT([no]) - fi - MYSQL_DIR= MYSQL_INC_DIR= @@ -152,6 +140,17 @@ fi dnl Enable extension if test "$PHP_MYSQL" != "no"; then + AC_MSG_CHECKING([for MySQL UNIX socket location]) + if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then + MYSQL_SOCK=$PHP_MYSQL_SOCK + AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ]) + AC_MSG_RESULT([$MYSQL_SOCK]) + elif test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL_SOCK" = "yes"; then + PHP_MYSQL_SOCKET_SEARCH + else + AC_MSG_RESULT([no]) + fi + AC_DEFINE(HAVE_MYSQL, 1, [Whether you have MySQL]) PHP_NEW_EXTENSION(mysql, php_mysql.c, $ext_shared) PHP_SUBST(MYSQL_SHARED_LIBADD) diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 9c109316b..28d4d8ec5 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mysql.c 289630 2009-10-14 13:51:25Z johannes $ */ +/* $Id: php_mysql.c 294891 2010-02-11 17:14:44Z johannes $ */ /* TODO: * @@ -125,10 +125,6 @@ typedef struct _php_mysql_conn { int multi_query; } php_mysql_conn; -#ifdef MYSQL_USE_MYSQLND -static MYSQLND_ZVAL_PCACHE *mysql_mysqlnd_zval_cache; -static MYSQLND_QCACHE *mysql_mysqlnd_qcache; -#endif #if MYSQL_VERSION_ID >= 40101 #define MYSQL_DISABLE_MQ if (mysql->multi_query) { \ @@ -411,9 +407,6 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("mysql.connect_timeout", "60", PHP_INI_ALL, OnUpdateLong, connect_timeout, zend_mysql_globals, mysql_globals) STD_PHP_INI_BOOLEAN("mysql.trace_mode", "0", PHP_INI_ALL, OnUpdateLong, trace_mode, zend_mysql_globals, mysql_globals) STD_PHP_INI_BOOLEAN("mysql.allow_local_infile", "1", PHP_INI_SYSTEM, OnUpdateLong, allow_local_infile, zend_mysql_globals, mysql_globals) -#ifdef MYSQL_USE_MYSQLND - STD_PHP_INI_ENTRY("mysql.cache_size", "2000", PHP_INI_SYSTEM, OnUpdateLong, cache_size, zend_mysql_globals, mysql_globals) -#endif PHP_INI_END() /* }}} */ @@ -432,10 +425,6 @@ static PHP_GINIT_FUNCTION(mysql) mysql_globals->trace_mode = 0; mysql_globals->allow_local_infile = 1; mysql_globals->result_allocated = 0; -#ifdef MYSQL_USE_MYSQLND - mysql_globals->cache_size = 0; - mysql_globals->mysqlnd_thd_zval_cache = NULL; -#endif } /* }}} */ @@ -465,9 +454,6 @@ ZEND_MODULE_STARTUP_D(mysql) return FAILURE; } #endif -#else - mysql_mysqlnd_zval_cache = mysqlnd_palloc_init_cache(MySG(cache_size)); - mysql_mysqlnd_qcache = mysqlnd_qcache_init_cache(); #endif return SUCCESS; @@ -493,9 +479,6 @@ PHP_MSHUTDOWN_FUNCTION(mysql) mysql_server_end(); #endif #endif -#else - mysqlnd_palloc_free_cache(mysql_mysqlnd_zval_cache); - mysqlnd_qcache_free_cache_reference(&mysql_mysqlnd_qcache); #endif UNREGISTER_INI_ENTRIES(); @@ -519,10 +502,6 @@ PHP_RINIT_FUNCTION(mysql) MySG(connect_errno) =0; MySG(result_allocated) = 0; -#ifdef MYSQL_USE_MYSQLND - MySG(mysqlnd_thd_zval_cache) = mysqlnd_palloc_rinit(mysql_mysqlnd_zval_cache); -#endif - return SUCCESS; } /* }}} */ @@ -559,7 +538,6 @@ PHP_RSHUTDOWN_FUNCTION(mysql) #ifdef MYSQL_USE_MYSQLND zend_hash_apply(&EG(persistent_list), (apply_func_t) php_mysql_persistent_helper TSRMLS_CC); - mysqlnd_palloc_rshutdown(MySG(mysqlnd_thd_zval_cache)); #endif return SUCCESS; @@ -585,20 +563,6 @@ PHP_MINFO_FUNCTION(mysql) php_info_print_table_row(2, "MYSQL_INCLUDE", PHP_MYSQL_INCLUDE); php_info_print_table_row(2, "MYSQL_LIBS", PHP_MYSQL_LIBS); #endif -#if defined(MYSQL_USE_MYSQLND) - { - zval values; - - php_info_print_table_header(2, "Persistent cache", mysql_mysqlnd_zval_cache? "enabled":"disabled"); - - if (mysql_mysqlnd_zval_cache) { - /* Now report cache status */ - mysqlnd_palloc_stats(mysql_mysqlnd_zval_cache, &values); - mysqlnd_minfo_print_hash(&values); - zval_dtor(&values); - } - } -#endif php_info_print_table_end(); @@ -704,6 +668,9 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) client_flags ^= CLIENT_LOCAL_FILES; } +#ifdef CLIENT_MULTI_RESULTS + client_flags |= CLIENT_MULTI_RESULTS; /* compatibility with 5.2, see bug#50416 */ +#endif #ifdef CLIENT_MULTI_STATEMENTS client_flags &= ~CLIENT_MULTI_STATEMENTS; /* don't allow multi_queries via connect parameter */ #endif @@ -776,8 +743,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) #ifndef MYSQL_USE_MYSQLND if (mysql_real_connect(mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL) #else - if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, - port, socket, client_flags, MySG(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL) + if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, port, socket, client_flags TSRMLS_CC) == NULL) #endif { /* Populate connect error globals so that the error functions can read them */ @@ -825,8 +791,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) #ifndef MYSQL_USE_MYSQLND if (mysql_real_connect(mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL) #else - if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, - port, socket, client_flags, MySG(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL) + if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, port, socket, client_flags TSRMLS_CC) == NULL) #endif { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Link to server lost, unable to reconnect"); @@ -838,7 +803,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) } } else { #ifdef MYSQL_USE_MYSQLND - mysqlnd_restart_psession(mysql->conn, MySG(mysqlnd_thd_zval_cache)); + mysqlnd_restart_psession(mysql->conn); #endif } } @@ -897,8 +862,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) #ifndef MYSQL_USE_MYSQLND if (mysql_real_connect(mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL) #else - if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, - port, socket, client_flags, MySG(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL) + if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, port, socket, client_flags TSRMLS_CC) == NULL) #endif { /* Populate connect error globals so that the error functions can read them */ diff --git a/ext/mysql/php_mysql.h b/ext/mysql/php_mysql.h index 33c3b2ed5..cef76ac5e 100644 --- a/ext/mysql/php_mysql.h +++ b/ext/mysql/php_mysql.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ */ -/* $Id: php_mysql.h 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: php_mysql.h 293036 2010-01-03 09:23:27Z sebastian $ */ #ifndef PHP_MYSQL_H #define PHP_MYSQL_H diff --git a/ext/mysql/php_mysql_structs.h b/ext/mysql/php_mysql_structs.h index d74eadc04..0247dc862 100644 --- a/ext/mysql/php_mysql_structs.h +++ b/ext/mysql/php_mysql_structs.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ */ -/* $Id: php_mysql_structs.h 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: php_mysql_structs.h 293036 2010-01-03 09:23:27Z sebastian $ */ #ifndef PHP_MYSQL_STRUCTS_H #define PHP_MYSQL_STRUCTS_H @@ -124,11 +124,6 @@ ZEND_BEGIN_MODULE_GLOBALS(mysql) long result_allocated; long trace_mode; long allow_local_infile; -#ifdef MYSQL_USE_MYSQLND - MYSQLND_THD_ZVAL_PCACHE *mysqlnd_thd_zval_cache; - MYSQLND_QCACHE *mysqlnd_qcache; - long cache_size; -#endif ZEND_END_MODULE_GLOBALS(mysql) #ifdef ZTS diff --git a/ext/mysql/tests/connect.inc b/ext/mysql/tests/connect.inc index 86c0ee674..b5cc03ecb 100755 --- a/ext/mysql/tests/connect.inc +++ b/ext/mysql/tests/connect.inc @@ -19,30 +19,40 @@ if (!function_exists('sys_get_temp_dir')) { } } -/* wrapper to simplify test porting */ -function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL) { - global $connect_flags; +if (!function_exists('my_mysql_connect')) { + /* wrapper to simplify test porting */ + function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL, $persistent = false) { + global $connect_flags; - $flags = ($flags === NULL) ? $connect_flags : $flags; + $flags = ($flags === NULL) ? $connect_flags : $flags; - if ($socket) - $host = sprintf("%s:%s", $host, $socket); - else if ($port) - $host = sprintf("%s:%s", $host, $port); + if ($socket) + $host = sprintf("%s:%s", $host, $socket); + else if ($port) + $host = sprintf("%s:%s", $host, $port); - if (!$link = mysql_connect($host, $user, $passwd, true, $flags)) { - printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n", - $host, $user, $passwd, - mysql_errno(), mysql_error()); - return false; - } + if ($persistent) { + $link = mysql_pconnect($host, $user, $passwd, $flags); + } else { + $link = mysql_connect($host, $user, $passwd, true, $flags); + } - if (!mysql_select_db($db, $link)) { - printf("[000-b] [%d] %s\n", mysql_errno($link), mysql_error($link)); - return false; - } + if (!$link) { + printf("[000-a] Cannot connect using host '%s', user '%s', password '****', persistent = %d, [%d] %s\n", + $host, $user, ($persistent) ? 1 : 0, + mysql_errno(), mysql_error()); + return false; + } - return $link; + if (!mysql_select_db($db, $link)) { + printf("[000-b] [%d] %s\n", mysql_errno($link), mysql_error($link)); + return false; + } + + return $link; + } +} else { + printf("skip Eeeek/BUG/FIXME - connect.inc included twice! skipif bug?\n"); } /* diff --git a/ext/mysql/tests/mysql_connect.phpt b/ext/mysql/tests/mysql_connect.phpt index be094cce2..773264e5a 100644 --- a/ext/mysql/tests/mysql_connect.phpt +++ b/ext/mysql/tests/mysql_connect.phpt @@ -35,19 +35,23 @@ printf("[005] Expecting boolean/false, got %s/%s\n", gettype($link), $link); // Run the following tests without an anoynmous MySQL user and use a password for the test user! ini_set('mysql.default_socket', $socket); -if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) { - printf("[006] Usage of mysql.default_socket failed\n"); -} else { - mysql_close($link); +if (!is_null($socket)) { + if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) { + printf("[006] Usage of mysql.default_socket failed\n"); + } else { + mysql_close($link); + } } if (!ini_get('sql.safe_mode')) { ini_set('mysql.default_port', $port); - if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) { - printf("[007] Usage of mysql.default_port failed\n"); - } else { - mysql_close($link); + if (!is_null($port)) { + if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) { + printf("[007] Usage of mysql.default_port failed\n"); + } else { + mysql_close($link); + } } ini_set('mysql.default_password', $passwd); diff --git a/ext/mysql/tests/mysql_pconn_disable.phpt b/ext/mysql/tests/mysql_pconn_disable.phpt index dfb04eeef..532e2e578 100644 --- a/ext/mysql/tests/mysql_pconn_disable.phpt +++ b/ext/mysql/tests/mysql_pconn_disable.phpt @@ -13,19 +13,11 @@ mysql.max_links=2 <?php require_once("connect.inc"); require_once("table.inc"); - // assert(ini_get('mysql.allow_persistent') == false); - if ($socket) - $myhost = sprintf("%s:%s", $host, $socket); - else if ($port) - $myhost = sprintf("%s:%s", $host, $port); - else - $myhost = $host; - - if (($plink = mysql_pconnect($myhost, $user, $passwd))) + if (($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket, NULL, true))) printf("[001] Can connect to the server.\n"); - if (($res = @mysql_query('SELECT id FROM test ORDER BY id ASC', $plink)) && + if (($res = mysql_query('SELECT id FROM test ORDER BY id ASC', $plink)) && ($row = mysql_fetch_assoc($res)) && (mysql_free_result($res))) { printf("[002] Can fetch data using persistent connection! Data = '%s'\n", @@ -35,7 +27,7 @@ mysql.max_links=2 $thread_id = mysql_thread_id($plink); mysql_close($plink); - if (!($plink = mysql_pconnect($myhost, $user, $passwd))) + if (!($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket, NULL, true))) printf("[003] Cannot connect, [%d] %s\n", mysql_errno(), mysql_error()); if (mysql_thread_id($plink) != $thread_id) @@ -44,7 +36,7 @@ mysql.max_links=2 $thread_id = mysql_thread_id($plink); mysql_close($plink); - if (!($plink = mysql_connect($myhost, $user, $passwd, true))) + if (!($plink = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))) printf("[005] Cannot connect, [%d] %s\n", mysql_errno(), mysql_error()); if (mysql_thread_id($plink) == $thread_id) diff --git a/ext/mysql/tests/mysql_pconn_max_links.phpt b/ext/mysql/tests/mysql_pconn_max_links.phpt index 1d39e98b4..3eca0e534 100644 --- a/ext/mysql/tests/mysql_pconn_max_links.phpt +++ b/ext/mysql/tests/mysql_pconn_max_links.phpt @@ -18,6 +18,19 @@ Persistent connections and mysql.max_persistent if (!mysql_select_db($db, $link)) die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link))); + if (!$res = mysql_query('SHOW VARIABLES LIKE "old_passwords"', $link)) { + die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link))); + } + + if (mysql_num_rows($res) != 1) { + die(sprintf("skip Can't check if old_passwords = ON")); + } + + $row = mysql_fetch_assoc($res); + mysql_free_result($res); + if ($row['Value'] == "ON") + die(sprintf("skip Test will fail because old_passwords = ON. Hint: old passwords are insecure!")); + if (!$res = mysql_query("SELECT CURRENT_USER() AS _user", $link)) die(sprintf("skip [%d] %s", mysql_errno($link), mysql_error($link))); diff --git a/ext/mysql/tests/mysql_phpinfo.phpt b/ext/mysql/tests/mysql_phpinfo.phpt index a57e42e6b..46600ab2d 100644 --- a/ext/mysql/tests/mysql_phpinfo.phpt +++ b/ext/mysql/tests/mysql_phpinfo.phpt @@ -1,8 +1,8 @@ --TEST-- phpinfo() mysql section --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -62,8 +62,7 @@ if ($IS_MYSQLND) { 'connect_failure', 'connection_reused', 'explicit_close', 'implicit_close', 'disconnect_close', 'in_middle_of_command_close', 'explicit_free_result', 'implicit_free_result', 'explicit_stmt_close', 'implicit_stmt_close', - 'put_hits', 'put_misses', 'get_hits', 'get_misses', - 'size', 'free_items', 'references', 'mysql.cache_size', + 'size', ); foreach ($expected as $k => $entry) if (!stristr($phpinfo, $entry)) diff --git a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt index 577ede375..a257f5fb8 100644 --- a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt +++ b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt @@ -4,6 +4,10 @@ LOAD DATA INFILE - open_basedir <?php require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); +require_once("connect.inc"); + +if (!$IS_MYSQLND) + die("skip mysqlnd only, libmysql does not know about open_basedir restrictions"); if (file_exists('./simple.csv') && !unlink('./simple.csv')) die("skip Cannot remove previous CSV file"); @@ -13,6 +17,13 @@ if (!$fp = fopen('./simple.csv', 'w')) fclose($fp); @unlink('./simple.csv'); + +if ($socket == "" && $host != NULL && $host != 'localhost' && $host != '.') { + /* could be a remote TCP/IP connection. LOCAL INFILE may not work */ + if (gethostbyaddr($host) != gethostname()) { + die("skip LOAD DATA LOCAL INFILE will fail if connecting to remote MySQL"); + } +} ?> --INI-- safe_mode=0 |
