Commit Graph

8588 Commits

Author SHA1 Message Date
drh
41584df573 Ensure that the affinity of columns is honored in the RETURNING clause.
See [forum:/forumpost/e0c7574ab2|forum post e0c7574ab2] for the bug report.

FossilOrigin-Name: 4711fb69547f4f17653ab116030c32fdcc2c836410349d1d025866ffc15704da
2021-12-29 04:31:54 +00:00
drh
6e627c44de Fix windowC tests to specify little-endian or big-endian UTF16, for
cross-platform portability.
[forum post 559b84a5c6|forum:/forumpost/559b84a5c6]

FossilOrigin-Name: adf3a1e6f7575964e467f6813ff980e802cf5a37aaa9e1736af702c493f276b1
2021-12-16 19:50:02 +00:00
drh
a91734894e Give the correct prefix to tests in the windowC.test module.
FossilOrigin-Name: fb43456324c26879767b08febf1b5a2b46a289f25398a3872f81d845afd5d84e
2021-12-16 19:43:16 +00:00
drh
aca5e49caa Fix a typo in the result of one of the new test cases.
FossilOrigin-Name: 4d02a129c4781c97981748f3c69564e1320d8085dfba4c207e54793390cd64ab
2021-12-16 17:21:34 +00:00
dan
2999068d2c Fix fts3 and fts4 so that they can still be used even if the other is dropped by a call to sqlite3_drop_modules().
FossilOrigin-Name: a0a8d6c9f0e91996003626e4f80dfac278e3c5bddd9ace5d442061e6c95e49dc
2021-12-16 15:29:49 +00:00
drh
52576b78f6 Enhance the virtual table query planner so that it is able to deal with
ORDER BY terms that contain COLLATE clauses as long as the specified
collation matches the virtual table.  This is especially important for
UNION ALL since a "COLLATE binary" is added to ORDER BY clauses if no
COLLATE clause exists in the original SQL.

FossilOrigin-Name: 5c3d398d20b86a1558720e995eddf11403aec2d160590571fa9525fe8f6efff9
2021-12-14 20:13:28 +00:00
drh
22f018c938 Minor fix to the ORDER BY elimination logic in generate_series().
FossilOrigin-Name: a2e50712fca9dff1b8d19631f792270c82da3c8696a5d9890cf0d1e13e950d60
2021-12-14 18:11:46 +00:00
drh
b574acb94f Add support for Bloom-filters as a performance optimization for joins.
FossilOrigin-Name: 633bfeeea2bccdd44126acf3f61ecca163c9d933bdc787a2c18a697dc9406882
2021-12-09 20:06:18 +00:00
drh
a11c5e22b5 Enable bloom filters for the right table of a LEFT JOIN. Fix unreachable
branches.

FossilOrigin-Name: d342ab722de1fc3f34219c9755253db9d88eb50a6fa5cc257207008b00e7fc03
2021-12-09 18:44:03 +00:00
drh
92704681a1 New test cases added to test/fuzzdata8.db
FossilOrigin-Name: 7046877006259a0073cca4ddb4541321d373c462eac9924be26b5ae224075732
2021-12-09 14:15:39 +00:00
drh
3b26b2b56b Check for foreign key constraint errors prior to returning the results from
a RETURNING clause.  See [forum:/forumpost/793beaf322|forum post 793beaf322].

FossilOrigin-Name: a818ba2ed635b91e279dde44236fc7446a33db2b46c9409b67021248c01bf4e5
2021-12-01 19:17:14 +00:00
drh
c1085ea412 In the automatic index generator logic, be more precise about when a
partial automatic index is allowed in order to capture more cases where it
is legal to use a partial automatic index.

FossilOrigin-Name: 664b461bb5063d98047fc2e51a3827235cd9f55ca2e23cb66e719eac53fb5437
2021-11-30 14:07:58 +00:00
drh
855a165fec Add platform "Darwin-arm64" to test/releasetest_data.tcl.
FossilOrigin-Name: 1d5c9aacb8ab6349935561cc12734cf348c12c86e4663ddc7af113b3ed0f6186
2021-11-26 20:26:37 +00:00
dan
2df026a549 Avoid splitting Failure-Detection test cases in wapptest.tcl.
FossilOrigin-Name: 654e6cf8ab493d48b1827bb8100d4e4366a8e889e647c233a9b1b1278a7133d0
2021-11-24 21:16:32 +00:00
dan
619a5f5572 Exclude two recently added tests in where.test from valgrind runs. They fail due to the subtly different handling of real numbers under valgrind.
FossilOrigin-Name: e842d2085b295ef1c927611f5d3b211fb6b513ca2676c074fe90331da81734eb
2021-11-23 11:34:43 +00:00
dan
70a05e9168 Omit wal mode tests in memdb1.test for builds and configurations that do not support wal mode.
FossilOrigin-Name: 0f13c0d9fd7757c6e0b845a285c0047d2c60293354335660d19d80ad799646fc
2021-11-22 16:50:41 +00:00
dan
b127d0fd2a Omit wal mode tests in vacuum-into.test for builds and configurations that do not support wal mode.
FossilOrigin-Name: 65de17635468791678b9d205552a4faec2d6c3b7d330c559b6f81ab072254533
2021-11-22 16:48:42 +00:00
dan
c7b29b0ce7 Do not attempt to run the tests in alterfault.est with SQLITE_OMIT_ALTERTABLE builds.
FossilOrigin-Name: 6f6f31c7df6831af28a24e69f744beeade739bb7bbb0810d5bbe592e4cd75e3d
2021-11-22 16:43:53 +00:00
dan
42ac4c2e5f Fix a typo in memdb1.test preventing tests from passing with -DSQLITE_DEFAULT_AUTOVACUUM=1 builds.
FossilOrigin-Name: eff4187c50790827d05bb28867cc6546196e7eee3b4c4de54b4e68bfb4e2830e
2021-11-22 16:27:36 +00:00
drh
b670fd5545 There are two possible error messages from stat-9.1, depending on
compile-time options.  Adjust the test case to accept either one.

FossilOrigin-Name: 0f567b61072e214c40cae1441889f83622a975f429b41803dfbed687718731c8
2021-11-22 16:06:57 +00:00
drh
81258cc911 In fuzzcheck, improve the defense against long delays due to
rogue busy_timeout macros in fuzzer-generated scripts.

