Commit Graph

20329 Commits

Author SHA1 Message Date
dan
e385d33a29 Ensure all bytes of the PgHdr1 structure are initialized. This avoids a valgrind error when running corruptI.test.
FossilOrigin-Name: a505e34d4ec31159a4508ec827fcffed0cf3bd5ea5ef0ac293016da02367a53a
2019-02-06 20:49:49 +00:00
dan
922b35801d Update an assert() in test_journal.c to take the new "VACUUM INTO" functionality into account.
FossilOrigin-Name: 0e6249cb958a40ead0edf6e75a2c46e8657db3d358c5fe78a9dc0fa5ed7ad929
2019-02-06 20:12:00 +00:00
dan
9c5f734339 Avoid attempting to delete a file while it is still open in walfault2.test.
FossilOrigin-Name: 9d54a63d6e3cd47b483cf0ee868a5e7f638bcb0e3cbdeaecc667f293b87a3e99
2019-02-06 19:42:02 +00:00
dan
6e08c4a5e6 Update test file dbfuzz001.test so that it works with SQLITE_ENABLE_OVERSIZE_CELL_CHECK builds.
FossilOrigin-Name: 4371a0c46ee7bfbc0a1507796bd9eefd3371adad81b8dda214d018854316727b
2019-02-06 18:08:42 +00:00
dan
531230d006 Add -DSQLITE_ENABLE_DESERIALIZE to the default testing configuration in test/releasetest.tcl.
FossilOrigin-Name: 433d6ef637a10ee017b5d8cadd125a162cfedc9895ae862b8dde6dddb7eda59b
2019-02-06 15:23:43 +00:00
dan
fbf6136c78 Do not attempt to test the shell ".trace" command in SQLITE_OMIT_TRACE builds.
FossilOrigin-Name: 3839e9098107604e1526c2b1e813c019607077dfe39d7eeb92f3466518dec3b1
2019-02-06 13:48:04 +00:00
dan
871b13492d Fix a problem preventing testfixture from being built with SQLITE_OMIT_VIRTUALTABLE.
FossilOrigin-Name: d2cca36adc69d2c8e7707d70cbd75c497eae6a1a3f8a9dd18249ca6804c9db5f
2019-02-06 13:41:19 +00:00
drh
d0ee3a1e6d When extending the size of SrcList objects, do not attempt to use
extra space on the end of the allocation, as that provides scarcely any
performance benefit but does greatly complicate cross-platform testing.

FossilOrigin-Name: 3087a0c31e9fbfaedb7cf10a2fda59bc22318ff178614aefcc00ac83d9a7bb14
2019-02-06 01:18:36 +00:00
drh
4acd754c79 If the query flattener detects an error, cause the SELECT code generator
to abort immediately.

FossilOrigin-Name: 3d3b142f1045080beb775a9cfe88ec143aa460750132e20059fd510291449850
2019-02-06 00:55:47 +00:00
drh
01996dae49 Back out check-in [008112bcef561a8], reenabling deprecated PRAGMAs when the
SQLITE_OMIT_DEPRECATED compile-time option is used, because way too many
TH3 tests depend on those deprecated PRAGMAs.

FossilOrigin-Name: 9dbf512d1c4627a28d60f4e7238cb100d7a4e11f976139b07ad1c59e9b584c7d
2019-02-06 00:11:13 +00:00
drh
569b1d9119 Omit the ".progress" command from the shell if it is compiled with the
SQLITE_OMIT_PROGRESS_CALLBACK option.

FossilOrigin-Name: 4d0a949fd92e19fbf243a2e3a1a7c2cdb111f9a6943949d2420dd846bc7d9285
2019-02-05 20:51:41 +00:00
drh
d46b6f57c9 Fix a harmless compiler warning in the memtrace.c extension.
FossilOrigin-Name: 2f468da4e9fb3edb5e902fa5d3c528726d1fb64d749d29e558ba3243c76bcb95
2019-02-05 19:52:39 +00:00
drh
fc4eeef9e7 Fix compiler warnings on Windows.
FossilOrigin-Name: 4978ee8b5405f958723b4ebbd4288bd08bff2b453da2d1c032d1ae904c2a3821
2019-02-05 19:48:46 +00:00
dan
dee9be9b3b Update the tester.tcl --malloctrace option so that it uses eu-addr2line instead of addr2line.
FossilOrigin-Name: 79c073878d56fc638b751b0e61295df182f7ee6f8ebd7319c1eeac1608abbac8
2019-02-05 16:53:26 +00:00
drh
d57936721b The IS NOT NULL operator does not imply that the operand is never NULL.
Fix for ticket [5948e09b8c415bc45da5cf]

FossilOrigin-Name: d840e9bb023a1e84a7739d764a0f6cf608fc3183ff8c366fcdb486ebd932f0c1
2019-02-05 14:36:33 +00:00
drh
24545d2300 Keep the temp_store_directory and data_store_directory pragmas even when
compiling with SQLITE_OMIT_DEPRECATED.

FossilOrigin-Name: 93386a7c97f27df69f79052ef4d80143bb6832a806885249c315d226b2a256b2
2019-02-05 12:16:53 +00:00
dan
41e0717bcb Update test file "resetdb.test" so that it works with the "prepare" permutation.
FossilOrigin-Name: 95d338124be2e0e18f17354b28f4320336202f1a4ec1177df753b2800e954bfb
2019-02-05 08:55:43 +00:00
drh
53d30dd371 Early detection of implausibly sized records to avoid unnecessary
large memory allocations.

