]> granicus.if.org Git - php/commitdiff
Respect the origin behavior (fix one test: ext/pdo_mysql/tests/bug_33689.phpt)
authorXinchen Hui <laruence@php.net>
Mon, 23 Jun 2014 11:34:23 +0000 (19:34 +0800)
committerXinchen Hui <laruence@php.net>
Mon, 23 Jun 2014 11:34:55 +0000 (19:34 +0800)
ext/mysql/php_mysql.c
ext/mysqli/mysqli_api.c
ext/mysqlnd/mysqlnd_result_meta.c
ext/mysqlnd/mysqlnd_wireprotocol.c

index db02c24f9aaf4c5b10961711e87f627710a5c0b9..cbef4e6960402e9f0bbc5103bdf0c87ad8d2e786 100644 (file)
@@ -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:""));
index c70971cc82a0a43701666c6c1c30d9d3efd8544b..dab3cd73a2201611078ab3cba082e65d3a9d40a0 100644 (file)
@@ -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 : ""));
index 088f52c4548e385789c972b78e91edfe40054848..c3906ed8a68e26a4017b505b1940e438cabdbddb 100644 (file)
@@ -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;
index 7931d6d0c6f23f65c80e09ec1628f780f55d88a0..8cdd712f0b913a0267b9b87fb52c5195b62ed90e 100644 (file)
@@ -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);