FossilOrigin-Name: 3024d7ca03541a6fe3d264fdc82dd49f8f6b51d2fbeec4dfc9c6dd72806b271a
2021-11-22 13:59:06 +00:00
dan
bb0c54283d Fix a crash in the fts3aux code that could occur handling corrupt records.
FossilOrigin-Name: cdcd65b89ecffd380483404f5b1379beffd7ff107acaa5bc1185651cfacaa220
2021-11-22 08:12:14 +00:00
drh
6f991147bd New test cases for STRICT and NOT NULL in PRIMARY KEY.
FossilOrigin-Name: 0eafbc2f31b83f48833b19894ff3252a63c319ff501506ef9f744cca813a3a24
2021-11-20 13:30:03 +00:00
dan
488b55856e Fix a problem causing an OOM within an ALTER TABLE ADD COLUMN command that adds a column with a CHECK constraint to go unreported.
FossilOrigin-Name: a33f5e93ecb7d84291f6fecc7b60f0c555034aa47e24584c63c78d8a94710d82
2021-11-16 13:36:50 +00:00
dan
8745f8a3c3 Fix a problem causing the count(*) optimization to be misapplied in some cases where an aggregate sub-query uses a count() expression that is aggregated against the outer query.
FossilOrigin-Name: e30917278c0ec750b1756ddc5e32d65c55464531d6ef64d2e72a412dfe634f58
2021-11-15 14:11:23 +00:00
drh
a2852ac4d2 Fix a faulty JSON assert() added 30 days ago by check-in [7b8ea2298927fd34].
dbsqlfuzz f30366e7b02562398a387ddcc681422fd4251190.

FossilOrigin-Name: 0e0c23fcc493a5d6beb6ab9554981bbc36ba1554fea0f8ba78dc41738f4bd1c2
2021-11-15 01:45:11 +00:00
drh
f9241a5fd0 Remove a NEVER() that was add yesterday. The fuzzer found a new test case
to make it happen.

FossilOrigin-Name: 83e6ac71073edfa0cd73788c30bdd5f09cb04c8a6a7d5123123dbcd354f430b8
2021-11-11 16:26:46 +00:00
drh
34e71830de Load new test cases into test/fuzzdata8.db
FossilOrigin-Name: 8b53ffe99df6f5443bd22a9d95433819eb44c7e8f044c2f3e9d52661741d5612
2021-11-10 15:23:00 +00:00
drh
995d33ae02 Change test case error message text to match the current implementation.
FossilOrigin-Name: de10795a1cf70925088e9652998e813665b2e147ffa4a4edab18c7e2c66bf5ae
2021-11-09 13:31:42 +00:00
dan
a32536b498 Fix the zeroblob() function and related APIs so that they work with SQLITE_OMIT_INCRBLOB builds.
FossilOrigin-Name: bc401a75dd9f3c29c5969ae36264e68ccefc0937e44e232ca1f6b550f7fd6e22
2021-11-08 19:35:26 +00:00
dan
1a39e45619 Fix an assert() in memdbTruncate() that could fail when processing a corrupt database.
FossilOrigin-Name: b1e2929860557cf88f98f0a4f2472e1a16be126bbb8050f0d728350f0cfe987a
2021-11-08 15:46:08 +00:00
drh
6d64b4a027 Ensure that the window function rewrite does not leave the parse tree
in an invalid state that might cause problems downstream before the
error is recognized and unwinds the stack.  Also take steps such that
an invalid parse tree does not cause problems even if it goes 
unrecognized.  
[forum:/forumpost/398e9d5aa9|Forum post 398e9d5aa9].

FossilOrigin-Name: 0f9fc6b6073365d5159cd71e7fe08f8dadbc7b42abd324361e809502f4359155
2021-11-07 23:33:01 +00:00
dan
35c7312ff0 Return an error if an attempt is made to drop an eponymous virtual table.
FossilOrigin-Name: 889dea52de874cd3bda9e811ef1e4ca53ab794ecabc65e9c780d9fb01eff3b2c
2021-11-06 18:22:50 +00:00
drh
62561b82f2 Avoid accessing the sqlite3_module.xShadowName field if (sqlite3_module.iVersion<3).
FossilOrigin-Name: a024764cef955099b498ea120d4127144880db6da411f074cf0fd1276989204e
2021-11-06 10:59:27 +00:00
drh
91acf7d353 Add the SQLITE_OPEN_EXRESCODE flag for sqlite3_open_v2().
FossilOrigin-Name: ff9373f42d8479be5cae6cc15dc7fe0cc125c6c0157f5375bf7e1e77c624655d
2021-11-05 19:36:26 +00:00
dan
695c87f67d Update sqllimits1.test to account for recent changes to SQL function strftime().
FossilOrigin-Name: 7bba415f91884a20f665e982376c2c5e91a4431e218c8eefe275be3684f2e59a
2021-11-05 14:13:12 +00:00
dan
11e29677a2 Fix vacuum3.test so that it works with SQLITE_OMIT_ALTERTABLE builds.
FossilOrigin-Name: 07cca2fa891e9a60ea128a4b96ee407e9dd0f2b9e31fcffbfc2ac594a0e1ffe6
2021-11-05 11:26:00 +00:00
dan
06ee284182 Update a test case in sqllimits1.test to account for the updated implementation of SQL function strftime().
FossilOrigin-Name: f474ac370accc5c780e7cb3e11c35f2b6104df929d3394a27db00c6b995e71b3
2021-11-05 11:18:31 +00:00
dan
2841abedde Fix a couple of problems with test scripts and SQLITE_OMIT_ALTERTABLE builds.
FossilOrigin-Name: 3ab5414d337536acad5675a3f1ca10e1ca925f0e7182def604b8b7a8fb53bf5a
2021-11-05 10:43:14 +00:00
dan
3555274419 Fix a crash that could occur in fts3 when processing a corrupt database.
FossilOrigin-Name: 2fad2a89527757b3956538a6bf91ebebe9c483f22f94e889e8b50c58f5100c5c
2021-11-04 18:04:55 +00:00
dan
de3fd373a1 Fix corruptN.test so that it works with SQLITE_DEFAULT_AUTOVACUUM=1 builds.
FossilOrigin-Name: f60e05bdbabe0449e5a12275b254ca9da39a2a5fdbff078ce28007a23044749e
2021-11-04 16:25:47 +00:00
dan
715e002d04 Update a test case in corruptN.test to account for the fact that if writable_schema=1 is set, no error is raised if a DELETE statement finds that an index entry is missing ([19e56291a7344c7a]).
FossilOrigin-Name: a90c5f0b5ba1ef0f41449cee10a65beb8b55b09fd1976e0e35814b1848979416
2021-11-04 16:15:46 +00:00
dan
a4adaa37fd Have wapptest.tcl avoid attempting to build fuzztest for SQLITE_OMIT_VIRTUALTABLE configurations.
FossilOrigin-Name: 53ee208d4ee8db1499a63b6652a8c5269e8fe85a75376adffdb912094ac1a681
2021-11-04 16:03:24 +00:00
drh
ddfec00de3 First the shadow table mechanism so that it works even if the shadow table
comes before the virtual table in the sqlite_schema table, as can happen
after a VACUUM.