FossilOrigin-Name: 2c8769c69f301307db6663adb8b7c0b89f5959516bf6110cb8ff4b21bd903f70
2019-02-04 21:10:24 +00:00
drh
af48257bc9 Mention the new -memtrace command-line option in the -help output of the CLI.
FossilOrigin-Name: ada91aefe37efe3c009691b5599e4d6acf182e5ec3cf28dda0871d09858498b3
2019-02-04 19:52:39 +00:00
drh
a790882d63 Add the -memtrace option to dbfuzz2.
FossilOrigin-Name: 67fecbc79d3e927a7e22f3589be3184114322635874e4b3170666e352d0bfe9d
2019-02-04 19:50:44 +00:00
drh
88862d49a6 Enhance dbfuzz2 so that with the -v option it shows the return code and
error message for any failing SQL statements.

FossilOrigin-Name: 3a127ef9f7feafe6ba8c75e4eb29e28aa61a30249082cc8767ada1ec0cc0b7f1
2019-02-04 19:45:26 +00:00
drh
f2305414cd Ensure that the sqlite3_exec() callback gets the correct number of columns
for a query, even if the schema changes out from under it.

FossilOrigin-Name: a16ffb5a4b30f1ac4a8384fccde0a0f69e49545b6f9be9267928609328c4a151
2019-02-04 19:12:54 +00:00
dan
4fc4ba771c Do not run shmlock.test as part of the inmemory_journal permutation.
FossilOrigin-Name: d3fea69cbb071867a90ad56ca05123ebf8e44689a92577a525a883c176c791bd
2019-02-04 16:42:57 +00:00
drh
e2d2ad6ece Update the test/fuzzdata8.db database with new interesting cases from
dbsqlfuzz.

FossilOrigin-Name: e467e4c8fa256ddd6c26c1f21bc26289a21f18b781737eaf706bc813ed8234fa
2019-02-04 16:36:24 +00:00
dan
83a635a267 Fix problems with SAVEPOINT and related commands within transactions on a corrupt database that include fts5 or some other virtual tables.
FossilOrigin-Name: b0da6e0dd1f9a9ba7646ee6bb3c14945e570303c9a42d20fa8a653570e12c3f9
2019-02-04 16:25:40 +00:00
drh
3f83f59154 Add the ".progress" command to the CLI.
FossilOrigin-Name: ad84ca24ff760f7a2b128f2eeb4d799a97f84b8b8a8bb8d9657c4c555f6ccf47
2019-02-04 14:53:18 +00:00
dan
0062ddd4c9 Fix another potential buffer overread in fts5.
FossilOrigin-Name: 14fba4cc5db2bc206f024bfa5dd82fffdbc7577162da2c3b15a91cc1c91f3846
2019-02-04 14:00:20 +00:00
dan
81f44cdbfb Fix another corruption case in fts5.
FossilOrigin-Name: e608085d3f7e3cc0015fde626e205ee9842ef3cd06dc879fbbc7f2067c592965
2019-02-04 11:54:22 +00:00
dan
41fc545147 Fix an assertion failure in fts3 triggered by a corrupt database.
FossilOrigin-Name: 560ebd4269fad07b8e988d070454017123593eb6762597d08e8c32d7b4fb92ac
2019-02-03 07:46:07 +00:00
drh
150edadf58 New testcase added to test/fuzzdata8.db.
FossilOrigin-Name: 2f5c1925b94d85489533549c58191feb1d803ad9d58b43f47fef42b72c531a38
2019-02-02 18:24:28 +00:00
drh
e5989723ba Honor key query parameters for SEE on the URI filename for ATTACH
and VACUUM INTO.

FossilOrigin-Name: 2e01096b8933a2315e3dffcd7d0de84c744c1b4be1d909388c61f0fd636ddb99
2019-02-02 15:59:49 +00:00
drh
9b2bd91d9a Give a link to the URI Filename document in the documentation to the
various sqlite3_uri_parameter() interfaces.

FossilOrigin-Name: 69b0b2ee536fda8975f60643f7f1891db4649958aca476822ea2a632ce731992
2019-02-02 15:05:25 +00:00
dan
8f5b14a5c2 Fix a buffer overread in fts5 debugging scalar function fts5_decode().
FossilOrigin-Name: 54f2399fb2a626602d405c857297f2da833f9f048cbc478f9110bed2e9bda299
2019-02-02 13:47:25 +00:00
mistachkin
844b900491 Fix harmless compiler warning.
FossilOrigin-Name: dddda685f3443d8a38901f758543fcde73d7b8cfe72b0ad5f419cd7459343bf5
2019-02-02 01:27:45 +00:00
drh
7ba03ea15a Slight adjustment to the printf formatter large memory allocation detector
so that it does not overestimate the amount of space needed for
oversize %d conversions.

FossilOrigin-Name: 1aee70d6de8a9b17ebb74a7cb1dad65139cde1b615dcce4d15d3a476fda8676b
2019-02-01 21:08:27 +00:00
drh
2964225247 Prevent the printf formatter from doing large memory allocations - larger
than either the size of the static buffer for interfaces like
sqlite3_snprintf(), or larger than SQLITE_LIMIT_LENGTH for interfaces that
are associated with a database connection.  This helps to prevent DOS
attacks on products that let hostile sources inject arbitrary SQL.  It also
helps fuzzers run faster and more effectively.

FossilOrigin-Name: 179e5d46054e5c86f53a79b7a0823d9a383da8391ad1d3c3b22645927a1e052b
2019-02-01 20:29:04 +00:00
drh
9a6d01bff5 Performance improvement in the parsing of options to %-formats in the
printf implementation.

FossilOrigin-Name: 40d8f8ae87abf928542c4e558a4c3a3eab18776a3e8db7ca1c5e5f744ca0bce3
2019-02-01 18:46:41 +00:00
drh
9c46c66c46 Ensure that the Walker.pParse structure is initialized when walking the
source tree to gather the WINDOW clauses on a query with window functions.

