]> granicus.if.org Git - php/commitdiff
@- OCIResult() could return garbage if called on empty result-sets. (thies)
authorThies C. Arntzen <thies@php.net>
Thu, 12 Sep 2002 09:48:03 +0000 (09:48 +0000)
committerThies C. Arntzen <thies@php.net>
Thu, 12 Sep 2002 09:48:03 +0000 (09:48 +0000)
# fix #19364

ext/oci8/oci8.c
ext/oci8/php_oci8.h

index ac29732286ce72a111794d0c4e42b27c68c85a5b..54deffb198d0f2b6248fc2426cf6f8f1251e03d5 100644 (file)
@@ -1244,7 +1244,7 @@ _oci_make_zval(zval *value,oci_statement *statement,oci_out_column *column, char
                        oci_debug("_oci_make_zval: %16s,retlen = %4d,retlen4 = %d,storage_size4 = %4d,indicator %4d, retcode = %4d",
                                          column->name,column->retlen,column->retlen4,column->storage_size4,column->indicator,column->retcode);
        
-       if (column->indicator == -1) { /* column is NULL */
+       if ((! statement->has_data) || (column->indicator == -1)) { /* column is NULL or statment has no current data */
                ZVAL_NULL(value); 
                return 0;
        }
@@ -1392,7 +1392,9 @@ static oci_statement *oci_parse(oci_connection *connection, char *query, int len
        if (query) {
                statement->last_query = estrdup(query);
        }
+
        statement->conn = connection;
+       statement->has_data = 0;
 
        statement->id = zend_list_insert(statement,le_stmt);
 
@@ -1769,6 +1771,7 @@ oci_fetch(oci_statement *statement, ub4 nrows, char *func TSRMLS_DC)
                }
 
                statement->error = 0; /* OCI_NO_DATA is NO error for us!!! */
+               statement->has_data = 0;
 
                return 0;
        }
@@ -1828,12 +1831,16 @@ oci_fetch(oci_statement *statement, ub4 nrows, char *func TSRMLS_DC)
                        _oci_make_zval(column->define->zval,statement,column,"OCIFetch",0 TSRMLS_CC);
                }
 
+               statement->has_data = 1;
+
                return 1;
        }
 
        oci_error(statement->pError, func, statement->error);
        oci_handle_error(statement->conn, statement->error);
 
+       statement->has_data = 0;
+
        return 0;
 }
 
index 07fdc8e9dc359ed0356d24bc5721f077723d2656..65d5e1220f9a89ac31649f005baa32d04b5a44e7 100644 (file)
@@ -119,6 +119,7 @@ typedef struct {
        HashTable *defines;
        int ncolumns;
        int executed;
+       int has_data;
        ub2 stmttype;
 } oci_statement;