FossilOrigin-Name: 005a8642773556825fe4c5d0b2c12517d35289308a30df0151ef7f080acb0172
2021-11-04 00:51:53 +00:00
drh
ac894af85e Improved the error message that results when a schema parse fails after
ALTER TABLE ADD COLUMN.

FossilOrigin-Name: b007a39dd3a46d13fe06f2a1eeb4e3fd4cad1a77892be6d175b31db1edd6f6a8
2021-11-03 15:59:17 +00:00
drh
926aac51ba Fix INSERT into STRICT table with STATIC generated columns.
FossilOrigin-Name: 24285d913678853213532d61aba077d576e3cd7629159e0a75dc3c16e54e2662
2021-11-03 14:02:48 +00:00
drh
80b957b753 Add the --strict option to speedtest1.c
FossilOrigin-Name: a247b5d88c12b1952b656e4f069c9229e0886ba16d7018ddf600e74592224792
2021-11-03 12:50:28 +00:00
drh
5c9290423d Fix an issue in PRAGMA integrity_check associated reporting NULL values in
a NOT NULL column of type ANY in a STRICT table.

FossilOrigin-Name: 5dff1f66731ae35daf9633f8bb3ea942a7c29f4240e57bd2023ee7fc116e7c92
2021-11-03 11:43:09 +00:00
drh
5d742e39d9 Proposed fix for a problem associated with OP_SeekScan that results in an
incorrect answer.  See ticket [5981a8c041a3c2f3].

FossilOrigin-Name: 266e9cbada531716c908c21d60a6038109722e3dd040237679ac0240fb5020ea
2021-11-02 20:52:20 +00:00
dan
07ed9c1100 Fix a minor memory leak in the shell tool. Omit running fuzztest as part of the Device-One release test configuration, as it is now incompatible with SQLITE_OMIT_VIRTUALTABLE.
FossilOrigin-Name: 4d70f27b7b5681cfdf1c44ac654e565ccff089e74d3edf6660578e04e4b0c9b9
2021-11-02 14:01:41 +00:00
drh
3d0107dda3 Add the --remove and --glob options to the .archive command in the CLI.
FossilOrigin-Name: ea7b12cdf868fdfebc0a20bdcba97aea863284b563d478b0e4cb3d2a8612afee
2021-11-02 11:24:37 +00:00
drh
1cd6042f90 Add recent dbsqlfuzz cases to test/fuzzdata8.db.
FossilOrigin-Name: 8c3f2536d2853acef05c4e8c07f301abb0687402c56ded5ff8614e79fb049423
2021-11-02 10:47:20 +00:00
larrybr
8f09f4b264 Add globbing option to shell's .archive command.
FossilOrigin-Name: 13fb74ac5e7578ab612af2ccc8147569d60dc35af84f496bcc5d648d223d6d6e
2021-11-02 00:18:11 +00:00
larrybr
7774fc010a Add a test for .ar -r and fix a use-of-uninitialized-variable bug
FossilOrigin-Name: 978d5ed4379b631a79cd46a75d9b5b403f3ec4ce7d9d52ed36a5678cdf04f7f2
2021-11-01 22:30:24 +00:00
dan
e7c23433fb Merge trunk changes into this branch.
FossilOrigin-Name: 638c1b0c50229800067eb1ba29d829b4d6e008256c21a1f67b4ce4d19ea307b3
2021-10-30 17:30:48 +00:00
drh
cfb5249622 Allow "VACUUM INTO" to change the page_size of a database even if the
original database is in WAL mode.  Enhancement suggested by
[forum:/forumpost/033f2c9d1f|forum post 033f2c9d1f].

FossilOrigin-Name: efc7e8c99a86e9d9eb81655ce96353847bd2cca64eb8f8d10e297f6f4d38e563
2021-10-29 13:10:02 +00:00
drh
37bbcb48a9 Add pragmas "multiplex_enabled", "multiplex_chunksize", and "multiplex_filecount" to the multiplexer implementation.
FossilOrigin-Name: 39c5e80dbf94ac3079b3e0c2c3e6608ac366e3f3de3cea4f4947addc3f52bc36
2021-10-29 12:29:22 +00:00
larrybr
6ac9a5cf5a Fix .import -skip issue reported at https://sqlite.org/forum/forumpost/4c0816c24fc9d16f?t=h
FossilOrigin-Name: 3aadbe17edc1efc7fa6c9600de84e23242ba7866d2dcef2189afd7ba4c97979f
2021-10-28 19:49:23 +00:00
drh
be2d6fdd71 Fix a harmless compiler warning in fuzzcheck.
FossilOrigin-Name: 1cfb7e8a095e1e24df5117aa7be97470d8ce91837ff83dabebac53fafee0b09c
2021-10-27 15:16:30 +00:00
drh
662bebb6bd Change fuzzcheck so that it accepts binary dbsql files.
FossilOrigin-Name: c87a2426b81f22bd21543aa2408625ae472d8fe6cbe6b04145937066e61123c9
2021-10-27 13:16:33 +00:00
drh
075201e50f Add the --script option to fuzzcheck.
FossilOrigin-Name: 5a9676bd4945ca098652780515e94d04859e73588d9db5558ab42f8b068a9ddb
2021-10-27 12:05:28 +00:00
drh
48b4bf269c Enhance fuzzcheck so that if an argument is an ordinary disk file (not
a database) it is read in and processed as a script.