FossilOrigin-Name: 4ca9d5d53d41d08fbce29f9da8cc0948df9c4c3136210af88b499cf889b5ccb8
2019-02-01 15:06:27 +00:00
drh
38a28a7434 New test cases added to test/fuzzdata8.db.
FossilOrigin-Name: e5924939c9c8f39367900360fa294cdb1220e9f68d183e32882e0926f775869d
2019-02-01 14:54:18 +00:00
drh
26b7ec8b24 Improve the strict enforcement of cell sizes in balancing from
check-in [12713f320b2c1def] so that it also works with table-btrees
in addition to index-btrees.

FossilOrigin-Name: ef27e7a08728aa7447ae19812803ac5c4a9d80c97541014bd292485792005a3e
2019-02-01 14:50:43 +00:00
dan
1c7d389a23 Fix an assert() in fts5 that could fail if the database is corrupt.
FossilOrigin-Name: 55f06aa3f890dc1dc5c2ed0e6777e46d609a6f9d223d1d4b5813097ce4f4e797
2019-02-01 14:40:44 +00:00
dan
abd7449478 Fix another corrupt-database-handling problem in fts5.
FossilOrigin-Name: 9876ae1b802a449aacbbdd42778653edc19e29315dc627c23ab7493d6492c800
2019-02-01 13:34:00 +00:00
drh
3bf0d7a881 Remove an incorrect assert() from the deserialize in-memory database VFS.
FossilOrigin-Name: 80151d7e3b9fd84086874a1cebed024b9e14005ea2d0108cf6efcd07373fcf51
2019-01-31 16:09:48 +00:00
drh
23a885956e Add the SQLITE_CONFIG_MEMDB_MAXSIZE configuration option for configuring
the default maximum size of an in-memory database created using
sqlite3_deserialize().  This is necessary to make the interface reasonably
testable.

FossilOrigin-Name: cb72ee0478ce98c48aae059fd5de4e36caf2b8c953e08fcb799bfd119ad46b73
2019-01-31 15:38:53 +00:00
dan
b92b019fe3 Fix another buffer overrun that could occur when quering a corrupt database using an fts5vocab table.
FossilOrigin-Name: b80119bd6044c0993210115732b6ae7b4b0b29c1471b0723bef24f2052c8e671
2019-01-31 14:37:18 +00:00
drh
6a0db87a2f If the amalgamation file "sqlite3.c" is generated using the
SQLITE_ENABLE_UPDATE_DELETE_LIMIT option, but then subsequently (mis-)compiled
without that option, and then a particular syntax error could cause
a memory leak, but for this fix.

FossilOrigin-Name: 1bb17c863a269ab8b28df94b9fdaac3ee70777ccd0a30300131bf67df6722052
2019-01-31 02:42:47 +00:00
drh
9b747068ba Improvements to "PRAGMA parser_trace=ON": Make it a flag pragma, and then
use the flag to show the complete SQL text at the beginning of the parse.

FossilOrigin-Name: 507c43537f00d089efb3c3020fb6e826e8f89f3efa2caaa12c5309d35dd0c22e
2019-01-31 01:39:01 +00:00
drh
8bf4126c84 Change the error message slightly for when two or more indexes have the
same rootpage.

FossilOrigin-Name: 916c52dad414b224695d455a42af36f85dff216504c2aa67d1d2c5818cdca8d6
2019-01-30 19:50:07 +00:00
dan
da7a4c0f7a When parsing the schema, check for duplicate index root page numbers before adding the index to the schema hash table.
FossilOrigin-Name: 6b360bc0b9ad18ccda9d58d43a8388d19999432bfdf294abcf5beb44ef990cb4
2019-01-30 19:12:13 +00:00
dan
56b99ebc32 Add test case for the previous commit.
FossilOrigin-Name: 197edb235b785c68fda7be788efbc61137d9452886599415a927b959ade93c65
2019-01-30 18:47:35 +00:00
drh
8d40673c84 Detect if two indexes of the same table share a common rootpage while
parsing the schema, and throw an error immediately.

FossilOrigin-Name: f21c6f1343edc4ba68f9f8e68caac34da0d1c651526ecaf61c0e2d66593a555e
2019-01-30 18:33:33 +00:00
drh
ba7bd02002 Fix an off-by-one error when parsing the names of indexes that do not have
arguments in the index_usage utility.

FossilOrigin-Name: dc794d8f518ed46536928a77a560d46e4f9365c30a00cd108f000d8556a66c00
2019-01-30 16:58:04 +00:00
drh
a8614259c1 Add the --progress, --using, and -q options to the index_usage utility program.
FossilOrigin-Name: a5e6be7cbc5d931308ddcc073c9cd6275c9711cae055d72a7c4aa71c1d15914c
2019-01-30 15:47:38 +00:00
drh
5a9c6bcc15 Enhancements to the index_usage utility program.
FossilOrigin-Name: 19c739b4a8a43d894e37a99fa34838f3e3fa1fe0d019aefbc33f1d38d76af1a4
2019-01-30 14:01:43 +00:00
dan
dd579233e8 Fix another buffer overread in fts5 that may occur when accessing a corrupt database.
FossilOrigin-Name: 760d14374d40bcd9ce3a89771c18dc236c9728553c4747c9b7452ee7b24f4140
2019-01-30 12:15:27 +00:00
drh
3f4f6823ac Fix harmless compiler warnings.
FossilOrigin-Name: 9a93c68a7673bda2e6c308d3b2798d0fb12fde399996cae24b1f0d5864adf355
2019-01-29 16:54:31 +00:00
drh
4551005332 Load all the latest dbsqlfuzz finds into test/fuzzdata8.db.
FossilOrigin-Name: e744d2dd93a78235e6c1d938b08232183b5ce7e355d1b7daf2199e585b03c106
2019-01-29 16:47:46 +00:00
drh
a046643820 More robust handling of corrupt database file in the rebalance operation of
the btree logic.

