diff options
Diffstat (limited to 'dev-db/sqlite/files')
4 files changed, 1548 insertions, 0 deletions
diff --git a/dev-db/sqlite/files/sqlite-3.28.0-full_archive-build.patch b/dev-db/sqlite/files/sqlite-3.28.0-full_archive-build.patch new file mode 100644 index 000000000000..95b53328c43c --- /dev/null +++ b/dev-db/sqlite/files/sqlite-3.28.0-full_archive-build.patch @@ -0,0 +1,461 @@ +Move some code to libsqlite3.so to avoid duplication. +Link executables against libsqlite3.so. +Increase timeout for fuzzcheck. +Fix building with dlopen() not available. + +--- /Makefile.in ++++ /Makefile.in +@@ -311,6 +311,9 @@ + # Source code for extensions + # + SRC += \ ++ $(TOP)/ext/expert/sqlite3expert.c \ ++ $(TOP)/ext/expert/sqlite3expert.h ++SRC += \ + $(TOP)/ext/fts1/fts1.c \ + $(TOP)/ext/fts1/fts1.h \ + $(TOP)/ext/fts1/fts1_hash.c \ +@@ -363,8 +366,11 @@ + $(TOP)/ext/rbu/sqlite3rbu.h \ + $(TOP)/ext/rbu/sqlite3rbu.c + SRC += \ ++ $(TOP)/ext/misc/appendvfs.c \ + $(TOP)/ext/misc/json1.c \ +- $(TOP)/ext/misc/stmt.c ++ $(TOP)/ext/misc/sqlar.c \ ++ $(TOP)/ext/misc/stmt.c \ ++ $(TOP)/ext/misc/zipfile.c + + # Generated source code files + # +@@ -435,7 +441,6 @@ + # Statically linked extensions + # + TESTSRC += \ +- $(TOP)/ext/expert/sqlite3expert.c \ + $(TOP)/ext/expert/test_expert.c \ + $(TOP)/ext/misc/amatch.c \ + $(TOP)/ext/misc/carray.c \ +@@ -461,7 +466,6 @@ + $(TOP)/ext/misc/totype.c \ + $(TOP)/ext/misc/unionvtab.c \ + $(TOP)/ext/misc/wholenumber.c \ +- $(TOP)/ext/misc/zipfile.c \ + $(TOP)/ext/userauth/userauth.c + + # Source code to the library files needed by the test fixture +@@ -640,25 +644,25 @@ + + libtclsqlite3.la: tclsqlite.lo libsqlite3.la + $(LTLINK) -no-undefined -o $@ tclsqlite.lo \ +- libsqlite3.la @TCL_STUB_LIB_SPEC@ $(TLIBS) \ ++ libsqlite3.la @TCL_STUB_LIB_SPEC@ \ + -rpath "$(TCLLIBDIR)" \ + -version-info "8:6:8" \ + -avoid-version + +-sqlite3$(TEXE): shell.c sqlite3.c +- $(LTLINK) $(READLINE_FLAGS) $(SHELL_OPT) -o $@ \ +- shell.c sqlite3.c \ +- $(LIBREADLINE) $(TLIBS) -rpath "$(libdir)" ++sqlite3$(TEXE): shell.c libsqlite3.la ++ $(LTLINK) $(READLINE_FLAGS) -o $@ \ ++ shell.c libsqlite3.la \ ++ $(LIBREADLINE) + +-sqldiff$(TEXE): $(TOP)/tool/sqldiff.c sqlite3.lo sqlite3.h +- $(LTLINK) -o $@ $(TOP)/tool/sqldiff.c sqlite3.lo $(TLIBS) ++sqldiff$(TEXE): $(TOP)/tool/sqldiff.c libsqlite3.la ++ $(LTLINK) -o $@ $(TOP)/tool/sqldiff.c libsqlite3.la + +-dbhash$(TEXE): $(TOP)/tool/dbhash.c sqlite3.lo sqlite3.h +- $(LTLINK) -o $@ $(TOP)/tool/dbhash.c sqlite3.lo $(TLIBS) ++dbhash$(TEXE): $(TOP)/tool/dbhash.c libsqlite3.la ++ $(LTLINK) -o $@ $(TOP)/tool/dbhash.c libsqlite3.la + +-scrub$(TEXE): $(TOP)/ext/misc/scrub.c sqlite3.lo ++scrub$(TEXE): $(TOP)/ext/misc/scrub.c libsqlite3.la + $(LTLINK) -o $@ -I. -DSCRUB_STANDALONE \ +- $(TOP)/ext/misc/scrub.c sqlite3.lo $(TLIBS) ++ $(TOP)/ext/misc/scrub.c libsqlite3.la + + srcck1$(BEXE): $(TOP)/tool/srcck1.c + $(BCC) -o srcck1$(BEXE) $(TOP)/tool/srcck1.c +@@ -768,7 +772,7 @@ + # Rule to build the amalgamation + # + sqlite3.lo: sqlite3.c +- $(LTCOMPILE) $(TEMP_STORE) -c sqlite3.c ++ $(LTCOMPILE) $(SHELL_OPT) $(TEMP_STORE) -c sqlite3.c + + # Rules to build the LEMON compiler generator + # +@@ -1065,14 +1069,9 @@ + # Source files that go into making shell.c + SHELL_SRC = \ + $(TOP)/src/shell.c.in \ +- $(TOP)/ext/misc/appendvfs.c \ + $(TOP)/ext/misc/shathree.c \ + $(TOP)/ext/misc/fileio.c \ + $(TOP)/ext/misc/completion.c \ +- $(TOP)/ext/misc/sqlar.c \ +- $(TOP)/ext/expert/sqlite3expert.c \ +- $(TOP)/ext/expert/sqlite3expert.h \ +- $(TOP)/ext/misc/zipfile.c \ + $(TOP)/ext/misc/memtrace.c \ + $(TOP)/src/test_windirent.c + +@@ -1240,15 +1239,15 @@ + + # Fuzz testing + fuzztest: fuzzcheck$(TEXE) $(FUZZDATA) sessionfuzz$(TEXE) $(TOP)/test/sessionfuzz-data1.db +- ./fuzzcheck$(TEXE) $(FUZZDATA) ++ ./fuzzcheck$(TEXE) --timeout 3600 $(FUZZDATA) + ./sessionfuzz$(TEXE) run $(TOP)/test/sessionfuzz-data1.db + + fastfuzztest: fuzzcheck$(TEXE) $(FUZZDATA) sessionfuzz$(TEXE) $(TOP)/test/sessionfuzz-data1.db +- ./fuzzcheck$(TEXE) --limit-mem 100M $(FUZZDATA) ++ ./fuzzcheck$(TEXE) --limit-mem 100M --timeout 3600 $(FUZZDATA) + ./sessionfuzz$(TEXE) run $(TOP)/test/sessionfuzz-data1.db + + valgrindfuzz: fuzzcheck$(TEXT) $(FUZZDATA) sessionfuzz$(TEXE) $(TOP)/test/sessionfuzz-data1.db +- valgrind ./fuzzcheck$(TEXE) --cell-size-check --limit-mem 10M --timeout 600 $(FUZZDATA) ++ valgrind ./fuzzcheck$(TEXE) --cell-size-check --limit-mem 10M --timeout 3600 $(FUZZDATA) + valgrind ./sessionfuzz$(TEXE) run $(TOP)/test/sessionfuzz-data1.db + + # The veryquick.test TCL tests. +@@ -1279,24 +1278,23 @@ + smoketest: $(TESTPROGS) fuzzcheck$(TEXE) + ./testfixture$(TEXE) $(TOP)/test/main.test $(TESTOPTS) + +-sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqlite3_analyzer.c.in ++sqlite3_analyzer.c: $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqlite3_analyzer.c.in + $(TCLSH_CMD) $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqlite3_analyzer.c.in >sqlite3_analyzer.c + +-sqlite3_analyzer$(TEXE): sqlite3_analyzer.c +- $(LTLINK) sqlite3_analyzer.c -o $@ $(LIBTCL) $(TLIBS) ++sqlite3_analyzer$(TEXE): sqlite3_analyzer.c libsqlite3.la ++ $(LTLINK) sqlite3_analyzer.c -o $@ libsqlite3.la $(LIBTCL) + +-sqltclsh.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/sqltclsh.tcl $(TOP)/ext/misc/appendvfs.c $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in ++sqltclsh.c: $(TOP)/src/tclsqlite.c $(TOP)/tool/sqltclsh.tcl $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in + $(TCLSH_CMD) $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in >sqltclsh.c + +-sqltclsh$(TEXE): sqltclsh.c +- $(LTLINK) sqltclsh.c -o $@ $(LIBTCL) $(TLIBS) ++sqltclsh$(TEXE): sqltclsh.c libsqlite3.la ++ $(LTLINK) sqltclsh.c -o $@ libsqlite3.la $(LIBTCL) + +-sqlite3_expert$(TEXE): $(TOP)/ext/expert/sqlite3expert.h $(TOP)/ext/expert/sqlite3expert.c $(TOP)/ext/expert/expert.c sqlite3.c +- $(LTLINK) $(TOP)/ext/expert/sqlite3expert.h $(TOP)/ext/expert/sqlite3expert.c $(TOP)/ext/expert/expert.c sqlite3.c -o sqlite3_expert $(TLIBS) ++sqlite3_expert$(TEXE): $(TOP)/ext/expert/sqlite3expert.h $(TOP)/ext/expert/expert.c libsqlite3.la ++ $(LTLINK) $(TOP)/ext/expert/expert.c -o sqlite3_expert libsqlite3.la + + CHECKER_DEPS =\ + $(TOP)/tool/mkccode.tcl \ +- sqlite3.c \ + $(TOP)/src/tclsqlite.c \ + $(TOP)/ext/repair/sqlite3_checker.tcl \ + $(TOP)/ext/repair/checkindex.c \ +@@ -1307,36 +1305,36 @@ + sqlite3_checker.c: $(CHECKER_DEPS) + $(TCLSH_CMD) $(TOP)/tool/mkccode.tcl $(TOP)/ext/repair/sqlite3_checker.c.in >$@ + +-sqlite3_checker$(TEXE): sqlite3_checker.c +- $(LTLINK) sqlite3_checker.c -o $@ $(LIBTCL) $(TLIBS) ++sqlite3_checker$(TEXE): sqlite3_checker.c libsqlite3.la ++ $(LTLINK) sqlite3_checker.c -o $@ libsqlite3.la $(LIBTCL) + +-dbdump$(TEXE): $(TOP)/ext/misc/dbdump.c sqlite3.lo ++dbdump$(TEXE): $(TOP)/ext/misc/dbdump.c libsqlite3.la + $(LTLINK) -DDBDUMP_STANDALONE -o $@ \ +- $(TOP)/ext/misc/dbdump.c sqlite3.lo $(TLIBS) ++ $(TOP)/ext/misc/dbdump.c libsqlite3.la + +-dbtotxt$(TEXE): $(TOP)/tool/dbtotxt.c +- $(LTLINK)-o $@ $(TOP)/tool/dbtotxt.c ++dbtotxt$(TEXE): $(TOP)/tool/dbtotxt.c ++ $(LTLINK) -o $@ $(TOP)/tool/dbtotxt.c + +-showdb$(TEXE): $(TOP)/tool/showdb.c sqlite3.lo +- $(LTLINK) -o $@ $(TOP)/tool/showdb.c sqlite3.lo $(TLIBS) ++showdb$(TEXE): $(TOP)/tool/showdb.c libsqlite3.la ++ $(LTLINK) -o $@ $(TOP)/tool/showdb.c libsqlite3.la + +-showstat4$(TEXE): $(TOP)/tool/showstat4.c sqlite3.lo +- $(LTLINK) -o $@ $(TOP)/tool/showstat4.c sqlite3.lo $(TLIBS) ++showstat4$(TEXE): $(TOP)/tool/showstat4.c libsqlite3.la ++ $(LTLINK) -o $@ $(TOP)/tool/showstat4.c libsqlite3.la + +-showjournal$(TEXE): $(TOP)/tool/showjournal.c sqlite3.lo +- $(LTLINK) -o $@ $(TOP)/tool/showjournal.c sqlite3.lo $(TLIBS) ++showjournal$(TEXE): $(TOP)/tool/showjournal.c ++ $(LTLINK) -o $@ $(TOP)/tool/showjournal.c + +-showwal$(TEXE): $(TOP)/tool/showwal.c sqlite3.lo +- $(LTLINK) -o $@ $(TOP)/tool/showwal.c sqlite3.lo $(TLIBS) ++showwal$(TEXE): $(TOP)/tool/showwal.c ++ $(LTLINK) -o $@ $(TOP)/tool/showwal.c + + showshm$(TEXE): $(TOP)/tool/showshm.c + $(LTLINK) -o $@ $(TOP)/tool/showshm.c + +-index_usage$(TEXE): $(TOP)/tool/index_usage.c sqlite3.lo +- $(LTLINK) $(SHELL_OPT) -o $@ $(TOP)/tool/index_usage.c sqlite3.lo $(TLIBS) ++index_usage$(TEXE): $(TOP)/tool/index_usage.c libsqlite3.la ++ $(LTLINK) -o $@ $(TOP)/tool/index_usage.c libsqlite3.la + +-changeset$(TEXE): $(TOP)/ext/session/changeset.c sqlite3.lo +- $(LTLINK) -o $@ $(TOP)/ext/session/changeset.c sqlite3.lo $(TLIBS) ++changeset$(TEXE): $(TOP)/ext/session/changeset.c libsqlite3.la ++ $(LTLINK) -o $@ $(TOP)/ext/session/changeset.c libsqlite3.la + + changesetfuzz$(TEXE): $(TOP)/ext/session/changesetfuzz.c sqlite3.lo + $(LTLINK) -o $@ $(TOP)/ext/session/changesetfuzz.c sqlite3.lo $(TLIBS) +@@ -1361,11 +1359,11 @@ + kvtest$(TEXE): $(TOP)/test/kvtest.c sqlite3.c + $(LTLINK) $(KV_OPT) -o $@ $(TOP)/test/kvtest.c sqlite3.c $(TLIBS) + +-rbu$(EXE): $(TOP)/ext/rbu/rbu.c $(TOP)/ext/rbu/sqlite3rbu.c sqlite3.lo +- $(LTLINK) -I. -o $@ $(TOP)/ext/rbu/rbu.c sqlite3.lo $(TLIBS) ++rbu$(EXE): $(TOP)/ext/rbu/rbu.c libsqlite3.la ++ $(LTLINK) -I. -o $@ $(TOP)/ext/rbu/rbu.c libsqlite3.la + +-loadfts$(EXE): $(TOP)/tool/loadfts.c libsqlite3.la +- $(LTLINK) $(TOP)/tool/loadfts.c libsqlite3.la -o $@ $(TLIBS) ++loadfts$(EXE): $(TOP)/tool/loadfts.c libsqlite3.la ++ $(LTLINK) $(TOP)/tool/loadfts.c libsqlite3.la -o $@ + + # This target will fail if the SQLite amalgamation contains any exported + # symbols that do not begin with "sqlite3_". It is run as part of the +--- /configure.ac ++++ /configure.ac +@@ -587,6 +587,9 @@ + if test "${enable_load_extension}" = "yes" ; then + OPT_FEATURE_FLAGS="" + AC_SEARCH_LIBS(dlopen, dl) ++ if test "${ac_cv_search_dlopen}" = "no" ; then ++ OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1" ++ fi + else + OPT_FEATURE_FLAGS="-DSQLITE_OMIT_LOAD_EXTENSION=1" + fi +--- /ext/misc/sqlar.c ++++ /ext/misc/sqlar.c +@@ -14,6 +14,8 @@ + ** for working with sqlar archives and used by the shell tool's built-in + ** sqlar support. + */ ++#ifdef SQLITE_HAVE_ZLIB ++ + #include "sqlite3ext.h" + SQLITE_EXTENSION_INIT1 + #include <zlib.h> +@@ -119,3 +121,5 @@ + } + return rc; + } ++ ++#endif /* SQLITE_HAVE_ZLIB */ +--- /ext/misc/zipfile.c ++++ /ext/misc/zipfile.c +@@ -24,6 +24,8 @@ + ** * No support for zip64 extensions + ** * Only the "inflate/deflate" (zlib) compression method is supported + */ ++#ifdef SQLITE_HAVE_ZLIB ++ + #include "sqlite3ext.h" + SQLITE_EXTENSION_INIT1 + #include <stdio.h> +@@ -2176,3 +2178,5 @@ + (void)pzErrMsg; /* Unused parameter */ + return zipfileRegister(db); + } ++ ++#endif /* SQLITE_HAVE_ZLIB */ +--- /ext/repair/sqlite3_checker.c.in ++++ /ext/repair/sqlite3_checker.c.in +@@ -2,6 +2,7 @@ + ** Read an SQLite database file and analyze its space utilization. Generate + ** text on standard output. + */ ++#define SQLITE_CORE 1 + #define TCLSH_INIT_PROC sqlite3_checker_init_proc + #define SQLITE_ENABLE_DBPAGE_VTAB 1 + #define SQLITE_ENABLE_JSON1 1 +@@ -14,7 +15,7 @@ + #define SQLITE_OMIT_SHARED_CACHE 1 + #define SQLITE_DEFAULT_MEMSTATUS 0 + #define SQLITE_MAX_EXPR_DEPTH 0 +-INCLUDE sqlite3.c ++#include "sqlite3.h" + INCLUDE $ROOT/src/tclsqlite.c + INCLUDE $ROOT/ext/misc/btreeinfo.c + INCLUDE $ROOT/ext/repair/checkindex.c +--- /src/shell.c.in ++++ /src/shell.c.in +@@ -61,6 +61,7 @@ + #include <stdio.h> + #include <assert.h> + #include "sqlite3.h" ++#include "ext/expert/sqlite3expert.h" + typedef sqlite3_int64 i64; + typedef sqlite3_uint64 u64; + typedef unsigned char u8; +@@ -127,6 +128,10 @@ + # define SHELL_USE_LOCAL_GETLINE 1 + #endif + ++#ifdef SQLITE_HAVE_ZLIB ++#include <zlib.h> ++#endif ++ + + #if defined(_WIN32) || defined(WIN32) + # include <io.h> +@@ -939,14 +944,7 @@ + INCLUDE ../ext/misc/shathree.c + INCLUDE ../ext/misc/fileio.c + INCLUDE ../ext/misc/completion.c +-INCLUDE ../ext/misc/appendvfs.c + INCLUDE ../ext/misc/memtrace.c +-#ifdef SQLITE_HAVE_ZLIB +-INCLUDE ../ext/misc/zipfile.c +-INCLUDE ../ext/misc/sqlar.c +-#endif +-INCLUDE ../ext/expert/sqlite3expert.h +-INCLUDE ../ext/expert/sqlite3expert.c + + #if defined(SQLITE_ENABLE_SESSION) + /* +@@ -4000,7 +3998,9 @@ + sqlite3_shathree_init(p->db, 0, 0); + sqlite3_completion_init(p->db, 0, 0); + #ifdef SQLITE_HAVE_ZLIB ++ extern int sqlite3_zipfile_init(sqlite3 *, char **, const sqlite3_api_routines *); + sqlite3_zipfile_init(p->db, 0, 0); ++ extern int sqlite3_sqlar_init(sqlite3 *, char **, const sqlite3_api_routines *); + sqlite3_sqlar_init(p->db, 0, 0); + #endif + sqlite3_create_function(p->db, "shell_add_schema", 3, SQLITE_UTF8, 0, +@@ -5971,6 +5971,7 @@ + goto end_ar_command; + } + sqlite3_fileio_init(cmd.db, 0, 0); ++ extern int sqlite3_sqlar_init(sqlite3 *, char **, const sqlite3_api_routines *); + sqlite3_sqlar_init(cmd.db, 0, 0); + sqlite3_create_function(cmd.db, "shell_putsnl", 1, SQLITE_UTF8, cmd.p, + shellPutsFunc, 0, 0); +@@ -9260,6 +9261,7 @@ + #endif + } + data.out = stdout; ++ extern int sqlite3_appendvfs_init(sqlite3 *, char **, const sqlite3_api_routines *); + sqlite3_appendvfs_init(0,0,0); + + /* Go ahead and open the database file if it already exists. If the +--- /test/sessionfuzz.c ++++ /test/sessionfuzz.c +@@ -700,42 +700,6 @@ + #include <assert.h> + #include "zlib.h" + +-/* +-** Implementation of the "sqlar_uncompress(X,SZ)" SQL function +-** +-** Parameter SZ is interpreted as an integer. If it is less than or +-** equal to zero, then this function returns a copy of X. Or, if +-** SZ is equal to the size of X when interpreted as a blob, also +-** return a copy of X. Otherwise, decompress blob X using zlib +-** utility function uncompress() and return the results (another +-** blob). +-*/ +-static void sqlarUncompressFunc( +- sqlite3_context *context, +- int argc, +- sqlite3_value **argv +-){ +- uLong nData; +- uLongf sz; +- +- assert( argc==2 ); +- sz = sqlite3_value_int(argv[1]); +- +- if( sz<=0 || sz==(nData = sqlite3_value_bytes(argv[0])) ){ +- sqlite3_result_value(context, argv[0]); +- }else{ +- const Bytef *pData= sqlite3_value_blob(argv[0]); +- Bytef *pOut = sqlite3_malloc(sz); +- if( Z_OK!=uncompress(pOut, &sz, pData, nData) ){ +- sqlite3_result_error(context, "error in uncompress()", -1); +- }else{ +- sqlite3_result_blob(context, pOut, sz, SQLITE_TRANSIENT); +- } +- sqlite3_free(pOut); +- } +-} +- +- + /* Run a chunk of SQL. If any errors happen, print an error message + ** and exit. + */ +--- /tool/mksqlite3c.tcl ++++ /tool/mksqlite3c.tcl +@@ -117,6 +117,7 @@ + rtree.h + sqlite3session.h + sqlite3.h ++ sqlite3expert.h + sqlite3ext.h + sqlite3rbu.h + sqliteicu.h +@@ -403,6 +404,10 @@ + sqlite3session.c + fts5.c + stmt.c ++ appendvfs.c ++ sqlar.c ++ sqlite3expert.c ++ zipfile.c + } { + copy_file tsrc/$file + } +--- /tool/sqlite3_analyzer.c.in ++++ /tool/sqlite3_analyzer.c.in +@@ -14,9 +14,6 @@ + #define SQLITE_DEFAULT_MEMSTATUS 0 + #define SQLITE_MAX_EXPR_DEPTH 0 + #define SQLITE_OMIT_LOAD_EXTENSION 1 +-#ifndef USE_EXTERNAL_SQLITE +-INCLUDE sqlite3.c +-#endif + INCLUDE $ROOT/src/tclsqlite.c + + const char *sqlite3_analyzer_init_proc(Tcl_Interp *interp){ +--- /tool/sqltclsh.c.in ++++ /tool/sqltclsh.c.in +@@ -27,19 +27,17 @@ + #define SQLITE_OMIT_SHARED_CACHE 1 + #define SQLITE_DEFAULT_MEMSTATUS 0 + #define SQLITE_MAX_EXPR_DEPTH 0 +-INCLUDE sqlite3.c +-INCLUDE $ROOT/ext/misc/appendvfs.c +-#ifdef SQLITE_HAVE_ZLIB +-INCLUDE $ROOT/ext/misc/zipfile.c +-INCLUDE $ROOT/ext/misc/sqlar.c +-#endif ++#include "sqlite3.h" + INCLUDE $ROOT/src/tclsqlite.c + + const char *sqlite3_tclapp_init_proc(Tcl_Interp *interp){ + (void)interp; ++ extern int sqlite3_appendvfs_init(sqlite3 *,char **, const sqlite3_api_routines *); + sqlite3_appendvfs_init(0,0,0); + #ifdef SQLITE_HAVE_ZLIB ++ extern int sqlite3_sqlar_init(sqlite3 *, char **, const sqlite3_api_routines *); + sqlite3_auto_extension((void(*)(void))sqlite3_sqlar_init); ++ extern int sqlite3_zipfile_init(sqlite3 *, char **, const sqlite3_api_routines *); + sqlite3_auto_extension((void(*)(void))sqlite3_zipfile_init); + #endif + diff --git a/dev-db/sqlite/files/sqlite-3.28.0-full_archive-segmentation_fault_fixes.patch b/dev-db/sqlite/files/sqlite-3.28.0-full_archive-segmentation_fault_fixes.patch new file mode 100644 index 000000000000..cf430a9ddc5a --- /dev/null +++ b/dev-db/sqlite/files/sqlite-3.28.0-full_archive-segmentation_fault_fixes.patch @@ -0,0 +1,954 @@ +https://sqlite.org/src/info/b2ce5ed175cb5029 +https://sqlite.org/src/info/6e4a5f22811bcd14 +https://sqlite.org/src/info/516ca8945150bdc1 +https://sqlite.org/src/info/e1724f1d618cfbcf +https://sqlite.org/src/info/c621fc668c6538f9 +https://sqlite.org/src/info/c509d8a8aebe0da4 +https://sqlite.org/src/info/a9b90aa12eecdd9f + +--- /ext/fts3/fts3_write.c ++++ /ext/fts3/fts3_write.c +@@ -3754,7 +3754,7 @@ + } + p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix); + +- if( nPrefix>p->iOff || nSuffix>p->nNode-p->iOff ){ ++ if( nPrefix>p->term.n || nSuffix>p->nNode-p->iOff || nSuffix==0 ){ + return FTS_CORRUPT_VTAB; + } + blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc); +@@ -3773,7 +3773,7 @@ + } + } + +- assert( p->iOff<=p->nNode ); ++ assert_fts3_nc( p->iOff<=p->nNode ); + return rc; + } + +--- /ext/fts5/fts5_buffer.c ++++ /ext/fts5/fts5_buffer.c +@@ -178,7 +178,11 @@ + i64 iOff = *piOff; + int iVal; + fts5FastGetVarint32(a, i, iVal); +- if( iVal==1 ){ ++ if( iVal<=1 ){ ++ if( iVal==0 ){ ++ *pi = i; ++ return 0; ++ } + fts5FastGetVarint32(a, i, iVal); + iOff = ((i64)iVal) << 32; + fts5FastGetVarint32(a, i, iVal); +--- /ext/fts5/test/fts5corrupt3.test ++++ /ext/fts5/test/fts5corrupt3.test +@@ -8128,6 +8128,215 @@ + INSERT INTO t1(t1) VALUES('optimize') + } {1 {database disk image is malformed}} + ++#------------------------------------------------------------------------- ++reset_db ++do_test 58.0 { ++ sqlite3 db {} ++ db deserialize [decode_hexdb { ++.open --hexdb ++| size 24576 pagesize 4096 filename crash-5a5acd0ab42d31.db ++| page 1 offset 0 ++| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. ++| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........ ++| 96: 00 00 00 00 0d 00 00 00 06 0e 0f 00 0f aa 0f 53 ...............S ++| 112: 0e e8 0e 8b 0e 33 0e 0f 00 00 00 00 00 00 00 00 .....3.......... ++| 3584: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22 ................ ++| 3600: 06 06 17 11 11 01 31 74 61 62 6c 65 62 62 62 62 ......1tablebbbb ++| 3616: 06 43 52 45 41 54 45 20 54 41 42 4c 45 20 62 62 .CREATE TABLE bb ++| 3632: 28 61 29 56 05 06 17 1f 1f 01 7d 74 61 62 6c 65 (a)V.......table ++| 3648: 74 31 5f 63 2a 6e 66 69 68 74 31 5f 63 6f 6e 66 t1_c*nfiht1_conf ++| 3664: 69 67 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 ig.CREATE TABLE ++| 3680: 27 74 31 5f 63 6f 6e 66 69 67 27 28 6b 20 50 52 't1_config'(k PR ++| 3696: 49 4d 41 52 59 20 4b 45 59 2c 20 76 29 20 57 49 IMARY KEY, v) WI ++| 3712: 54 48 4f 55 54 20 52 4f 57 49 44 5b 04 07 17 21 THOUT ROWID[...! ++| 3728: 21 01 81 01 74 61 62 6c 65 74 31 5f 64 6f 73 73 !...tablet1_doss ++| 3744: 69 7a 65 74 31 5f 64 6f 63 73 69 7a 65 04 43 52 izet1_docsize.CR ++| 3760: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 64 EATE TABLE 't1_d ++| 3776: 6f 63 73 69 7a 65 27 28 69 64 20 49 4e 54 45 47 ocsize'(id INTEG ++| 3792: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 ER PRIMARY KEY, ++| 3808: 73 7a 20 42 4c 4f 42 29 69 03 07 17 19 19 01 81 sz BLOB)i....... ++| 3824: 2d 74 61 62 6c 65 74 31 5f 69 64 78 74 31 5f 69 -tablet1_idxt1_i ++| 3840: 64 78 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 dx.CREATE TABLE ++| 3856: 27 74 31 5f 69 64 78 27 28 73 65 67 69 64 2c 20 't1_idx'(segid, ++| 3872: 74 65 72 6d 2c 20 70 67 6e 6f 2c 20 50 52 49 4d term, pgno, PRIM ++| 3888: 41 52 59 20 4b 45 59 28 73 65 67 69 64 2c 20 74 ARY KEY(segid, t ++| 3904: 65 72 6d 29 29 20 57 49 54 48 4f 55 54 20 52 4f erm)) WITHOUT RO ++| 3920: 57 49 44 55 02 07 17 1b 1b 01 81 01 74 61 62 6c WIDU........tabl ++| 3936: 65 74 31 5f 64 61 74 61 74 31 5f 64 61 74 61 02 et1_datat1_data. ++| 3952: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 CREATE TABLE 't1 ++| 3968: 5f 64 61 74 61 27 28 69 64 20 49 4e 54 45 47 45 _data'(id INTEGE ++| 3984: 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 R PRIMARY KEY, b ++| 4000: 6c 6f 63 6b 20 42 4c 4f 42 29 54 01 07 17 11 11 lock BLOB)T..... ++| 4016: 08 81 15 74 61 62 6c 65 74 31 74 31 43 52 45 41 ...tablet1t1CREA ++| 4032: 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 TE VIRTUAL TABLE ++| 4048: 20 74 31 20 55 53 49 4e 47 20 66 74 73 35 28 61 t1 USING fts5(a ++| 4064: 2c 62 2c 70 72 65 66 69 78 3d 22 32 2c 32 2c 33 ,b,prefix=.2,2,3 ++| 4080: 2c 34 22 2c 20 63 6f 6e 74 65 6e 74 3d 22 22 29 ,4., content=..) ++| page 2 offset 4096 ++| 0: 0d 0b 6a 00 37 09 4c 02 0f e7 09 4c 0f c6 0f a4 ..j.7.L....L.... ++| 16: 0f 88 0f 6d 0f 4b 0f 2c 0f 0e 0e ec 0e cd 0e ae ...m.K.,........ ++| 32: 0e 8e 0e 6c 0e 4b 0e 29 0e 08 0d e6 0d c4 0d b5 ...l.K.)........ ++| 48: 0d 97 0d 76 0d 54 0d 30 fd 15 0c f3 0c d3 0c b5 ...v.T.0........ ++| 64: 0c 95 0c 73 0c 54 0c 32 0c 10 0b ee 0b cc 0b b0 ...s.T.2........ ++| 80: 0b 8d 0b 7e 0b 48 0b 2e 0b 0b 0a ef 0a cc 0a ad ...~.H.......... ++| 96: 0a 8c 0a 6d 0a 4d 0a 2b 0a 0c 00 00 00 00 00 00 ...m.M.+........ ++| 2368: 00 00 00 00 00 00 00 00 00 00 00 00 15 0a 03 00 ................ ++| 2384: 30 00 00 00 9c 01 03 35 00 03 01 01 12 02 01 12 0......5........ ++| 2400: 03 01 11 1c 8c 80 80 80 80 10 03 00 3e 00 00 00 ............>... ++| 2416: 17 01 05 05 34 74 61 62 6c 03 02 03 01 04 77 68 ....4tabl.....wh ++| 2432: 65 72 03 02 06 09 1b 8c 80 80 80 80 0f 03 00 3c er.............< ++| 2448: 00 00 00 16 05 34 66 74 73 34 03 02 02 01 04 6e .....4fts4.....n ++| 2464: 75 6d 62 03 06 01 04 09 1b 8c 80 80 80 80 0e 03 umb............. ++| 2480: 00 3c 00 00 00 16 04 33 74 68 65 03 06 01 01 04 .<.....3the..... ++| 2496: 01 03 77 68 65 03 02 04 04 0a 1b 8c 80 80 80 80 ..whe........... ++| 2512: 0d 03 00 3c 00 00 00 16 04 33 6e 75 6d 03 06 01 ...<.....3num... ++| 2528: 01 05 01 03 74 61 62 05 62 03 04 0a 19 8c 80 80 ....tab.b....... ++| 2544: 80 80 0c 03 00 38 00 00 00 14 03 39 a7 68 03 02 .....8.....9.h.. ++| 2560: 04 10 04 33 66 74 73 03 02 02 04 07 18 8c 80 80 ...3fts......... ++| 2576: 80 80 0b 03 00 36 00 00 00 13 03 32 74 61 03 02 .....6.....2ta.. ++| 2592: 03 02 01 68 03 06 01 01 04 04 07 1b 8c 80 80 80 ...h............ ++| 2608: 80 0a 03 00 3c 00 00 00 16 03 32 6e 75 03 06 01 ....<.....2nu... ++| 2624: 01 05 01 02 6f 66 03 06 01 01 06 04 09 19 8c 80 ....of.......... ++| 2640: 80 80 80 09 03 00 38 00 00 00 14 03 32 66 74 03 ......8.....2ft. ++| 2656: 02 02 01 02 69 73 03 06 01 01 03 04 07 18 8c 80 ....is.......... ++| 2672: 80 80 80 08 03 00 36 00 00 00 13 02 31 74 03 08 ......6.....1t.. ++| 2688: 03 01 01 04 01 01 77 03 02 04 04 09 1a 8c 80 80 ......w......... ++| 2704: 80 80 07 03 00 3a ff 00 00 15 02 31 6e 03 08 01 .....:.....1n... ++| 2720: 01 02 05 01 01 6f 03 06 01 01 06 04 09 18 8c 80 .....o.......... ++| 2736: 80 80 80 06 03 00 36 00 00 00 13 04 02 31 66 03 ......6......1f. ++| 2752: 02 01 f1 01 69 03 06 01 01 03 05 06 1c 8c 80 80 ....i........... ++| 2768: 80 80 05 03 00 3e 00 00 00 17 04 30 74 68 65 03 .....>.....0the. ++| 2784: 06 01 01 14 01 05 77 68 65 72 65 03 02 04 0a 15 ......where..... ++| 2800: 8c 80 80 80 80 04 03 00 30 00 00 00 11 01 01 06 ........0....... ++| 2816: 06 30 74 61 62 6c cc 03 02 03 07 1c 8c 80 80 80 .0tabl.......... ++| 2832: 80 03 03 00 3e 00 00 00 17 07 30 6e 75 6d 62 65 ....>.....0numbe ++| 2848: 72 03 06 01 01 05 01 02 6f 66 02 06 04 0d 13 8c r.......of...... ++| 2864: 80 80 80 80 02 03 00 2c 00 00 00 0f 01 01 03 02 .......,........ ++| 2880: 30 6e 03 06 01 01 02 07 1b 8c 80 80 80 80 01 03 0n.............. ++| 2896: 00 3c 00 00 00 16 08 30 66 74 73 34 61 75 78 03 .<.....0fts4aux. ++| 2912: 02 02 01 02 69 73 03 06 04 0c 00 00 00 14 2a 00 ....is........*. ++| 2928: 00 00 01 01 02 24 00 02 01 01 12 02 01 12 08 88 .....$.......... ++| 2944: 80 80 80 80 12 03 00 16 00 00 00 05 02 1c 88 80 ................ ++| 2960: 80 80 80 11 03 00 3e 00 00 00 17 05 34 72 6f 77 ......>.....4row ++| 2976: 73 02 06 01 01 05 01 04 74 68 65 72 02 02 04 0b s.......ther.... ++| 2992: 15 88 80 80 80 80 10 03 00 3e 10 00 00 11 02 01 .........>...... ++| 3008: 01 07 05 34 62 65 74 77 02 02 04 08 1b 88 80 80 ...4betw........ ++| 3024: 80 80 0f 03 00 3c 00 00 00 16 04 04 33 72 6f 77 .....<......3row ++| 3040: 02 06 01 01 05 01 03 74 68 65 02 08 05 0a 1b 88 .......the...... ++| 3056: 80 80 80 80 0e 03 05 0c 00 00 00 16 01 01 02 04 ................ ++| 3072: 33 61 72 65 02 02 03 01 03 62 65 74 02 02 07 08 3are.....bet.... ++| 3088: 1b 88 80 80 80 80 0d 03 00 3c 00 00 00 16 03 32 .........<.....2 ++| 3104: 74 68 02 08 02 01 01 07 00 04 33 61 6e 64 02 06 th........3and.. ++| 3120: 04 01 1b 88 80 80 80 80 0c 03 00 3c 00 00 00 16 ...........<.... ++| 3136: 03 32 69 6e 02 06 01 01 06 01 02 72 6f 02 06 01 .2in.......ro... ++| 3152: 01 05 04 09 18 88 80 80 80 80 0b 03 00 36 00 00 .............6.. ++| 3168: 00 13 02 03 32 61 72 02 02 03 01 02 62 65 02 02 ....2ar.....be.. ++| 3184: 04 05 07 1b 88 80 bf 80 80 0a 03 00 3c 00 00 00 ............<... ++| 3200: 16 02 31 74 02 08 02 01 01 07 00 03 32 61 6e 02 ..1t........2an. ++| 3216: 06 01 01 04 09 19 88 80 80 80 80 09 03 00 38 00 ..............8. ++| 3232: 00 00 14 02 31 6e 02 06 01 01 03 01 01 72 02 06 ....1n.......r.. ++| 3248: 01 01 05 03 08 17 88 80 80 80 80 08 03 00 34 00 ..............4. ++| 3264: 01 00 12 02 31 62 02 02 04 01 01 69 02 06 01 01 ....1b.....i.... ++| 3280: 06 04 06 19 88 80 80 80 80 07 03 00 38 00 00 00 ............8... ++| 3296: 14 04 02 31 32 02 02 05 01 01 61 02 08 03 01 01 ...12.....a..... ++| 3312: 02 05 06 1b 88 80 80 80 80 06 03 00 3c 00 00 00 ............<... ++| 3328: 16 06 30 74 68 65 72 65 02 12 02 00 02 31 31 02 ..0there.....11. ++| 3344: 06 01 01 04 0a 15 88 80 80 80 80 05 03 00 30 00 ..............0. ++| 3360: 00 00 11 01 01 05 04 30 74 68 65 02 06 71 01 07 .......0the..q.. ++| 3376: 07 1c 88 80 80 80 80 04 03 00 3e 00 00 00 17 01 ..........>..... ++| 3392: 01 06 02 30 6e 02 06 01 01 03 01 04 72 6f 77 73 ...0n.......rows ++| 3408: 02 06 07 08 1b 88 80 80 80 80 03 03 00 3c 00 00 .............<.. ++| 3424: 00 16 08 30 62 65 74 77 65 65 6e 02 02 04 01 02 ...0between..... ++| 3440: 69 6e 02 06 04 0c 1a 88 80 80 80 80 02 03 00 3a in.............: ++| 3456: 08 f0 00 15 04 30 61 6e 64 02 06 01 01 02 02 02 .....0and....... ++| 3472: 72 65 02 02 03 04 0a 17 88 80 80 80 80 01 03 00 re.............. ++| 3488: 34 00 00 00 12 02 30 31 02 06 01 01 04 01 01 32 4.....01.......2 ++| 3504: 02 02 07 04 08 08 84 80 80 80 80 12 03 00 16 00 ................ ++| 3520: 00 00 05 04 1b 84 80 80 80 80 11 03 00 3c 00 00 .............<.. ++| 3536: 00 16 05 34 74 61 62 6c 01 06 01 01 05 02 03 65 ...4tabl.......e ++| 3552: 72 6d 01 02 04 0b 1b 84 80 80 80 80 10 03 00 3c rm.............< ++| 3568: 00 00 00 16 05 34 65 61 63 68 01 02 03 01 04 70 .....4each.....p ++| 3584: 72 65 73 01 02 05 04 09 1a 84 80 80 80 80 0f 03 res............. ++| 3600: 00 3a 00 00 00 15 04 33 74 65 72 01 02 04 02 02 .:.....3ter..... ++| 3616: 68 65 01 06 01 01 03 04 08 1b 84 80 80 80 80 0e he.............. ++| 3632: 03 00 3c 00 00 00 16 04 33 70 72 65 01 02 05 01 ..<.....3pre.... ++| 3648: 03 74 61 62 01 06 01 01 05 04 08 1a 84 80 80 80 .tab............ ++| 3664: 80 0d 03 00 3a 00 00 00 15 04 33 66 6f 72 01 02 ....:.....3for.. ++| 3680: 02 02 02 74 73 01 06 01 01 04 03 f8 1b 84 80 80 ...ts........... ++| 3696: 80 80 0c 03 00 3c 00 00 00 16 03 32 74 68 01 06 .....<.....2th.. ++| 3712: 01 01 03 00 04 33 65 61 63 01 02 03 04 09 18 84 .....3eac....... ++| 3728: 80 80 80 80 0b 03 00 36 00 00 00 13 03 32 74 61 .......6.....2ta ++| 3744: 01 06 01 01 05 02 01 65 00 02 04 04 09 19 84 80 .......e........ ++| 3760: 80 80 80 0a 03 10 38 00 00 00 14 03 32 69 6e 01 ......8.....2in. ++| 3776: 06 01 01 02 01 02 70 72 01 02 05 04 09 18 84 80 ......pr........ ++| 3792: 80 80 80 09 03 00 36 00 00 00 13 03 32 66 6f 01 ......6.....2fo. ++| 3808: 02 02 02 01 74 01 06 01 01 04 04 07 1b 84 80 80 ....t........... ++| 3824: 80 80 08 03 00 3c 00 00 00 16 02 31 74 01 0a 04 .....<.....1t... ++| 3840: 01 00 03 04 00 03 32 65 61 01 02 03 04 0a 17 84 ......2ea....... ++| 3856: 80 80 80 80 07 03 00 34 00 00 00 12 02 31 69 01 .......4.....1i. ++| 3872: 06 01 01 02 de 01 70 01 02 05 04 08 18 84 80 80 ......p......... ++| 3888: 80 80 06 03 00 36 00 00 00 13 02 31 65 01 02 03 .....6.....1e... ++| 3904: 01 01 66 01 08 02 01 01 04 04 06 1b 84 80 80 80 ..f............. ++| 3920: 80 05 03 00 3c 00 00 00 16 05 30 74 65 72 6d 01 ....<.....0term. ++| 3936: 02 04 02 02 68 65 01 06 01 01 03 04 09 14 84 80 ....he.......... ++| 3952: 80 80 80 04 03 00 2e 00 00 00 10 06 30 74 61 62 ............0tab ++| 3968: 6c 65 01 06 01 01 05 04 15 84 80 80 80 80 03 03 le.............. ++| 3984: 00 30 00 00 00 11 02 08 30 70 72 65 73 65 6e 74 .0......0present ++| 4000: 01 02 05 05 1b 84 80 80 80 80 02 03 00 3c 00 00 .............<.. ++| 4016: 00 16 04 30 66 74 73 01 06 01 01 04 01 02 69 6e ...0fts.......in ++| 4032: 01 06 01 01 04 0a 1a 84 80 80 80 80 01 03 00 3a ...............: ++| 4048: 00 00 00 15 05 30 65 61 63 68 00 f2 03 01 03 66 .....0each.....f ++| 4064: 6f 72 01 02 02 04 09 06 01 03 00 12 03 0b 0f 00 or.............. ++| 4080: 00 08 8c 80 80 80 80 11 03 00 16 00 00 00 05 04 ................ ++| page 3 offset 8192 ++| 0: 0a 00 00 00 32 0e 4f 00 0f fa 0f f1 0f e9 0f e1 ....2.O......... ++| 16: 0f d8 0f d1 0f c9 0f c1 0f b9 0f c1 0f a9 0f a0 ................ ++| 32: 0f 98 0f 90 0f 87 0f 80 0f 78 0f 71 0f 68 0f 5f .........x.q.h._ ++| 48: 0f 56 0f 4d 0f 41 0f 38 0f 2f 0f 26 0f 1d 0f 13 .V.M.A.8./.&.... ++| 64: 0f 0a 0f 01 0e f7 0e ee 0e e6 0e dd 0e d7 0e cd ................ ++| 80: 0e c3 0e ba 0e b0 0e a8 0e 9f 0e 96 0e 8e 0e 85 ................ ++| 3648: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 ................ ++| 3664: 04 01 10 01 03 34 74 20 07 04 01 0e 01 03 34 1e .....4t ......4. ++| 3680: 09 04 01 12 34 03 33 74 68 1c 08 04 01 10 01 03 ....4.3th....... ++| 3696: 33 6e 1a 08 04 01 10 01 03 32 77 18 08 04 01 10 3n.......2w..... ++| 3712: 01 03 32 74 16 08 04 01 10 01 03 32 6e 14 07 04 ..2t.......2n... ++| 3728: 01 0e 01 03 32 12 08 04 01 0f f1 03 31 74 10 08 ....2.......1t.. ++| 3744: 04 01 10 01 03 31 6e 0e 07 04 01 0e 01 03 30 fc .....1n.......0. ++| 3760: 09 04 01 12 01 03 30 74 68 0a 08 04 01 10 01 03 ......0th....... ++| 3776: 30 74 08 09 04 01 12 01 03 30 6e 75 06 08 04 01 0t.......0nu.... ++| 3792: 10 01 03 30 6e 04 06 04 01 0c 01 05 52 08 04 01 ...0n.......R... ++| 3808: 10 01 02 34 72 22 07 04 01 0e 01 02 34 20 08 04 ...4r.......4 .. ++| 3824: 01 10 01 02 33 72 1e 09 04 01 12 01 02 33 61 72 ....3r.......3ar ++| 3840: 1c 08 04 01 10 01 02 32 74 1a 08 04 01 10 b3 02 .......2t....... ++| 3856: 32 69 18 09 04 01 12 01 02 32 61 72 16 08 04 01 2i.......2ar.... ++| 3872: 10 01 02 31 74 14 08 04 01 10 01 02 31 6e 12 08 ...1t.......1n.. ++| 3888: 04 01 10 01 02 31 62 10 08 04 01 10 01 02 31 32 .....1b.......12 ++| 3904: 0e 0b 04 01 16 01 02 30 74 68 65 72 0c 08 04 01 .......0ther.... ++| 3920: 10 01 02 30 74 0a 08 04 01 10 01 02 30 6e 08 08 ...0t.......0n.. ++| 3936: 04 01 10 01 02 30 62 06 09 04 01 10 01 02 30 61 .....0b.......0a ++| 3952: 04 06 04 01 0c 01 02 02 07 04 09 10 01 34 74 22 .............4t. ++| 3968: 06 04 09 0e 01 34 20 08 04 09 12 01 33 74 65 1e .....4 .....3te. ++| 3984: 07 04 09 10 01 33 70 1c 07 f4 09 11 01 33 66 1a .....3p......3f. ++| 4000: 08 04 09 12 01 32 74 68 18 07 04 09 10 01 32 e4 .....2th......2. ++| 4016: 16 07 04 09 10 01 32 69 14 07 04 09 10 01 32 66 ......2i......2f ++| 4032: 12 07 04 09 10 01 31 74 10 07 04 09 10 01 31 69 ......1t......1i ++| 4048: 0e 06 04 09 0e 01 31 0c 08 04 09 12 01 30 74 65 ......1......0te ++| 4064: 0a 07 04 09 10 01 30 74 08 00 00 00 00 00 00 00 ......0t........ ++| page 4 offset 12288 ++| 4064: 00 00 00 00 00 00 00 00 00 00 00 05 03 03 00 10 ................ ++| 4080: 03 05 05 02 03 00 10 04 06 05 01 03 00 10 04 04 ................ ++| page 5 offset 16384 ++| 0: 0a 00 00 00 02 0f eb 00 0f eb 0f f4 00 00 00 00 ................ ++| 4064: 00 00 00 00 00 00 00 00 00 00 00 08 03 15 01 70 ...............p ++| 4080: 67 73 7a 18 0b 03 1b 01 76 65 72 73 69 6f 6e 04 gsz.....version. ++| page 6 offset 20480 ++| 4080: 00 00 23 03 02 01 03 03 02 00 00 00 00 00 00 00 ..#............. ++| end crash-5a5acd0ab42d31.db ++}]} {} ++ ++do_execsql_test 58.1 { ++ SELECT * FROM t1('t*'); ++} {{} {} {} {} {} {}} + + sqlite3_fts5_may_be_corrupt 0 + finish_test +--- /src/btree.c ++++ /src/btree.c +@@ -4284,10 +4284,9 @@ + rc = newDatabase(pBt); + pBt->nPage = get4byte(28 + pBt->pPage1->aData); + +- /* The database size was written into the offset 28 of the header +- ** when the transaction started, so we know that the value at offset +- ** 28 is nonzero. */ +- assert( pBt->nPage>0 ); ++ /* pBt->nPage might be zero if the database was corrupt when ++ ** the transaction was started. Otherwise, it must be at least 1. */ ++ assert( CORRUPT_DB || pBt->nPage>0 ); + } + sqlite3BtreeLeave(p); + } +@@ -7637,6 +7636,7 @@ + u16 maskPage = pOld->maskPage; + u8 *piCell = aData + pOld->cellOffset; + u8 *piEnd; ++ VVA_ONLY( int nCellAtStart = b.nCell; ) + + /* Verify that all sibling pages are of the same "type" (table-leaf, + ** table-interior, index-leaf, or index-interior). +@@ -7665,6 +7665,10 @@ + */ + memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*(limit+pOld->nOverflow)); + if( pOld->nOverflow>0 ){ ++ if( limit<pOld->aiOvfl[0] ){ ++ rc = SQLITE_CORRUPT_BKPT; ++ goto balance_cleanup; ++ } + limit = pOld->aiOvfl[0]; + for(j=0; j<limit; j++){ + b.apCell[b.nCell] = aData + (maskPage & get2byteAligned(piCell)); +@@ -7684,6 +7688,7 @@ + piCell += 2; + b.nCell++; + } ++ assert( (b.nCell-nCellAtStart)==(pOld->nCell+pOld->nOverflow) ); + + cntOld[i] = b.nCell; + if( i<nOld-1 && !leafData){ +--- /src/resolve.c ++++ /src/resolve.c +@@ -866,7 +866,9 @@ + #ifndef SQLITE_OMIT_WINDOWFUNC + if( pExpr->y.pWin ){ + Select *pSel = pNC->pWinSelect; +- sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef); ++ if( IN_RENAME_OBJECT==0 ){ ++ sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef); ++ } + sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition); + sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy); + sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter); +--- /src/vdbe.c ++++ /src/vdbe.c +@@ -264,7 +264,7 @@ + ** is clear. Otherwise, if this is an ephemeral cursor created by + ** OP_OpenDup, the cursor will not be closed and will still be part + ** of a BtShared.pCursor list. */ +- p->apCsr[iCur]->isEphemeral = 0; ++ if( p->apCsr[iCur]->pBtx==0 ) p->apCsr[iCur]->isEphemeral = 0; + sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); + p->apCsr[iCur] = 0; + } +@@ -3686,7 +3686,10 @@ + if( pCx ){ + /* If the ephermeral table is already open, erase all existing content + ** so that the table is empty again, rather than creating a new table. */ +- rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0); ++ assert( pCx->isEphemeral ); ++ if( pCx->pBtx ){ ++ rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0); ++ } + }else{ + pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE); + if( pCx==0 ) goto no_mem; +--- /test/altertab3.test ++++ /test/altertab3.test +@@ -142,6 +142,39 @@ + ALTER TABLE Table0 RENAME Col0 TO Col0; + } + ++#------------------------------------------------------------------------- ++reset_db ++do_execsql_test 7.1.0 { ++ CREATE TABLE t1(a,b,c); ++ CREATE TRIGGER AFTER INSERT ON t1 BEGIN ++ SELECT a, rank() OVER w1 FROM t1 ++ WINDOW w1 AS (PARTITION BY b, percent_rank() OVER w1); ++ END; ++} ++ ++do_execsql_test 7.1.2 { ++ ALTER TABLE t1 RENAME TO t1x; ++ SELECT sql FROM sqlite_master; ++} { ++ {CREATE TABLE "t1x"(a,b,c)} ++ {CREATE TRIGGER AFTER INSERT ON "t1x" BEGIN ++ SELECT a, rank() OVER w1 FROM "t1x" ++ WINDOW w1 AS (PARTITION BY b, percent_rank() OVER w1); ++ END} ++} ++ ++do_execsql_test 7.2.1 { ++ DROP TRIGGER after; ++ CREATE TRIGGER AFTER INSERT ON t1x BEGIN ++ SELECT a, rank() OVER w1 FROM t1x ++ WINDOW w1 AS (PARTITION BY b, percent_rank() OVER w1 ORDER BY d); ++ END; ++} ++ ++do_catchsql_test 7.2.2 { ++ ALTER TABLE t1x RENAME TO t1; ++} {1 {error in trigger AFTER: no such column: d}} ++ + finish_test + + +--- /test/corruptL.test ++++ /test/corruptL.test +@@ -838,4 +838,32 @@ + INSERT INTO t3 SELECT * FROM t2; + } {1 {database disk image is malformed}} + ++#------------------------------------------------------------------------- ++reset_db ++do_test 9.0 { ++ sqlite3 db {} ++ db deserialize [decode_hexdb { ++| size 8192 pagesize 4096 filename crash-ab10597e4e1c32.db ++| page 1 offset 0 ++| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. ++| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 00 .....@ ........ ++| 96: 00 00 00 00 0d 00 00 00 01 0f d6 00 0f d6 00 00 ................ ++| 4048: 00 00 00 00 00 00 28 01 06 17 11 11 01 3d 74 61 ......(......=ta ++| 4064: 62 6c 65 74 31 74 31 02 43 52 45 41 54 45 20 54 blet1t1.CREATE T ++| 4080: 41 42 4c 45 20 74 31 28 61 2c 62 2c 63 2c 64 29 ABLE t1(a,b,c,d) ++| page 2 offset 4096 ++| 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ ++| end crash-ab10597e4e1c32.db ++}]} {} ++ ++do_execsql_test 9.1 { ++ SAVEPOINT one; ++} ++do_catchsql_test 9.3 { ++ I |
