Skip to content

Commit 6083a38

Browse files
committed
Unbundle libsqlite3
Since there is no need to patch libsqlite3 for our purposes, and since libsqlite3 ≥ 3.3.9 (which is our current requirement) is widely available on distros, there is no reason anymore to bundle the library. Besides removing the bundled libsqlite, and adapting the configuration respectively, we also fix the use of the SQLITE_ENABLE_COLUMN_METADATA compile time constant to detect whether sqlite3_column_table_name() is available by a working feature detection (otherwise bug_42589.phpt would fail). We also skip bug73068.phpt for libsqlite 3.11.0 to 3.14.1 which have a bug (<https://sqlite.org/src/info/ef360601>). We also completely drop support for the obscure pdo_sqlite_external extension (which could have been enabled on Windows only by passing `--pdo-sqlite-external` to configure), since it is not needed anymore. Furthermore, we remove references to the bundled libsqlite from Makefile.gcov, CONTRIBUTING.md and README.REDIST.BINS.
1 parent 61330b0 commit 6083a38

File tree

14 files changed

+134
-231540
lines changed

14 files changed

+134
-231540
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ addons:
1717
- libsasl2-dev
1818
- libxpm-dev
1919
- libzip-dev
20+
- libsqlite3-dev
2021

2122

2223
services:

CONTRIBUTING.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ locations.
154154
└─ ...
155155
└─ skeleton/ # Skeleton for developing new extensions with `ext/ext_skel.php`
156156
└─ ...
157-
└─ sqlite3/
158-
├─ libsqlite/ # https://www.sqlite.org mirror: https://github.com/mackyle/sqlite
159-
└─ ...
160157
└─ standard/
161158
└─ html_tables/
162159
├─ mappings/ # https://www.unicode.org/Public/MAPPINGS/

Makefile.gcov

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ php_lcov.info: lcov-test
5757
cp $$x.bbg lcov_data/$$y.bbg ; \
5858
fi; \
5959
done; \
60-
for dir in ext/bcmath/libbcmath ext/date/lib ext/fileinfo/libmagic ext/gd/libgd ext/mbstring/libmbfl ext/mbstring/oniguruma ext/pcre/pcre2lib ext/sqlite3/libsqlite ext/xmlrpc/libxmlrpc ext/zip/lib; do \
60+
for dir in ext/bcmath/libbcmath ext/date/lib ext/fileinfo/libmagic ext/gd/libgd ext/mbstring/libmbfl ext/mbstring/oniguruma ext/pcre/pcre2lib ext/xmlrpc/libxmlrpc ext/zip/lib; do \
6161
if test -d lcov_data/$$dir; then \
6262
rm -rf lcov_data/$$dir ; \
6363
fi; \

README.REDIST.BINS

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
1. libmagic (ext/fileinfo) see ext/fileinfo/libmagic/LICENSE
2-
2. Oniguruma (ext/mbstring) see ext/mbstring/oniguruma/COPYING
3-
3. libmbfl (ext/mbstring) see ext/mbstring/libmbfl/LICENSE
4-
4. pcre2lib (ext/pcre)
5-
5. ext/standard crypt
6-
6. ext/standard crypt's blowfish implementation
7-
7. Sqlite/Sqlite3 ext/sqlite3 ext/sqlite
8-
8. ext/standard/rand
9-
9. ext/standard/scanf
10-
10. ext/standard/strnatcmp.c
11-
11. ext/standard/uuencode
12-
12. libxmlrpc ext/xmlrpc
13-
13. main/snprintf.c
14-
14. main/strlcat
15-
15. main/strlcpy
16-
16. libgd see ext/gd/libgd/COPYING
17-
17. ext/phar portions of tar implementations
18-
18. ext/phar/zip.c portion extracted from libzip
19-
19. libbcmath (ext/bcmath) see ext/bcmath/libbcmath/COPYING.LIB
1+
1. libmagic (ext/fileinfo) see ext/fileinfo/libmagic/LICENSE
2+
2. Oniguruma (ext/mbstring) see ext/mbstring/oniguruma/COPYING
3+
3. libmbfl (ext/mbstring) see ext/mbstring/libmbfl/LICENSE
4+
4. pcre2lib (ext/pcre)
5+
5. ext/standard crypt
6+
6. ext/standard crypt's blowfish implementation
7+
7. ext/standard/rand
8+
8. ext/standard/scanf
9+
9. ext/standard/strnatcmp.c
10+
10. ext/standard/uuencode
11+
11. libxmlrpc ext/xmlrpc
12+
12. main/snprintf.c
13+
13. main/strlcat
14+
14. main/strlcpy
15+
15. libgd see ext/gd/libgd/COPYING
16+
16. ext/phar portions of tar implementations
17+
17. ext/phar/zip.c portion extracted from libzip
18+
18. libbcmath (ext/bcmath) see ext/bcmath/libbcmath/COPYING.LIB
2019

2120

2221
4. pcre2lib (ext/pcre)
@@ -195,16 +194,7 @@ Blowfish library (I can't be sure if I would think of something if I
195194
hadn't seen his code).
196195

197196

198-
7. Sqlite/Sqlite3 ext/sqlite3 ext/sqlite
199-
200-
The author disclaims copyright to this source code. In place of
201-
a legal notice, here is a blessing:
202-
May you do good and not evil.
203-
May you find forgiveness for yourself and forgive others.
204-
May you share freely, never taking more than you give.
205-
206-
207-
8. ext/standard/rand
197+
7. ext/standard/rand
208198

209199
The following php_mt_...() functions are based on a C++ class MTRand by
210200
Richard J. Wagner. For more information see the web page at
@@ -258,7 +248,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
258248
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
259249

260250

261-
9. ext/standard/scanf
251+
8. ext/standard/scanf
262252

263253
scanf.c --
264254

@@ -306,7 +296,7 @@ permission to use and distribute the software in accordance with the
306296
terms specified in this license.
307297

308298

309-
10. ext/standard/strnatcmp.c
299+
9. ext/standard/strnatcmp.c
310300

311301
strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
312302
Copyright (C) 2000 by Martin Pool <mbp@humbug.org.au>
@@ -328,7 +318,7 @@ freely, subject to the following restrictions:
328318
3. This notice may not be removed or altered from any source distribution.
329319

330320

331-
11. ext/standard/uuencode
321+
10. ext/standard/uuencode
332322

333323
Portions of this code are based on Berkeley's uuencode/uudecode
334324
implementation.
@@ -365,7 +355,7 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
365355
SUCH DAMAGE.
366356

367357

368-
12. libxmlrpc ext/xmlrpc
358+
11. libxmlrpc ext/xmlrpc
369359

370360
Copyright 2000 Epinions, Inc.
371361

@@ -390,7 +380,7 @@ NEGLIGENCE), EVEN IF EPINIONS, INC. IS AWARE OF THE POSSIBILITY OF SUCH
390380
DAMAGES.
391381

392382

393-
13. main/snprintf.c
383+
12. main/snprintf.c
394384

395385
Copyright (c) 2002, 2006 Todd C. Miller <Todd.Miller@courtesan.com>
396386

@@ -465,8 +455,8 @@ SIO stdio-replacement strx_* functions by Panos Tsirigotis
465455
<panos@alumni.cs.colorado.edu> for xinetd.
466456

467457

468-
14. main/strlcat
469-
15. main/strlcpy
458+
13. main/strlcat
459+
14. main/strlcpy
470460

471461
Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
472462
All rights reserved.
@@ -494,7 +484,7 @@ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
494484
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
495485

496486

497-
17. ext/phar portions of tar implementations
487+
16. ext/phar portions of tar implementations
498488

499489
portions of tar implementations in ext/phar - phar_tar_octal() are based on an
500490
implementation by Tim Kientzle from libarchive, licensed with this license:
@@ -523,7 +513,7 @@ implementation by Tim Kientzle from libarchive, licensed with this license:
523513
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
524514

525515

526-
18. ext/phar/zip.c portion extracted from libzip
516+
17. ext/phar/zip.c portion extracted from libzip
527517

528518
zip_dirent.c -- read directory entry (local or central), clean dirent
529519
Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner

ext/pdo_sqlite/config.m4

Lines changed: 39 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -31,78 +31,50 @@ if test "$PHP_PDO_SQLITE" != "no"; then
3131

3232
php_pdo_sqlite_sources_core="pdo_sqlite.c sqlite_driver.c sqlite_statement.c"
3333

34-
if test "$PHP_PDO_SQLITE" != "yes"; then
35-
SEARCH_PATH="$PHP_PDO_SQLITE /usr/local /usr" # you might want to change this
36-
SEARCH_FOR="/include/sqlite3.h" # you most likely want to change this
37-
if test -r $PHP_PDO_SQLITE/$SEARCH_FOR; then # path given as parameter
38-
PDO_SQLITE_DIR=$PHP_PDO_SQLITE
39-
else # search default path list
40-
AC_MSG_CHECKING([for sqlite3 files in default path])
41-
for i in $SEARCH_PATH ; do
42-
if test -r $i/$SEARCH_FOR; then
43-
PDO_SQLITE_DIR=$i
44-
AC_MSG_RESULT(found in $i)
45-
fi
46-
done
47-
fi
48-
if test -z "$PDO_SQLITE_DIR"; then
49-
AC_MSG_RESULT([not found])
50-
AC_MSG_ERROR([Please reinstall the sqlite3 distribution])
51-
fi
52-
53-
PHP_ADD_INCLUDE($PDO_SQLITE_DIR/include)
54-
55-
LIBNAME=sqlite3
56-
LIBSYMBOL=sqlite3_open
57-
58-
PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
59-
[
60-
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $PDO_SQLITE_DIR/$PHP_LIBDIR, PDO_SQLITE_SHARED_LIBADD)
61-
AC_DEFINE(HAVE_PDO_SQLITELIB,1,[ ])
62-
],[
63-
AC_MSG_ERROR([wrong sqlite lib version or lib not found])
64-
],[
65-
-L$PDO_SQLITE_DIR/$PHP_LIBDIR -lm
66-
])
67-
PHP_CHECK_LIBRARY(sqlite3,sqlite3_key,[
68-
AC_DEFINE(HAVE_SQLITE3_KEY,1, [have commercial sqlite3 with crypto support])
69-
])
70-
PHP_CHECK_LIBRARY(sqlite3,sqlite3_close_v2,[
71-
AC_DEFINE(HAVE_SQLITE3_CLOSE_V2, 1, [have sqlite3_close_v2])
72-
])
73-
74-
PHP_SUBST(PDO_SQLITE_SHARED_LIBADD)
75-
PHP_NEW_EXTENSION(pdo_sqlite, $php_pdo_sqlite_sources_core, $ext_shared,,-I$pdo_cv_inc_path)
76-
else
77-
# use bundled libs
78-
if test "$enable_maintainer_zts" = "yes"; then
79-
threadsafe_flags="-DSQLITE_THREADSAFE=1"
80-
else
81-
threadsafe_flags="-DSQLITE_THREADSAFE=0"
82-
fi
83-
84-
AC_DEFINE(HAVE_SQLITE3_CLOSE_V2, 1, [have sqlite3_close_v2])
85-
other_flags="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_CORE=1 -DSQLITE_ENABLE_COLUMN_METADATA=1"
86-
87-
dnl As long as intl is not shared we can have ICU support
88-
if test "$PHP_INTL" = "yes" && test "$PHP_INTL_SHARED" != "yes"; then
89-
other_flags="$other_flags -DSQLITE_ENABLE_ICU=1"
34+
SEARCH_PATH="$PHP_PDO_SQLITE /usr/local /usr" # you might want to change this
35+
SEARCH_FOR="/include/sqlite3.h" # you most likely want to change this
36+
if test -r $PHP_PDO_SQLITE/$SEARCH_FOR; then # path given as parameter
37+
PDO_SQLITE_DIR=$PHP_PDO_SQLITE
38+
else # search default path list
39+
AC_MSG_CHECKING([for sqlite3 files in default path])
40+
for i in $SEARCH_PATH ; do
41+
if test -r $i/$SEARCH_FOR; then
42+
PDO_SQLITE_DIR=$i
43+
AC_MSG_RESULT(found in $i)
9044
fi
45+
done
46+
fi
47+
if test -z "$PDO_SQLITE_DIR"; then
48+
AC_MSG_RESULT([not found])
49+
AC_MSG_ERROR([Please reinstall the sqlite3 distribution])
50+
fi
9151

