Commit Graph

8297 Commits

Author SHA1 Message Date
dan
4df68e0ae5 Update an allocation routine in the sessions module to allow it to allocate the maximum size permitted by sqlite3_realloc64().
FossilOrigin-Name: 0b45e821911e4a852edd6d9e9cfe5f9de33337edf76fb12b79adaf11a4b83e8a
2021-05-25 15:21:54 +00:00
dan
c00727ab58 Fix a problem in the in-memory journal code that could occasionally lead to a segfault when a sub-transaction that modified zero pages was committed.
FossilOrigin-Name: 17960165f5840cab45b7a8bb02779ebfb321c68f33ec6da9ab14063ccd134fa4
2021-05-24 14:35:19 +00:00
drh
0fcf6f01e7 Minor comment improvements in fuzzcheck.c.
FossilOrigin-Name: 7aca8d52c16c2192d9c1ff03a976c482a60365cef8d2474b540ff4c84e8737b4
2021-05-24 12:28:13 +00:00
drh
b6b06bb339 New dbsqlfuzz cases added to test/fuzzdata8.db.
FossilOrigin-Name: 5bb5c9ec049488f95e47bbd9f1db9038ffabad3cfafa613acdaa790ab4034eee
2021-05-24 12:13:10 +00:00
drh
0542812726 Additional defenses (above and beyond [b986600520696b0c]) to prevent an
invalid subquery from causing problems downstream.  If an error is found
while analyzing a subquery expression, change the expression to TK_ERROR
so inhibit further processing on that expression.
dbsqlfuzz cf624b8c0484c66e0f552bf6475e3e3f2c22b24e.

FossilOrigin-Name: 0be6b6c9f7c562e764792a4a5eb53ed11b230174b19361f7cd7778c743314bbd
2021-05-24 00:17:04 +00:00
drh
7cc73b399e Do not push a WITH clause onto the processing stack if prior errors have
occurred.  dbsqlfuzz 6b7a144674e215f06ddfeb9042c873d9ee956ac0.

FossilOrigin-Name: c2066dde53b9872dbb991e27419dd031791c942fe23826556f52efbd66c51662
2021-05-23 17:47:04 +00:00
drh
5e1a7ded4d Do not invoke sqlite3ExprAffinity() after a syntax error that might have
left the tree in an inconsistent state.  See also [e8a1515b44380cc5] and
[forum:/forumpost/7e484e225c|forum post 7e484e225c].

FossilOrigin-Name: b986600520696b0c91c4ccc6aff1b698391b4bcaf8a3ea436be1967883faa2fe
2021-05-22 11:23:20 +00:00
drh
93c8139c1a If there are errors in a nested CTE, be sure to abandon processing. Do not
continue since the parse tree may have been left in a goofy state which could
cause use-after-free and segfaults.
See [forum:/forumpost/aa4a7a3980|forum post aa4a7a3980] for an example.

FossilOrigin-Name: 94225d693932eb0b5d7799d40513afbd31ed40e1e156675eb92ad7216f1ff20f
2021-05-21 21:49:07 +00:00
drh
ec2f689b21 Fix a faulty assert() statement in sqlite3ExprListDup(). This is a continuation
of the fix at [59812e7ef705226c].

FossilOrigin-Name: 240f7494bfa3e0806ae2f971e78039c62a419de647cb9e807309f90e1d2a536d
2021-05-20 23:25:28 +00:00
drh
a76b7f5296 Enhance one test case to use various alternative definitions of DUAL.
FossilOrigin-Name: 179dcb6ba771f0e94e06b5e3c5534d8005d27b2c9b4601be20fd68abfbc5dfd0
2021-05-20 18:11:45 +00:00
dan
90bc36fb30 Ensure that objects within view definitions are not incorrectly resolved to CTEs that are part of the statement using the view.
FossilOrigin-Name: f7dcc4b5197c6413be31384b390bb98a737d3f9edb7964433448c3b90b35a436
2021-05-20 17:15:06 +00:00
drh
cd1499f47b Replace [0f0959c6f95046e8] with a new and better solution that also fixes the
CTE name resolution problem described in
[forum:/forumpost/8590e3f6dc|forum post 8590e3f6dc].
Test cases for both problems added.