FossilOrigin-Name: 978dc89df521f5855678128b3c0eb503c67c1b97ddb297076e5f2c03d6297605
2021-10-26 22:36:41 +00:00
larrybr
f9a49b0cad Add phase and error number to CLI error messages.
FossilOrigin-Name: 7f87a298688c37bbad8fd2e1cf0e8fbcc36f0c211dcfa3685298525648dbe21b
2021-10-26 16:57:09 +00:00
drh
629c2eaf46 Fix the busy_timeout restriction on fuzzcheck so that it can deal with
hexadecimal integer literals.

FossilOrigin-Name: 4b41535b096dec4b15a85e657102a72d4288728da6103f3fdcbe0e6f244c673a
2021-10-26 09:53:51 +00:00
drh
63e8f03c78 Do not allow large busy_timeout pragmas in fuzzcheck, as they accomplish
nothing other than making the tests unnecessarily slow.

FossilOrigin-Name: fba441bf9f6ed729a66ccd4e42b5a8859bf3952d70a66bc9a2496ec49d90a60c
2021-10-25 12:54:23 +00:00
drh
c8f7211d8f Improve the authorizer filter for ATTACH on fuzzcheck.
FossilOrigin-Name: 87d49e80878674470d280de79c8ade222dd006e65c90e79616c4f72c7c32dabb
2021-10-23 22:14:11 +00:00
drh
be53656171 Update fuzzcheck so that it allows ATTACH statements with memdb filenames.
FossilOrigin-Name: 31671237e560b52dc27f707309269069a6bdcd017df9844908e77b57dc11f180
2021-10-23 11:30:35 +00:00
drh
dc88b40285 Fix the previous check-in so that it works with virtual tables that add new
shadow tables the first time they are referenced.

FossilOrigin-Name: f73b499e539b9551a70deecec4fc10c3a4af3830324977861cd0558f9782a1d3
2021-10-21 19:48:14 +00:00
drh
b18a11ed37 Fix the finish_test proc in tester.tcl so that it works for Windows test
builds.  Fix for problem introduced yesterday by check-in [3658417bf300e004].

FossilOrigin-Name: f52b84e69e5fcbe59ccc6163e7e78aa3822f2c354c88f8a76a2d1d4c90a99821
2021-10-20 18:17:31 +00:00
drh
dec8572d8a Fix a problem with the CARRAY extension when the SQLITE_TRANSIENT destructor
is used for non-text arrays.
[forum:/forumpost/48e525b266|Forum thread 48e525b266].

FossilOrigin-Name: cac910c15f409c5358843643b2f90252eb90328b9e5ff84cedbccb604d9891af
2021-10-20 13:48:12 +00:00
drh
60a2fc8244 Merge multi-module test logic improvements from trunk.
FossilOrigin-Name: e00a44ac10d68b7bdaff1d9c237b598696eddc2d7392574aee1a95d94b4f165a
2021-10-19 19:26:27 +00:00
drh
06ec7c662d Improved cleanup in finish_test so that specifying multiple test modules
on the "./testfixture" command-line is more likely to work.

FossilOrigin-Name: 3658417bf300e004e5166ee69aa2d8c70697b87ea7456cb6337b0ad6d60257d5
2021-10-19 18:59:10 +00:00
dan
a24df58fe8 Fix permutations.test so that it can be called with a test file pattern that uses square brackets.
FossilOrigin-Name: 55b6241871a3b52d835ebdc52a1ce6c736861cf7a03331391c5d6ffd39720514
2021-10-19 18:53:30 +00:00
dan
37c906e63a Update test scripts to unregister the test devsim VFS after it is used.
FossilOrigin-Name: bb0e18ae4a49c305dd8b26886a3a4f3c6dad380edca57af835da4ad470ca8eb6
2021-10-19 18:40:00 +00:00
drh
7bf3d01a83 Merge trunk enhancements into the autovacuum-pages-callback branch.
FossilOrigin-Name: c26c9e5040ef4c52f2a99597e3a7c3eabd52c905d874fc76ca10fd54b749fa97
2021-10-19 18:00:05 +00:00
dan
1273d69c82 Have the btree layer detect when a "DELETE FROM tbl" statement is clearing a database page that is still in use (due to database corruption) and report SQLITE_CORRUPT.
FossilOrigin-Name: a6fda39e81d0da98dd6b60b32e6df786f0089c1f4ac7f3a2936afd118bd04353
2021-10-16 17:09:36 +00:00
drh
1bbfc6744c Demostrate a prototype sqlite3_autovacuum_pages() interface.
FossilOrigin-Name: bb6f2b8b486c225043bc64e5f74ff6bbad6c5d1f337f0c81eeb6172b087bb943
2021-10-15 23:02:27 +00:00
drh
8436f53ebe New tests added to test/fuzzdata8.db.
FossilOrigin-Name: e944d71760e3ee3de5dd518a04dad54d66ae4d40dac172b64d16c508471e30a1
2021-10-13 20:29:05 +00:00
drh
febf0352cd Remove a NEVER() macro in ALTER TABLE due to an
obscure case of a nested CTE inside an UPDATE within a
trigger.  dbsqlfuzz e89174cbfad2d904f06b5e24df0a22510b6a1c1e

FossilOrigin-Name: 9e2f06b84f9942772c30bed2ac71b3296c9adf9661dbf8916d56996253ee8d28
2021-10-13 14:01:44 +00:00
drh
4fc80671f5 Fix the group_concat() inverse function implementation so that it correctly
handles BLOB inputs when database text encoding is UTF16.