92-
if test "$PHP_SQLITE3" != "yes"; then
93-
PHP_ADD_SOURCES(PHP_EXT_DIR(sqlite3), libsqlite/sqlite3.c)
94-
fi
52+
PHP_ADD_INCLUDE($PDO_SQLITE_DIR/include)
9553

96-
PHP_NEW_EXTENSION(pdo_sqlite,
97-
$php_pdo_sqlite_sources_core,
98-
$ext_shared,,-DPDO_SQLITE_BUNDLED=1 $other_flags $threadsafe_flags -I$pdo_cv_inc_path)
54+
LIBNAME=sqlite3
55+
LIBSYMBOL=sqlite3_open
9956

100-
PHP_SUBST(PDO_SQLITE_SHARED_LIBADD)
101-
PHP_ADD_EXTENSION_DEP(pdo_sqlite, sqlite3)
102-
PHP_ADD_INCLUDE($abs_srcdir/ext/sqlite3/libsqlite)
57+
PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
58+
[
59+
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $PDO_SQLITE_DIR/$PHP_LIBDIR, PDO_SQLITE_SHARED_LIBADD)
60+
AC_DEFINE(HAVE_PDO_SQLITELIB,1,[ ])
61+
],[
62+
AC_MSG_ERROR([wrong sqlite lib version or lib not found])
63+
],[
64+
-L$PDO_SQLITE_DIR/$PHP_LIBDIR -lm
65+
])
66+
PHP_CHECK_LIBRARY(sqlite3,sqlite3_key,[
67+
AC_DEFINE(HAVE_SQLITE3_KEY,1, [have commercial sqlite3 with crypto support])
68+
])
69+
PHP_CHECK_LIBRARY(sqlite3,sqlite3_close_v2,[
70+
AC_DEFINE(HAVE_SQLITE3_CLOSE_V2, 1, [have sqlite3_close_v2])
71+
])
72+
PHP_CHECK_LIBRARY(sqlite3,sqlite3_column_table_name,[
73+
AC_DEFINE(HAVE_SQLITE3_COLUMN_TABLE_NAME, 1, [have sqlite3_column_table_name])
74+
])
10375