FossilOrigin-Name: 5614279daff5007d6e047c5c1b3cc82ba80a5c91c529525b0fe68b79ee82dd2c
2021-05-20 00:44:04 +00:00
dan
3d691fd9ff Allow aggregate sub-selects within ORDER BY and PARTITION BY clauses of window frame definitions.
FossilOrigin-Name: 3daab94977af5e8a95690acc555540311403d890a3261a9757c633fcaaf428a9
2021-05-19 14:49:51 +00:00
drh
9088186bfb Improved column name and column type determination for the RETURNING clause.
FossilOrigin-Name: 699c33990a9438f28673ecf34f1e521d1af0b01c6ee30a608c0c91d2d593590e
2021-05-19 12:17:03 +00:00
larrybr
99bd552503 Cure some TCL test failures and narrow an object scope.
FossilOrigin-Name: 1155696c700862de1a8b1318bc41cd5cd01dec1af2c7720d8ef1e5c3321c425d
2021-05-19 02:33:42 +00:00
drh
93ffb50fcd In the MULTI-INDEX OR query plan, code for sub-expressions can sometimes be
generated twice.  But for some subqueries, generating code off of the same
tree twice causes problems.  So now MULTI-INDEX OR makes a copy of the
sub-expressions it uses to avoid code-generating them more than once.
dbsqlfuzz 9ebd2140e7206ff724e665f172faea28af801635.

FossilOrigin-Name: 4a55f72542c8bcc80253aa77043314cecb29d73cb4f51aa80f7811e86cc8ef68
2021-05-18 19:10:10 +00:00
dan
be12083bc7 Fix problems with refering to CTEs from within sub-selects in PARTITION BY or ORDER BY clauses of window frame definitions. Also a problem with renaming a column when the schema contains a trigger containing a correlated sub-select within a window frames PARTITION BY or ORDER BY clause.
FossilOrigin-Name: 4c6cd54a8db78e5535912e76856bed4f797261aaca4248c69d2e2452194de297
2021-05-17 16:20:41 +00:00
drh
ba39ca4058 When deleting an SQL function that does not exist, return without doing
anything at all rather than creating a tombstone function.  In this way,
function deletes that happen inside virtual-table destructors that are run
when a database connection is closing do not create new tombstones in the
function table after the function table has already been purged.
[forum:/forumpost/726219164b|forum post 726219164b].

FossilOrigin-Name: 391c73132c80df944fb49a17d8fe78203c54ac48f968ee9dd9dd8c769c0b4b10
2021-05-17 13:11:24 +00:00
drh
6a9595a76b Avoid adding superfluous virtual WHERE clause terms that might arise due
to the constant propagation optimization.

FossilOrigin-Name: cf63abbe559d04f993f99a37d41ba4a97c0261094f1d4cc05cfa23b1e11731f5
2021-05-14 15:37:00 +00:00
drh
756748ea86 The content columns of the index-btree that implements a WITHOUT ROWID
table are not ordered and so the query planner should not assume they
are ordered.  Fix for the issue identified by
[forum:/forumpost/6c8960f545|forum post 6c8960f545].

FossilOrigin-Name: c21bc5a2353e660f2acf5ed916921a4ee416910d0b3f2deb512a05c54138d1c0
2021-05-13 13:43:40 +00:00
drh
85ffcae177 Add the new threadtest5 test program for stressing multiple database
connections in the same process hammering on a single database.
Primarily designed to test memdb, but works on any database.

FossilOrigin-Name: 8db1c06958b8e1691440d4fd392648b74a1940b721852dabd315005efad520fc
2021-05-12 14:17:20 +00:00
drh
8d889afc0d Enable the sqlite3_serialize() and sqlite3_deserialize() interfaces by
default.  Omit the SQLITE_ENABLE_DESERIALIZE option and replace it with
the SQLITE_OMIT_DESERIALIZE option.

FossilOrigin-Name: 6df3b03e00b1143be8fed3a39a58ce81063020275aa1ac13d87c84f1ceda6e27
2021-05-08 17:18:23 +00:00
drh
4752bbd872 Detect misuse of aggregate functions in the ORDER BY clause of a query
even if the query also contains window functions.

FossilOrigin-Name: 0d11d777c8d368f0b6e9faf3afccf7da1b041d303a68782e43aebd713aaecf51
2021-05-07 15:46:36 +00:00
drh
67656ac78a When applying the optimization that disables WHERE clause terms that drive
indexes, make sure not to do so if the term being disabled is a transitive
constraint.  Fix for the problem identified by
[forum:forumpost/eb8613976a|forum post eb8613976a].