FossilOrigin-Name: 97704cb7d29fa7cc4ea9a6761a7844c1946d637ea2b22d287fc787ae0f63c407
2019-01-29 16:41:13 +00:00
dan
e25646d64c Avoid an integer overflow in the fts5 snippet() function triggered by a corrupt database record.
FossilOrigin-Name: 7c862c4655841e1263cf548d01f5b4331685ab7d396494891cad0a5f50c63e16
2019-01-29 16:34:45 +00:00
dan
eb2ed10ec0 Avoid a crash when the fts5 snippet() function (or similar) is used with a special query pattern, like '*id' or '*reads'.
FossilOrigin-Name: 9d58a15737f7379fed724749cfd5b4de5b44231870e99fc664683ad483c3e6ba
2019-01-29 15:30:03 +00:00
dan
3993397e6c Fix a buffer overrun triggered by a merge operation on a corrupt fts5 database.
FossilOrigin-Name: 7ee3cd5b2cdf8db35f70400b3df58f7c421c78ae77c50f22b0ee22d5a3039429
2019-01-29 11:42:43 +00:00
drh
4a7e9a25b6 Set a low limit on the length of strings and blobs in the OSSFuzz module,
in an effort to avoid timeouts when the fuzzer does things like
"randomblob(1e12)".

FossilOrigin-Name: 119d1609fa415894fdd0aa19440ca1c658bd01910838a4cfadbe0e304b033bfd
2019-01-29 02:37:22 +00:00
drh
3967d946c7 Fix the query planner so that it is able to use an index on a CAST expression.
FossilOrigin-Name: 2c886f3d49c9569e9f6ee28b89b57e2d4004c8972d11da0c23f7b2d2e0c9900a
2019-01-28 19:06:17 +00:00
drh
e86974c619 Fix a performance regression caused by the previous commit.
FossilOrigin-Name: c4db0ad12d4f3d2800d36404f391b325cdc4aa7f8dcea93b2d63a489d9095ad4
2019-01-28 18:58:54 +00:00
dan
95d5a88058 Make indexes on CAST(...) expressions work.
FossilOrigin-Name: 3ef711d98fb239cf24472f124e7b36b0dde33355de5a2c9a3a978bbdd042a735
2019-01-28 18:08:59 +00:00
dan
c7def600bd Fix a buffer overread in fts3 that could occur when accessing a corrupt database.
FossilOrigin-Name: a9faf9033910927c74553e66c474d84ed3386f263cef3eec299e25d8306f410d
2019-01-28 16:50:42 +00:00
dan
6c43dbad98 Do not assume that text parameters passed to fts4aux queries do not contain embedded nul characters.
FossilOrigin-Name: df04859a995571cd6faf1abe088725708f35e81195760274df9e2ec9bd47f69f
2019-01-28 13:27:25 +00:00
drh
9e35a61e59 Add a new test case to fuzzdata8.db.
FossilOrigin-Name: ce8e279a7d37594e865c2d9197a5efe5d647e11f074dbaf4a4ee31c74c71dbc9
2019-01-28 11:54:13 +00:00
drh
0c873bf28a Change the definition of the BtCursor.skipNext field so that it is undefined
for states CURSOR_VALID and CURSOR_INVALID.

FossilOrigin-Name: 6089d5dba73437d787259033e94a38cf1b0c87cac4a89c27e69d8239c22f496e
2019-01-28 00:42:06 +00:00
drh
c07eee7a50 Improvements to the ".eqp trace" command in the CLI so that it ensures that
the schema has been read prior to activing the tracing feature, to avoid
cluttering the output with a trace of the schema parse.

FossilOrigin-Name: 42687d45aa1a2b2a32ddfc5711b4ae9cf76b8cfbeb20b57d6705ecaf5824fcb6
2019-01-27 19:50:56 +00:00
drh
05d49d1442 New test cases form dbsqlfuzz
FossilOrigin-Name: 9cf8ebd141aa2eb661d457624c76433bd9e4abfdef04aa52e28bc169172c2c8f
2019-01-27 02:45:32 +00:00
drh
211a0857b9 Window functions that can abort should indicate this, so that if they are
used in DML statement, a statement journal will be used.

FossilOrigin-Name: 0ea05a0eb96acb860d8af2e788e29a5ae3b161e7892ab62f1ff2f3e722c0dcb6
2019-01-27 02:41:34 +00:00
drh
e5da9356e0 Update fuzzcheck so that with the --load-dbsql options it screens its
inputs to ensure that they are valid dbsqlfuzz cases.  Add new dbsqlfuzz
finds to the test/fuzzdata8.db database.

FossilOrigin-Name: 004f7d9bbeee049c22a7e1c82c6cc0ea79a237967de3ff57686acea3060d5f45
2019-01-27 01:11:40 +00:00
drh
e6a9efb976 Ensure that the btree cursor is correctly set up prior to backing it up
as part of a delete operation on a divider cell in an index.

FossilOrigin-Name: a3ea1a822d3a110f4f186f2fc8550f435c8c98635d058096b7be9d4df7066b8b
2019-01-26 23:34:50 +00:00
dan
32bb700a95 Fix a broken assert() in fts3. Also some test script issues causing failures with builds that do not support fts3.
FossilOrigin-Name: d59567dda231e7ffec437d5e055676cf42d791196406cdc696cafa2583eb483b
2019-01-26 21:05:54 +00:00
drh
b4e5039316 Add the ".eqp trace" command to the CLI when using SQLITE_DEBUG, as a
convenient shorthand for "PRAGMA vdbe_debug=ON" but with automatic indentation
feature for program listings provided by the CLI.

FossilOrigin-Name: 626502faa17b5b7a0fa36cabfd12e463eb09aec048d01c587a18d3977cf04662
2019-01-26 15:40:04 +00:00
drh
0814acd981 Do not accidently truncate zeroblob values when doing an arithmetic
operation.  Fix for ticket [bb4bdb9f7f654b0bb9f34cfba].

