Commit: 43ecd8fe1b307945df0e45ed14cab4be8aacdedb Author: Andrey Hristov <and...@php.net> Fri, 8 Feb 2013 18:09:50 +0100 Parents: 0da369ae5048185f8e5e26e0e89191de09da22cb Branches: PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=43ecd8fe1b307945df0e45ed14cab4be8aacdedb Log: mysqli_savepoint()/mysqli_release_savepoint() Changed paths: M ext/mysqli/mysqli_api.c M ext/mysqli/mysqli_fe.c M ext/mysqli/mysqli_fe.h M ext/mysqli/mysqli_nonapi.c M ext/mysqli/tests/mysqli_class_mysqli_interface.phpt Diff: diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 760ee3c..3d651fc 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -714,7 +714,7 @@ PHP_FUNCTION(mysqli_commit) #if !defined(MYSQLI_USE_MYSQLND) if (mysqli_commit_or_rollback_libmysql(mysql->mysql, TRUE, flags, name)) { #else - if (mysqlnd_commit(mysql->mysql, flags, name)) { + if (FAIL == mysqlnd_commit(mysql->mysql, flags, name)) { #endif RETURN_FALSE; } @@ -1960,7 +1960,7 @@ PHP_FUNCTION(mysqli_rollback) #if !defined(MYSQLI_USE_MYSQLND) if (mysqli_commit_or_rollback_libmysql(mysql->mysql, FALSE, flags, name)) { #else - if (mysqlnd_rollback(mysql->mysql, flags, name)) { + if (FAIL == mysqlnd_rollback(mysql->mysql, flags, name)) { #endif RETURN_FALSE; } diff --git a/ext/mysqli/mysqli_fe.c b/ext/mysqli/mysqli_fe.c index 411ab11..6f2e404 100644 --- a/ext/mysqli/mysqli_fe.c +++ b/ext/mysqli/mysqli_fe.c @@ -97,6 +97,24 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_begin_transaction, 0, 0, 0) ZEND_ARG_INFO(0, name) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_savepoint, 0, 0, 2) + MYSQLI_ZEND_ARG_OBJ_INFO_LINK() + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_savepoint, 0, 0, 1) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_release_savepoint, 0, 0, 2) + MYSQLI_ZEND_ARG_OBJ_INFO_LINK() + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_release_savepoint, 0, 0, 1) + ZEND_ARG_INFO(0, name) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_commit, 0, 0, 1) MYSQLI_ZEND_ARG_OBJ_INFO_LINK() ZEND_ARG_INFO(0, flags) @@ -430,7 +448,9 @@ const zend_function_entry mysqli_functions[] = { #if defined(MYSQLI_USE_MYSQLND) PHP_FE(mysqli_reap_async_query, arginfo_mysqli_only_link) #endif + PHP_FE(mysqli_release_savepoint, arginfo_mysqli_release_savepoint) PHP_FE(mysqli_rollback, arginfo_mysqli_rollback) + PHP_FE(mysqli_savepoint, arginfo_mysqli_savepoint) PHP_FE(mysqli_select_db, arginfo_mysqli_select_db) #ifdef HAVE_MYSQLI_SET_CHARSET PHP_FE(mysqli_set_charset, arginfo_mysqli_set_charset) @@ -528,7 +548,9 @@ const zend_function_entry mysqli_link_methods[] = { #endif PHP_FALIAS(escape_string, mysqli_real_escape_string, arginfo_class_mysqli_real_escape_string) PHP_FALIAS(real_query, mysqli_real_query, arginfo_class_mysqli_query) + PHP_FALIAS(release_savepoint, mysqli_release_savepoint, arginfo_class_mysqli_release_savepoint) PHP_FALIAS(rollback, mysqli_rollback, arginfo_class_mysqli_rollback) + PHP_FALIAS(savepoint, mysqli_savepoint, arginfo_class_mysqli_savepoint) PHP_FALIAS(select_db,mysqli_select_db, arginfo_class_mysqli_select_db) #ifdef HAVE_MYSQLI_SET_CHARSET PHP_FALIAS(set_charset, mysqli_set_charset, arginfo_class_mysqli_set_charset) diff --git a/ext/mysqli/mysqli_fe.h b/ext/mysqli/mysqli_fe.h index e6cd3a6..7e447c6 100644 --- a/ext/mysqli/mysqli_fe.h +++ b/ext/mysqli/mysqli_fe.h @@ -108,6 +108,8 @@ PHP_FUNCTION(mysqli_sqlstate); PHP_FUNCTION(mysqli_ssl_set); PHP_FUNCTION(mysqli_stat); PHP_FUNCTION(mysqli_refresh); +PHP_FUNCTION(mysqli_savepoint); +PHP_FUNCTION(mysqli_release_savepoint); PHP_FUNCTION(mysqli_stmt_affected_rows); PHP_FUNCTION(mysqli_stmt_close); PHP_FUNCTION(mysqli_stmt_data_seek); diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index c08fbae..c3a56fc 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -1112,7 +1112,7 @@ PHP_FUNCTION(mysqli_begin_transaction) RETURN_FALSE; } #else - if (mysqlnd_begin_transaction(mysql->mysql, flags, name)) { + if (FAIL == mysqlnd_begin_transaction(mysql->mysql, flags, name)) { RETURN_FALSE; } #endif @@ -1121,6 +1121,75 @@ PHP_FUNCTION(mysqli_begin_transaction) /* }}} */ +#if !defined(MYSQLI_USE_MYSQLND) +/* {{{ proto bool mysqli_savepoint_libmysql */ +static int mysqli_savepoint_libmysql(MYSQL * conn, const char * const name, zend_bool release) +{ + int ret; + char * query; + unsigned int query_len = spprintf(&query, 0, release? "RELEASE SAVEPOINT `%s`":"SAVEPOINT `%s`", name); + ret = mysql_real_query(conn, query, query_len); + efree(query); + return ret; +} +/* }}} */ +#endif + + +/* {{{ proto bool mysqli_savepoint(object link, string name) + Starts a transaction */ +PHP_FUNCTION(mysqli_savepoint) +{ + MY_MYSQL *mysql; + zval *mysql_link; + char * name = NULL; + int name_len = 0; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &name, &name_len) == FAILURE) { + return; + } + MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); + +#if !defined(MYSQLI_USE_MYSQLND) + if (mysqli_savepoint_libmysql(mysql->mysql, name, FALSE)) { +#else + if (FAIL == mysqlnd_savepoint(mysql->mysql, name)) { +#endif + RETURN_FALSE; + } + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto bool mysqli_release_savepoint(object link, string name) + Starts a transaction */ +PHP_FUNCTION(mysqli_release_savepoint) +{ + MY_MYSQL *mysql; + zval *mysql_link; + char * name = NULL; + int name_len = 0; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &name, &name_len) == FAILURE) { + return; + } + MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); + if (!name || !name_len) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Savepoint name not provided"); + } +#if !defined(MYSQLI_USE_MYSQLND) + if (mysqli_savepoint_libmysql(mysql->mysql, name, TRUE)) { +#else + if (FAIL == mysqlnd_savepoint(mysql->mysql, name)) { +#endif + RETURN_FALSE; + } + RETURN_TRUE; +} +/* }}} */ + + /* * Local variables: * tab-width: 4 diff --git a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt index 44e9865..ea86c19 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt @@ -47,6 +47,8 @@ require_once('skipifconnectfailure.inc'); 'real_query' => true, 'refresh' => true, 'rollback' => true, + 'release_savepoint' => true, + 'savepoint' => true, 'select_db' => true, 'set_charset' => true, 'set_opt' => true, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php