FossilOrigin-Name: 38a1326b4bd11bbe2846990d099c28520d17ab4cace1af67248c2472f89df929
2021-10-12 22:55:04 +00:00
dan
dee0359ddb Fix a use-after-free in fts3 that could follow an optimize() in the middle of a SELECT statement when the hash table is non-empty.
FossilOrigin-Name: 8124b2ceb71447157283b16f9a7fa6e250003b9ddf1c1b45f91db64aed79b5da
2021-10-12 11:30:07 +00:00
drh
75231eae07 New test cases added to test/fuzzdata8.db
FossilOrigin-Name: 2e475fecadc6d9e9a0537435827f56a5c7345f69a9b713d7812da4c9a0f27a96
2021-10-11 09:48:59 +00:00
dan
867bc4de2e Break the tcl release tests into smaller units to better take advantage of multi-processor systems.
FossilOrigin-Name: 03cef1c30d96cd42682f57667bb3072c7643ef43fe05eda2d8b82c30789234af
2021-10-07 19:27:17 +00:00
drh
3768f175cc Once corner case for the fix at [8b24c177061c3836] was not quite right.
Caught overnight by both OSSFuzz and dbsqlfuzz and repaired here.

FossilOrigin-Name: 79e90a8225b90593e384eab49a8d1d3c93a3deaf2739dcc30f6c88852df80d04
2021-10-06 10:04:04 +00:00
drh
36db90d3dd Fix query plans created by whereShortCut() so that they always check
transitive constraints that drive an index.  The is analogous to the
[f1f9b5de3c59489b] check-in, just for whereShortCut() rather than the
full query planner. Fix for the issue described by
[forum:/forumpost/a65cacbf5e1c41ba|forum post a65cacbf5e1c41ba].

FossilOrigin-Name: 8b24c177061c38361588f419eda9b7943b72a0c6b2855b6f39272451b8a1b813
2021-10-04 11:10:15 +00:00
larrybr
d797d6b626 In CLI, ensure correct line-accumulation state whenever line(s) are dumped or processed. And test this.
FossilOrigin-Name: be211a9c59234ef202e772fcaae18be43c44e1e00674f137cad2d903e00bfcab
2021-10-03 22:03:59 +00:00
drh
260ff08133 Fix a problem with group_concat() when it is used as a window function with
a sliding window, as described by
[forum:/forumpost/f3eb24a6c0|forum thread f3eb24a6c0].

FossilOrigin-Name: f47f7f78227830c065d9ce715b8456eab81a38d680f76bf4ff08f298d84f9c7a
2021-10-01 22:48:52 +00:00
dan
37f3ac8faa Change things so that SQLITE_OMIT_VIRTUALTABLE implies SQLITE_OMIT_ALTER_TABLE.
FossilOrigin-Name: 2f7c946c5f25a858167f5193ca06e53310394c8cff15426ab8a1327a1ec835fd
2021-10-01 20:39:50 +00:00
drh
817424fe37 Merge updates from trunk
FossilOrigin-Name: 35351371c5e9602dec210ad0926ff8a1a269556ce1a166e81eb0543938e0c57e
2021-10-01 02:16:52 +00:00
dan
0abb7ec36c Fix a typo in altertab3.test.
FossilOrigin-Name: 18d38b13104a9c3367ec205bfa17fbdc3d792ba68a369b1c6f046096ef6cc581
2021-09-29 19:18:53 +00:00
dan
ab632bc97e Fix another problem with ALTER TABLE and vector UPDATE statements within triggers.
FossilOrigin-Name: a0df216f7c3f8963efba0b1ffee65d6a63309d846ffdcf2d2932cb4f1d4967b7
2021-09-29 18:33:26 +00:00
larrybr
34896c6855 Sync w/trunk
FossilOrigin-Name: a4c18b2f0ce4a0f4d0c4f4c25dc69fbed4cb4876d2b69e3e5e0e756410892d74
2021-09-29 16:35:14 +00:00
dan
a92f9586e0 Add extra tests for the group_concat() fix on this branch.
FossilOrigin-Name: 3d148615f9d9c6a3d63d8eb015f3d70f453a66de49b28e665831254387c700b9
2021-09-29 14:14:16 +00:00
larrybr
dde13e6f88 Get group_concat() to handle varying separator lengths when windowing
FossilOrigin-Name: 98e0f2bf67cdee1da1edadeb54ff8564728b3f28fc821e46e8de201247c3fc87
2021-09-29 00:32:13 +00:00
dan
a7f7c1c4af Fix a potential ALTER TABLE problem with expressions like ( (<sub-select>) IN () ).
FossilOrigin-Name: df0d7e36dbf98ab5405d8366ce92fb85176d4388b47a57b0ca1aa1ba6ae5212e
2021-09-28 10:44:54 +00:00
dan
5a69d19eea Fix a problem in ALTER TABLE causing table or column references in sub-selects ton the RHS of a vector SET clause in an UPDATE within a trigger (i.e. "SET (a,b) = ( (SELECT...), <expr> )").
FossilOrigin-Name: 255b0eeed113d83b474efc5bc8fc790a270bc43ee598df4b2c378e1ad2d729b7
2021-09-27 15:44:03 +00:00
drh
76ec55fddb Load recent dbsqlfuzz cases into test/fuzzdata8.db.
FossilOrigin-Name: 7a8fcf6d2c8e3c8f10ff515c8c00c761d15a28eef8e0e31e09e22feb06c9443b
2021-09-25 20:28:39 +00:00
dan
c28cc32d81 Fix a bad interaction between the pager cache and the dbstat module that could lead to a malfunction following an OOM. dbsqlfuzz 9ed3e4e3816219d3509d711636c38542bf3f40b1.
FossilOrigin-Name: e03554a6a8c33d820922edccf605a2ce92055315bf22e464207ea8c0d81e3dd6
2021-09-25 18:21:01 +00:00
drh
84d90319e5 Dbsqlfuzz (a097eaad43c3c845b236126df92fb49b25449b0c) found a way to reach the
assert() that was added to sqlite3_declare_vtab() by [eb94f4a8174436b1].
This check-in fixes the problem.

FossilOrigin-Name: 857d26a68cf439e9cba4f8a3b326c69366fc486a876b76835538709ee39b8713
2021-09-24 19:57:32 +00:00
drh
ebd1ff62c5 Ensure that sqlite_stat1 and sqlite_stat4 are ordinary tables (not views or
virtual tables) before trying to load them
(dbsqlfuzz bc02a0cde82dee801a8d6f653d2831680f87dca1).  This prevents
sqlite3_declare_vtab() from running with db->init.busy turned on.  Even so,
enhance sqlite3_declare_vtab() to be able to deal with db->init.busy being on,
in case there are undiscovered paths to that state.
Each of these two changes are independently sufficient to prevent the problem
fixed by the previous check-in [c7560c1329965ab5] but there
is no harm in keeping that third layer of protection in place.

