[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
felipe Sun May 17 16:39:30 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: - Changed %s to %v on createAggregate() error message http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.42&r2=1.43&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.42 php-src/ext/sqlite3/sqlite3.c:1.43 --- php-src/ext/sqlite3/sqlite3.c:1.42 Fri May 8 07:58:12 2009 +++ php-src/ext/sqlite3/sqlite3.c Sun May 17 16:39:30 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.42 2009/05/08 07:58:12 tony2001 Exp $ */ +/* $Id: sqlite3.c,v 1.43 2009/05/17 16:39:30 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -920,14 +920,14 @@ } if (!zend_is_callable(step_callback, 0, &callback_name TSRMLS_CC)) { - php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name); + php_sqlite3_error(db_obj, "Not a valid callback function %v", Z_UNIVAL(callback_name)); zval_dtor(&callback_name); RETURN_FALSE; } zval_dtor(&callback_name); if (!zend_is_callable(fini_callback, 0, &callback_name TSRMLS_CC)) { - php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name); + php_sqlite3_error(db_obj, "Not a valid callback function %v", Z_UNIVAL(callback_name)); zval_dtor(&callback_name); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
tony2001Fri May 8 07:58:12 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: fix ZTS build http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.41&r2=1.42&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.41 php-src/ext/sqlite3/sqlite3.c:1.42 --- php-src/ext/sqlite3/sqlite3.c:1.41 Thu May 7 22:44:37 2009 +++ php-src/ext/sqlite3/sqlite3.c Fri May 8 07:58:12 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.41 2009/05/07 22:44:37 felipe Exp $ */ +/* $Id: sqlite3.c,v 1.42 2009/05/08 07:58:12 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -34,6 +34,7 @@ #include "zend_exceptions.h" #include "zend_interfaces.h" +#include "SAPI.h" ZEND_DECLARE_MODULE_GLOBALS(sqlite3) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
felipe Thu May 7 22:44:37 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: - Fix build http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.40&r2=1.41&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.40 php-src/ext/sqlite3/sqlite3.c:1.41 --- php-src/ext/sqlite3/sqlite3.c:1.40 Thu May 7 16:52:40 2009 +++ php-src/ext/sqlite3/sqlite3.c Thu May 7 22:44:37 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.40 2009/05/07 16:52:40 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.41 2009/05/07 22:44:37 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -28,6 +28,7 @@ #include "ext/standard/file.h" #include "php_sqlite3.h" #include "php_sqlite3_structs.h" +#include "main/SAPI.h" #include -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
scottmacThu May 7 16:52:40 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: MFB Print warning when using loadExtension on non cli, cgi and embeded http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.39&r2=1.40&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.39 php-src/ext/sqlite3/sqlite3.c:1.40 --- php-src/ext/sqlite3/sqlite3.c:1.39 Thu May 7 16:50:54 2009 +++ php-src/ext/sqlite3/sqlite3.c Thu May 7 16:52:40 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.39 2009/05/07 16:50:54 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.40 2009/05/07 16:52:40 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -324,6 +324,16 @@ return; } +#ifdef ZTS + if ((strncmp(sapi_module.name, "cgi", 3) != 0) && + (strcmp(sapi_module.name, "cli") != 0) && + (strncmp(sapi_module.name, "embed", 5) != 0) + ) { + php_sqlite3_error(db_obj, "Not supported in multithreaded Web servers"); + RETURN_FALSE; + } +#endif + if (!SQLITE3G(extension_dir)) { php_sqlite3_error(db_obj, "SQLite Extension are disabled"); RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
scottmacThu May 7 16:50:54 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: Some unicode updates for sqlite3 http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.38&r2=1.39&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.38 php-src/ext/sqlite3/sqlite3.c:1.39 --- php-src/ext/sqlite3/sqlite3.c:1.38 Mon Apr 27 18:15:54 2009 +++ php-src/ext/sqlite3/sqlite3.c Thu May 7 16:50:54 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.38 2009/04/27 18:15:54 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.39 2009/05/07 16:50:54 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -94,7 +94,8 @@ { php_sqlite3_db_object *db_obj; zval *object = getThis(); - char *filename, *encryption_key, *fullpath; + zstr filename; + char *encryption_key, *fullpath; zend_uchar filename_type; int filename_len, encryption_key_len = 0; long flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; @@ -116,17 +117,17 @@ } if (filename_type == IS_UNICODE) { - if (php_stream_path_encode(NULL, &filename, &filename_len, (UChar *)filename, filename_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { + if (php_stream_path_encode(NULL, &filename.s, &filename_len, filename.u, filename_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Unable to decode filepath", 0 TSRMLS_CC); return; } } - if (strncmp(filename, ":memory:", 8) != 0) { - if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) { + if (strncmp(filename.s, ":memory:", 8) != 0) { + if (!(fullpath = expand_filepath(filename.s, NULL TSRMLS_CC))) { zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Unable to expand filepath", 0 TSRMLS_CC); if (filename_type == IS_UNICODE) { - efree(filename); + efree(filename.s); } return; } @@ -134,17 +135,17 @@ if (php_check_open_basedir(fullpath TSRMLS_CC)) { zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "open_basedir prohibits opening %s", fullpath); if (filename_type == IS_UNICODE) { - efree(filename); + efree(filename.s); } efree(fullpath); return; } } else { - fullpath = estrdup(filename); + fullpath = estrdup(filename.s); } if (filename_type == IS_UNICODE) { - efree(filename); + efree(filename.s); } #if SQLITE_VERSION_NUMBER >= 3005000 @@ -1264,7 +1265,7 @@ } /* }}} */ -/* {{{ proto bool SQLite3Stmt::bindParam(int parameter_number, mixed parameter [, int type]) +/* {{{ proto bool SQLite3Stmt::bindParam(mixed parameter_number, mixed parameter [, int type]) U Bind Paramater to a stmt variable. */ PHP_METHOD(sqlite3stmt, bindParam) { @@ -1295,7 +1296,7 @@ } /* }}} */ -/* {{{ proto bool SQLite3Stmt::bindValue(inte parameter_number, mixed parameter [, int type]) +/* {{{ proto bool SQLite3Stmt::bindValue(mixed parameter_number, mixed parameter [, int type]) U Bind Value of a parameter to a stmt variable. */ PHP_METHOD(sqlite3stmt, bindValue) { @@ -1654,7 +1655,7 @@ } /* }}} */ -/* {{{ proto int SQLite3Result::__construct() +/* {{{ proto int SQLite3Result::__construct() U __constructor for SQLite3Result. */ PHP_METHOD(sqlite3result, __construct) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
iliaa Wed Feb 18 20:07:55 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: MFB: Removed unused var http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.35&r2=1.36&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.35 php-src/ext/sqlite3/sqlite3.c:1.36 --- php-src/ext/sqlite3/sqlite3.c:1.35 Tue Feb 10 00:44:09 2009 +++ php-src/ext/sqlite3/sqlite3.c Wed Feb 18 20:07:55 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.35 2009/02/10 00:44:09 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.36 2009/02/18 20:07:55 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -930,7 +930,7 @@ static size_t php_sqlite3_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) { - php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream->abstract; +/* php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream->abstract; */ return 0; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c /ext/sqlite3/tests sqlite3_15_open_error.phpt sqlite3_21_security.phpt
scottmacTue Feb 10 00:44:09 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c /php-src/ext/sqlite3/tests sqlite3_15_open_error.phpt sqlite3_21_security.phpt Log: MFB: The constructor should also throw exceptions, make this semi useful now. http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.34&r2=1.35&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.34 php-src/ext/sqlite3/sqlite3.c:1.35 --- php-src/ext/sqlite3/sqlite3.c:1.34 Wed Feb 4 09:58:39 2009 +++ php-src/ext/sqlite3/sqlite3.c Tue Feb 10 00:44:09 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.34 2009/02/04 09:58:39 pajoye Exp $ */ +/* $Id: sqlite3.c,v 1.35 2009/02/10 00:44:09 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -74,36 +74,46 @@ zend_uchar filename_type; int filename_len, encryption_key_len = 0; long flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; + zend_error_handling error_handling; + db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(object TSRMLS_CC); + zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|lS", &filename, &filename_len, &filename_type, &flags, &encryption_key, &encryption_key_len)) { + zend_restore_error_handling(&error_handling TSRMLS_CC); return; } + zend_restore_error_handling(&error_handling TSRMLS_CC); + if (db_obj->initialised) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Already initialised DB Object"); + zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Already initialised DB Object", 0 TSRMLS_CC); + return; } if (filename_type == IS_UNICODE) { if (php_stream_path_encode(NULL, &filename, &filename_len, (UChar *)filename, filename_len, REPORT_ERRORS, FG(default_context)) == FAILURE) { - RETURN_FALSE; + zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Unable to decode filepath", 0 TSRMLS_CC); + return; } } if (strncmp(filename, ":memory:", 8) != 0) { if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) { + zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Unable to expand filepath", 0 TSRMLS_CC); if (filename_type == IS_UNICODE) { efree(filename); } - RETURN_FALSE; + return; } if (php_check_open_basedir(fullpath TSRMLS_CC)) { + zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "open_basedir prohibits opening %s", fullpath); if (filename_type == IS_UNICODE) { efree(filename); } efree(fullpath); - RETURN_FALSE; + return; } } else { fullpath = estrdup(filename); @@ -119,7 +129,7 @@ /* Todo: utf-16 = sqlite3_open16 */ if (sqlite3_open(fullpath, &(db_obj->db)) != SQLITE_OK) { #endif - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to open database: %s", sqlite3_errmsg(db_obj->db)); + zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Unable to open database: %s", sqlite3_errmsg(db_obj->db)); if (fullpath) { efree(fullpath); } @@ -131,6 +141,7 @@ #if SQLITE_HAS_CODEC if (encryption_key_len > 0) { if (sqlite3_key(db_obj->db, encryption_key, encryption_key_len) != SQLITE_OK) { + zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Unable to open database: %s", sqlite3_errmsg(db_obj->db)); return; } } @@ -143,7 +154,6 @@ if (fullpath) { efree(fullpath); } - RETURN_TRUE; } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/sqlite3_15_open_error.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/sqlite3/tests/sqlite3_15_open_error.phpt diff -u php-src/ext/sqlite3/tests/sqlite3_15_open_error.phpt:1.2 php-src/ext/sqlite3/tests/sqlite3_15_open_error.phpt:1.3 --- php-src/ext/sqlite3/tests/sqlite3_15_open_error.phpt:1.2Fri Jul 25 21:34:15 2008 +++ php-src/ext/sqlite3/tests/sqlite3_15_open_error.phptTue Feb 10 00:44:09 2009 @@ -7,14 +7,14 @@ $unreadable = dirname(__FILE__) . '/unreadable.db'; touc
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
pajoye Wed Feb 4 09:58:39 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: - fix build http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.33&r2=1.34&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.33 php-src/ext/sqlite3/sqlite3.c:1.34 --- php-src/ext/sqlite3/sqlite3.c:1.33 Sat Jan 24 13:08:35 2009 +++ php-src/ext/sqlite3/sqlite3.c Wed Feb 4 09:58:39 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.33 2009/01/24 13:08:35 tony2001 Exp $ */ +/* $Id: sqlite3.c,v 1.34 2009/02/04 09:58:39 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1038,7 +1038,7 @@ return -1; } -PHPAPI php_stream_ops php_stream_sqlite3_ops = { +static php_stream_ops php_stream_sqlite3_ops = { php_sqlite3_stream_write, php_sqlite3_stream_read, php_sqlite3_stream_close, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
tony2001Sat Jan 24 13:08:37 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: fix build http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.32&r2=1.33&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.32 php-src/ext/sqlite3/sqlite3.c:1.33 --- php-src/ext/sqlite3/sqlite3.c:1.32 Sat Jan 24 12:16:57 2009 +++ php-src/ext/sqlite3/sqlite3.c Sat Jan 24 13:08:35 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.32 2009/01/24 12:16:57 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.33 2009/01/24 13:08:35 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1080,7 +1080,7 @@ sqlite3_stream->position = 0; sqlite3_stream->size = sqlite3_blob_bytes(blob); - stream = php_stream_alloc_rel(&php_stream_sqlite3_ops, sqlite3_stream, 0, "rb"); + stream = php_stream_alloc(&php_stream_sqlite3_ops, sqlite3_stream, 0, "rb"); if (stream) { php_stream_to_zval(stream, return_value); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
scottmacSat Jan 24 12:16:59 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: Add blobOpen method for reading SQlite3 blobs via streams. http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.31&r2=1.32&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.31 php-src/ext/sqlite3/sqlite3.c:1.32 --- php-src/ext/sqlite3/sqlite3.c:1.31 Tue Jan 20 09:57:25 2009 +++ php-src/ext/sqlite3/sqlite3.c Sat Jan 24 12:16:57 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.31 2009/01/20 09:57:25 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.32 2009/01/24 12:16:57 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -794,7 +794,7 @@ } /* }}} */ -/* {{{ proto bool SQLite3::createFunction(string name, mixed callback [, int argcount])) +/* {{{ proto bool SQLite3::createFunction(string name, mixed callback [, int argcount]) Allows registration of a PHP function as a SQLite UDF that can be called within SQL statements. */ PHP_METHOD(sqlite3, createFunction) { @@ -847,7 +847,7 @@ } /* }}} */ -/* {{{ proto bool SQLite3::createAggregate(string name, mixed step, mixed final [, int argcount])) +/* {{{ proto bool SQLite3::createAggregate(string name, mixed step, mixed final [, int argcount]) Allows registration of a PHP function for use as an aggregate. */ PHP_METHOD(sqlite3, createAggregate) { @@ -912,6 +912,184 @@ } /* }}} */ +typedef struct { + sqlite3_blob *blob; + size_t position; + size_t size; +} php_stream_sqlite3_data; + +static size_t php_sqlite3_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) +{ + php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream->abstract; + + return 0; +} + +static size_t php_sqlite3_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) +{ + php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream->abstract; + + if (sqlite3_stream->position + count >= sqlite3_stream->size) { + count = sqlite3_stream->size - sqlite3_stream->position; + stream->eof = 1; + } + if (count) { + if (sqlite3_blob_read(sqlite3_stream->blob, buf, count, sqlite3_stream->position) != SQLITE_OK) { + return 0; + } + sqlite3_stream->position += count; + } + return count; +} + +static int php_sqlite3_stream_close(php_stream *stream, int close_handle TSRMLS_DC) +{ + php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream->abstract; + + if (sqlite3_blob_close(sqlite3_stream->blob) != SQLITE_OK) { + /* Error occured, but it still closed */ + } + + efree(sqlite3_stream); + + return 0; +} + +static int php_sqlite3_stream_flush(php_stream *stream TSRMLS_DC) +{ + /* do nothing */ + return 0; +} + +/* {{{ */ +static int php_sqlite3_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC) +{ + php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream->abstract; + + switch(whence) { + case SEEK_CUR: + if (offset < 0) { + if (sqlite3_stream->position < (size_t)(-offset)) { + sqlite3_stream->position = 0; + *newoffs = -1; + return -1; + } else { + sqlite3_stream->position = sqlite3_stream->position + offset; + *newoffs = sqlite3_stream->position; + stream->eof = 0; + return 0; + } + } else { + if (sqlite3_stream->position + (size_t)(offset) > sqlite3_stream->size) { + sqlite3_stream->position = sqlite3_stream->size; + *newoffs = -1; + return -1; + } else { + sqlite3_stream->position = sqlite3_stream->position + offset; + *newoffs = sqlite3_stream->position; + stream->eof = 0; + return 0; + } + } + case SEEK_SET: + if (sqlite3_stream->size < (size_t)(offset)) { + sqlite3_stream->position = sqlite3_stream->size; + *newoffs =
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c /ext/sqlite3/tests bug47159.phpt
scottmacTue Jan 20 09:57:26 2009 UTC Added files: /php-src/ext/sqlite3/tests bug47159.phpt Modified files: /php-src/ext/sqlite3sqlite3.c Log: Fix bug #47159 - Any SQLite3 statement prepared should be added to the freelist http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.30&r2=1.31&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.30 php-src/ext/sqlite3/sqlite3.c:1.31 --- php-src/ext/sqlite3/sqlite3.c:1.30 Tue Jan 20 00:24:05 2009 +++ php-src/ext/sqlite3/sqlite3.c Tue Jan 20 09:57:25 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.30 2009/01/20 00:24:05 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.31 2009/01/20 09:57:25 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -384,6 +384,8 @@ zval *object = getThis(); char *sql; int sql_len, errcode; + php_sqlite3_free_list *free_item; + db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(object TSRMLS_CC); SQLITE3_CHECK_INITIALIZED(db_obj->initialised, SQLite3) @@ -402,7 +404,7 @@ stmt_obj->db_obj_zval = getThis(); Z_ADDREF_P(object); - + /* Todo: utf-8 or utf-16 = sqlite3_prepare16_v2 */ errcode = sqlite3_prepare_v2(db_obj->db, sql, sql_len, &(stmt_obj->stmt), NULL); if (errcode != SQLITE_OK) { @@ -410,7 +412,14 @@ zval_dtor(return_value); RETURN_FALSE; } + stmt_obj->initialised = 1; + + free_item = emalloc(sizeof(php_sqlite3_free_list)); + free_item->stmt_obj = stmt_obj; + free_item->stmt_obj_zval = return_value; + + zend_llist_add_element(&(db_obj->free_list), &free_item); } /* }}} */ @@ -1094,7 +1103,6 @@ zval *object = getThis(); int return_code = 0; struct php_sqlite3_bound_param *param; - php_sqlite3_free_list *free_item; stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); @@ -1170,11 +1178,6 @@ } return_code = sqlite3_step(stmt_obj->stmt); - free_item = emalloc(sizeof(php_sqlite3_free_list)); - free_item->stmt_obj = stmt_obj; - free_item->stmt_obj_zval = getThis(); - - zend_llist_add_element(&(stmt_obj->db_obj->free_list), &free_item); switch (return_code) { case SQLITE_ROW: /* Valid Row */ @@ -1217,6 +1220,7 @@ char *sql; int sql_len, errcode; zend_error_handling error_handling; + php_sqlite3_free_list *free_item; stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); @@ -1248,6 +1252,12 @@ RETURN_FALSE; } stmt_obj->initialised = 1; + + free_item = emalloc(sizeof(php_sqlite3_free_list)); + free_item->stmt_obj = stmt_obj; + free_item->stmt_obj_zval = getThis(); + + zend_llist_add_element(&(db_obj->free_list), &free_item); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/bug47159.phpt?view=markup&rev=1.1 Index: php-src/ext/sqlite3/tests/bug47159.phpt +++ php-src/ext/sqlite3/tests/bug47159.phpt --TEST-- Bug #45798 (sqlite3 doesn't track unexecuted statements) --SKIPIF-- --FILE-- prepare("SELECT 1"); var_dump($stmt->close()); var_dump($db->close()); print "done"; ?> --EXPECT-- bool(true) bool(true) done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
scottmacTue Jan 20 00:24:06 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: Fix bug #47145 - As soon as sqlite3_step is called on a statement it always must be finalised. http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.29&r2=1.30&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.29 php-src/ext/sqlite3/sqlite3.c:1.30 --- php-src/ext/sqlite3/sqlite3.c:1.29 Mon Jan 19 22:45:29 2009 +++ php-src/ext/sqlite3/sqlite3.c Tue Jan 20 00:24:05 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.29 2009/01/19 22:45:29 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.30 2009/01/20 00:24:05 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1094,6 +1094,8 @@ zval *object = getThis(); int return_code = 0; struct php_sqlite3_bound_param *param; + php_sqlite3_free_list *free_item; + stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); if (zend_parse_parameters_none() == FAILURE) { @@ -1168,13 +1170,16 @@ } return_code = sqlite3_step(stmt_obj->stmt); + free_item = emalloc(sizeof(php_sqlite3_free_list)); + free_item->stmt_obj = stmt_obj; + free_item->stmt_obj_zval = getThis(); + + zend_llist_add_element(&(stmt_obj->db_obj->free_list), &free_item); switch (return_code) { case SQLITE_ROW: /* Valid Row */ case SQLITE_DONE: /* Valid but no results */ { - php_sqlite3_free_list *free_item; - sqlite3_reset(stmt_obj->stmt); object_init_ex(return_value, php_sqlite3_result_entry); result = (php_sqlite3_result *)zend_object_store_get_object(return_value TSRMLS_CC); @@ -1186,12 +1191,6 @@ result->stmt_obj = stmt_obj; result->stmt_obj_zval = getThis(); - free_item = emalloc(sizeof(php_sqlite3_free_list)); - free_item->stmt_obj = stmt_obj; - free_item->stmt_obj_zval = getThis(); - - zend_llist_add_element(&(stmt_obj->db_obj->free_list), &free_item); - break; } case SQLITE_ERROR: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
scottmacMon Jan 19 22:45:30 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: MFB Fixed bug #47141 - Unable to fetch error messages after the database can't be opened. http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.28&r2=1.29&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.28 php-src/ext/sqlite3/sqlite3.c:1.29 --- php-src/ext/sqlite3/sqlite3.c:1.28 Mon Jan 5 09:32:48 2009 +++ php-src/ext/sqlite3/sqlite3.c Mon Jan 19 22:45:29 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.28 2009/01/05 09:32:48 tony2001 Exp $ */ +/* $Id: sqlite3.c,v 1.29 2009/01/19 22:45:29 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -243,7 +243,7 @@ zval *object = getThis(); db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(object TSRMLS_CC); - SQLITE3_CHECK_INITIALIZED(db_obj->initialised, SQLite3) + SQLITE3_CHECK_INITIALIZED(db_obj->db, SQLite3) if (zend_parse_parameters_none() == FAILURE) { return; @@ -261,7 +261,7 @@ zval *object = getThis(); db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(object TSRMLS_CC); - SQLITE3_CHECK_INITIALIZED(db_obj->initialised, SQLite3) + SQLITE3_CHECK_INITIALIZED(db_obj->db, SQLite3) if (zend_parse_parameters_none() == FAILURE) { return; @@ -970,7 +970,7 @@ } if (sqlite3_clear_bindings(stmt_obj->stmt) != SQLITE_OK) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to execute statement: %s", sqlite3_errmsg(sqlite3_db_handle(stmt_obj->stmt))); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to clear statement: %s", sqlite3_errmsg(sqlite3_db_handle(stmt_obj->stmt))); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
tony2001Mon Jan 5 09:32:48 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: fix build http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.27&r2=1.28&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.27 php-src/ext/sqlite3/sqlite3.c:1.28 --- php-src/ext/sqlite3/sqlite3.c:1.27 Sun Jan 4 16:32:05 2009 +++ php-src/ext/sqlite3/sqlite3.c Mon Jan 5 09:32:48 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.27 2009/01/04 16:32:05 iliaa Exp $ */ +/* $Id: sqlite3.c,v 1.28 2009/01/05 09:32:48 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1469,6 +1469,9 @@ ZEND_ARG_INFO(0, argument_count) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_execute, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3stmt_bindparam, 0, 0, 2) ZEND_ARG_INFO(0, param_number) ZEND_ARG_INFO(1, param) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
iliaa Sun Jan 4 16:32:05 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: MFB: Added missing initialization http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.26&r2=1.27&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.26 php-src/ext/sqlite3/sqlite3.c:1.27 --- php-src/ext/sqlite3/sqlite3.c:1.26 Sat Jan 3 22:07:22 2009 +++ php-src/ext/sqlite3/sqlite3.c Sun Jan 4 16:32:05 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.26 2009/01/03 22:07:22 felipe Exp $ */ +/* $Id: sqlite3.c,v 1.27 2009/01/04 16:32:05 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -72,7 +72,7 @@ zval *object = getThis(); char *filename, *encryption_key, *fullpath; zend_uchar filename_type; - int filename_len, encryption_key_len; + int filename_len, encryption_key_len = 0; long flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(object TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
felipe Sat Jan 3 22:07:22 2009 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: - Removed unnecessary repeated arginfos - Changed sqlite3stmt and sqlite3result to ZEND_ACC_PRIVATE to avoid reflection instantiation http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.25&r2=1.26&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.25 php-src/ext/sqlite3/sqlite3.c:1.26 --- php-src/ext/sqlite3/sqlite3.c:1.25 Wed Dec 31 11:12:36 2008 +++ php-src/ext/sqlite3/sqlite3.c Sat Jan 3 22:07:22 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.25 2008/12/31 11:12:36 sebastian Exp $ */ +/* $Id: sqlite3.c,v 1.26 2009/01/03 22:07:22 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1439,40 +1439,14 @@ ZEND_ARG_INFO(0, encryption_key) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_close, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_exec, 0) - ZEND_ARG_INFO(0, query) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_version, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_lastinsertrowid, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_lasterrorcode, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_lasterrormsg, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_loadextension, 0) ZEND_ARG_INFO(0, shared_library) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_changes, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3_escapestring, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3_prepare, 0, 0, 1) - ZEND_ARG_INFO(0, query) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3_query, 0, 0, 1) ZEND_ARG_INFO(0, query) ZEND_END_ARG_INFO() @@ -1495,21 +1469,6 @@ ZEND_ARG_INFO(0, argument_count) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_paramcount, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_close, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_reset, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_clear, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_execute, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3stmt_bindparam, 0, 0, 2) ZEND_ARG_INFO(0, param_number) ZEND_ARG_INFO(1, param) @@ -1526,9 +1485,6 @@ ZEND_ARG_INFO(0, sqlite3) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_numcolumns, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3result_columnname, 0, 0, 1) ZEND_ARG_INFO(0, column_number) ZEND_END_ARG_INFO() @@ -1541,29 +1497,23 @@ ZEND_ARG_INFO(0, mode) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_reset, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_finalize, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_construct, 0) +ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_void, 0) ZEND_END_ARG_INFO() /* }}} */ /* {{{ php_sqlite3_class_methods */ static zend_function_entry php_sqlite3_class_methods[] = { PHP_ME(sqlite3, open, arginfo_sqlite3_open, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, close, arginfo_sqlite3_close, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, exec, arginfo_sqlite3_exec, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, version, arginfo_sqlite3_version, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME(sqlite3, lastInsertRowID, arginfo_sqlite3_lastinsertrowid, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, lastErrorCode, arginfo_sqlite3_lasterrorcode, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, lastErrorMsg, arginfo_sqlite3_lasterrormsg, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, close, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, exec, arginfo_sqlite3_query, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, version, arginfo_sqlite3_void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(sqlite3, lastInsertRowID,arginfo_sqlite3_void, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, lastErrorCode, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, lastErrorMsg, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, loadExtension, arginfo_sqlite3_loadextension, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, changes, arginfo_sqlite3_changes, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, changes, arginfo_sqlite3_void,
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c /ext/sqlite3/tests sqlite3_29_createfunction.phpt
felipe Fri Nov 28 15:36:34 2008 UTC Added files: /php-src/ext/sqlite3/tests sqlite3_29_createfunction.phpt Modified files: /php-src/ext/sqlite3sqlite3.c Log: - Fixed memory leaks in createFunction and createAggregate methods http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.22&r2=1.23&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.22 php-src/ext/sqlite3/sqlite3.c:1.23 --- php-src/ext/sqlite3/sqlite3.c:1.22 Thu Nov 27 19:02:45 2008 +++ php-src/ext/sqlite3/sqlite3.c Fri Nov 28 15:36:34 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.22 2008/11/27 19:02:45 dmitry Exp $ */ +/* $Id: sqlite3.c,v 1.23 2008/11/28 15:36:34 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -817,6 +817,7 @@ MAKE_STD_ZVAL(func->func); *(func->func) = *callback_func; zval_copy_ctor(func->func); + INIT_PZVAL(func->func); func->argc = sql_func_num_args; func->next = db_obj->funcs; @@ -876,10 +877,12 @@ MAKE_STD_ZVAL(func->step); *(func->step) = *step_callback; zval_copy_ctor(func->step); + INIT_PZVAL(func->step); MAKE_STD_ZVAL(func->fini); *(func->fini) = *fini_callback; zval_copy_ctor(func->fini); + INIT_PZVAL(func->fini); func->argc = sql_func_num_args; func->next = db_obj->funcs; http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/sqlite3_29_createfunction.phpt?view=markup&rev=1.1 Index: php-src/ext/sqlite3/tests/sqlite3_29_createfunction.phpt +++ php-src/ext/sqlite3/tests/sqlite3_29_createfunction.phpt --TEST-- SQLite3::createFunction - Basic test --SKIPIF-- --FILE-- createfunction($func, $func)); var_dump($db->querySingle('SELECT strtoupper("test")')); $func2 = 'strtolower'; var_dump($db->createfunction($func2, $func2)); var_dump($db->querySingle('SELECT strtolower("TEST")')); var_dump($db->createfunction($func, $func2)); var_dump($db->querySingle('SELECT strtoupper("tEst")')); ?> --EXPECTF-- bool(true) %string|unicode%(4) "TEST" bool(true) %string|unicode%(4) "test" bool(true) %string|unicode%(4) "test" -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
pajoye Thu Nov 20 10:20:37 2008 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: - declarations must be.. 1st http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.20&r2=1.21&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.20 php-src/ext/sqlite3/sqlite3.c:1.21 --- php-src/ext/sqlite3/sqlite3.c:1.20 Wed Nov 19 01:59:07 2008 +++ php-src/ext/sqlite3/sqlite3.c Thu Nov 20 10:20:37 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.20 2008/11/19 01:59:07 colder Exp $ */ +/* $Id: sqlite3.c,v 1.21 2008/11/20 10:20:37 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1409,9 +1409,10 @@ { php_sqlite3_result *result_obj; zval *object = getThis(); - result_obj = (php_sqlite3_result *)zend_object_store_get_object(object TSRMLS_CC); zend_error_handling error_handling; + result_obj = (php_sqlite3_result *)zend_object_store_get_object(object TSRMLS_CC); + zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC); php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLite3Result cannot be directly instantiated"); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
pajoye Tue Nov 18 14:25:54 2008 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: - declaration has to be first... http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.18&r2=1.19&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.18 php-src/ext/sqlite3/sqlite3.c:1.19 --- php-src/ext/sqlite3/sqlite3.c:1.18 Mon Nov 17 19:32:31 2008 +++ php-src/ext/sqlite3/sqlite3.c Tue Nov 18 14:25:54 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.18 2008/11/17 19:32:31 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.19 2008/11/18 14:25:54 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1205,10 +1205,11 @@ php_sqlite3_db_object *db_obj; zval *object = getThis(); zval *db_zval; - stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); char *sql; int sql_len, errcode; + stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); + zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &db_zval, php_sqlite3_sc_entry, &sql, &sql_len) == FAILURE) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c
scottmacMon Nov 17 19:32:31 2008 UTC Modified files: /php-src/ext/sqlite3sqlite3.c Log: Fix #46033 - Segfault when instantiating SQLite3stmt and SQLite3Result directly. http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.17&r2=1.18&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.17 php-src/ext/sqlite3/sqlite3.c:1.18 --- php-src/ext/sqlite3/sqlite3.c:1.17 Mon Nov 17 11:26:24 2008 +++ php-src/ext/sqlite3/sqlite3.c Mon Nov 17 19:32:31 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.17 2008/11/17 11:26:24 felipe Exp $ */ +/* $Id: sqlite3.c,v 1.18 2008/11/17 19:32:31 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -530,7 +530,7 @@ } /* }}} */ -/* {{{ proto SQLite3Result SQLite3::querySingle(String Query [, entire_row = false]) +/* {{{ proto SQLite3Result SQLite3::querySingle(String Query [, bool entire_row = false]) Returns a string of the first column, or an array of the entire row. */ PHP_METHOD(sqlite3, querySingle) { @@ -1090,6 +1090,8 @@ return; } + SQLITE3_CHECK_INITIALIZED(stmt_obj->initialised, SQLite3) + if (stmt_obj->bound_params) { zend_hash_internal_pointer_reset(stmt_obj->bound_params); while (zend_hash_get_current_data(stmt_obj->bound_params, (void **)¶m) == SUCCESS) { @@ -1195,6 +1197,47 @@ } /* }}} */ +/* {{{ proto int SQLite3Stmt::__construct(SQLite3 dbobject, String Statement) U + __constructor for SQLite3Stmt. */ +PHP_METHOD(sqlite3stmt, __construct) +{ + php_sqlite3_stmt *stmt_obj; + php_sqlite3_db_object *db_obj; + zval *object = getThis(); + zval *db_zval; + stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); + char *sql; + int sql_len, errcode; + + zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &db_zval, php_sqlite3_sc_entry, &sql, &sql_len) == FAILURE) { + return; + } + + db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(db_zval TSRMLS_CC); + + SQLITE3_CHECK_INITIALIZED(db_obj->initialised, SQLite3) + + if (!sql_len) { + RETURN_FALSE; + } + + stmt_obj->db_obj = db_obj; + stmt_obj->db_obj_zval = db_zval; + + Z_ADDREF_P(db_zval); + + errcode = sqlite3_prepare_v2(db_obj->db, sql, sql_len, &(stmt_obj->stmt), NULL); + if (errcode != SQLITE_OK) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to prepare statement: %d, %s", errcode, sqlite3_errmsg(db_obj->db)); + zval_dtor(return_value); + RETURN_FALSE; + } + stmt_obj->initialised = 1; +} +/* }}} */ + /* {{{ proto int SQLite3Result::numColumns() U Number of columns in the result set. */ PHP_METHOD(sqlite3result, numColumns) @@ -1356,6 +1399,21 @@ } /* }}} */ +/* {{{ proto int SQLite3Result::__construct() + __constructor for SQLite3Result. */ +PHP_METHOD(sqlite3result, __construct) +{ + php_sqlite3_result *result_obj; + zval *object = getThis(); + result_obj = (php_sqlite3_result *)zend_object_store_get_object(object TSRMLS_CC); + + zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC); + + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLite3Result cannot be directly instantiated"); + +} +/* }}} */ + /* {{{ arginfo */ ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_open, 0) ZEND_ARG_INFO(0, filename) @@ -1446,6 +1504,10 @@ ZEND_ARG_INFO(0, type) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_construct, 1) + ZEND_ARG_INFO(0, sqlite3) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_numcolumns, 0) ZEND_END_ARG_INFO() @@ -1466,6 +1528,9 @@ ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_finalize, 0) ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_construct, 0) +ZEND_END_ARG_INFO() /* }}} */ /* {{{ php_sqlite3_class_methods */ @@ -1486,7 +1551,7 @@ PHP_ME(sqlite3, createFunction, arginfo_sqlite3_createfunction, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, createAggregate, arginfo_sqlite3_createaggregate, ZEND_ACC_PUBLIC) /* Aliases */ - PHP_MALIAS(sqlite3, __construct, open, arginfo_sqlite3_open, ZEND_ACC_PUBLIC) + PHP_MALIAS(sqlite3, __construct, open, arginfo_sqlite3_open, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) {NULL, NULL, NULL} }; /* }}} */ @@ -1500,6 +1565,7 @@ PHP_ME(sqlite3stmt, execute,arginfo_sqlite3stmt_execute, ZEND_ACC_PUBLIC) PHP_ME(sqlite3stmt, bindParam, arginfo_sqlite3stmt_bindparam, ZEND_ACC_PUBLIC) PHP_ME(sqlite3stmt, bindValue, arginfo_sqlite3stmt_bindvalue, ZEND_AC
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c /ext/sqlite3/tests sqlite3_23_escape_string.phpt
scottmacTue Sep 30 11:13:43 2008 UTC Modified files: /php-src/ext/sqlite3sqlite3.c /php-src/ext/sqlite3/tests sqlite3_23_escape_string.phpt Log: SQLite3::escapeString can be static as it doesn't rely on an instance of SQLite http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.13&r2=1.14&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.13 php-src/ext/sqlite3/sqlite3.c:1.14 --- php-src/ext/sqlite3/sqlite3.c:1.13 Mon Sep 15 01:00:52 2008 +++ php-src/ext/sqlite3/sqlite3.c Tue Sep 30 11:13:43 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.13 2008/09/15 01:00:52 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.14 2008/09/30 11:13:43 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1507,7 +1507,7 @@ PHP_ME(sqlite3, lastErrorMsg, arginfo_sqlite3_lasterrormsg, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, loadExtension, arginfo_sqlite3_loadextension, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, changes, arginfo_sqlite3_changes, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, escapeString, arginfo_sqlite3_escapestring, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, escapeString, arginfo_sqlite3_escapestring, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(sqlite3, prepare, arginfo_sqlite3_prepare, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, query, arginfo_sqlite3_query, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, querySingle, arginfo_sqlite3_querysingle, ZEND_ACC_PUBLIC) http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt diff -u php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt:1.2 php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt:1.3 --- php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt:1.2 Fri Jul 25 21:34:15 2008 +++ php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt Tue Sep 30 11:13:43 2008 @@ -12,7 +12,7 @@ var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); echo "INSERT into table\n"; -var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", '" . $db->escapeString("test''%") . "')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", '" . SQLite3::escapeString("test''%") . "')")); var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); echo "SELECTING results\n"; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c /ext/sqlite3/tests bug45798.phpt
felipe Tue Aug 12 13:32:31 2008 UTC Added files: /php-src/ext/sqlite3/tests bug45798.phpt Modified files: /php-src/ext/sqlite3sqlite3.c Log: - Fixed bug #45798 (sqlite3 doesn't notice if variable was bound) http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.11&r2=1.12&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.11 php-src/ext/sqlite3/sqlite3.c:1.12 --- php-src/ext/sqlite3/sqlite3.c:1.11 Wed Aug 6 14:02:44 2008 +++ php-src/ext/sqlite3/sqlite3.c Tue Aug 12 13:32:30 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.11 2008/08/06 14:02:44 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.12 2008/08/12 13:32:30 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1096,6 +1096,7 @@ /* If the ZVAL is null then it should be bound as that */ if (Z_TYPE_P(param->parameter) == IS_NULL) { sqlite3_bind_null(stmt_obj->stmt, param->param_number); + zend_hash_move_forward(stmt_obj->bound_params); continue; } http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/bug45798.phpt?view=markup&rev=1.1 Index: php-src/ext/sqlite3/tests/bug45798.phpt +++ php-src/ext/sqlite3/tests/bug45798.phpt --TEST-- Bug #45798 (sqlite3 doesn't notice if variable was bound) --SKIPIF-- --FILE-- exec('CREATE TABLE test (time INTEGER, id STRING)'); $db->exec("INSERT INTO test (time, id) VALUES (" . time() . ", 'a')"); $db->exec("INSERT INTO test (time, id) VALUES (" . time() . ", 'b')"); $stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC"); $stmt->bindParam(1, $foo, SQLITE3_TEXT); $results = $stmt->execute(); while ($result = $results->fetchArray(SQLITE3_NUM)) { var_dump($result); } $results->finalize(); $db->close(); print "done"; ?> --EXPECT-- done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sqlite3 sqlite3.c /ext/sqlite3/tests sqlite3_12_unfinalized_stmt_cleanup.phpt sqlite3_25_create_aggregate.phpt
scottmacWed Aug 6 14:02:44 2008 UTC Modified files: /php-src/ext/sqlite3sqlite3.c /php-src/ext/sqlite3/tests sqlite3_12_unfinalized_stmt_cleanup.phpt sqlite3_25_create_aggregate.phpt Log: MFB: Update coding standards and fix a test, this was already in 5.3 alpha 1 http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.10&r2=1.11&diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.10 php-src/ext/sqlite3/sqlite3.c:1.11 --- php-src/ext/sqlite3/sqlite3.c:1.10 Sat Aug 2 04:40:45 2008 +++ php-src/ext/sqlite3/sqlite3.c Wed Aug 6 14:02:44 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.10 2008/08/02 04:40:45 felipe Exp $ */ +/* $Id: sqlite3.c,v 1.11 2008/08/06 14:02:44 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -375,7 +375,7 @@ } /* }}} */ -/* {{{ proto sqlite3_stmt SQLite3::prepare(String Query) +/* {{{ proto SQLite3Stmt SQLite3::prepare(String Query) Returns a prepared SQL statement for execution. */ PHP_METHOD(sqlite3, prepare) { @@ -414,8 +414,8 @@ } /* }}} */ -/* {{{ proto sqlite3_result SQLite3::query(String Query) - Returns true or false, for queries that return data it will return a sqlite3_result object. */ +/* {{{ proto SQLite3Result SQLite3::query(String Query) + Returns true or false, for queries that return data it will return a SQLite3Result object. */ PHP_METHOD(sqlite3, query) { php_sqlite3_db_object *db_obj; @@ -530,7 +530,7 @@ } /* }}} */ -/* {{{ proto sqlite3_result SQLite3::querySingle(String Query [, entire_row = false]) +/* {{{ proto SQLite3Result SQLite3::querySingle(String Query [, entire_row = false]) Returns a string of the first column, or an array of the entire row. */ PHP_METHOD(sqlite3, querySingle) { @@ -893,9 +893,9 @@ } /* }}} */ -/* {{{ proto int SQLite3_stmt::paramCount() U +/* {{{ proto int SQLite3Stmt::paramCount() U Returns the number of parameters within the prepared statement. */ -PHP_METHOD(sqlite3_stmt, paramCount) +PHP_METHOD(sqlite3stmt, paramCount) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -909,9 +909,9 @@ } /* }}} */ -/* {{{ proto bool SQLite3_stmt::close() U +/* {{{ proto bool SQLite3Stmt::close() U Closes the prepared statement. */ -PHP_METHOD(sqlite3_stmt, close) +PHP_METHOD(sqlite3stmt, close) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -927,9 +927,9 @@ } /* }}} */ -/* {{{ proto bool SQLite3_stmt::reset() U +/* {{{ proto bool SQLite3Stmt::reset() U Reset the prepared statement to the state before it was executed, bindings still remain. */ -PHP_METHOD(sqlite3_stmt, reset) +PHP_METHOD(sqlite3stmt, reset) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -947,9 +947,9 @@ } /* }}} */ -/* {{{ proto bool SQLite3_stmt::clear() U +/* {{{ proto bool SQLite3Stmt::clear() U Clear all current bound parameters. */ -PHP_METHOD(sqlite3_stmt, clear) +PHP_METHOD(sqlite3stmt, clear) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -1013,9 +1013,9 @@ } /* }}} */ -/* {{{ proto bool SQLite3_stmt::bindParam(int parameter_number, mixed parameter [, int type]) +/* {{{ proto bool SQLite3Stmt::bindParam(int parameter_number, mixed parameter [, int type]) Bind Paramater to a stmt variable. */ -PHP_METHOD(sqlite3_stmt, bindParam) +PHP_METHOD(sqlite3stmt, bindParam) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -1044,9 +1044,9 @@ } /* }}} */ -/* {{{ proto bool SQLite3_stmt::bindValue(inte parameter_number, mixed parameter [, int type]) +/* {{{ proto bool SQLite3Stmt::bindValue(inte parameter_number, mixed parameter [, int type]) Bind Value of a parameter to a stmt variable. */ -PHP_METHOD(sqlite3_stmt, bindValue) +PHP_METHOD(sqlite3stmt, bindValue) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -1075,9 +1075,9 @@ } /* }}} */ -/* {{{ proto SQLite3_result SQLite3_stmt::execute() +/* {{{ proto SQLite3Result SQLite3Stmt::execute() Executes a prepared statement and returns a result set object. */ -PHP_METHOD(sqlite3_stmt, execute) +PHP_METHOD(sqlite3stmt, execute) { php_sqlite3_stmt *stmt_obj; php_sqlite3_result *result; @@ -1194,15 +1194,15 @@ } /* }}} */ -/* {{{ proto int SQLite3_result::numColumns() U +/* {{{ proto int SQLite3Result::numColumns() U Number of columns in the result set. */ -PHP_METHOD(sqlite3_result, numColumns) +PHP_METHOD(sqlite3result, numColumns) { php_sqlite3_result *result_obj; zval *object = getThis(); result_obj = (php_sqlite3_result *)zend_object_store_get_object(object TSRMLS_CC); - SQLITE3_CHECK_INITIALIZED(result_obj->stmt_obj->initialised, SQLite3_result) + SQLITE3_CHECK_INITIAL