Merge branch 'phpng' of https://git.php.net/repository/php-src into phpng

Conflicts:
	ext/pdo_pgsql/tests/common.phpt
This commit is contained in:
Xinchen Hui 2014-05-20 15:50:41 +08:00
commit f2028491aa
12 changed files with 12 additions and 271 deletions

View file

@ -10,7 +10,6 @@ if (PHP_MYSQLND != "no") {
"mysqlnd_alloc.c " +
"mysqlnd_auth.c " +
"mysqlnd_block_alloc.c " +
"mysqlnd_bt.c " +
"mysqlnd_charset.c " +
"mysqlnd_debug.c " +
"mysqlnd_driver.c " +

View file

@ -18,7 +18,7 @@ fi
dnl If some extension uses mysqlnd it will get compiled in PHP core
if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
mysqlnd_ps_sources="mysqlnd_ps.c mysqlnd_ps_codec.c"
mysqlnd_base_sources="mysqlnd.c mysqlnd_alloc.c mysqlnd_bt.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
mysqlnd_base_sources="mysqlnd.c mysqlnd_alloc.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
mysqlnd_loaddata.c mysqlnd_reverse_api.c mysqlnd_net.c \
mysqlnd_statistics.c mysqlnd_driver.c mysqlnd_ext_plugin.c mysqlnd_auth.c \
mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c\

View file

@ -1,241 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2014 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 |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Georg Richter <georg@mysql.com> |
| Andrey Hristov <andrey@mysql.com> |
| Ulf Wendel <uwendel@mysql.com> |
+----------------------------------------------------------------------+
*/
/* $Id: mysqlnd_debug.c 309303 2011-03-16 12:42:59Z andrey $ */
#include "php.h"
#include "Zend/zend_builtin_functions.h"
/* Follows code borrowed from zend_builtin_functions.c because the functions there are static */
/* {{{ gettraceasstring() macros */
#define TRACE_APPEND_CHR(chr) \
*str = (char*)erealloc(*str, *len + 1 + 1); \
(*str)[(*len)++] = chr
#define TRACE_APPEND_STRL(val, vallen) \
{ \
int l = vallen; \
*str = (char*)erealloc(*str, *len + l + 1); \
memcpy((*str) + *len, val, l); \
*len += l; \
}
#define TRACE_APPEND_STR(val) \
TRACE_APPEND_STRL(val, sizeof(val)-1)
inline void trace_append_key(HashTable *ht, const char *key) {
zval *ztmp;
if ((ztmp = zend_hash_str_find(ht, key, sizeof(key))) != NULL) {
TRACE_APPEND_STRL(Z_STRVAL_P(ztmp)->val, Z_STRVAL_P(ztmp)->len);
}
}
/* }}} */
static int
mysqlnd_build_trace_args(zval *arg TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
char **str;
int *len;
str = va_arg(args, char**);
len = va_arg(args, int*);
/* the trivial way would be to do:
* conver_to_string_ex(arg);
* append it and kill the now tmp arg.
* but that could cause some E_NOTICE and also damn long lines.
*/
switch (Z_TYPE_P(arg)) {
case IS_NULL:
TRACE_APPEND_STR("NULL, ");
break;
case IS_STRING: {
int l_added;
TRACE_APPEND_CHR('\'');
if (Z_STRLEN_P(arg) > 15) {
TRACE_APPEND_STRL(Z_STRVAL_P(arg), 15);
TRACE_APPEND_STR("...', ");
l_added = 15 + 6 + 1; /* +1 because of while (--l_added) */
} else {
l_added = Z_STRLEN_P(arg);
TRACE_APPEND_STRL(Z_STRVAL_P(arg), l_added);
TRACE_APPEND_STR("', ");
l_added += 3 + 1;
}
while (--l_added) {
if ((*str)[*len - l_added] < 32) {
(*str)[*len - l_added] = '?';
}
}
break;
}
case IS_TRUE:
TRACE_APPEND_STR("true, ");
break;
case IS_FALSE:
TRACE_APPEND_STR("false, ");
break;
case IS_RESOURCE:
TRACE_APPEND_STR("Resource id #");
/* break; */
case IS_LONG: {
long lval = Z_LVAL_P(arg);
char s_tmp[MAX_LENGTH_OF_LONG + 1];
int l_tmp = zend_sprintf(s_tmp, "%ld", lval); /* SAFE */
TRACE_APPEND_STRL(s_tmp, l_tmp);
TRACE_APPEND_STR(", ");
break;
}
case IS_DOUBLE: {
double dval = Z_DVAL_P(arg);
char *s_tmp;
int l_tmp;
s_tmp = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
l_tmp = zend_sprintf(s_tmp, "%.*G", (int) EG(precision), dval); /* SAFE */
TRACE_APPEND_STRL(s_tmp, l_tmp);
/* %G already handles removing trailing zeros from the fractional part, yay */
efree(s_tmp);
TRACE_APPEND_STR(", ");
break;
}
case IS_ARRAY:
TRACE_APPEND_STR("Array, ");
break;
case IS_OBJECT: {
zend_string *class_name;
/* see #67299, may be removed now */
int dupl = 0;
TRACE_APPEND_STR("Object(");
class_name = zend_get_object_classname(Z_OBJ_P(arg) TSRMLS_CC);
TRACE_APPEND_STRL(class_name->val, class_name->len);
if (!dupl) {
efree(class_name);
}
TRACE_APPEND_STR("), ");
break;
}
default:
break;
}
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
static int
mysqlnd_build_trace_string(zval *frame TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
char *s_tmp, **str;
int *len, *num;
long line;
HashTable *ht = Z_ARRVAL_P(frame);
zval *zfile, *tmp, *zline;
uint * level;
level = va_arg(args, uint *);
str = va_arg(args, char**);
len = va_arg(args, int*);
num = va_arg(args, int*);
if (!*level) {
return ZEND_HASH_APPLY_KEEP;
}
--*level;
s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 1 + 1);
sprintf(s_tmp, "#%d ", (*num)++);
TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
efree(s_tmp);
if ((zfile = zend_hash_str_find(ht, "file", sizeof("file"))) != NULL) {
if ((zline = zend_hash_str_find(ht, "line", sizeof("line"))) != NULL) {
line = Z_LVAL_P(zline);
} else {
line = 0;
}
s_tmp = emalloc(Z_STRLEN_P(zfile) + MAX_LENGTH_OF_LONG + 4 + 1);
sprintf(s_tmp, "%s(%ld): ", Z_STR_P(zfile)->val, line);
TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
efree(s_tmp);
} else {
TRACE_APPEND_STR("[internal function]: ");
}
trace_append_key(ht, "class");
trace_append_key(ht, "type");
trace_append_key(ht, "function");
TRACE_APPEND_CHR('(');
if (zend_hash_find(ht, "args", sizeof("args"), (void**)&tmp) == SUCCESS) {
int last_len = *len;
zend_hash_apply_with_arguments(Z_ARRVAL_P(tmp) TSRMLS_CC, (apply_func_args_t)mysqlnd_build_trace_args, 2, str, len);
if (last_len != *len) {
*len -= 2; /* remove last ', ' */
}
}
TRACE_APPEND_STR(")\n");
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
PHPAPI char *
mysqlnd_get_backtrace(uint max_levels, size_t * length TSRMLS_DC)
{
zval *trace;
char *res = estrdup(""), **str = &res, *s_tmp;
int res_len = 0, *len = &res_len, num = 0;
if (max_levels == 0) {
max_levels = 99999;
}
MAKE_STD_ZVAL(trace);
zend_fetch_debug_backtrace(trace, 0, 0, 0 TSRMLS_CC);
zend_hash_apply_with_arguments(Z_ARRVAL_P(trace) TSRMLS_CC, (apply_func_args_t)mysqlnd_build_trace_string, 4, &max_levels, str, len, &num);
zval_ptr_dtor(&trace);
if (max_levels) {
s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 7 + 1);
sprintf(s_tmp, "#%d {main}", num);
TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
efree(s_tmp);
}
res[res_len] = '\0';
*length = res_len;
return res;
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/

View file

@ -792,7 +792,6 @@ static struct st_mysqlnd_plugin_trace_log mysqlnd_plugin_trace_log_plugin =
},
{/* methods */
mysqlnd_debug_init,
mysqlnd_get_backtrace
}
};