FossilOrigin-Name: eb94f4a8174436b1f0deed0a43618a20018387bb815be658314ca6b454c446fb
2021-09-24 12:59:33 +00:00
drh
2a6a72a81c Ensure that the db->init.azInit array is initialized at all times.
dbsqlfuzz 0ad6d441f9bf3dfc32626a9900bc1700495b16f9

FossilOrigin-Name: c7560c1329965ab57cd71393c044b110561b83641d08677bc51044df9e377882
2021-09-24 02:14:35 +00:00
drh
6caccc1660 Enhance the TCL-based test harness so that it is possible to list multiple
test modules on the "testfixture" command-line and have them all run.
For example: "<tt>./testfixture test/shell*.test</tt>"

FossilOrigin-Name: 45caf9b85fc75abe80e3d2704fc634e4b103647c912c3fbffb1847d8cb581b62
2021-09-22 10:57:30 +00:00
larrybr
866c44704f Speed and (slightly) simplify shell's input line early processing.
FossilOrigin-Name: a1c7f7f8e1b46440234be96e813e4c2c28150413dd95dcab5d13b9c80a202edf
2021-09-21 19:19:28 +00:00
drh
2e50f67073 Add the "PRAGMA table_list" command with its corresponding eponymous
table-valued function: "pragma_table_list".

FossilOrigin-Name: 2c0e7ae541e9ecb86aa58fa7e7057def8aac1b1af1af1aa80b8bf2d260f9a2f9
2021-09-21 17:26:23 +00:00
larrybr
6b7e47fa58 Adjust shell tests for *Nix and Windows test platform anomaly
FossilOrigin-Name: 577544c5a2f193e00e5ca55b7feae96568198019573b9b0b37e2bf4300d6d524
2021-09-19 18:31:55 +00:00
larrybr
7e00984a47 Sync w/trunk, further streamline shell's resumable prescan.
FossilOrigin-Name: 9e00f9f7c03c192a3fb6b22851db0626515c59daac5ce6520229c42c838bf5b7
2021-09-18 21:35:22 +00:00
dan
bea28c73a3 Add a reference counter to a structure used internally by the Tcl interface so that it does not segfault if the database connection is closed from any of the various callback scripts that may be invoked.
FossilOrigin-Name: e54a33ce56432b23947583d34cf12fc64a55bbc49eb77c7f33cff5926df51070
2021-09-16 14:17:14 +00:00
drh
c0bd26a23a Update requirements marks to reflect recent documentation changes.
FossilOrigin-Name: 08cab8921e670a0d1758b505fe8c7455f6194cec69d1b7b77de91688be1028a6
2021-09-14 18:57:30 +00:00
larrybr
8d463ce135 CLI prescanner made to match SQLite's rules for delimited identifiers. Tests begun.
FossilOrigin-Name: 15b105c520968855ad960d8929f80af9e9bedc155237af9af1956f7b546947f2
2021-09-11 02:42:04 +00:00
drh
7f58117921 Back out changes [00286ca5d998d802] and [6844ede29e1dac93] (replacing the
associated branches with NEVER()) and add a single new test to
btreeOverwriteCell() that detects when an overflow pages is also mapped
into a b-tree page and raises and immediate SQLITE_CORRUPT error before
making any changes.
dbsqlfuzz 81791bd980fe6935ff2c7334ec8bef11c1c12b82 and others.

FossilOrigin-Name: 32210fa4ac4f06e1705ef808731c7be040a23f9a8630986440100c5d4e76dc07
2021-09-10 01:02:42 +00:00
drh
3acb3b7845 Remove a NEVER() in btree that is sometimes reachable.
dbsqlfuzz b9140023005430654c8fe544cf0a082ef8d561c1.

FossilOrigin-Name: 6844ede29e1dac93a392dfb1e7e676bb9d0a2e7bbec0a4a5804ffc2025a99b66
2021-09-09 19:19:02 +00:00
drh
30ad4a6932 Improved database corruption detection in the editPage() subroutine
of the btree rebalancer.
dbsqlfuzz f035b1b5a100a5f0cffb95c958b6c67d7c5eaf1f.

FossilOrigin-Name: 00286ca5d998d80214d5e8d501a3b305f432cda1c0ef67ca530e1219565909b7
2021-09-09 14:03:55 +00:00
drh
94b70d8343 Fix PRAGMA integrity_check so that it does not try to enforce types on
ANY columns in a STRICT table.

FossilOrigin-Name: 57384fda8db43964871be5e48ae1c72c67533046b523f161d60a41fdc8e96b9e
2021-09-08 19:25:21 +00:00
drh
59bccb2637 New test cases added to fuzzdata8.db. No code changes.
FossilOrigin-Name: 51e5aadafe1a4ba6a0be7fc1732d1ec940cbc5e23723b76267c2abf887d713ac
2021-09-07 19:23:32 +00:00
drh
eb61630b40 Fix a potential NULL pointer deference in the LIKE optimization. The
problem was introduced by the addition of generated columns
in check-in [b855acf1831943b3] (SQLite version 3.31.0, 2020-01-22).
Reported by Wang Ke in
[forum/forumpost/699b44b3ee|forum post 699b44b3ee].

FossilOrigin-Name: b9417d400f4585004f434837022709f818044d5844fe208fe01595a6b226ef7d
2021-09-07 15:41:25 +00:00
drh
905b82d5f5 Fix an issue in the "shrink.test" test script reported by
[forum:/forumpost/90a74bd61861f58f|forum post 90a74bd618].

FossilOrigin-Name: 6c3734edb2ecabd85a715c853ef58da39381af26d3dd32e53c068b4fcf6fb98f
2021-09-06 15:59:32 +00:00
dan
beed24d57e Do not disable a rowid=? term used to drive an IPK index if it is a transitive constraint.
FossilOrigin-Name: 46e28cbcf6044b36aa4ddcda09adb49a46c6c6a8d41d558467ede3091304aa8c
2021-08-30 17:02:48 +00:00
drh
b9fd0101bd Back out the change that allows typeless columns in strict tables. Replace
that capability with an ANY type for strict tables that will accept any
datatype with BLOB affinity.

