Require SQLite ≥ 3.7.4 for ext/sqlite3

`SQLite3::readOnly()` uses `sqlite3_stmt_readonly()` which is only
available as of libsqlite 3.7.4.  For older SQLite3 versions we return
always `false`, which can be confusing.  Instead of sticking with this
behavior, or even undefining the method for old SQLite3 versions, we
lift the requirements to SQLite 3.7.4 (released on 2010-12-08),
according to a respective discussion[1].

Since pdo_sqlite doesn't use `sqlite3_stmt_readonly()`, we stick with
the minimum requirement of SQLite 3.5.0.

[1] <https://github.com/php/php-src/pull/3614>
This commit is contained in:
Christoph M. Becker 2018-11-29 15:10:39 +01:00
parent 1674db8c40
commit a757ebb5b5
4 changed files with 7 additions and 8 deletions

2
NEWS
View file

@ -41,7 +41,7 @@ PHP NEWS
- SQLite3: - SQLite3:
. Unbundled libsqlite. (cmb) . Unbundled libsqlite. (cmb)
. Lifted requirements to SQLite 3.5.0. (cmb) . Lifted requirements to SQLite 3.7.4. (cmb)
. Forbid (un)serialization of SQLite3, SQLite3Stmt and SQLite3Result. (cmb) . Forbid (un)serialization of SQLite3, SQLite3Stmt and SQLite3Result. (cmb)
. Added support for the SQLite @name notation. (cmb, BohwaZ) . Added support for the SQLite @name notation. (cmb, BohwaZ)

View file

@ -135,8 +135,9 @@ PHP 7.4 UPGRADE NOTES
Use corresponding constants instead (e.g. ReflectionMethod::IS_PUBLIC). Use corresponding constants instead (e.g. ReflectionMethod::IS_PUBLIC).
- SQLite3: - SQLite3:
. The bundled libsqlite has been removed. To build the SQLite3 and/or . The bundled libsqlite has been removed. To build the SQLite3 extension
PDO_SQLite extensions a system libsqlite3 ≥ 3.5.0 is now required. a system libsqlite3 ≥ 3.7.4 is now required. To build the PDO_SQLite
extension a system libsqlite3 ≥ 3.5.0 is now required.
. (Un)serialization of SQLite3, SQLite3Stmt and SQLite3Result is now explictly . (Un)serialization of SQLite3, SQLite3Stmt and SQLite3Result is now explictly
forbidden. Formerly, serialization of instances of these classes was forbidden. Formerly, serialization of instances of these classes was
possible, but unserialization yielded unusable objects. possible, but unserialization yielded unusable objects.

View file

@ -33,14 +33,14 @@ if test $PHP_SQLITE3 != "no"; then
AC_MSG_ERROR([Please reinstall the sqlite distribution from http://www.sqlite.org]) AC_MSG_ERROR([Please reinstall the sqlite distribution from http://www.sqlite.org])
fi fi
AC_MSG_CHECKING([for SQLite 3.5.0+]) AC_MSG_CHECKING([for SQLite 3.7.4+])
PHP_CHECK_LIBRARY(sqlite3, sqlite3_open_v2, [ PHP_CHECK_LIBRARY(sqlite3, sqlite3_stmt_readonly, [
AC_MSG_RESULT(found) AC_MSG_RESULT(found)
PHP_ADD_LIBRARY_WITH_PATH(sqlite3, $SQLITE3_DIR/$PHP_LIBDIR, SQLITE3_SHARED_LIBADD) PHP_ADD_LIBRARY_WITH_PATH(sqlite3, $SQLITE3_DIR/$PHP_LIBDIR, SQLITE3_SHARED_LIBADD)
PHP_ADD_INCLUDE($SQLITE3_DIR/include) PHP_ADD_INCLUDE($SQLITE3_DIR/include)
],[ ],[
AC_MSG_RESULT([not found]) AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please install SQLite 3.5.0 first or check libsqlite3 is present]) AC_MSG_ERROR([Please install SQLite 3.7.4 first or check libsqlite3 is present])
],[ ],[
-L$SQLITE3_DIR/$PHP_LIBDIR -lm -L$SQLITE3_DIR/$PHP_LIBDIR -lm
]) ])

View file

@ -1386,11 +1386,9 @@ PHP_METHOD(sqlite3stmt, readOnly)
SQLITE3_CHECK_INITIALIZED(stmt_obj->db_obj, stmt_obj->initialised, SQLite3); SQLITE3_CHECK_INITIALIZED(stmt_obj->db_obj, stmt_obj->initialised, SQLite3);
SQLITE3_CHECK_INITIALIZED_STMT(stmt_obj->stmt, SQLite3Stmt); SQLITE3_CHECK_INITIALIZED_STMT(stmt_obj->stmt, SQLite3Stmt);
#if SQLITE_VERSION_NUMBER >= 3007004
if (sqlite3_stmt_readonly(stmt_obj->stmt)) { if (sqlite3_stmt_readonly(stmt_obj->stmt)) {
RETURN_TRUE; RETURN_TRUE;
} }
#endif
RETURN_FALSE; RETURN_FALSE;
} }
/* }}} */ /* }}} */