Fixed bug #35248 (sqlite_query() doesnt set error_msg when return value is
authorIlia Alshanetsky <iliaa@php.net>
Thu, 17 Nov 2005 14:38:36 +0000 (14:38 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 17 Nov 2005 14:38:36 +0000 (14:38 +0000)
being used).

NEWS
ext/sqlite/sqlite.c
ext/sqlite/tests/bug35248.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 19e30e664166acc965497ec990904ed414b3b9a9..44b9b5e6763cfe4b9b666602f1b5ec787d65af7f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,18 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+17 Nov 2005, PHP 5.1 Release Candidate 6
+- Make zend_parse_params handle integers in a non-strict fashion, but emit an 
+  E_NOTICE on non well formed interger values. (Ilia)
+- Fixed bug #35249 (compile failure when ext/readline is compiled as shared).
+  (Jani)
+- Fixed bug #35248 (sqlite_query() doesnt set error_msg when return value is
+  being used). (Ilia) 
+- Fixed bug #35079 (stream_set_blocking(true) toggles, not enables 
+  blocking). (askalski at gmail dot com, Tony)
+
 16 Nov 2005, PHP 5.1 Release Candidate 5
+- Added an E_STRICT warning on the usage of {} for accessing of string offsets.
+  (Ilia)
 - Changed type hints to allow "null" as default value for class and array.
   (Marcus, Derick, Dmitry)
 - Fixed __get/__set to allow recursive calls for different properties. (Dmitry)
@@ -19,8 +31,6 @@ PHP                                                                        NEWS
 - Fixed bug #35142 (SOAP Client/Server Complex Object Support). (Dmitry)
 - Fixed bug #35135 (PDOStatment without related PDO object may crash). (Ilia)
 - Fixed bug #35091 (SoapClient leaks memory). (Dmitry)
-- Fixed bug #35079 (stream_set_blocking(true) toggles, not enables 
-  blocking). (askalski at gmail dot com, Tony)
 - Fixed bug #35078 (configure does not find ldap_start_tls_s). (Jani)
 - Fixed bugs #35022, #35019 (Regression in the behavior of key() and current()
   functions). (Ilia)
index 243ade6573600ca2873e9ace8fb632c38bb3d411..e1c12198553f3c46e258c99d2bd99e619fb9ac09 100644 (file)
@@ -1516,7 +1516,7 @@ next_row:
 /* }}} */
 
 /* {{{ sqlite_query */
-void sqlite_query(zval *object, struct php_sqlite_db *db, char *sql, long sql_len, int mode, int buffered, zval *return_value, struct php_sqlite_result **prres TSRMLS_DC)
+void sqlite_query(zval *object, struct php_sqlite_db *db, char *sql, long sql_len, int mode, int buffered, zval *return_value, struct php_sqlite_result **prres, zval *errmsg TSRMLS_DC)
 {
        struct php_sqlite_result res, *rres;
        int ret;
@@ -1532,6 +1532,9 @@ void sqlite_query(zval *object, struct php_sqlite_db *db, char *sql, long sql_le
 
        if (ret != SQLITE_OK) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errtext);
+               if (errmsg) {
+                       ZVAL_STRING(errmsg, errtext, 1);
+               }
                sqlite_freemem(errtext);
                goto terminate;
        } else if (!res.vm) { /* empty query */
@@ -1632,7 +1635,7 @@ PHP_FUNCTION(sqlite_unbuffered_query)
                return;
        }
 
-       sqlite_query(object, db, sql, sql_len, (int)mode, 0, return_value, NULL TSRMLS_CC);
+       sqlite_query(object, db, sql, sql_len, (int)mode, 0, return_value, NULL, errmsg TSRMLS_CC);
 }
 /* }}} */
 
@@ -1757,7 +1760,7 @@ PHP_FUNCTION(sqlite_query)
                return;
        }
 
-       sqlite_query(object, db, sql, sql_len, (int)mode, 1, return_value, NULL TSRMLS_CC);
+       sqlite_query(object, db, sql, sql_len, (int)mode, 1, return_value, NULL, errmsg TSRMLS_CC);
 }
 /* }}} */
 
@@ -2168,7 +2171,7 @@ PHP_FUNCTION(sqlite_array_query)
        }
        
        rres = (struct php_sqlite_result *)emalloc(sizeof(*rres));
-       sqlite_query(NULL, db, sql, sql_len, (int)mode, 0, NULL, &rres TSRMLS_CC);
+       sqlite_query(NULL, db, sql, sql_len, (int)mode, 0, NULL, &rres, NULL TSRMLS_CC);
        if (db->last_err_code != SQLITE_OK) {
                if (rres) {
                        efree(rres);
@@ -2284,7 +2287,7 @@ PHP_FUNCTION(sqlite_single_query)
        }
 
        rres = (struct php_sqlite_result *)emalloc(sizeof(*rres));
-       sqlite_query(NULL, db, sql, sql_len, PHPSQLITE_NUM, 0, NULL, &rres TSRMLS_CC);
+       sqlite_query(NULL, db, sql, sql_len, PHPSQLITE_NUM, 0, NULL, &rres, NULL TSRMLS_CC);
        if (db->last_err_code != SQLITE_OK) {
                if (rres) {
                        efree(rres);
diff --git a/ext/sqlite/tests/bug35248.phpt b/ext/sqlite/tests/bug35248.phpt
new file mode 100644 (file)
index 0000000..4898a41
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Bug #35248 (sqlite_query does not return parse error message)
+--SKIPIF--
+<?php if (!extension_loaded("sqlite")) print "skip"; ?>
+--FILE--
+<?php
+       $db = sqlite_open(":memory:");
+       $res = @sqlite_query($db, "asdfesdfa", SQLITE_NUM, $err);
+       var_dump($err);
+       $res = @sqlite_unbuffered_query($db, "asdfesdfa", SQLITE_NUM, $err);
+       var_dump($err);
+?>
+--EXPECT--
+string(30) "near "asdfesdfa": syntax error"
+string(30) "near "asdfesdfa": syntax error"