Browse Source

Fixed bug #35248 (sqlite_query() doesnt set error_msg when return value is

being used).
PHP-5.1
Ilia Alshanetsky 20 years ago
parent
commit
d734669230
  1. 14
      NEWS
  2. 13
      ext/sqlite/sqlite.c
  3. 15
      ext/sqlite/tests/bug35248.phpt

14
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)

13
ext/sqlite/sqlite.c

@ -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);

15
ext/sqlite/tests/bug35248.phpt

@ -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"
Loading…
Cancel
Save