FossilOrigin-Name: d8fd1a2bfd51848ea612142d23475b268b3f5269e558f2e09713d1ac18b18274
2021-08-23 10:28:02 +00:00
drh
2a0eefd665 Allow typeless columns in STRICT tables that are able to accept any
data type.

FossilOrigin-Name: 1e2dcc2d4ee88c0aed40d1472b1c7d43fd43822891729ad6a2c55d5b912e7ad7
2021-08-21 20:54:19 +00:00
drh
ce68b6bfeb Defer deleting subqueries in the compound-SELECT code generator until the
end of code generation, in order to avoid deleting expressions out from under
the aggregation function sanity checking assert()s that occur near the
end of SELECT code generation.  This fixes the assertion fault described by
[forum:/forumpost/cfcb4b461d|forum post cfcb4b461d].

FossilOrigin-Name: 600f1991e5c0a5d89cd8776a157b6fd72c7489791085876925e8dd7ab146fe1f
2021-08-21 16:42:58 +00:00
drh
faf9c77b4b Improved error messages for the SQLITE_CONSTRAINT_DATATYPE error.
FossilOrigin-Name: 39abca01479c0f4f747b7b21fa05181896b00ed7559f0ab74aa575c23097ac21
2021-08-20 08:05:42 +00:00
drh
9e1209d111 Enhance PRAGMA integrity_check so that it verifies the datatype of
all columns in STRICT tables.

FossilOrigin-Name: 97c9248b3b81facce569bfa3fb405d44a1d1041e87132e8f649458c95620ccb2
2021-08-19 02:58:15 +00:00
drh
ab16578b72 STRICT tables require all fields of the PRIMARY KEY to be NOT NULL.
FossilOrigin-Name: 5efdf9acad9d54783f5134b7e9338f44336862d87dc324d315b8d55e44df1923
2021-08-19 00:24:43 +00:00
drh
3b7a0ccd5c Merge the WITHOUT ROWID, NOT NULL ON CONFLICT bug fix into the strict-tables
branch.

FossilOrigin-Name: 7ee01ee47da247a80bcf16f88eb187b8c0928024536435ed20797a1a90495511
2021-08-18 23:00:43 +00:00
drh
fd46ec6476 Fix ON CONFLICT clause processing for NOT NULL constraints of PRIMARY KEY
columns on WITHOUT ROWID tables.
Ticket [f2be158c57aaa8c6]

FossilOrigin-Name: 13abba0941a724eb62455650976b03678e4455b6b3090c84a2ab2f4a7656b4d8
2021-08-18 22:26:51 +00:00
drh
72532f52bc Trying to insert an incorrect datatype into a STRICT table raises an
SQLITE_CONSTRAINT_DATATYPE error.  Seems to work, though lots more testing
is needed.

FossilOrigin-Name: a19305e5cfedf5c472200d6e05c1396443e348f052a40a0979f860f2ff06851d
2021-08-18 19:22:27 +00:00
drh
44183f83d0 What would it be like if you could add the keyword "STRICT" after a CREATE
TABLE statement to cause the table to (1) allow only a few well-defined
datatypes, (2) rigidly enforce those types, (3) require NOT NULL on PK
columns, (4) always enforce foreign key constraint, and so forth?  This
branch seeks to explore that question.

FossilOrigin-Name: 78732b9f98936693ae29c85a692c35a84c7d065aec79903af34b08d18f10a5e6
2021-08-18 13:13:58 +00:00
dan
0546027cd7 By default, do not use memory mapping to access the temporary files used for external sorts. The old behaviour (to use memory mapping by default) may be restored by building with SQLITE_ENABLE_SORTER_MMAP defined.
FossilOrigin-Name: 306694dfb462f9d1f128461e7a8f15a0bb9b21fbc696caa1832f4b20749490d1
2021-08-12 14:22:30 +00:00
drh
df67ec08ff Do not apply the push-down optimization to CTE subqueries that will be
reused in other contexts in where the same optimization is unlikely to
be valid.  Fix for the bug reported by
[forum:/forumpost/d496c3d29bc93736|forum post d496c3d29bc93736].

FossilOrigin-Name: a7ce29a6ef2e0362bbc9b23719d936dce07209b2651153c774682f599bbd888e
2021-08-11 13:48:56 +00:00
drh
c2df4d6adb Recognize certain standard datatypes ("INT", "INTEGER", "REAL", "TEXT", and
"BLOB") and if a column has one of those datatypes, store the type part of
the bit-field information in the Column structure to save space.

FossilOrigin-Name: d2da62a9df63036b02dadca3798de9e623c2680b3ef0c37d2b18bb88693afd7f
2021-07-30 23:30:30 +00:00
drh
e48f261ebf If a generated column uses the optional keywords GENERATE ALWAYS, try to avoid
putting those keywords in the typename of the column.
[forum:/forumpost/ff3ffe09251c105b|Forum post ff3ffe09251c105b]

FossilOrigin-Name: 3c954863f45271a3518acf51fd685a641878811fb5cfcbdbad85154aeccdc902
2021-07-30 20:09:08 +00:00
larrybr
1ae057d873 Remove sqldiff --visible-controls option, make it always happen. Add test cases for controls made visible
FossilOrigin-Name: ff74c0cc4cefa5271b12ecfff3f2fd4749852d9d1d01f4ae64a07a26decc001b
2021-07-26 19:49:01 +00:00
drh
55b8b73e74 Fix ALTER TABLE DROP COLUMN so that it generates valid bytecode even when
operating on a corrupt database and using PRAGMA writable_schema=ON.
dbsqlfuzz 5f09e7bcc78b4954d06bf9f2400d7715f48d1fef

FossilOrigin-Name: b65f4f763979ee9e0b943c787609ea22d6f7e01d41dfc1e084ec50a085a3550c
2021-07-22 18:22:51 +00:00
drh
348e002ec9 One of the optimizations of check-in [de9c86c9e4cdb34f] does not work for
terms originating in the ON/USING clause, as demonstrated by
[forum:/forumpost/6cf3bb457c3f4685|forum post 6cf3bb457c3f4685].  This
check-in disables that optimization for ON/USING terms.  Also improve the
TreeView display for the resulting "true"/"false" nodes to show that they
originate from the ON/USING clause.  Add a testcase() to the other optimization
to show that it can still be used for ON/USING terms.