FossilOrigin-Name: f1f9b5de3c59489b94963685660b3ddc45eece5535b02fec399b6ece0e38563d
2021-05-04 23:21:35 +00:00
drh
433a3e935d Back out the EXISTS-to-IN optimization. It slows things down rather than
speeds them up depending on the query.  And (see
[forum:/forumpost/8692d94725|forum post 8692d94725]) it sometimes results in
an incorrect answer.  We may come back and revisit this optimization later,
but for now it seems best just to disable it.

FossilOrigin-Name: 16252d73fa73569fd7506676f6ffbbcd43addfb105384fb74449d30ca720904a
2021-05-04 12:07:16 +00:00
drh
736d11ed21 Back out the NEVER() inserted by [c7309ed3c7588c7e] because it is reachable
after all.  dbsqlfuzz bc17a306a09329bba0ecc61547077f6178bcf321

FossilOrigin-Name: 20a4f3f12cdd8823d53d91025fa41e284c9f629b1d049eb486ff8dc4a1736e1f
2021-05-01 12:09:36 +00:00
drh
5960724789 Fix the operation of the "-" argument to --load-dbsql in the fuzzcheck program.
FossilOrigin-Name: 1f18b3cbee7e1342fdd66e45ef744fea3db2ba4513943c0582ff8ef98974865e
2021-04-29 18:03:42 +00:00
drh
81f5ef05a9 Fix the IN-early-out optimization so that it works even for the corner case
where the NULL bypass fires before the affinity of the LHS operator has been
set.  Fix for the problem described in
[forum:/forumpost/6a3ec138e9|forum post 6a3ec138e9].

FossilOrigin-Name: eb40248ce606b792a02e4e0b7dd826a82891c5f4c9793f3ca5d332e593109525
2021-04-29 15:49:34 +00:00
drh
5e26d07d62 Update test/fuzzdata8.db with recent dbsqlfuzz finds.
FossilOrigin-Name: bce2ea393a872b5b70ef3b9cedce3d406725dcc56d8800ee4f7ec29562cc3f9b
2021-04-29 10:48:50 +00:00
drh
3765c03243 Further improvements to the handling of RETURNING clauses on changes
to TEMP tables with triggers.
dbsqlfuzz 683913e98f54fe4f14e8dd11a48011f73bdca58d

FossilOrigin-Name: ff3538ae37a02f4f36a15cddd1245171e724aac9c84b2e576980fd3806302775
2021-04-27 17:18:10 +00:00
drh
a476768340 RETURNING bug fix: Correctly deal with RETURNING statements on changes to
TEMP tables that also have triggers.
dbsqlfuzz 78b9400770ef8cc7d9427dfba26f4fcf46ea7dc2

FossilOrigin-Name: d0b15eccbfe1e50c3daf7b2fd4769a52bba35d553b07e462ca3f5f22df6742fd
2021-04-27 13:04:18 +00:00
drh
d8bc250b91 New dbsqlfuzz cases added to test/fuzzdata8.db.
FossilOrigin-Name: 88d20500c516fe89ad1cd42f7366ca190c3790f911f11ab332b86b675f5f69ba
2021-04-26 22:30:49 +00:00
drh
c7f5077e88 Fix the [/info/df1d6482f9e92daf|UNION ALL flattener optimization] so that it
works better with recursive CTEs.
dbsqlfuzz 88ed5c66789fced139d148aed823cba7c0926dd7

FossilOrigin-Name: f80d7bb2c305c1dd4658767660b33259032c048a91f18c654a6bda7332c54a0c
2021-04-26 21:23:01 +00:00
larrybr
ada2323d95 refix altertab.test
FossilOrigin-Name: db032156932fb0dcae5ffb7cbdfb711079daa595713fcb254f09f8ef90c81d95
2021-04-26 20:18:08 +00:00
drh
8ed8ddf759 When doing the optimization that attempts to avoid sorting on a
GROUP BY, do not assume that the values in an index on an expression are
non-NULL.  Bug discovered by Wang Ke's fuzzer and reported at
[forum:/forumpost/74330094d8|forum post 74330094d8].