FossilOrigin-Name: 13f6942eb0da2d92a0830f18640ce64208bd0cd6ff6d0c97e4a4c57ac3d65ba6
2019-01-25 20:09:04 +00:00
drh
b2e61bc66b Reinitialize debugging information on registers of a trigger prior to each
invocation of the trigger.  This prevents false-positives from the
sqlite3VdbeMemAboutToChange() test logic.

FossilOrigin-Name: 98b3b97573ccb3d986d1552f97f96e15088a598945923adcac77010c1e8b7fe4
2019-01-25 19:29:01 +00:00
drh
f69af053dc Fix harmless compiler warnings.
FossilOrigin-Name: 3ff220ad378d547538b4501e6b2201e835a2c66891e5e40856db377c101a50e5
2019-01-25 18:17:37 +00:00
drh
0578084507 Fix the assert_fts3_nc() macro so that it works for test builds that omit
SQLITE_DEBUG.

FossilOrigin-Name: b10df2b569e356551cf51ca179f307e4f8827413ee9feb886db1f1e0650e6c5f
2019-01-25 18:17:03 +00:00
drh
ed457037c4 Fix harmless compiler warnings in fuzzcheck
FossilOrigin-Name: a82539665718c8183d9d0bb7bcb3adcb1a23294b8c30f364829a982dab89a332
2019-01-25 17:51:06 +00:00
dan
c2ea77e5b2 Fix a segfault that could follow an OOM when querying a table that has one or more columns with default values "true" or "false".
FossilOrigin-Name: 202f9919c222ee933924c63c15ad36ec4481457b1e4d9179af14c9f284117c0c
2019-01-25 17:26:59 +00:00
dan
e88609f23e Fix asan warnings in fts5 triggered by corrupt databases - passing NULL to memcmp, out-of-range left-shift values and signed integer overflow.
FossilOrigin-Name: 93f8ec146d63af13f04e337ada4fa75e9254f72b1394df09701ae12e185f27e2
2019-01-25 16:54:06 +00:00
dan
c1f6618217 Add an assert_fts3_nc() macro to fts3 - for assert() conditions that are only true when it is guaranteed that the fts3 database is not corrupt.
FossilOrigin-Name: 3498908cd7f3d0e35b70796537124e3da0bd99d48750ba51bcb9eba87e28ed4d
2019-01-25 14:48:18 +00:00
drh
31ab7d8e5c Extend fuzzcheck so that it can process dbsqlfuzz cases. Add a collection
of interesting dbsqlfuzz cases to the standard test suite.

FossilOrigin-Name: e2991a7ecf5dd241c4bab7c7cadc4901043fb0c3ea1fac70b684f6d8332677f1
2019-01-25 14:23:36 +00:00
drh
94f0a83421 Fix the xFetch method of the "memdb" VFS (used by deserialize) so that it
is robust against corrupt database file.

FossilOrigin-Name: 2c1ef40e787a6bc355b50168527a47eb09acd30d0d88cff8336a434ad554115d
2019-01-25 14:16:01 +00:00
dan
ba14c69b4f Fix a couple of assert() statments in btree.c that could fail with corrupt databases.
FossilOrigin-Name: 5eb5e8289fa71e5e29e081d33d4a59c64b463bf6b06d7070c05c46d77d808ad4
2019-01-25 13:42:12 +00:00
drh
725a9c7f6c In fuzzcheck, activate vdbe_debug for dbsqlfuzz cases when using the -vvvvv
verbosity level or above.

FossilOrigin-Name: 2e6f7c2aced49824a38b3494b796a8ec73aa7a90b51159f670596df15ed1c5ab
2019-01-25 13:03:38 +00:00
drh
df21659a40 Improved automatic detection of dbsqlfuzz cases in fuzzcheck.
FossilOrigin-Name: 1ef24e89c9630fd383ba32f5aefcf9c27907f27f5072f3537a1cfd75a093a8d7
2019-01-25 04:43:26 +00:00
drh
a47e709e89 Add the ability to process dbsqlfuzz cases in fuzzcheck and add an initial
set of interesting dbsqlfuzz cases.

FossilOrigin-Name: fb9074ff450a67feaa62ca61d19154de26d5c8a8d147409ee6d1fbd667b2914f
2019-01-25 04:00:14 +00:00
dan
813ed78054 Fix a buffer overread in fts3 that could occur in a prefix query on a corrupted database.
FossilOrigin-Name: d0d5689371577b2861d4a9464443d055f3256f3f51d89e0388233a4cbe2601ee
2019-01-24 17:41:12 +00:00
dan
f467744d5f Fix a problem with running ALTER TABLE on a schema that contains expressions of the type "col IN ()" (empty set on RHS of IN operator).
FossilOrigin-Name: 2d9cd06715092c312c8c0ec392696a0e90ed090b074e2082e0b830f1399aa941
2019-01-24 16:27:10 +00:00
drh
3cc9af2140 Omit deprecated PRAGMAs when compiling with the -DSQLITE_OMIT_DEPRECATED option.
FossilOrigin-Name: 008112bcef561a8a3ebfb007cbef36cbc0071f547e6ebdba3d3bbb39e2c48c7a
2019-01-24 16:07:18 +00:00
drh
491b6d897d Make sure the column name flags are restored correctly after an error
inside of sqlite3ResultSetOfSelect().

FossilOrigin-Name: b1601db7adba2dccd4f90fbbe5099c801a2b0d97af087fbe82ed98d05496b38c
2019-01-24 15:51:03 +00:00
dan
b0c4c94996 Fix a potential problem with "INSERT INTO ... SELECT * FROM" (or VACUUM) statements on a corrupted database.
FossilOrigin-Name: db4b4c2c1e9f1adacfb1b2fedb717a4d8bb0a299c3b11835404a99fcd67bf24b
2019-01-24 15:16:17 +00:00
drh
936ade4dba Change a integer variable in sqlite3VdbeRecordUnpack() to unsigned in order
to avoid any possibility of an integer overflow.