View file

@ -66,7 +66,6 @@ struct st_mysqlnd_plugin_trace_log
struct
{
MYSQLND_DEBUG * (*trace_instance_init)(const char * skip_functions[] TSRMLS_DC);
char * (*get_backtrace)(uint max_levels, size_t * length TSRMLS_DC);
} methods;
};
@ -74,7 +73,6 @@ void mysqlnd_debug_trace_plugin_register(TSRMLS_D);
PHPAPI MYSQLND_DEBUG * mysqlnd_debug_init(const char * skip_functions[] TSRMLS_DC);
PHPAPI char * mysqlnd_get_backtrace(uint max_levels, size_t * length TSRMLS_DC);
#if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1400))
#ifdef PHP_WIN32

View file

@ -630,8 +630,6 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s
stmt->state = MYSQLND_STMT_INITTED;
}
} else {
unsigned int to_log = MYSQLND_G(log_mask);
to_log &= fields_eof->server_status;
DBG_INF_FMT("warnings=%u server_status=%u", fields_eof->warning_count, fields_eof->server_status);
conn->upsert_status->warning_count = fields_eof->warning_count;
/*
@ -649,13 +647,6 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s
} else if (fields_eof->server_status & SERVER_QUERY_WAS_SLOW) {
statistic = STAT_QUERY_WAS_SLOW;
}
if (to_log) {
#if A0
char *backtrace = mysqlnd_get_backtrace(TSRMLS_C);
php_log_err(backtrace TSRMLS_CC);
efree(backtrace);
#endif
}
MYSQLND_INC_CONN_STATISTIC(conn->stats, statistic);
}
} while (0);

View file

@ -404,7 +404,9 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
/* ensure that we free any previous unfetched results */
#ifndef PDO_USE_MYSQLND
if (S->stmt) {
stmt->column_count = (int)mysql_num_fields(S->result);
if (S->result) {
stmt->column_count = (int)mysql_num_fields(S->result);
}
mysql_stmt_free_result(S->stmt);
}
#endif

View file

@ -102,5 +102,4 @@ require dirname(__FILE__) . '/mysql_pdo_test.inc';
MySQLPDOTest::dropTestTable();
?>
--EXPECTF--
[001] Call to PDO::setAttribute(int attribute, mixed value) has changed the type of value from integer to boolean, test will not work properly
done!
done!

View file

@ -18,7 +18,7 @@ if (false !== getenv('PDO_PGSQL_TEST_DSN')) {
$config['ENV']['PDOTEST_ATTR'] = getenv('PDO_PGSQL_TEST_ATTR');
}
} else {
$config['ENV']['PDOTEST_DSN'] = 'pgsql:host=localhost port=5432 dbname=test user=postgres password=postgres';
$config['ENV']['PDOTEST_DSN'] = 'pgsql:host=localhost port=5432 dbname=test user= password=';
}
return $config;

