com php-src: fix build with old system libsqlite (sqlite3 _errstr may be missing): ext/sqlite3/config0 .m4 ext/sqlite3/sqlite3.c
| From: | Remi Collet | Date: | Wed, 02 Aug 2017 12:01:56 +0000 |
| Subject: | com php-src: fix build with old system libsqlite (sqlite3 _errstr may be missing): ext/sqlite3/config0 .m4 ext/sqlite3/sqlite3.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98908@lists.php.net to get a copy of this message | ||
Commit: 666cb6c80226467be262c088a26246c48cdef7e5
Author: Remi Collet <remi@php.net> Wed, 2 Aug 2017 14:01:56 +0200
Parents: b2934d2612a1d1d422010ff47c4a9d2a00ed83ee
Branches: PHP-7.0 PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=666cb6c80226467be262c088a26246c48cdef7e5
Log:
fix build with old system libsqlite (sqlite3_errstr may be missing)
Changed paths:
M ext/sqlite3/config0.m4
M ext/sqlite3/sqlite3.c
Diff:
diff --git a/ext/sqlite3/config0.m4 b/ext/sqlite3/config0.m4
index 3aa4492..ba760e1 100644
--- a/ext/sqlite3/config0.m4
+++ b/ext/sqlite3/config0.m4
@@ -53,6 +53,9 @@ if test $PHP_SQLITE3 != "no"; then
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_errstr,[
+ AC_DEFINE(HAVE_SQLITE3_ERRSTR, 1, [have sqlite3_errstr function])
+ ])
PHP_CHECK_LIBRARY(sqlite3,sqlite3_load_extension,
[],
@@ -75,7 +78,7 @@ if test $PHP_SQLITE3 != "no"; then
debug_flags="-DSQLITE_DEBUG=1"
fi
- other_flags="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1
-DSQLITE_CORE=1 -DSQLITE_ENABLE_COLUMN_METADATA=1"
+ other_flags="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1
-DSQLITE_CORE=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DHAVE_SQLITE3_ERRSTR=1"
dnl As long as intl is not shared we can have ICU support
if test "$PHP_INTL" = "yes" && test "$PHP_INTL_SHARED" !=
"yes"; then
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index dcbc03c..a22f455 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -148,7 +148,11 @@ PHP_METHOD(sqlite3, open)
#endif
if (rc != SQLITE_OK) {
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s",
+#ifdef HAVE_SQLITE3_ERRSTR
db_obj->db ? sqlite3_errmsg(db_obj->db) : sqlite3_errstr(rc));
+#else
+ db_obj->db ? sqlite3_errmsg(db_obj->db) : "");
+#endif
if (fullpath != filename) {
efree(fullpath);
}