com php-src: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport: Zend/zend _hash.c ext/mysqli/mysqli_api.c
ext/mysqli/mysqli _nonapi.c ext/mysqlnd/mysqlnd.c

From: Date: Sat, 22 Mar 2014 09:24:11 +0000
Subject: com php-src: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport: Zend/zend _hash.c ext/mysqli/mysqli_api.c
ext/mysqli/mysqli _nonapi.c ext/mysqlnd/mysqlnd.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-76575@lists.php.net to get a copy of this message
Commit: 69ae149b4fa148d7692a1069773b19841a0ad562 Author: Anatol Belski <ab@php.net> Sat, 22 Mar 2014 10:24:11 +0100 Parents: 10248d3b5abd74d55d4cb01b5714e76188debeb4 61103cc25c6df153eccbdc0e1baa6493d07660dc Branches: str_size_and_int64_56_backport Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=69ae149b4fa148d7692a1069773b19841a0ad562 Log: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport * origin/PHP-5.6: Revert "Add helper function for updating bucket contents" Rename+move zend_hash_apply_deleter and reuse it Make zend_hash_apply_deleter() void, to allow reuse Add helper function for updating bucket contents Remove unnecessary check Fixes after merge Emit a warning in case of unallowed characters. Fix another place this code is used - reuse add info: empty strings are interned don't replace with ?, just skip it Conflicts: Zend/zend_hash.c ext/mysqlnd/mysqlnd.c Changed paths: MM Zend/zend_hash.c MM ext/mysqli/mysqli_api.c MM ext/mysqli/mysqli_nonapi.c MM ext/mysqlnd/mysqlnd.c Diff: diff --cc Zend/zend_hash.c index 241431d,135d3c3..c296979 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@@ -141,9 -141,54 +141,54 @@@ ZEND_API zend_uint_t zend_hash_func(con static const Bucket *uninitialized_bucket = NULL; - ZEND_API int _zend_hash_init(HashTable *ht, zend_uint_t nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) + static zend_always_inline void i_zend_hash_bucket_delete(HashTable *ht, Bucket *p) + { + #ifdef ZEND_SIGNALS + TSRMLS_FETCH(); + #endif + + HANDLE_BLOCK_INTERRUPTIONS(); + if (p->pLast) { + p->pLast->pNext = p->pNext; + } else { + ht->arBuckets[p->h & ht->nTableMask] = p->pNext; + } + if (p->pNext) { + p->pNext->pLast = p->pLast; + } + if (p->pListLast != NULL) { + p->pListLast->pListNext = p->pListNext; + } else { + /* Deleting the head of the list */ + ht->pListHead = p->pListNext; + } + if (p->pListNext != NULL) { + p->pListNext->pListLast = p->pListLast; + } else { + /* Deleting the tail of the list */ + ht->pListTail = p->pListLast; + } + if (ht->pInternalPointer == p) { + ht->pInternalPointer = p->pListNext; + } + ht->nNumOfElements--; + if (ht->pDestructor) { + ht->pDestructor(p->pData); + } + if (p->pData != &p->pDataPtr) { + pefree(p->pData, ht->persistent); + } + pefree(p, ht->persistent); + HANDLE_UNBLOCK_INTERRUPTIONS(); + } + + static void zend_hash_bucket_delete(HashTable *ht, Bucket *p) { + i_zend_hash_bucket_delete(ht, p); + } + + ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) { - uint i = 3; + zend_uint_t i = 3; SET_INCONSISTENT(HT_OK); @@@ -434,13 -476,10 +476,10 @@@ ZEND_API int zend_hash_rehash(HashTabl return SUCCESS; } -ZEND_API int zend_hash_del_key_or_index(HashTable *ht, const char *arKey, uint nKeyLength, ulong h, int flag) +ZEND_API int zend_hash_del_key_or_index(HashTable *ht, const char *arKey, zend_size_t nKeyLength, zend_uint_t h, int flag) { - uint nIndex; + zend_uint_t nIndex; Bucket *p; - #ifdef ZEND_SIGNALS - TSRMLS_FETCH(); - #endif IS_CONSISTENT(ht); diff --cc ext/mysqlnd/mysqlnd.c index ce7b6c6,61be5ca..65b3941 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@@ -2677,9 -2677,52 +2677,52 @@@ MYSQLND_METHOD(mysqlnd_conn_data, tx_co /* }}} */ + /* {{{ mysqlnd_escape_string_for_tx_name_in_comment */ + static char * + mysqlnd_escape_string_for_tx_name_in_comment(const char * const name TSRMLS_DC) + { + char * ret = NULL; + DBG_ENTER("mysqlnd_escape_string_for_tx_name_in_comment"); + if (name) { + zend_bool warned = FALSE; + const char * p_orig = name; + char * p_copy; + p_copy = ret = mnd_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 if (warned == FALSE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Transaction name truncated. Must be only [0-9A-Za-z\\-_=]+"); + warned = TRUE; + } + ++p_orig; + } + *p_copy++ = '*'; + *p_copy++ = '/'; + *p_copy++ = 0; + } + DBG_RETURN(ret); + } + /* }}} */ + + /* {{{ mysqlnd_conn_data::tx_commit_ex */ static enum_func_status -MYSQLND_METHOD(mysqlnd_conn_data, tx_commit_or_rollback)(MYSQLND_CONN_DATA * conn, const zend_bool commit, const unsigned int flags, const char * const name TSRMLS_DC) +MYSQLND_METHOD(mysqlnd_conn_data, tx_commit_or_rollback)(MYSQLND_CONN_DATA * conn, const zend_bool commit, const php_uint_t flags, const char * const name TSRMLS_DC) { size_t this_func = STRUCT_OFFSET(struct st_mysqlnd_conn_data_methods, tx_commit_or_rollback); enum_func_status ret = FAIL; @@@ -2785,12 -2802,14 +2802,14 @@@ MYSQLND_METHOD(mysqlnd_conn_data, tx_be smart_str_0(&tmp_str); { - char * commented_name = NULL; - php_size_t commented_name_len = name? mnd_sprintf(&commented_name, 0, " /*%s*/", name):0; + char * name_esc = mysqlnd_escape_string_for_tx_name_in_comment(name TSRMLS_CC); char * query; - php_size_t query_len = mnd_sprintf(&query, 0, "START TRANSACTION%s %s", commented_name? commented_name:"", tmp_str.c? tmp_str.c:""); - unsigned int query_len = mnd_sprintf(&query, 0, "START TRANSACTION%s %s", name_esc? name_esc:"", tmp_str.c? tmp_str.c:""); ++ php_size_t query_len = mnd_sprintf(&query, 0, "START TRANSACTION%s %s", name_esc? name_esc:"", tmp_str.c? tmp_str.c:""); smart_str_free(&tmp_str); - + if (name_esc) { + mnd_efree(name_esc); + name_esc = NULL; + } if (!query) { SET_OOM_ERROR(*conn->error_info); break;

« previous php.cvs (#76575) next »