FossilOrigin-Name: 1b536f6fd8d58800042f130842f0586aaa357841ee0d1b690a9815c865d50826
2019-01-24 14:16:20 +00:00
drh
55469bbafb Use memmove() instead of memcpy() in a place where buffers might overlap
if the database file is badly corrupted, to prevent warnings
from ASAN and valgrind.

FossilOrigin-Name: 65ad6c55f1ba9bc2f75afffa3adaf19f145fad7ac9a00ccce6372e9a2cc4341b
2019-01-24 13:36:47 +00:00
drh
6a02f237e3 Remove an unreachable branch.
FossilOrigin-Name: 4c976f171342ba2d39779279c28f3bc088572c440922e3e4421a3bf541263360
2019-01-24 04:44:54 +00:00
dan
b4738ddb20 Fix an assert() in vdbemem.c that could fire if the database was corrupt.
FossilOrigin-Name: a70958cd7d5cf750c293537856918e5789013b70f6a827f724d83559b38629c8
2019-01-23 20:31:56 +00:00
dan
a5f9f42a0e Fix a problem with renaming a table within a schema that contains a composite query that uses a column alias as an ORDER BY term.
FossilOrigin-Name: 2ca6b8f84ec07e313aa4e1c0894827401b418dcc4221e9c54c384f1c3893952a
2019-01-23 19:50:46 +00:00
drh
e3dadac591 Stricter enforcement of cell sizes when doing balancing operations on the
btree, in order to catch file corruption sooner.

FossilOrigin-Name: 12713f320b2c1def273dd8b7833dddaaad5331aba779d4b1ec9aa949814f38fe
2019-01-23 19:25:59 +00:00
dan
f8f47dd8c5 Fix another fts5 crash that can occur if the database is corrupted.
FossilOrigin-Name: 44ce8baa47192be03c8f11777904c3c07fa5cc5c97b6d8e81572d380995ac688
2019-01-23 19:17:05 +00:00
dan
d99950310f Fix problems with sub-selects in WINDOW definitions. Also rename-column operations when the column being renamed appears in a WINDOW definition that is part of a VIEW or TRIGGER.
FossilOrigin-Name: 0387cb3add992b2028efe4f2100188d8f9fdfdcb233329857aa4b46a293cfc97
2019-01-23 16:59:24 +00:00
dan
4c7bdd1597 Fix a buffer overwrite triggered by a prefix query on a corrupt fts5 table.
FossilOrigin-Name: 1d8172a94bce2d067027685e5aa1dc8f5d5d55b5da0832ad2836f6939de68c8f
2019-01-23 12:19:22 +00:00
dan
ccfa550922 Fix a buffer overrun that could occur in fts5 if a prefix query is made on a corrupt database.
FossilOrigin-Name: 1abc4415648e69362061e9f9a4f2c1d419ba33801999b377650d8b9a4d2d3a7c
2019-01-22 21:17:40 +00:00
dan
8e4fe01dda Do not run shmlock.test as part of the journaltest permutation.
FossilOrigin-Name: 5b7d0c784e6467154d9549af0163d788b69d5e5a6478a735834cdea945e7dbb7
2019-01-22 20:18:29 +00:00
drh
c5ea2d474d Use _strdup() instead of strdup() on Windows builds of the CLI, to avoid
a compiler warning reported on the mailing list.

FossilOrigin-Name: a7126a4f4fb4e3e25be95d673323f835252bb2b427469616046a90b2acf64071
2019-01-22 16:44:59 +00:00
drh
f186f0b058 Fix the SQLITE_DESERIALIZE_READONLY feature so that it does not cause
an assertion fault in the pager.

FossilOrigin-Name: b9eccef7825c61980678599358b62bc394283124653061ce163ead0c653f481d
2019-01-22 16:43:47 +00:00
drh
178edcd774 Update dbfuzz2 to set a maximum database size of 100MiB by default, but
with the new --max-db-size N option to change that limit.

FossilOrigin-Name: 21d6bb78ef2979d011b917d2d6519d7cd0009fcad83ed23ab2e9a5e02d8e51ab
2019-01-22 16:11:31 +00:00
drh
6ca644818b Enhancements to deserialize: (1) Add the SQLITE_FCNTL_SIZE_LIMIT file control
to set a maximum size for an in-memory database, defaulting to 
SQLITE_MEMDB_DEFAULT_MAXSIZE or 1GiB.  (2) Honor the SQLITE_DESERIALIZE_READONLY
flag. (3) Enhance the TCL interface to support -maxsize N and -readonly BOOLEAN.
(4) Add the --maxsize option to the ".open" command and on the command-line for
the CLI.

FossilOrigin-Name: 30f08d58882819a69e353bcc1b6b349664bbfbe00aa1c115ba44a9fd899fcc5b
2019-01-22 16:06:20 +00:00
drh
247c1b4a0b Make sure cursors are opened on all indexes for an UPDATE OR REPLACE
regardless of whether or not the indexes are partial or contain columns
that might need to be updated.

FossilOrigin-Name: e148cdad35520e6684cfeba23b003f60b55f83a6bf621aff16be8aa5612cdcee
2019-01-22 13:45:48 +00:00
dan
2c7a73eaea Fix another segfault caused by a corrupt fts3 database.
FossilOrigin-Name: ba3b8412726548a0716c1a2d67260c3b7e31956474f4cd4ce607cf2cebc667dd
2019-01-22 12:21:28 +00:00
drh
9b13365bba Ensure that a key comparison does not read a collating sequence past the
end of the KeyInfo, even if the key field of an index is corrupted by having
a string in the last column instead of the ROWID.

