summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2014-06-23 19:34:23 +0800
committerXinchen Hui <laruence@php.net>2014-06-23 19:34:55 +0800
commit56a966e88a98bf04b2cd253b9b18136c0cc4028b (patch)
treeb676c55d97100d30ea965eeb1bdf812898e757d3
parent92a708989380bfb5d5da00665895025398bdbc91 (diff)
downloadphp-git-56a966e88a98bf04b2cd253b9b18136c0cc4028b.tar.gz
Respect the origin behavior (fix one test: ext/pdo_mysql/tests/bug_33689.phpt)
-rw-r--r--ext/mysql/php_mysql.c2
-rw-r--r--ext/mysqli/mysqli_api.c2
-rw-r--r--ext/mysqlnd/mysqlnd_result_meta.c8
-rw-r--r--ext/mysqlnd/mysqlnd_wireprotocol.c4
4 files changed, 9 insertions, 7 deletions
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index db02c24f9a..cbef4e6960 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -2426,7 +2426,7 @@ PHP_FUNCTION(mysql_fetch_field)
#if MYSQL_USE_MYSQLND
add_property_str(return_value, "name", STR_COPY(mysql_field->name));
add_property_str(return_value, "table", STR_COPY(mysql_field->table));
- add_property_str(return_value, "def", STR_COPY(mysql_field->def));
+ add_property_str(return_value, "def", mysql_field->def? STR_COPY(mysql_field->def) : STR_EMPTY_ALLOC());
#else
add_property_string(return_value, "name", (mysql_field->name?mysql_field->name:""));
add_property_string(return_value, "table", (mysql_field->table?mysql_field->table:""));
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index c70971cc82..dab3cd73a2 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -1153,7 +1153,7 @@ static void php_add_field_properties(zval *value, const MYSQL_FIELD *field TSRML
add_property_str(value, "orgname", STR_COPY(field->org_name));
add_property_str(value, "table", STR_COPY(field->table));
add_property_str(value, "orgtable", STR_COPY(field->org_table));
- add_property_str(value, "def", STR_COPY(field->def));
+ add_property_str(value, "def", field->def? STR_COPY(field->def) : STR_EMPTY_ALLOC());
add_property_str(value, "db", STR_COPY(field->db));
#else
add_property_string(value, "name",(field->name ? field->name : ""));
diff --git a/ext/mysqlnd/mysqlnd_result_meta.c b/ext/mysqlnd/mysqlnd_result_meta.c
index 088f52c454..c3906ed8a6 100644
--- a/ext/mysqlnd/mysqlnd_result_meta.c
+++ b/ext/mysqlnd/mysqlnd_result_meta.c
@@ -33,7 +33,9 @@ static void
php_mysqlnd_free_field_metadata(MYSQLND_FIELD *meta, zend_bool persistent TSRMLS_DC)
{
if (meta) {
- STR_RELEASE(meta->def);
+ if (meta->def) {
+ STR_RELEASE(meta->def);
+ }
STR_RELEASE(meta->name);
STR_RELEASE(meta->org_name);
STR_RELEASE(meta->table);
@@ -262,7 +264,9 @@ MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * co
new_fields[i].org_table = STR_DUP(orig_fields[i].org_table, persistent);
new_fields[i].db = STR_DUP(orig_fields[i].db, persistent);
new_fields[i].catalog = STR_DUP(orig_fields[i].catalog, persistent);
- new_fields[i].def = STR_DUP(orig_fields[i].def, persistent);
+ if (orig_fields[i].def) {
+ new_fields[i].def = STR_DUP(orig_fields[i].def, persistent);
+ }
}
new_meta->current_field = 0;
new_meta->field_count = meta->field_count;
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
index 7931d6d0c6..8cdd712f0b 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
@@ -1328,9 +1328,7 @@ php_mysqlnd_rset_field_read(void * _packet, MYSQLND_CONN_DATA * conn TSRMLS_DC)
DBG_INF_FMT("Def found, length %lu, persistent=%u", len, packet->persistent_alloc);
meta->def = STR_INIT((char *)p, len, packet->persistent_alloc);
p += len;
- } else {
- meta->def = STR_EMPTY_ALLOC();
- }
+ }
DBG_INF_FMT("allocing root. persistent=%u", packet->persistent_alloc);