diff options
author | Johannes Schlüter <johannes@php.net> | 2009-01-22 21:01:58 +0000 |
---|---|---|
committer | Johannes Schlüter <johannes@php.net> | 2009-01-22 21:01:58 +0000 |
commit | 074b08485201dc3af205a76ea609d53050ec8229 (patch) | |
tree | 0aba3e9a330c2a1d592127e3e27f8ce6de57939a | |
parent | 20b20bbdb32a872b25eab67b7f474d3724ebc054 (diff) | |
download | php-git-074b08485201dc3af205a76ea609d53050ec8229.tar.gz |
MFH: export mysql_refresh
[DOC] This makes mysql_refresh() as described in
http://dev.mysql.com/doc/refman/6.0/en/mysql-refresh.html
available as mysqli_Refresh() and mysqli->refresh()
MYSQLI_REFRESH_BACKUP_LOG is only available when linking libmysql 6.0
or mysqlnd
-rw-r--r-- | ext/mysqli/mysqli.c | 12 | ||||
-rw-r--r-- | ext/mysqli/mysqli_api.c | 16 | ||||
-rw-r--r-- | ext/mysqli/mysqli_fe.c | 3 | ||||
-rw-r--r-- | ext/mysqli/php_mysqli_structs.h | 1 | ||||
-rw-r--r-- | ext/mysqli/tests/mysqli_class_mysqli_interface.phpt | 1 | ||||
-rw-r--r-- | ext/mysqli/tests/mysqli_constants.phpt | 12 | ||||
-rw-r--r-- | ext/mysqli/tests/mysqli_poll.phpt | 24 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_enum_n_def.h | 9 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_libmysql_compat.h | 11 |
9 files changed, 77 insertions, 12 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 569dd640e3..da126faba5 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -862,6 +862,18 @@ PHP_MINIT_FUNCTION(mysqli) REGISTER_LONG_CONSTANT("MYSQLI_SERVER_QUERY_WAS_SLOW", SERVER_QUERY_WAS_SLOW, CONST_CS | CONST_PERSISTENT); #endif + REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_GRANT", REFRESH_GRANT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_LOG", REFRESH_LOG, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_TABLES", REFRESH_TABLES, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_HOSTS", REFRESH_HOSTS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_STATUS", REFRESH_STATUS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_THREADS", REFRESH_THREADS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_SLAVE", REFRESH_SLAVE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_MASTER", REFRESH_MASTER, CONST_CS | CONST_PERSISTENT); +#ifdef REFRESH_BACKUP_LOG + REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_BACKUP_LOG", REFRESH_BACKUP_LOG, CONST_CS | CONST_PERSISTENT); +#endif + return SUCCESS; } /* }}} */ diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 92a9690326..b7c7e8ea43 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -2068,6 +2068,22 @@ PHP_FUNCTION(mysqli_stat) } /* }}} */ + +/* {{{ proto bool mysqli_refresh(object link, long options) + Flush tables or caches, or reset replication server information */ +PHP_FUNCTION(mysqli_refresh) +{ + MY_MYSQL *mysql; + zval *mysql_link = NULL; + long options; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_link, mysqli_link_class_entry, &options) == FAILURE) { + return; + } + MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_INITIALIZED); + RETURN_BOOL(!mysql_refresh(mysql->mysql, options)); +} +/* }}} */ /* {{{ proto int mysqli_stmt_attr_set(object stmt, long attr, long mode) */ diff --git a/ext/mysqli/mysqli_fe.c b/ext/mysqli/mysqli_fe.c index c4724f4a36..e553cbf677 100644 --- a/ext/mysqli/mysqli_fe.c +++ b/ext/mysqli/mysqli_fe.c @@ -178,6 +178,8 @@ const zend_function_entry mysqli_functions[] = { PHP_FE(mysqli_use_result, NULL) PHP_FE(mysqli_warning_count, NULL) + PHP_FE(mysqli_refresh, NULL) + /* Aliases */ PHP_FALIAS(mysqli_bind_param, mysqli_stmt_bind_param, third_arg_force_by_ref_rest) PHP_FALIAS(mysqli_bind_result, mysqli_stmt_bind_result, second_arg_force_by_ref_rest) @@ -252,6 +254,7 @@ const zend_function_entry mysqli_link_methods[] = { PHP_FALIAS(store_result,mysqli_store_result,NULL) PHP_FALIAS(thread_safe,mysqli_thread_safe,NULL) PHP_FALIAS(use_result,mysqli_use_result,NULL) + PHP_FALIAS(refresh,mysqli_refresh,NULL) {NULL, NULL, NULL} }; /* }}} */ diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h index abca0470fc..3e077ed736 100644 --- a/ext/mysqli/php_mysqli_structs.h +++ b/ext/mysqli/php_mysqli_structs.h @@ -471,6 +471,7 @@ PHP_FUNCTION(mysqli_embedded_server_start); PHP_FUNCTION(mysqli_sqlstate); PHP_FUNCTION(mysqli_ssl_set); PHP_FUNCTION(mysqli_stat); +PHP_FUNCTION(mysqli_refresh); PHP_FUNCTION(mysqli_stmt_affected_rows); PHP_FUNCTION(mysqli_stmt_close); PHP_FUNCTION(mysqli_stmt_data_seek); diff --git a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt index 30ed9d074a..05c76e65dc 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt @@ -45,6 +45,7 @@ require_once('skipifconnectfailure.inc'); 'real_connect' => true, 'real_escape_string' => true, 'real_query' => true, + 'refresh' => true, 'rollback' => true, 'select_db' => true, 'set_charset' => true, diff --git a/ext/mysqli/tests/mysqli_constants.phpt b/ext/mysqli/tests/mysqli_constants.phpt index 471381ef6d..883be59593 100644 --- a/ext/mysqli/tests/mysqli_constants.phpt +++ b/ext/mysqli/tests/mysqli_constants.phpt @@ -84,6 +84,14 @@ require_once('skipifconnectfailure.inc'); "MYSQLI_REPORT_ERROR" => true, "MYSQLI_REPORT_OFF" => true, "MYSQLI_SET_CHARSET_NAME" => true, + "MYSQLI_REFRESH_GRANT" => true, + "MYSQLI_REFRESH_LOG" => true, + "MYSQLI_REFRESH_TABLES" => true, + "MYSQLI_REFRESH_HOSTS" => true, + "MYSQLI_REFRESH_STATUS" => true, + "MYSQLI_REFRESH_THREADS" => true, + "MYSQLI_REFRESH_SLAVE" => true, + "MYSQLI_REFRESH_MASTER" => true, ); /* depends on the build - experimental */ @@ -91,6 +99,10 @@ require_once('skipifconnectfailure.inc'); $expected_constants['MYSQLI_OPT_INT_AND_FLOAT_NATIVE'] = true; } + if ($IS_MYSQLND || defined('MYSQLI_REFRESH_BACKUP_LOG')) { + $expected_constants['MYSQLI_REFRESH_BACKUP_LOG'] = true; + } + if ($IS_MYSQLND) { $version = 50007 + 1; $expected_constants['MYSQLI_OPT_NET_CMD_BUFFER_SIZE'] = true; diff --git a/ext/mysqli/tests/mysqli_poll.phpt b/ext/mysqli/tests/mysqli_poll.phpt index fc0980544f..1bfae4bdbe 100644 --- a/ext/mysqli/tests/mysqli_poll.phpt +++ b/ext/mysqli/tests/mysqli_poll.phpt @@ -28,28 +28,28 @@ if (!$IS_MYSQLND) if (NULL !== ($tmp = @mysqli_poll())) printf("[002] Expecting NULL got %s\n", var_export($tmp, true)); - if (NULL !== ($tmp = @mysqli_poll(array($link)))) + $l = array($link); + if (NULL !== ($tmp = @mysqli_poll($l))) printf("[003] Expecting NULL got %s\n", var_export($tmp, true)); - if (NULL !== ($tmp = @mysqli_poll(array($link), NULL))) + $l = array($link); $n = NULL; + if (NULL !== ($tmp = @mysqli_poll($l, $n))) printf("[004] Expecting NULL got %s\n", var_export($tmp, true)); - if (NULL !== ($tmp = @mysqli_poll(array($link), NULL, NULL))) + $l = array($link); $n = NULL; + if (NULL !== ($tmp = @mysqli_poll($l, $n, $n))) printf("[005] Expecting NULL got %s\n", var_export($tmp, true)); - $int_val = 43; - $myerrors = &$int_val; - - if (NULL !== ($tmp = @mysqli_poll(array($link), $myerrors, NULL, 1))) - printf("[006] Expecting NULL got %s\n", var_export($tmp, true)); - - if (NULL !== ($tmp = @mysqli_poll(array($link), NULL, NULL, -1))) + $l = array($link); $e = NULL; $r = NULL; + if (NULL !== ($tmp = @mysqli_poll($l, $e, $r, -1))) printf("[007] Expecting boolean/false got %s/%s\n", gettype($tmp), var_export($tmp, true)); - if (NULL !== ($tmp = @mysqli_poll(array($link), NULL, NULL, 0, -1))) + $l = array($link); $e = NULL; $r = NULL; + if (NULL !== ($tmp = @mysqli_poll($l, $e, $r, 0, -1))) printf("[008] Expecting boolean/false got %s/%s\n", gettype($tmp), var_export($tmp, true)); - if (0 !== ($tmp = (mysqli_poll(array($link), array($link), array($link), 0, 1)))) + $read = $error = $reject = array($link); + if (0 !== ($tmp = (mysqli_poll($read, $error, $reject, 0, 1)))) printf("[009] Expecting int/0 got %s/%s\n", gettype($tmp), var_export($tmp, true)); diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h index 4fab45beb2..a1a1ae0eba 100644 --- a/ext/mysqlnd/mysqlnd_enum_n_def.h +++ b/ext/mysqlnd/mysqlnd_enum_n_def.h @@ -431,6 +431,15 @@ typedef enum mysqlnd_collected_stats #define MYSQLND_DEFAULT_PREFETCH_ROWS (ulong) 1 +#define MYSQLND_REFRESH_GRANT 1 /* Refresh grant tables */ +#define MYSQLND_REFRESH_LOG 2 /* Start on new log file */ +#define MYSQLND_REFRESH_TABLES 4 /* close all tables */ +#define MYSQLND_REFRESH_HOSTS 8 /* Flush host cache */ +#define MYSQLND_REFRESH_STATUS 16 /* Flush status variables */ +#define MYSQLND_REFRESH_THREADS 32 /* Flush thread cache */ +#define MYSQLND_REFRESH_SLAVE 64 /* Reset master info and restart slave */ +#define MYSQLND_REFRESH_MASTER 128 /* Remove all bin logs in the index */ +#define MYSQLND_REFRESH_BACKUP_LOG 0x200000L #endif /* MYSQLND_ENUM_N_DEF_H */ diff --git a/ext/mysqlnd/mysqlnd_libmysql_compat.h b/ext/mysqlnd/mysqlnd_libmysql_compat.h index acb55bb5d0..b23d2fd125 100644 --- a/ext/mysqlnd/mysqlnd_libmysql_compat.h +++ b/ext/mysqlnd/mysqlnd_libmysql_compat.h @@ -73,6 +73,7 @@ #define mysql_ping(r) mysqlnd_ping((r)) #define mysql_real_escape_string(r,a,b,c) mysqlnd_real_escape_string((r), (a), (b), (c)) #define mysql_real_query(r,a,b) mysqlnd_query((r), (a), (b)) +#define mysql_refresh(conn, options) mysqlnd_refresh((conn), (options)) #define mysql_rollback(r) mysqlnd_rollback((r)) #define mysql_select_db(r,a) mysqlnd_select_db((r), (a) ,strlen((a))) #define mysql_set_server_option(r,o) mysqlnd_set_server_option((r), (o)) @@ -118,4 +119,14 @@ #define mysql_warning_count(r) mysqlnd_warning_count((r)) #define mysql_eof(r) (((r)->unbuf && (r)->unbuf->eof_reached) || (r)->stored_data) +#define REFRESH_GRANT MYSQLND_REFRESH_GRANT +#define REFRESH_LOG MYSQLND_REFRESH_LOG +#define REFRESH_TABLES MYSQLND_REFRESH_TABLES +#define REFRESH_HOSTS MYSQLND_REFRESH_HOSTS +#define REFRESH_STATUS MYSQLND_REFRESH_STATUS +#define REFRESH_THREADS MYSQLND_REFRESH_THREADS +#define REFRESH_SLAVE MYSQLND_REFRESH_SLAVE +#define REFRESH_MASTER MYSQLND_REFRESH_MASTER +#define REFRESH_BACKUP_LOG MYSQLND_REFRESH_BACKUP_LOG + #endif /* MYSQLND_LIBMYSQL_COMPAT_H */ |