104-
AC_CHECK_FUNCS(usleep nanosleep)
105-
fi
76+
PHP_SUBST(PDO_SQLITE_SHARED_LIBADD)
77+
PHP_NEW_EXTENSION(pdo_sqlite, $php_pdo_sqlite_sources_core, $ext_shared,,-I$pdo_cv_inc_path)
10678

10779
dnl Solaris fix
10880
PHP_CHECK_LIBRARY(rt, fdatasync, [PHP_ADD_LIBRARY(rt,, PDO_SQLITE_SHARED_LIBADD)])

ext/pdo_sqlite/config.w32

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,12 @@
33
ARG_WITH("pdo-sqlite", "for pdo_sqlite support", "no");
44

55
if (PHP_PDO_SQLITE != "no") {
6-
EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c", null, "/DSQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_FTS4=1 /D SQLITE_ENABLE_FTS5=1 /D SQLITE_ENABLE_JSON1=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 /I" + configure_module_dirname + "/../sqlite3/libsqlite /I" + configure_module_dirname);
7-
8-
ADD_EXTENSION_DEP('pdo_sqlite', 'pdo');
9-
// If pdo_sqlite is static, and sqlite3 is also static, then we don't add a second copy of the sqlite3 libs
10-
if (PHP_PDO_SQLITE_SHARED || PHP_SQLITE3_SHARED || PHP_SQLITE3 == 'no') {
11-
ADD_SOURCES(configure_module_dirname + "/../sqlite3/libsqlite", "sqlite3.c", "pdo_sqlite");
12-
}
13-
}
6+
if (SETUP_SQLITE3("pdo_sqlite", PHP_PDO_SQLITE, PHP_PDO_SQLITE_SHARED)) {
7+
EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c");
148

15-
ARG_WITH("pdo-sqlite-external", "for pdo_sqlite support from an external dll", "no");
16-
if (PHP_PDO_SQLITE_EXTERNAL != "no") {
17-
if (CHECK_HEADER_ADD_INCLUDE("sqlite3.h", "CFLAGS_PDO_SQLITE_EXTERNAL", PHP_PDO_SQLITE_EXTERNAL + ";" + PHP_PHP_BUILD + "\\include\\sqlite3") &&
18-
CHECK_LIB("sqlite3-import.lib", "pdo_sqlite_external", PHP_PDO_SQLITE_EXTERNAL + ";" + PHP_PHP_BUILD + "\\lib")
19-
&& ADD_EXTENSION_DEP('pdo_sqlite_external', 'pdo') ) {
20-
EXTENSION("pdo_sqlite_external", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c", null, "/I" + configure_module_dirname, null, "ext\\pdo_sqlite_external");
9+
ADD_EXTENSION_DEP('pdo_sqlite', 'pdo');
10+
AC_DEFINE("HAVE_SQLITE3_COLUMN_TABLE_NAME", 1, "have sqlite3_column_table_name");
2111
} else {
22-
WARNING("pdo-sqlite-external support can't be enabled, libraries or headers are missing")
23-
PHP_PDO_SQLITE_EXTERNAL = "no"
12+
WARNING("pdo_sqlite not enabled; libraries and/or headers not found");
2413
}
2514
}

ext/pdo_sqlite/sqlite_statement.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *ret
331331
add_assoc_string(return_value, "sqlite:decl_type", (char *)str);
332332
}
333333

334-
#ifdef SQLITE_ENABLE_COLUMN_METADATA
334+
#ifdef HAVE_SQLITE3_COLUMN_TABLE_NAME
335335
str = sqlite3_column_table_name(S->stmt, colno);
336336
if (str) {
337337
add_assoc_string(return_value, "table", (char *)str);

ext/sqlite3/config.w32

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
ARG_WITH("sqlite3", "SQLite 3 support", "no");
44

55
if (PHP_SQLITE3 != "no") {
6-
ADD_FLAG("CFLAGS_SQLITE3", "/D SQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_FTS4=1 /D SQLITE_ENABLE_FTS5=1 /D SQLITE_ENABLE_JSON1=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 /D SQLITE_API=__declspec(dllexport) ");
7-
EXTENSION("sqlite3", "sqlite3.c", null, "/I" + configure_module_dirname + "/libsqlite /I" + configure_module_dirname + " /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
8-
9-
ADD_SOURCES(configure_module_dirname + "/libsqlite", "sqlite3.c", "sqlite3");
10-
11-
AC_DEFINE("HAVE_SQLITE3", 1, "SQLite support");
12-
AC_DEFINE("HAVE_SQLITE3_ERRSTR", 1, "have sqlite3_errstr function")
13-
AC_DEFINE("HAVE_SQLITE3_CLOSE_V2", 1, "have sqlite3_close_v2")
14-
PHP_INSTALL_HEADERS("ext/sqlite3", "libsqlite/sqlite3.h");
6+
if (SETUP_SQLITE3("sqlite3", PHP_SQLITE3, PHP_SQLITE3_SHARED)) {
7+
EXTENSION("sqlite3", "sqlite3.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
8+
9+
AC_DEFINE("HAVE_SQLITE3", 1, "SQLite support");
10+
AC_DEFINE("HAVE_SQLITE3_ERRSTR", 1, "have sqlite3_errstr function");
11+
AC_DEFINE("HAVE_SQLITE3_CLOSE_V2", 1, "have sqlite3_close_v2");
12+
} else {
13+
WARNING("sqlite3 not enabled; libraries and/or headers not found");
14+
}
1515
}

0 commit comments

Comments
 (0)