FossilOrigin-Name: 058a8006dceda78a894ea9446f057aa60b6d38e96506d4d91bda0ee2f9314ba3
2019-01-22 02:34:35 +00:00
drh
87c3ad4537 Enhance the btree search routine so that it does early detection of
impossibly large keys and thereby avoids a large malloc() call.

FossilOrigin-Name: 3ecaaee69f49e43d38047b7d53b82689eba7f7d33541fcac3c32b6dc8a568458
2019-01-21 23:18:22 +00:00
dan
129371553c Avoid deferencing a freed pointer following an OOM or SQLITE_CORRUPT error in
the fts3 xDestroy method.

FossilOrigin-Name: 505ed9a47825240979338a24044559613fbbd2a7850bdff70c7164da054ec63d
2019-01-21 17:57:31 +00:00
dan
ac30553f76 Remove a faulty assert() from fts3.
FossilOrigin-Name: 6c33a303ebbb0f5193ead535280ba63118e14fb4f9977ce80dc716a0b082ec99
2019-01-21 16:12:20 +00:00
drh
e6c628e98c Make sure the extra bytes allocated for the saved cursor position by
check-in [160b1e31c0f27257] are initialized to zero.

FossilOrigin-Name: 2737564929e86ead84a3ff6512369268198d38b46e3e02866f8ce34babc76cb9
2019-01-21 16:01:17 +00:00
drh
50b910a8b5 Add the --memtrace option to the CLI.
FossilOrigin-Name: a1e12fa2a8eb5648a96cc2d8d39899d6f87c5e2269cec7de486964c8b915e724
2019-01-21 14:55:03 +00:00
drh
7c04c69204 Minor fix the fallocate.test module change from [7cd56cad5efead5]
FossilOrigin-Name: 94fb7a47003c3c1a52e833e98d27399cfec5382afde2b3990e8223c8bff7cfa0
2019-01-21 14:49:14 +00:00
drh
5976552a72 Add the --max-data and --max-as options to dbfuzz2. Also cause dbfuzz2 to
show its maximum RSS size upon exit in standalone mode with the -v option.

FossilOrigin-Name: 7ce93e824a954d1e0cf8d7343e59a2660175f42bd4dac02aed8ad77644e7eb2f
2019-01-21 13:47:55 +00:00
drh
8ed07d1274 Add the --max-stack option to dbfuzz2.
FossilOrigin-Name: c11ae4fed89484f0a0061002861b5d599bbda8e40a1f0c33fdbe8cb072134d5c
2019-01-20 00:03:59 +00:00
dan
27a037354c Avoid a division-by-zero error in fts5 caused by a corrupt database.
FossilOrigin-Name: 928e622178bd004be52b2271ac554176aebe9d6e115ecac4e7072eccbb4262b5
2019-01-19 15:55:27 +00:00
dan
b8852ae083 Remove a broken assert() triggered by a "PRAGMA max_page_count = N"
invocation, where N is larger than the number of pages in the database image,
but smaller than the number of pages in the database file.

FossilOrigin-Name: 7cd56cad5efead5097e9918c87313bb46e583fe62bae0df1be60e10117e2c3cb
2019-01-19 15:27:09 +00:00
dan
93b6c1666d Fix a problem with using ALTER TABLE to rename a table or column when the
database schema contains a trigger or view that itself contains an expression
 "<column> AND 0".

FossilOrigin-Name: 908ff7fffa302255a74e2334ca3a1779ed43acb0268fce5a83a56fd16794dc88
2019-01-19 14:07:37 +00:00
dan
225b05795f Fix a memory leak introduced by [55c5d72a].
FossilOrigin-Name: fbd681dce2905d8b8ad7948ba684b0b62d6c04be0f7a2992ee7d6836a99010de
2019-01-18 21:17:08 +00:00
dan
6e0a75a2b8 Fix a crash in the fts5vocab module caused by including a "term < NULL" term
in a WHERE clause.

FossilOrigin-Name: 9e717c4377c0116a5d36815fbc30f8b8803f14770d30be361feb27cc5b5b537b
2019-01-18 21:12:32 +00:00
dan
a86b20820d Fix an infinite loop caused by a corrupt database in fts3. Also an undefined
left-shift in fts5.

FossilOrigin-Name: 55c5d72af9510e2f27c33544d804a58d4282b0efb384ead38484129ce91b574f
2019-01-18 21:03:15 +00:00
dan
4c1c79035f Avoid passing a NULL pointer to memcpy in fts5, even if the database is corrupt.
FossilOrigin-Name: acccc9808f52009b2c7794770c8b7efe2ce861fa184d32e287e7114c74e2b522
2019-01-18 20:15:02 +00:00
drh
d00ad9a656 Typecasts added to the GeoPoly extension to avoid harmless UBSAN warnings.
FossilOrigin-Name: a1f6a093ac4a2de8c5b02c30fe57e09770460fd5bdddfe9c7a9a24fb83a6b491
2019-01-18 19:33:56 +00:00
dan
451297752c Fix problems causing undefined left-shift operations in the fts3 snippet()
function.

FossilOrigin-Name: b90dbaed3092236e97f9796fa63989a3648060e16189e1267c430f4a7e799fac
2019-01-18 19:26:48 +00:00
drh
ed968fa4cb Avoid integer overflow when computing the array of a bounding box with
the rtree_i32 virtual table.

FossilOrigin-Name: b352f1590d20a574b0681e011ececcf4f41fa5b157503d330e03939404aca0e9
2019-01-18 18:52:17 +00:00
drh
e3b89d2c5f Handle oversize floating point values carefully when converting to integers
for the '%' binary operator.

