diff options
Diffstat (limited to 'ext/sqlite3')
-rw-r--r-- | ext/sqlite3/config0.m4 | 3 | ||||
-rw-r--r-- | ext/sqlite3/libsqlite/sqlite3.c | 22 | ||||
-rw-r--r-- | ext/sqlite3/php_sqlite3.h | 2 | ||||
-rw-r--r-- | ext/sqlite3/sqlite3.c | 25 | ||||
-rw-r--r-- | ext/sqlite3/tests/bug53463.phpt | 2 | ||||
-rw-r--r-- | ext/sqlite3/tests/bug63921-32bit.phpt | 27 | ||||
-rw-r--r-- | ext/sqlite3/tests/bug63921-64bit.phpt | 27 | ||||
-rw-r--r-- | ext/sqlite3/tests/sqlite3_15_open_error.phpt | 4 |
8 files changed, 89 insertions, 23 deletions
diff --git a/ext/sqlite3/config0.m4 b/ext/sqlite3/config0.m4 index ac58b35cf0..1365def033 100644 --- a/ext/sqlite3/config0.m4 +++ b/ext/sqlite3/config0.m4 @@ -50,6 +50,9 @@ if test $PHP_SQLITE3 != "no"; then PHP_CHECK_LIBRARY(sqlite3,sqlite3_key,[ AC_DEFINE(HAVE_SQLITE3_KEY, 1, [have commercial sqlite3 with crypto support]) ]) + PHP_CHECK_LIBRARY(sqlite3,sqlite3_column_table_name,[ + AC_DEFINE(SQLITE_ENABLE_COLUMN_METADATA, 1, [have sqlite3 with column metadata enabled]) + ]) PHP_CHECK_LIBRARY(sqlite3,sqlite3_load_extension, [], diff --git a/ext/sqlite3/libsqlite/sqlite3.c b/ext/sqlite3/libsqlite/sqlite3.c index a3d542a40c..d96367e212 100644 --- a/ext/sqlite3/libsqlite/sqlite3.c +++ b/ext/sqlite3/libsqlite/sqlite3.c @@ -23307,7 +23307,7 @@ static int os2OpenSharedMemory( os2File *fd, int szRegion ) { sqlite3_mutex_leave(pNode->mutex); } else { - /* Error occured. Free our link object. */ + /* Error occurred. Free our link object. */ sqlite3_free(pLink); } @@ -28994,7 +28994,7 @@ static int fillInUnixFile( unixEnterMutex(); rc = findInodeInfo(pNew, &pNew->pInode); if( rc!=SQLITE_OK ){ - /* If an error occured in findInodeInfo(), close the file descriptor + /* If an error occurred in findInodeInfo(), close the file descriptor ** immediately, before releasing the mutex. findInodeInfo() may fail ** in two scenarios: ** @@ -32173,7 +32173,7 @@ static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){ ** containing the lower 32-bits of the new file-offset. Or, if it fails, ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine - ** whether an error has actually occured, it is also necessary to call + ** whether an error has actually occurred, it is also necessary to call ** GetLastError(). */ dwRet = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); @@ -32273,7 +32273,7 @@ static int winWrite( int amt, /* Number of bytes to write */ sqlite3_int64 offset /* Offset into the file to begin writing at */ ){ - int rc; /* True if error has occured, else false */ + int rc; /* True if error has occurred, else false */ winFile *pFile = (winFile*)id; /* File handle */ assert( amt>0 ); @@ -37068,7 +37068,7 @@ int sqlite3PagerTrace=1; /* True to enable tracing */ ** * A write transaction is active. ** * An EXCLUSIVE or greater lock is held on the database file. ** * All writing and syncing of journal and database data has finished. -** If no error occured, all that remains is to finalize the journal to +** If no error occurred, all that remains is to finalize the journal to ** commit the transaction. If an error did occur, the caller will need ** to rollback the transaction. ** @@ -54279,7 +54279,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( insertCell(pPage, idx, newCell, szNew, 0, 0, &rc); assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 ); - /* If no error has occured and pPage has an overflow cell, call balance() + /* If no error has occurred and pPage has an overflow cell, call balance() ** to redistribute the cells within the tree. Since balance() may move ** the cursor, zero the BtCursor.info.nSize and BtCursor.validNKey ** variables. @@ -57935,7 +57935,7 @@ SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){ } sqlite3DbFree(v->db, sIter.apSub); - /* Return true if hasAbort==mayAbort. Or if a malloc failure occured. + /* Return true if hasAbort==mayAbort. Or if a malloc failure occurred. ** If malloc failed, then the while() loop above may not have iterated ** through all opcodes and hasAbort may be set incorrectly. Return ** true for this case to prevent the assert() in the callers frame @@ -59562,7 +59562,7 @@ SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *p, int eOp){ /* If p->iStatement is greater than zero, then this Vdbe opened a ** statement transaction that should be closed here. The only exception - ** is that an IO error may have occured, causing an emergency rollback. + ** is that an IO error may have occurred, causing an emergency rollback. ** In this case (db->nStatement==0), and there is nothing to do. */ if( db->nStatement && p->iStatement ){ @@ -59697,7 +59697,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){ ** ** Even if the statement is read-only, it is important to perform ** a statement or transaction rollback operation. If the error - ** occured while writing to the journal, sub-journal or database + ** occurred while writing to the journal, sub-journal or database ** file as part of an effort to free up cache space (see function ** pagerStress() in pager.c), the rollback is required to restore ** the pager to a consistent state. @@ -61245,7 +61245,7 @@ end_of_step: assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE ); if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ /* If this statement was prepared using sqlite3_prepare_v2(), and an - ** error has occured, then return the error code in p->rc to the + ** error has occurred, then return the error code in p->rc to the ** caller. Set the error code in the database handle to the same value. */ rc = db->errCode = p->rc; @@ -113286,7 +113286,7 @@ static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ }else{ int rc = sqlite3_reset(pCsr->pStmt); if( rc==SQLITE_OK ){ - /* If no row was found and no error has occured, then the %_content + /* If no row was found and no error has occurred, then the %_content ** table is missing a row that is present in the full-text index. ** The data structures are corrupt. */ diff --git a/ext/sqlite3/php_sqlite3.h b/ext/sqlite3/php_sqlite3.h index b558f70340..131e70102c 100644 --- a/ext/sqlite3/php_sqlite3.h +++ b/ext/sqlite3/php_sqlite3.h @@ -21,7 +21,7 @@ #ifndef PHP_SQLITE3_H #define PHP_SQLITE3_H -#define PHP_SQLITE3_VERSION "0.7-dev" +#define PHP_SQLITE3_VERSION "0.7" extern zend_module_entry sqlite3_module_entry; #define phpext_sqlite3_ptr &sqlite3_module_entry diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index a80159e7a8..df449d7380 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -103,7 +103,7 @@ PHP_METHOD(sqlite3, open) 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, "s|ls", &filename, &filename_len, &flags, &encryption_key, &encryption_key_len)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|ls", &filename, &filename_len, &flags, &encryption_key, &encryption_key_len)) { zend_restore_error_handling(&error_handling TSRMLS_CC); return; } @@ -730,7 +730,11 @@ static int sqlite3_do_callback(struct php_sqlite3_fci *fc, zval *cb, int argc, s switch (sqlite3_value_type(argv[i])) { case SQLITE_INTEGER: +#if LONG_MAX > 2147483647 + ZVAL_LONG(*zargs[i + is_agg], sqlite3_value_int64(argv[i])); +#else ZVAL_LONG(*zargs[i + is_agg], sqlite3_value_int(argv[i])); +#endif break; case SQLITE_FLOAT: @@ -774,7 +778,11 @@ static int sqlite3_do_callback(struct php_sqlite3_fci *fc, zval *cb, int argc, s if (retval) { switch (Z_TYPE_P(retval)) { case IS_LONG: +#if LONG_MAX > 2147483647 + sqlite3_result_int64(context, Z_LVAL_P(retval)); +#else sqlite3_result_int(context, Z_LVAL_P(retval)); +#endif break; case IS_NULL: @@ -1097,7 +1105,7 @@ static int php_sqlite3_stream_close(php_stream *stream, int close_handle TSRMLS_ 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 */ + /* Error occurred, but it still closed */ } efree(sqlite3_stream); @@ -1493,7 +1501,11 @@ PHP_METHOD(sqlite3stmt, execute) switch (param->type) { case SQLITE_INTEGER: convert_to_long(param->parameter); +#if LONG_MAX > 2147483647 + sqlite3_bind_int64(stmt_obj->stmt, param->param_number, Z_LVAL_P(param->parameter)); +#else sqlite3_bind_int(stmt_obj->stmt, param->param_number, Z_LVAL_P(param->parameter)); +#endif break; case SQLITE_FLOAT: @@ -2121,7 +2133,6 @@ static void php_sqlite3_result_object_free_storage(void *object TSRMLS_DC) /* {{ static zend_object_value php_sqlite3_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { - zval *tmp; zend_object_value retval; php_sqlite3_db_object *intern; @@ -2134,7 +2145,7 @@ static zend_object_value php_sqlite3_object_new(zend_class_entry *class_type TSR zend_llist_init(&(intern->free_list), sizeof(php_sqlite3_free_list *), (llist_dtor_func_t)php_sqlite3_free_list_dtor, 0); zend_object_std_init(&intern->zo, class_type TSRMLS_CC); - zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_property_ctor,(void *) &tmp, sizeof(zval *)); + object_properties_init(&intern->zo, class_type); retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_sqlite3_object_free_storage, NULL TSRMLS_CC); retval.handlers = (zend_object_handlers *) &sqlite3_object_handlers; @@ -2145,7 +2156,6 @@ static zend_object_value php_sqlite3_object_new(zend_class_entry *class_type TSR static zend_object_value php_sqlite3_stmt_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { - zval *tmp; zend_object_value retval; php_sqlite3_stmt *intern; @@ -2156,7 +2166,7 @@ static zend_object_value php_sqlite3_stmt_object_new(zend_class_entry *class_typ intern->db_obj_zval = NULL; zend_object_std_init(&intern->zo, class_type TSRMLS_CC); - zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_property_ctor,(void *) &tmp, sizeof(zval *)); + object_properties_init(&intern->zo, class_type); retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_sqlite3_stmt_object_free_storage, NULL TSRMLS_CC); retval.handlers = (zend_object_handlers *) &sqlite3_stmt_object_handlers; @@ -2167,7 +2177,6 @@ static zend_object_value php_sqlite3_stmt_object_new(zend_class_entry *class_typ static zend_object_value php_sqlite3_result_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { - zval *tmp; zend_object_value retval; php_sqlite3_result *intern; @@ -2180,7 +2189,7 @@ static zend_object_value php_sqlite3_result_object_new(zend_class_entry *class_t intern->stmt_obj_zval = NULL; zend_object_std_init(&intern->zo, class_type TSRMLS_CC); - zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_property_ctor,(void *) &tmp, sizeof(zval *)); + object_properties_init(&intern->zo, class_type); retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_sqlite3_result_object_free_storage, NULL TSRMLS_CC); retval.handlers = (zend_object_handlers *) &sqlite3_result_object_handlers; diff --git a/ext/sqlite3/tests/bug53463.phpt b/ext/sqlite3/tests/bug53463.phpt index dcfc13d5ba..744a214612 100644 --- a/ext/sqlite3/tests/bug53463.phpt +++ b/ext/sqlite3/tests/bug53463.phpt @@ -27,4 +27,4 @@ echo "Done\n"; --EXPECT-- string(8) "whatever" bool(false) -Done
\ No newline at end of file +Done diff --git a/ext/sqlite3/tests/bug63921-32bit.phpt b/ext/sqlite3/tests/bug63921-32bit.phpt new file mode 100644 index 0000000000..8c1c6b9414 --- /dev/null +++ b/ext/sqlite3/tests/bug63921-32bit.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #63921 sqlite3::bindvalue and relative PHP functions aren't using sqlite3_*_int64 API +--SKIPIF-- +<?php +if (!extension_loaded('sqlite3')) die('skip'); +if (PHP_INT_SIZE > 4) die('skip'); // skip for 64bit builds - there is another test for that +?> +--FILE-- +<?php +$num = PHP_INT_MAX; // 32 bits +$conn = new sqlite3(':memory:'); +$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))'); + +$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)'); +$stmt->bindValue(':id', 1, SQLITE3_INTEGER); +$stmt->bindValue(':num', $num, SQLITE3_INTEGER); +$stmt->execute(); + +$stmt = $conn->query('SELECT num FROM users'); +$result = $stmt->fetchArray(); + +var_dump($num,$result[0]); + +?> +--EXPECT-- +int(2147483647) +string(10) "2147483647" diff --git a/ext/sqlite3/tests/bug63921-64bit.phpt b/ext/sqlite3/tests/bug63921-64bit.phpt new file mode 100644 index 0000000000..8e821fd2d0 --- /dev/null +++ b/ext/sqlite3/tests/bug63921-64bit.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #63921 sqlite3::bindvalue and relative PHP functions aren't using sqlite3_*_int64 API +--SKIPIF-- +<?php +if (!extension_loaded('sqlite3')) die('skip'); +if (PHP_INT_SIZE < 8) die('skip'); // skip for 32bit builds - there is another test for that +?> +--FILE-- +<?php +$num = 100004313234244; // notice this exceeds 32 bits +$conn = new sqlite3(':memory:'); +$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))'); + +$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)'); +$stmt->bindValue(':id', 1, SQLITE3_INTEGER); +$stmt->bindValue(':num', $num, SQLITE3_INTEGER); +$stmt->execute(); + +$stmt = $conn->query('SELECT num FROM users'); +$result = $stmt->fetchArray(); + +var_dump($num,$result[0]); + +?> +--EXPECT-- +int(100004313234244) +string(15) "100004313234244" diff --git a/ext/sqlite3/tests/sqlite3_15_open_error.phpt b/ext/sqlite3/tests/sqlite3_15_open_error.phpt index 9b0496f889..fc05b87802 100644 --- a/ext/sqlite3/tests/sqlite3_15_open_error.phpt +++ b/ext/sqlite3/tests/sqlite3_15_open_error.phpt @@ -5,14 +5,14 @@ SQLite3::open error test if(substr(PHP_OS, 0, 3) == 'WIN' ) { die('skip non windows test'); } -require_once(dirname(__FILE__) . '/skipif.inc'); +require_once(__DIR__ . '/skipif.inc'); if (posix_geteuid() == 0) { die('SKIP Cannot run test as root.'); } ?> --FILE-- <?php -$unreadable = dirname(__FILE__) . '/unreadable.db'; +$unreadable = __DIR__ . '/unreadable.db'; touch($unreadable); chmod($unreadable, 0200); try { |