FossilOrigin-Name: 1f6796044008e6f3a61bcf390c0c7eb31947e971f0edada74e7a3a211f8ae76a
2021-07-22 16:07:01 +00:00
drh
74e5a5a703 Run a "PRAGMA quick_check", if necessary, on the modified table after
an ALTER TABLE ADD COLUMN to verify that added NOT NULL or CHECK constraints
are satisfied by existing rows.  Abort the ADD COLUMN if not.
[forum:/forumpost/c04814903d6ec4f7|Forum post c04814903d6ec4f7].

FossilOrigin-Name: e3794997c34f03db2a4ac0ca5b76727d0e031778d92b08eaaf9631689ec3e56d
2021-07-20 16:07:15 +00:00
dan
d59f983501 Avoid a malfunction that could occur if the same correlated column reference appears in both the GROUP BY and the HAVING clause of a sub-select. dbsqlfuzz a779227f721a834df95f4f42d0c31550a1f8b8a2.
FossilOrigin-Name: 1e35cc6d5c2f563c6bb163bb150d7bc6ede4c993efa828af1face3261bf65a2c
2021-07-20 14:57:49 +00:00
drh
0f91a5352b Fix issues in the new ADD COLUMN constraint checking. Add preliminary
test cases.

FossilOrigin-Name: 48434ad3fa9504c063d812d119bc8f622548fd02b3d478ff247b11474c4ce5db
2021-07-20 08:23:54 +00:00
drh
53fa02507b It does not work to deserialized into TEMP, so do not allow it. The
sqlite3_deserialize() routine now returns SQLITE_ERROR if you try.

FossilOrigin-Name: 18068cc60698d4944a9d682cdf34b14b4d4b32f043f8d584dbf41c2bb5ac6220
2021-07-20 02:02:24 +00:00
mistachkin
f5b70d06ea Fix compilation of 'threadtest3' for some older versions of MSVC.
FossilOrigin-Name: b5ede6a68891820bd5b6d051b1b641bc1cd49104cad2466db184134d14f58f5b
2021-07-20 00:18:22 +00:00
drh
de3246176b More precision in comparing integers and floating point values while
processing the integer primary key for OP_SeekGE and similar.
[forum:/forumpost/2bdb86a068|Forum post 2bdb86a068].

FossilOrigin-Name: f9c6426de3b413ff8fcf04a00931ca5f123f996c572b35181af114afa8d811d7
2021-07-19 20:52:31 +00:00
dan
bb2d2a50f9 Updates so that "threadtest3[.exe]" can be built for windows with MSVC.
FossilOrigin-Name: 4ce585fb07274284e3add6adcb66ed06e4b109584704d1ec7152bf43ca8d5d85
2021-07-19 16:49:13 +00:00
drh
e46ec734c7 Modify the generate_series() table-valued functions so that its first
argument (the START value) is required.  Throw an error if that argument
is not supplied.  In this was the series.c loadable extension can be used
as a demonstration of how to code an xBestIndex function to require certain
parameters.  Compile with -DZERO_ARGUMENT_GENERATE_SERIES to obtain the
legacy behavior.

FossilOrigin-Name: 459d85a2898d6a53f43b4ad48d2f39edd1bbe37a4f97426a5d666c39c52576a4
2021-07-16 17:04:17 +00:00
dan
20235e56f7 Fix a use-after-free error in ioerr.test caused by an error in test code.
FossilOrigin-Name: 1594056aab068b9fae82f6b885828c7127d9bedcc37c4340486e32791bc87c7a
2021-07-14 21:18:31 +00:00
dan
8eed584786 Fix an assert() that might fail if sqlite3_create_function_v2() is invoked with NULL xStep and xFinal callbacks and a non-NULL xDestroy.
FossilOrigin-Name: ab1550a608684b6b9104b555a975482cfabca5053b7d7dcc60d63a0e3a8d707d
2021-07-09 14:59:12 +00:00
dan
bd24e8faa3 Preserve and return to the user any error message returned by a failed xConnect() call on an eponymous virtual table that prevents a query from being compiled.
FossilOrigin-Name: bbbbeb59a6a14b94dcbaf218cbcfbd39feba4a1df5b37c0e1a955391393eeec4
2021-07-08 18:29:25 +00:00
drh
9d41caf361 Fix a harmless compiler warning in the "fuzzcheck" test program.
FossilOrigin-Name: 8c432642572c8c4b7251f413def0725b3b8e9e7fe10230aa0aabe86b58e5902d
2021-07-07 19:44:32 +00:00
drh
4f16ff9d06 Follow-up to [68db1ff9c44fa9c3]: The number of registers needed by
PRAGMA foreign_key_check was increased too late for an assert() deep
down inside of sqlite3ExprCode().  So move the size increase a little
earlier.
[forum:/forumpost/79c9e4797d|Forum post 79c9e4797d].

FossilOrigin-Name: 7072404ad0267b8ee774b2804ea59ea28e29316521d76d76a701595e51d1be97
2021-07-07 16:48:24 +00:00
dan
74777f994d Improve the error message in cases where there is a row-value on the LHS of an IN() operator, the RHS is a list (not a sub-select) and at least one element of the list is not a row-value with the correct number of elements.
FossilOrigin-Name: 6b22f4e71dbc14c887ebbda67095b5faaa8079cac87cd4ab5a2ae90c71cd9633
2021-07-07 13:53:55 +00:00
dan
9289f5103d Handle "<vector> IN (<vector>, <vector> ...)" in the same way as "<vector> IN (VALUES(<vector>, <vector>, ...)".
FossilOrigin-Name: 981d230ece98ce89502dab02aa44f73699a9d0e4fce3e9e9dfd47444a5a9990f
2021-07-06 20:44:32 +00:00
dan
5daf69e5f4 Allow sub-queries in the FROM clause of an UPDATE...FROM statement to access the object being updated without using an alias, as is required in the parent query.
FossilOrigin-Name: 740cb43025449b7d7b47a97ad00885e54b7701cbcb14f4a50c7523022e3936d5
2021-07-05 11:27:13 +00:00