FossilOrigin-Name: 048add13fc10e69ae504a49c4663612381d928b2cf1f9cdab4ff34bd40f601a3
2019-01-18 17:53:50 +00:00
dan
0e14e98706 Fix a fairly obscure problem allowing an "ALTER TABLE RENAME col TO ..." statement to modify the schema in such a way as to break a reference within a trigger program.
FossilOrigin-Name: 64bec9e6214c6932fab5a3fb8c569ae14cd2d603bd0f8b26104815c3bb9d396a
2019-01-18 16:06:18 +00:00
drh
3cb79202f8 Use the full 64-bit integer value in the argument to randomblob().
FossilOrigin-Name: 05df5f7aeaf2132810452e8871132d1e66650a841991cb2a9ce32f2d03e20bf4
2019-01-18 14:53:15 +00:00
drh
21908b2166 Disable the xfer-optimization if the two tables have the same root page
due to schema corruption.

FossilOrigin-Name: f31b3bd2a6a8aa35a6454f37f3a4b4595e2ad74256cd180439019ab4c6c2059e
2019-01-17 20:19:35 +00:00
dan
934d4f7bac Fix another corruption related crash in fts5.
FossilOrigin-Name: 4538d9afe4e6360e20c7b474e77314e5ad293453e1edbe356bf6ea84c05857ee
2019-01-17 20:06:56 +00:00
drh
aa0f2d0efa Add the SQLITE_ENABLE_EARLY_CURSOR_CLOSE compile-time option which causes
read cursors to be closed after their usefulness ends during a two-pass
UPDATE.

FossilOrigin-Name: 7def6c8edd85f19ee09038e01541f75b1f71ca39b9fb782b8f0fcac89207c353
2019-01-17 19:33:16 +00:00
dan
f66da6ce8e Fix a buffer overwrite that could occur when running an fts5 prefix query
against a corrupt database.

FossilOrigin-Name: 3910b5639d5c96d1840d4feeea64d3a55073531b7365a4e75d9cda6f119f3cfc
2019-01-17 19:11:10 +00:00
dan
25fb50674f Fix problems with joining two or more fts5_vocab tables that access the same
underlying fts5 table.

FossilOrigin-Name: 49956395e14b61f6bf839e59ae7dd95eb32ebf32f3d16388844de6621b9c2d98
2019-01-17 17:39:15 +00:00
drh
29c992cb04 Revamp the SrcList allocator routines to be methods of Parse instead of
being methods of the "sqlite3" object, so that they can leave better error
messages when the SrcList object grows too large.

FossilOrigin-Name: df08d472b090b212fb77ce2aae0e1ffe79ae5db4b1accf55e6fdb18e8b0a7098
2019-01-17 15:40:41 +00:00
drh
0ad7aa8182 Limit the size of SrcList objects to 200 entries (compile-time configurable
using -DSQLITE_MAX_SRCLIST=n).  The maximum number of tables in a join has
always been 64, so this is not a real constraint on capability.  Limiting the
size of a SrcList prevents DOS attacks (discovered by OSSFuzz) using crazy
nexted CTE joins.

FossilOrigin-Name: 7cac614d5df55eb092b863163483b6782b942b21bd15fd787576fef5619fa849
2019-01-17 14:34:46 +00:00
drh
04fcef00ee Fix a corner-case for the logic that cause an insert of a NULL into an
INTEGER PRIMARY KEY column to be converted into a valid integer key,
when the NULL results from a CASE expression that lacks an ELSE clause.

FossilOrigin-Name: 9a425051e7ba59e797636f5cf32b5f6efafdb21c8d5300e099b8008b829c1439
2019-01-17 04:40:04 +00:00
drh
30fdb45da0 Ensure that the variable-length integer decoder in FTS3 never tries to
left-shift a negative number.

FossilOrigin-Name: 10ffc1fe006a1766ff2f1ffc6129786afb86b6b1f8d3a17334e8ecb838d37b9c
2019-01-17 03:43:38 +00:00
drh
f20bbc5f69 Fix a failure in sqlite3ExprCompare()
FossilOrigin-Name: 835e2cc55feea2f2426c99816c27f9c35d2fd4cdd9bf1c7f46f889ecfd222778
2019-01-17 01:06:00 +00:00
dan
8b20e4a3eb Fix a problem with fix [b4b57413].
FossilOrigin-Name: ca7b7aaed010ec67bec5355a9ac1d7f229d6d5f2ba2d796b76f5e908b1267688
2019-01-16 20:48:13 +00:00
dan
e011ee2830 Fix a problem in the fts3 matchinfo() function with corrupt database handling.
FossilOrigin-Name: 24ed5fb6aea30b098d2faf3cf9d638933e518657217e903239ffaa1e25d34f66
2019-01-16 19:44:09 +00:00
drh
375afb8bda Fix a problem in the code generator for sorting results with SRT_EphemTab
and a LIMIT clause.

FossilOrigin-Name: 49fcde2f1f981ac0c75728bed3444e7c1d3167311db282d3375c96ce090b2210
2019-01-16 19:26:31 +00:00
dan
5e970a8f40 Fix a problem with renaming a column that is used as part of an ORDER BY on a
compound SELECT within a database view or trigger.

FossilOrigin-Name: b4b5741366578b25ec6e4c415ab8239215e53b1c900be613575f40a826cfccc9
2019-01-16 14:58:37 +00:00
dan
fb8ac325d7 Avoid a dangling pointer comparison when renaming a table that has a trigger
that itself contains a window function with an (illegal) column reference in a
FOLLOWING expression.

FossilOrigin-Name: d45bee36f2c1091a2d32c16ca8921bf4e7c9e40c46d0a36fbcb179ecfafcfbf0
2019-01-16 12:05:22 +00:00
dan
4ccb41fc99 Fix a memory leak that could occur in fts3 when handling a corrupt database.
FossilOrigin-Name: 65cebb06a0afcbcb4157c3d518a62ed188b1e90d9e9b69d88fece484bcb6e380
2019-01-16 11:38:06 +00:00