FossilOrigin-Name: 7178dc3a32c3a4a33e437fd5026f6f72e4809ceb7d2cd12a25a74b80d5c95d33
2021-04-26 14:32:48 +00:00
dan
bb0eec438d Do not initialize eponymous virtual tables when parsing the schema. This can happen if the db is corrupt.
FossilOrigin-Name: cb8c41aa20bb351c4c712ed7a3617187ceeb0905ede1e6f561bc1d89f31c95ea
2021-04-26 14:09:48 +00:00
larrybr
3ff6a5edd9 Skip test when no JSON.
FossilOrigin-Name: 6fcb2438f88a70ed67e19103bfa263a6c98b06962207f153559c9516d8c7b5d5
2021-04-25 23:13:04 +00:00
drh
113a33c539 Make window range queries more robust against corrupt database files.
dbsqlfuzz f22df3a7b2aab0937a415484514fc2f68a293c99.

FossilOrigin-Name: 506333742103c1f440db5da819a36f3b518f7b49e94a7b74419b02bbcadc5a78
2021-04-24 23:40:05 +00:00
drh
971ae9f66a Fix testcase altertab-25.1 due to check-in [c7909e8e0d0577c6] disallowing
ALTER TABLE on eponymous virtual tables.

FossilOrigin-Name: 32255e39cbde65492d88177464cee9e10cb20cf3105208416be131e2c89b63e1
2021-04-24 12:20:10 +00:00
drh
1521270010 Fix harmless compiler warnings in fuzzcheck.
FossilOrigin-Name: e7b4ffecc610c494ebd506977402ec48cc799780f96c6293c0ccf27697160aa1
2021-04-23 13:57:53 +00:00
drh
ba6619d7be Enhance the --load-dbsql and related options of fuzzcheck so that if the
argument is a single - then filenames are read from standard input.

FossilOrigin-Name: e1548802b6de7037baf388d27a7f3658abafe07b6f48d5ec97e5f644303592d8
2021-04-23 12:58:16 +00:00
drh
292ed6decf Give a better final output line for the --spinner option on fuzzcheck.
FossilOrigin-Name: 93729614e21ee674b83b0d2babb71bb758f1a2ec55bf9bda057fb7739f2e14e0
2021-04-23 12:16:16 +00:00
drh
d84f10ed13 New dbsqlfuzz cases added to test/fuzzdata8.db.
FossilOrigin-Name: 8da88508932e475c8c6af1553268ff02e3e013b78ccc94b14532ec928fc62537
2021-04-23 11:50:23 +00:00
dan
f3d5a68461 Fix an assert() in fts5_index.c that may fail if the database records are corrupt.
FossilOrigin-Name: dfadb96edfef1d49e48a659264b9eb8d7f98d95d159d95c92c30dd4ba6c6e739
2021-04-23 11:37:01 +00:00
drh
3d8c92d041 Raise an error on an attempt to rename an eponymous virtual table.
FossilOrigin-Name: c7909e8e0d0577c6109f13c0b14fb565239aae8af8963d659f363e124f3437fc
2021-04-22 18:02:48 +00:00
drh
68b63c0195 Fix the date/time translation logic in the zipfile extension so that it
works with boundary cases. See
[forum:/forumpost/d82289d69f|forum post d82289d69f] for the trouble report.

FossilOrigin-Name: c8de5f061359c174e143e5e81ade8aa9b7d71ba57287459cf0f4f2c94459c345
2021-04-22 14:43:16 +00:00
drh
7437c25b63 Add recent dbsqlfuzz test cases to test/fuzzdata8.db.
FossilOrigin-Name: 6fe50dcc239d2d1fc2a38aa705f4c75cbe26b3e48d098537306d96d6a4005659
2021-04-21 12:03:36 +00:00
dan
fe599b05f2 Fix a problem allowing SQL variables to be used expressions within the second and subsequent ON CONFLICT clauses of an UPSERT within a trigger.
FossilOrigin-Name: 2a28910a17dc5b3ce43062fdf879f9622f6ec2db19ed780fa7fe5cae781be7b7
2021-04-21 11:32:22 +00:00
dan
5b482a9832 Update an assert() in btree.c that may fail with a corrupt database.
FossilOrigin-Name: d74bf88c5a027cf080a2892a3538fe5104952b5b3759a6eba1b1a98a75ddf5f4
2021-04-20 13:31:51 +00:00
dan
0a746cc528 Ensure that all records are updated by setting the OPFLAG_SAVEPOSITION flag when updating records as part of ALTER TABLE DROP COLUMN.
FossilOrigin-Name: 354a4db5cb769c6aed386f43ee26d7e42342e92f781eef100c09751dc5b51751
2021-04-18 05:30:39 +00:00