View file

@ -3036,7 +3036,7 @@ PHP_FUNCTION(pg_free_result)
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
if (Z_LVAL_P(result) == 0) {
if (Z_RES_P(result) == NULL) {
RETURN_FALSE;
}
zend_list_close(Z_RES_P(result));
@ -5787,7 +5787,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
}
convert_to_boolean(is_enum);
if (Z_LVAL_P(is_enum)) {
if (Z_TYPE_P(is_enum) == IS_TRUE) {
/* enums need to be treated like strings */
data_type = PG_TEXT;
} else {

View file

@ -712,15 +712,8 @@ PHP_METHOD(Phar, webPhar)
switch (Z_TYPE(retval)) {
case IS_STRING:
efree(entry);
if (fci.retval != &retval) {
entry = estrndup(Z_STRVAL_P(fci.retval), Z_STRLEN_P(fci.retval));
entry_len = Z_STRLEN_P(fci.retval);
} else {
entry = Z_STRVAL(retval);
entry_len = Z_STRLEN(retval);
}
entry = estrndup(Z_STRVAL_P(fci.retval), Z_STRLEN_P(fci.retval));
entry_len = Z_STRLEN_P(fci.retval);
break;
case IS_TRUE:
case IS_FALSE:
@ -3832,7 +3825,6 @@ PHP_METHOD(Phar, addFile)
php_stream_to_zval(resource, &zresource);
phar_add_file(&(phar_obj->archive), fname, fname_len, NULL, 0, &zresource TSRMLS_CC);
zval_ptr_dtor(&zresource);
php_stream_close(resource);
}
/* }}} */

View file

@ -281,7 +281,9 @@ static void destroy_server_data(xmlrpc_server_data *server TSRMLS_DC)
static void xmlrpc_server_destructor(zend_resource *rsrc TSRMLS_DC)
{
if (rsrc && rsrc->ptr) {
rsrc->gc.refcount++;
destroy_server_data((xmlrpc_server_data*) rsrc->ptr TSRMLS_CC);
rsrc->gc.refcount--;
}
}