diff options
author | Andrey Hristov <andrey@php.net> | 2014-03-19 18:54:39 +0200 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2014-03-19 18:54:39 +0200 |
commit | 01c2ec03bcbb03dba378ad4606561c3c147b7ad5 (patch) | |
tree | 633a3b011501e0294016aff8be3c8d71512c07ee /ext/mysqli/mysqli_api.c | |
parent | d613b0acc2969512da55cdc6649879cfa489f668 (diff) | |
parent | d63ed101ee7bb632c54504b1278c79414a75a792 (diff) | |
download | php-git-01c2ec03bcbb03dba378ad4606561c3c147b7ad5.tar.gz |
Merge branch 'PHP-5.5' into PHP-5.6
Conflicts:
NEWS
configure.in
ext/mysqli/mysqli_api.c
main/php_version.h
Diffstat (limited to 'ext/mysqli/mysqli_api.c')
-rw-r--r-- | ext/mysqli/mysqli_api.c | 155 |
1 files changed, 97 insertions, 58 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 53639a0670..15fcaae6f3 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -34,63 +34,6 @@ #include "php_mysqli_structs.h" #include "mysqli_priv.h" -#if !defined(MYSQLI_USE_MYSQLND) -/* {{{ mysqli_tx_cor_options_to_string */ -static void mysqli_tx_cor_options_to_string(const MYSQL * const conn, smart_str * str, const unsigned int mode) -{ - if (mode & TRANS_COR_AND_CHAIN && !(mode & TRANS_COR_AND_NO_CHAIN)) { - if (str->len) { - smart_str_appendl(str, ", ", sizeof(", ") - 1); - } - smart_str_appendl(str, "AND CHAIN", sizeof("AND CHAIN") - 1); - } else if (mode & TRANS_COR_AND_NO_CHAIN && !(mode & TRANS_COR_AND_CHAIN)) { - if (str->len) { - smart_str_appendl(str, ", ", sizeof(", ") - 1); - } - smart_str_appendl(str, "AND NO CHAIN", sizeof("AND NO CHAIN") - 1); - } - - if (mode & TRANS_COR_RELEASE && !(mode & TRANS_COR_NO_RELEASE)) { - if (str->len) { - smart_str_appendl(str, ", ", sizeof(", ") - 1); - } - smart_str_appendl(str, "RELEASE", sizeof("RELEASE") - 1); - } else if (mode & TRANS_COR_NO_RELEASE && !(mode & TRANS_COR_RELEASE)) { - if (str->len) { - smart_str_appendl(str, ", ", sizeof(", ") - 1); - } - smart_str_appendl(str, "NO RELEASE", sizeof("NO RELEASE") - 1); - } - smart_str_0(str); -} -/* }}} */ - - -/* {{{ proto bool mysqli_commit_or_rollback_libmysql */ -static int mysqli_commit_or_rollback_libmysql(MYSQL * conn, zend_bool commit, const unsigned int mode, const char * const name) -{ - int ret; - smart_str tmp_str = {0, 0, 0}; - mysqli_tx_cor_options_to_string(conn, &tmp_str, mode); - smart_str_0(&tmp_str); - - { - char * commented_name = NULL; - unsigned int commented_name_len = name? spprintf(&commented_name, 0, " /*%s*/", name):0; - char * query; - unsigned int query_len = spprintf(&query, 0, (commit? "COMMIT%s %s":"ROLLBACK%s %s"), - commented_name? commented_name:"", tmp_str.c? tmp_str.c:""); - smart_str_free(&tmp_str); - - ret = mysql_real_query(conn, query, query_len); - efree(query); - if (commented_name) { - efree(commented_name); - } - } -} -/* }}} */ -#endif /* {{{ proto mixed mysqli_affected_rows(object link) Get number of affected rows in previous MySQL operation */ @@ -704,7 +647,103 @@ PHP_FUNCTION(mysqli_close) } /* }}} */ -/* {{{ proto bool mysqli_commit(object link) + +#if !defined(MYSQLI_USE_MYSQLND) +/* {{{ mysqli_tx_cor_options_to_string */ +static void mysqli_tx_cor_options_to_string(const MYSQL * const conn, smart_str * str, const unsigned int mode) +{ + if (mode & TRANS_COR_AND_CHAIN && !(mode & TRANS_COR_AND_NO_CHAIN)) { + if (str->len) { + smart_str_appendl(str, " ", sizeof(" ") - 1); + } + smart_str_appendl(str, "AND CHAIN", sizeof("AND CHAIN") - 1); + } else if (mode & TRANS_COR_AND_NO_CHAIN && !(mode & TRANS_COR_AND_CHAIN)) { + if (str->len) { + smart_str_appendl(str, " ", sizeof(" ") - 1); + } + smart_str_appendl(str, "AND NO CHAIN", sizeof("AND NO CHAIN") - 1); + } + + if (mode & TRANS_COR_RELEASE && !(mode & TRANS_COR_NO_RELEASE)) { + if (str->len) { + smart_str_appendl(str, " ", sizeof(" ") - 1); + } + smart_str_appendl(str, "RELEASE", sizeof("RELEASE") - 1); + } else if (mode & TRANS_COR_NO_RELEASE && !(mode & TRANS_COR_RELEASE)) { + if (str->len) { + smart_str_appendl(str, " ", sizeof(" ") - 1); + } + smart_str_appendl(str, "NO RELEASE", sizeof("NO RELEASE") - 1); + } + smart_str_0(str); +} +/* }}} */ + + + +/* {{{ proto bool mysqli_commit_or_rollback_libmysql */ +static int mysqli_commit_or_rollback_libmysql(MYSQL * conn, zend_bool commit, const unsigned int mode, const char * const name) +{ + int ret; + smart_str tmp_str = {0, 0, 0}; + mysqli_tx_cor_options_to_string(conn, &tmp_str, mode); + smart_str_0(&tmp_str); + + { + char * query; + char * name_esc = NULL; + size_t query_len; + + if (name) { + const char * p_orig = name; + char * p_copy; + p_copy = name_esc = emalloc(strlen(name) + 1 + 2 + 2 + 1); /* space, open, close, NullS */ + *p_copy++ = ' '; + *p_copy++ = '/'; + *p_copy++ = '*'; + while (1) { + register char v = *p_orig; + if (v == 0) { + break; + } + if ((v >= '0' && v <= '9') || + (v >= 'a' && v <= 'z') || + (v >= 'A' && v <= 'Z') || + v == '-' || + v == '_' || + v == ' ' || + v == '=') + { + *p_copy = v; + } else { + *p_copy = '?'; + } + ++p_orig; + ++p_copy; + } + *p_copy++ = '*'; + *p_copy++ = '/'; + *p_copy++ = 0; + } + + query_len = spprintf(&query, 0, (commit? "COMMIT%s %s":"ROLLBACK%s %s"), + name_esc? name_esc:"", tmp_str.c? tmp_str.c:""); + smart_str_free(&tmp_str); + if (name_esc) { + efree(name_esc); + name_esc = NULL; + } + + ret = mysql_real_query(conn, query, query_len); + efree(query); + } + return ret; +} +/* }}} */ +#endif + + +/* {{{ proto bool mysqli_commit(object link[, int flags [, string name ]]) Commit outstanding actions and close transaction */ PHP_FUNCTION(mysqli_commit) { |