Commit Graph

23382 Commits

Author SHA1 Message Date
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
6bcaba70ac Have the dbstat virtual table take a copy of each page buffer that it traverses instead of just a reference to the page-cache object. This avoids problems if an error causes transaction rollback while a dbstat cursor is open. dbsqlfuzz crash-417224040fee04f0f0e62b70265c518893b08769.
FossilOrigin-Name: 6ab25f8bd52d6412a9600143de364f6d8ad8e2c835315fafca6f54d5f38a49dc
2021-09-27 17:11:20 +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
4b67c655af Fix a memory leak in rtree triggered by corrupt database records. dbsqlfuzz 397ad036a9013d7318da30ef84947d2baaaa6d6c.
FossilOrigin-Name: 706322c2b5bb31e14c1120a94520b21fa623ff119e3890170e36b37d8bde721a
2021-09-25 20:19:16 +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
1580d50b76 Add const to parameters on various internal interfaces.
FossilOrigin-Name: 70c221c5cf7b4d9ed34f16d045f262f99d16aa3db84f80cf0b03ee82ba28d075
2021-09-25 17:07:57 +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
b6dad520e5 Add lots of new "const" on internal function parameters. There is opportunity
for many more - this is a work in progress.

FossilOrigin-Name: a3c71a673ddd1c299bdae550fb955077b77088329a8ca2895dfb23538b524a8e
2021-09-24 16:14:47 +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
dd31c033c6 Fix harmless compiler warnings.
FossilOrigin-Name: d678ecca02698753d1b33e072566112e94ea36d0d3a8f4a24d2b09d131968d88
2021-09-22 14:43:35 +00:00
drh
68911c2a2a For shell.c.in, define CHAR_BITS to 8 on platforms that do not have that
value set by default.  This fixes the build on older machines.

FossilOrigin-Name: 96610cc8251ad4ff8d7f0536f20f4572a996bfa8d24bec8a7925a333e507da1e
2021-09-22 14:26:22 +00:00
drh
fd7abcd15b Fix harmless compiler warnings in shell.c.in, and a compiler warning in
sqlite3expert.c which is a real error, though also harmless.

FossilOrigin-Name: 56da0e9c0321d1fd3c360722cd6284296f9ba459f6b37ab35c81ecabd18f12e3
2021-09-22 13:43:16 +00:00
drh
c2f61c18d1 Fix an incorrect assert() in rtree that was added recently
by [f7ad73c49507c943].  Change it to testcase().

FossilOrigin-Name: 3aa0bf3a098ee9a62c79f266f94e4d290056d0f3e91237944893d6bbb686861f
2021-09-22 13:07:10 +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
drh
6d9f034ba8 Use sqlite3_snprintf() for the ".changes" output formatting in the shell
because it now uses %lld, and some older C compilers do not understand that
construct.

FossilOrigin-Name: 53dadf80672a4fe05341fe40873b6cfa73f6bc1e07cc41fcf10fe290c9156363
2021-09-22 10:28:50 +00:00
larrybr
b565bee66b Fix .expert name collision bug reported at https://sqlite.org/forum/forumpost/05e6f32984561f57?t=h
FossilOrigin-Name: 4a3f98ad0dd2a8c0370042611a041bed2bd8d9ca82d6706e2db349eb97aaf1f0
2021-09-21 20:03:05 +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
b3e4423137 Accomplish fileio standalone for Win32 with less intervention.
FossilOrigin-Name: af5dcc9c2a3a45d10b985f6b7ea18d39c75502ed10fa6496aad787dbe8c8c3fb
2021-09-20 21:42:39 +00:00
larrybr
3d99743423 Allow fileio extension to be a stand-alone DLL for Win32
FossilOrigin-Name: d1cc3105b2baceb9f426fd6bc8d8317de3af09a0f02517715bd292c68e282fa1
2021-09-20 20:15:28 +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
5488e0827a Further tests for legacy rtree geom callbacks.
FossilOrigin-Name: 99d6bb22e8735681443bfe67287aa15ce2c57d0d63e304abf8aa01fde50dd021
2021-09-18 16:15:54 +00:00
larrybr
d96bcc75e8 Shell's .read pipe now works for Windows too.
FossilOrigin-Name: 929bcc4098549692c573779d65c4c28027b0a2f48ebbf5b3f038deee24374b67
2021-09-17 21:12:47 +00:00
dan
01ed72f2c5 Add tests for legacy geometry callbacks to rtreedoc2.test.
FossilOrigin-Name: 6ad00e52eda5bc4cb8e6fffbd7538bcd4c6b22f84b837a746eba6bf8c91eb55a
2021-09-17 20:43:27 +00:00
drh
3780f9a4aa Make the affinity() function available even if compiled without
SQLITE_DEBUG.  Surround the implementation of all test-only SQL functions
with #ifndef SQLITE_UNTESTABLE.

FossilOrigin-Name: b7e00ef8059f6fb5658c6ad6f337cfdf065a5f1b1130452122282f3a69e98a93
2021-09-17 13:07:15 +00:00
drh
89b1715415 The dbsqlfuzz fuzzer found a refutation for a recent ALWAYS() macro.
FossilOrigin-Name: ebfc18aaa6506ccac80f297a1792e726972bb39c0b5c8706faadeb8df94a45e9
2021-09-16 22:23:36 +00:00
drh
8e4616c280 Minor changes to rtree.c so that we can get full branch coverage even when
it is compiled without geopoly.

FossilOrigin-Name: f05ae9b5864459493154037d2c902d203c4a43007b5d61bd4beb1eed56e06d13
2021-09-16 20:16:39 +00:00
dan
72fb42d570 Add tests to rtreedoc.test.
FossilOrigin-Name: b18c6ec46079520e0db8b42586ce9370a4038d0b4f719cfb98488037883e2537
2021-09-16 19:50:54 +00:00
drh
051c9ba1be Add a single new ALWAYS() to rtree.c, with justification.
FossilOrigin-Name: 778e4499cdf2083d5431738099dedf0aade9271f661e09ca3278e0109bb1e720
2021-09-16 17:02:59 +00:00
drh
495f78d851 Add a tag comment in rtree.c. No changes to code.
FossilOrigin-Name: 213410fa9cceb4ce34bf590ba65648ebeb94cc8d0c29a8881222208097162a95
2021-09-16 16:41:59 +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
eb56e29053 Mark an unreachable branch in rtree.
FossilOrigin-Name: e6c4afd5b365b8dea8c0742352a09029da0f9715dd2407d4ccf53f1e0a4ce625
2021-09-16 14:07:09 +00:00
drh
86b262ecfa Back out a couple of ALWAYS() macros from [4fab9089868bbb05]. Test case
added to TH3.

FossilOrigin-Name: d26963a530ccbe36a174823d2f0bd7e06c6fca4f38ecdd04cd700c4000cc3719
2021-09-16 13:52:28 +00:00
drh
e73e957c1e For ALTER TABLE RENAME COLUMN, do not try to filter virtual tables out of
calls to sqlite_rename_column().  Let the function filter them itself.
The WHERE clause can mistakenly let virtual tables through if the
sqlite_schema table is corrupt.  The sqlite_rename_column() function must
deal with them.  We might as well let it deal with them always.

FossilOrigin-Name: 7c82b43b7cdb825f431d3a778f8b34e32666ccb3b067f1f2533d3b3dcca7bdc9
2021-09-16 13:20:29 +00:00
drh
11eb9c6a28 Under SQLITE_DEBUG with PRAGMA vdbe_trace=ON, show an output line if the
VDBE aborts for any reason.

FossilOrigin-Name: 7e3d6810039ca4563aa68dfa3671f570792a10f75c8eea68aa7dfd02d17702ca
2021-09-16 12:33:53 +00:00
drh
162f153579 Simplify the routine that attempts to estimate the size of an rtree index
by looking at the sqlite_stat1 entry for the %_rowid table.

FossilOrigin-Name: 06c329c17c2c2de8bc1ca7f3b0b929055675761a8be7a7e8b4a9fc5cca0d1679
2021-09-16 07:32:24 +00:00
drh
36784e0fb1 Mark various unreachable branches in rtree.c with ALWAYS() or NEVER().
FossilOrigin-Name: 4fab9089868bbb05a192da09bc201f0a84c5b9bef39dcb063afc1d7658299fdd
2021-09-16 05:39:07 +00:00
drh
c464ec6710 New ALWAYS() and assert() to mark unreachable branches in rtree.c.
FossilOrigin-Name: f7ad73c49507c9436adc7fe1b865f801eefcc7ea6b3ba35e83e63029beb03016
2021-09-16 05:24:40 +00:00
drh
5f9c7ba9d8 In rtree.c, remove an incorrect ALWAYS(). Add other ALWAYS() and NEVER().
FossilOrigin-Name: cbaac8878aac0623beb5af3bc79a5b1c0179213206fd658b8c4fcc3531889480
2021-09-15 19:53:22 +00:00
drh
750f2331c4 Add more ALWAYS() macros on unreachable branches in rtree.c
FossilOrigin-Name: fbba89dac9591c56da81bd0808910fbc64640f3ccfd95845ecab4d3aea46ca61
2021-09-15 19:13:24 +00:00
drh
8038cb99b0 Fix the xBestIndex method on rtree so that it correctly recognizes that
rowid=? works the same as id=?.

FossilOrigin-Name: c74c07cc86443057d34284ae31eb68470741592b0e61072fd5e120e82919169b
2021-09-15 16:20:15 +00:00
drh
04bd2c837b Add ALWAYS() macros on some unreachable branches in rtree.
FossilOrigin-Name: 9123f680ae3100f4c781ac4f5b8afac49bb5d4231b5931ad112b1b615f22f613
2021-09-15 15:56:00 +00:00
dan
f02c324bc1 Further updates to rtreedoc.test.
FossilOrigin-Name: e66727837ddd5d1344c252323d52600b6138f5a2471f63d09b5a28ea2c22e595
2021-09-15 15:53:01 +00:00
larrybr
998e910346 Fix non-build for a test configuration
FossilOrigin-Name: c9a4ab059050a83d811149ff196ff16ea9e4c301627482800982b87cd30ddbbc
2021-09-15 14:48:02 +00:00
drh
83569e2e9e Simplify some of the corrupt shadow-table detection logic in rtree.
FossilOrigin-Name: 0c4f37aa475bd4bd17c20c02ab2d9f63d0a6a08b0e2bbfa559f7b972ece6f4fc
2021-09-15 13:09:55 +00:00
larrybr
b01f1389f2 Squelch needless narrowing warning.
FossilOrigin-Name: 5540e6abc1a2a8540113ec9bfebe1fb78d6a044f45396dd1926b65ff17ff236b
2021-09-15 11:15:03 +00:00
dan
5f835b7847 Ensure rtreedoc.test is not run for builds without the rtree extension.
FossilOrigin-Name: 42dff223470e9c096b8486ef232ac41b70d0875d8ae07630bfaaea1515ffa8d0
2021-09-15 10:49:31 +00:00
dan
f159323c42 Add test cases to rtreedoc.test.
FossilOrigin-Name: afe0ec4d589d87a07c0daf3fc4de884b82a8bceed593ba4e44caa1cf033a6715
2021-09-14 20:07:58 +00:00
drh
c0bd26a23a Update requirements marks to reflect recent documentation changes.
FossilOrigin-Name: 08cab8921e670a0d1758b505fe8c7455f6194cec69d1b7b77de91688be1028a6
2021-09-14 18:57:30 +00:00
dan
a2fef2f031 Add test cases to rtreedoc.test.
FossilOrigin-Name: b62de1269f17fcc944ff404a20c4f705ffe99c44d6c54f42c29e69753aac8092
2021-09-14 14:16:36 +00:00
dan
6962d78c4d Minor updates to rtreedoc.test.
FossilOrigin-Name: b22c75e41ded29afd026b32b73b87f6427340a9ac1d46147db8edac20eb7beb5
2021-09-14 11:27:20 +00:00
larrybr
d000785d40 Shell to .read any named character source file/device (again.)
FossilOrigin-Name: c6fe4f8d639db25f0a339f4071f0ae34b90dcfec8dcc2c571f969e2614a38e05
2021-09-13 23:11:46 +00:00
dan
db45212a35 Add test cases to rtreedoc.test.
FossilOrigin-Name: 4ee99d315487a3aa09911191a74c6a12693784c5359243eb1396d8868566e80a
2021-09-13 18:32:02 +00:00
drh
82456a661d Add assert() statements to refute
[forum:/forumpost/9f4e7f58fbb66ddd|forum post 9f4e7f58fbb66ddd].

FossilOrigin-Name: 83a83475c5064ea62016a03e9173ecd2a1fec7f6296f1ee99896fa0a38b4196a
2021-09-13 18:16:15 +00:00
dan
30918bfb0b Add new test file rtreedoc.test.
FossilOrigin-Name: 8c4b1482eeb31856bce20eda1ce74959e19da11962f74d406a608747a92fe429
2021-09-13 16:36:20 +00:00
drh
57dd7e6ad8 Fix an incorrect comment and possible integer overflow in pager
resulting from check-in [23ca23894af352ea].  Problem reported by
[forum:/forumpost/e2ea1a3f61|forum post e2ea1a3f61].  Also change
the datatype of Pager.pageSize to i64 even though page size never
exceeds 65536, in order to help prevent future problems of this kind.

FossilOrigin-Name: f4a552ed9f4ab35520b634954c39748cc7bda535f426280b79da1b99f70599ac
2021-09-13 13:53:13 +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
larrybr
31aa366293 Make replace.tcl useful with TCL 8.4
FossilOrigin-Name: 2dd61dd97b0326b59b0bc3c83b4d4b9acf811c5acae4d1003e7525ba7a26daf5
2021-09-10 22:00:43 +00:00
larrybr
a96bbe9af6 Make CLI prescan handle goofy identifier delimiters too. Streamline code.
FossilOrigin-Name: 968aed690ba7240f8a256f5ba679cc971f432ff9af0ff99744824af79b952545
2021-09-10 19:45:22 +00:00
larrybr
3a9793e40f Fix (luckily harmless) typo in memdb.c per https://sqlite.org/forum/forumpost/15af8872d5999df1
FossilOrigin-Name: d577030cdad165474b082afbe64782e2eb3290331b0e3045b1e85ee6fe011504
2021-09-10 18:35:59 +00:00
larrybr
ae509121d0 When showHeader set at CLI invocation, do not auto-set it later.
FossilOrigin-Name: 733b7d4f95a4e2f0df323974f323c40c2486b188d442e74306a4b580fd8a8bd8
2021-09-10 01:45:20 +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
larrybr
8bc4cbce6b Speed-up CLI's processing for huge block comments, for any content
FossilOrigin-Name: c4568f9f458bad16bd4481f1f6f5e7b6f39f5ccf23f2b05890078577ce2ab9a2
2021-09-10 00:58:46 +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
4c5b7b922c Avoid masking off an OOM fault in rtreecheck().
FossilOrigin-Name: 3ebfe7128a20b270de65ebf4620f62e34ea6cc46b472cc52aed96af504eb9637
2021-09-09 18:06:07 +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
larrybr
31bffb44fa Speedup CLI's gulping of many huge block SQL comments.
FossilOrigin-Name: 729620c5c0c642243be2fdda98f18d04efaf78ce365092e655cf60c9fee0874f
2021-09-08 21:49:03 +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
larrybr
2c09a8ad6f For sqldiff, sqlite_schema comparisons must use compound (synthesized) PK.
FossilOrigin-Name: 5bdd8466129b8e477c8349847f19f2a5adea3f650cca6dbafa3b835e5a538d09
2021-09-07 20:58:49 +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
larrybr
a933ec4c25 Make sqldiff able to compare sqlite_schema tables (for detailed schema differences.)
FossilOrigin-Name: 7ff92da9f183bc24a0d93996df771df7a712df1122ad897cb9143cde7d57ef7d
2021-09-07 19:04:42 +00:00
dan
eb84c6ef35 Fix a memory leak in fts5 that could occur when writing to an fts5 table that is being scanned by an fts5vocab cursor.
FossilOrigin-Name: 1183552de10b64a776874a23be8962c0693e5e0cd1a191ea8fa5d6a02b691e4a
2021-09-07 16:05:48 +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
dan
fb8ca7de0c Fix a use-after-free error that could occur if an fts5 table is written while scanning it using an fts5vocab cursor.
FossilOrigin-Name: e751c2ec786b5c1a1c9640fdc3fde036879a2c32db2bd67fe7c72604780f67b8
2021-09-06 16:15:23 +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
drh
e534c7b97f Restore the use of system isnan() that was removed by
check-in [ea748edecb261f2b].  See
[forum:/forumpost/d7c530ac587f59e6|forum thread d7c530ac587f59e6].

FossilOrigin-Name: b3cfe23bec0b95ca673802526704200e2396df715fdded72aa71addd7f47e0e1
2021-09-06 11:44:19 +00:00
drh
e7e9539d99 Fix an assertion fault in pcache introduced by [4bc93658aa563f2f] and
detected by OSSFuzz.  Test case in TH3.

FossilOrigin-Name: 2262a49467fa56c386080dac3e99a66e16c1700e138dba74db66e7b93ae76bf5
2021-09-03 18:11:12 +00:00
dan
748d8b9cdd Have the planner ensure that if one scan uses a subset of the WHERE clause of another, that scan is estimated to cost less and return fewer rows.
FossilOrigin-Name: c7b34930e27597e7f634ad76be55fc436dcb84ea48d5b41b5d7f3596285dd672
2021-08-31 15:53:58 +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
6d77a2948e Patch lemon to fix "error" token handling, according ot
[forum:/forumpost/e680f42f53090061|forum post e680f42f53090061].

FossilOrigin-Name: 106b5e5355a3836a9756333e6dcbb13f0878a5352dab00973b8f0900879bd724
2021-08-27 11:26:37 +00:00
drh
b97e2ad10a Add the --safe to the CLI. Also the --nonce option and the .nonce command.
FossilOrigin-Name: c76870cb1a8e2e1389ad864c51b9f596dff21df8bb58f438f0a2cacfa63b22a4
2021-08-26 18:31:39 +00:00
drh
5ced0a914e Correctly preserve the collating sequence for a column when changing
its datatype.  Fix for the problem reported by
[forum:/forumpost/e5c76b738e|forum post e5c76b738e].  Test cases
in TH3.

FossilOrigin-Name: c7f0813cabf9d8ab367bead5ba8cf20132b8bb9274d8e47b76ad66a10517dd2a
2021-08-24 17:07:44 +00:00
drh
0ccda5294f Fix a typo in a comment. No changes to code.
FossilOrigin-Name: d953646a63bf96a8e6e57fefaa60ae1487e5e4eb776fb38cd9c4ce002e74d016
2021-08-23 15:56:01 +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
8eaf6c620e Improvement to error handling in Lemon. No impact on SQLite.
[forum:/forumpost/2f468f43cbc48d7f|Forum post 2f468f43cbc48d7f]

FossilOrigin-Name: 18cc2f85744a18b6810d30baebe07a7a1bd332348e13b1a50d779edc616fb0c1
2021-08-20 19:51:22 +00:00
drh
9135c8206e Support for STRICT tables. A table with the STRICT option only allows a few
core datatypes on columns and enforces those types rigidly.  Also, PRIMARY KEY
columns must be NOT NULL.

FossilOrigin-Name: f9c1d3441b87ee296542faa724410d16a348143cba24fe74292eefc48e038a55
2021-08-20 15:44:48 +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
7b4b74acc7 Do not allow the xfer-optimization to move the content of an ordinary
table into a strict table.

FossilOrigin-Name: 1ed1b594d3c03ced68eb2b1285dfd8b9641cda20db1b1b7ae1afee217a3a9fe2
2021-08-20 01:12:39 +00:00
drh
71c770fbda Improved comments. Fewer opcodes for integrity_check on strict tables.
FossilOrigin-Name: 4ee57fb588b41ab76649c605f57c7bcf5b7b638435af458d69f69a8ccbb121e8
2021-08-19 16:29:33 +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
drh
b70f2eabb4 Rename the Column.eType field to Column.eCType - with an extra "C".
FossilOrigin-Name: b9b0dcd5af072c22f2ce71cf9584b5b572fbcfbce6410a7d703b586adb8938ba
2021-08-18 12:05:22 +00:00
drh
d519bbdf5c Fix an off-by-one error in the error-handling logic of the Lemon
parser-generator.  This does not affect SQLite.
[forum:/forumpost/cff80737bf|Forum cff80737bf].

FossilOrigin-Name: 7cca80808cef192fe0479477056a028e230a164fd368e72100def065d424ca2c
2021-08-17 19:59:09 +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
a76b151dab During DELETE, if an index entry is missing, do not raise the
SQLITE_CORRUPT_INDEX error (added by [f339f31f9e9a856b]) if in
"PRAGMA writable_schema=ON" mode.

FossilOrigin-Name: 19e56291a7344c7aa69e2845f11cb865ee10a6b89a00bbe74b3babbeebe0357b
2021-08-11 18:43:54 +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
834c688171 Improved comment on the OP_OpenDup used to get a new cursor for a
reused materialized CTE.

FossilOrigin-Name: b1926cc0ab2b81c7df30c4baa6014efcfddb9631f6e46a55c1cec0113ee1afdc
2021-08-11 13:19:13 +00:00
drh
f9d349a80d Fix a compiler warning in pcache1. Reduce the maximum size of a pcache1
cache to 2147418112 pages.

FossilOrigin-Name: 4bc93658aa563f2fa84f7f85f7f9f336dc80425640140c0fc2aec4a3606fad48
2021-08-09 19:54:27 +00:00
mistachkin
bdf15bbd62 Further improvements to the eOpenState bit values.
FossilOrigin-Name: d44f74f14a387960ce105913526b572f4a3d1935351c6aab10cee85946488a9e
2021-08-09 18:13:38 +00:00
drh
8a72882425 Ensure that the pcache1 cache size does not get so big that it overflows
the integer that is keeping track of the cache size.

FossilOrigin-Name: bf9d70fc2fde06a3f132270a26d4abe321687169066aff26ad9e92757c7f9ee4
2021-08-09 18:07:06 +00:00
drh
9d16fb1c09 Fix harmless compiler warnings and improve the presentation for the new
--threadsafe option to the CLI.

FossilOrigin-Name: 7929dc2f6f304b077c174d41711b49a24120adeb0b29cb6acb4d6a40852d7e00
2021-08-09 17:45:00 +00:00
drh
af6d1afd24 Undocumented "--threadsafe N" option added to the CLI for testing purposes.
One of SQLITE_CONFIG_SINGLETHREAD, _MULTITHREAD, or _SERIALIZED is called
depending on the value of the N integer.

FossilOrigin-Name: 2d8f297c115f378854c1f2198e47ac5af5f222a5de8cc7575c42154094e71b53
2021-08-09 17:37:58 +00:00
drh
c806917441 Improved Hamming bit-distance between the SQLITE_STATE constants.
FossilOrigin-Name: 5100b0456bc91f11e4a0bcf0d426ae4d8328cd9341ee2f9c83d0fa9f73047a83
2021-08-09 17:36:22 +00:00
drh
687d74dfcc Fix comments associated with sqlite3.eOpenState. No logic changes.
FossilOrigin-Name: fd8f498f5d5f7fcb78dd8f6f9323d20b9e2904b249ec735477a0f03cb47b8561
2021-08-09 13:06:59 +00:00
drh
5f9de6ecf4 Refactor sqlite3.magic into sqlite3.eOpenState.
FossilOrigin-Name: e5d6512aa1fa0016a679c6e0cb665a0c67ad16f1daa0c18a96b2ebae1beefd15
2021-08-07 23:16:52 +00:00
dan
b419452c7e Fix an RBU problem with restarting an update after the *-oal file is already larger than 4GiB.
FossilOrigin-Name: 087b8b41c6ed76b55c11315e7e95679d67590be20ae21108b593d00bb7d1c57a
2021-08-06 20:17:39 +00:00
drh
d519c03669 Attempt to fix the showwal.c utility program so that it works on WAL files
larger than 4GiB.

FossilOrigin-Name: 5c0f9ea98a2b944857fe05d53a0143cb827b7d8215c37f33f1bce47ec1189952
2021-08-06 19:38:23 +00:00
drh
15482bc3f3 Fix harmless compiler warnings. Omit redundant copies of os_common.h and
hwtime.h from the amalgamation.

FossilOrigin-Name: 091427007818537bb2f860c42dad867cb19050899186d4d180d195a1c6a98798
2021-08-06 15:26:01 +00:00
drh
65b400931d Store the collating sequence name for each column of a table as an
extension to the column name, for an additional savings in the heap space
needed to hold the schema.

FossilOrigin-Name: 832ac4c1ee384be0de72a4bdd55ed87e0f8294e7df5eefcf6b4942db3d85a69e
2021-08-05 15:27:19 +00:00
drh
324f91a591 Add NEVER() macros on recently introduced unreachable branches.
FossilOrigin-Name: 806939eb5947f9187dc9c4814b26e9f94ec0186596c7be97981dbea7c2169c26
2021-08-04 14:50:23 +00:00
drh
3edc927ecd Always prefer built-in SQL functions over app-defined SQL functions within
sqlite3NestedParse().  Formerly this was the case for a few calls to
sqlite3NestedParse(), but not for all of them.

FossilOrigin-Name: 164662ef01ad45ca570c44631a1117cccce6e34b00dbba7f422c089e8ffaa932
2021-08-04 13:42:12 +00:00
dan
fd779e2fa1 Avoid using LIKE with the target db in RBU. It is possible the user may issue "PRAGMA case_sensitive_like = 1" or override the like() user function, causing RBU to malfunction.
FossilOrigin-Name: 7cbd8cd5aa768a0b72f769fa390fae1158d1dcfac5273b9d0238ecf2f52e273d
2021-08-04 11:29:18 +00:00
drh
7061aa8977 Fix the build for SQLITE_ENABLE_UPDATE_DELETE_LIMIT.
FossilOrigin-Name: 5150d2da06ab3c7e3bea1865413cd21c64d5cefb91d3d874e9dd0bf51aea754b
2021-08-03 23:23:23 +00:00
drh
76f2477531 Improved harmony with the reuse-schema branch.
FossilOrigin-Name: cbc703f70d16de0e93b276528fc761290f30af770ceb4b4d11d6a6e6506ac67c
2021-08-03 18:45:41 +00:00
drh
cf9d36d1b3 Refactor field names in the Column object, zCnName and zCnColl, to make them
unique and thus easier to find amid all the other code.

FossilOrigin-Name: 8b781dcaf68e0cf12a844708c82eee00193e340195cbca915d077e4846983bf3
2021-08-02 18:03:43 +00:00
drh
f38524d20d Refactor the Table object to reduce its memory footprint.
FossilOrigin-Name: bbb6759bcf6e01d36dfc787a82a610d359f50aaeac8104b73883a84906d54e1f
2021-08-02 16:41:57 +00:00
drh
79cf2b7120 Refactor the way that DEFAULT expressions are stored on columns, in order
to save memory in the common case where the column has no DEFAULT clause.

FossilOrigin-Name: 8646547e54211d44c415663c33775c4268550f8332949c4731a4bb6ec9cc663a
2021-07-31 20:30:41 +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
drh
77441faff5 Avoid clownfeet in the names columns when the column names are quoted
in the original CREATE TABLE statement.

FossilOrigin-Name: 980f7292afd45a8e73272e2139b55b99ab86167febec9fd0bf0356e8167b2ee9
2021-07-30 18:39:59 +00:00
drh
7b3c514b53 Reduce clownfooting in the allocation of the Table.aCol array. This reduces
the amount of heap space required to hold large schemas by about 11%.

FossilOrigin-Name: 2941ded0acbdcf914567bf7451cfd9b770269545c20d3fa7107c40492689afad
2021-07-30 12:47:35 +00:00
drh
f873392dde Enhance the wal.c source file with an ASCII-art schematic of the -shm file
header.

FossilOrigin-Name: a6c160e08a61d105f8aab959440ac5ec4f1aaca8f0d393e08e7c2c67815b5bb2
2021-07-29 18:34:35 +00:00
drh
b71959cb4e Improvements to asserts to enforce magic numbers in the wal-index format.
Also improve automatic configure and make builds on legacy PPC iBooks.

FossilOrigin-Name: 87b8d47889f1990442aa90398614656658207085d064381074f72bda9bdcbfa5
2021-07-29 17:31:40 +00:00
drh
5025cb581f Complete warning-free build on old PPC iBook.
FossilOrigin-Name: ef2a0850394b1c6c1fc84b26694a3712ae1e50d52bb78fea2ec40148a7d833de
2021-07-29 17:23:23 +00:00
drh
944d85dfe2 Fix an error in one of the assert() statements added by [23b08fe9db24a953].
FossilOrigin-Name: ad24334bc06dc9ae52825a1873a1eab6c258d77fcc00dec55884ddddecd9932e
2021-07-29 17:01:44 +00:00
drh
20de9f6cb1 Minor tweaks to various TCL build scripts so that they work even for TCL 8.4,
which is obsolete, but is also all that is available for some legacy platforms.

FossilOrigin-Name: 2269ce64f707c4a198fcb9a72933648ea61a80b4251024b8058ff28ad81b4917
2021-07-29 16:49:28 +00:00
drh
fd4c7862ee Improve comments and add new assert() statements in WAL to help document
how everything works.

FossilOrigin-Name: 23b08fe9db24a953cc231b093cf74d140c9965d22964d0401ff8ab3d4ecba443
2021-07-29 16:48:21 +00:00
drh
02a9996e40 Remove ALWAYS() macros that can be true if the internal test function
implies_nonnull_row() is used in the result set of a query and contains
comparison operator against a computed column.
dbsqlfuzz 4c34db5bff6247f33ee49e341a1f3018e72be0a0.

FossilOrigin-Name: 4d1dbfa35c7dc0f09321b2e274a00e506f4ca65322454652d5891d815a6966d3
2021-07-29 00:33:20 +00:00
dan
779e990629 Add test case to ensure that sessions works with DELETE statements that use the truncate optimization (i.e. a DELETE without a WHERE clause).
FossilOrigin-Name: a2fc531177c3a061f2881198bb711d502db7cd831351b6a5dd415936845b6625
2021-07-28 18:13:28 +00:00
drh
c6da6dba69 Fix a harmless uninitialized variable read that occurs after an error
associated with a subquery that uses DISTINCT.  Found by a fuzzer.

FossilOrigin-Name: e9719f975f61c4c9f40ea077b049eed97d0957b925a4b6149d9ee21ce827b6a1
2021-07-28 02:04:58 +00:00
drh
9045e7d696 Reduce the scope of a variable in order to fix a harmless compiler warning
that occurs under -DSQLITE_OMIT_AUTOMATIC_INDEX.

FossilOrigin-Name: 36d5dbbe13562f4ea6435e620d102f8515bd0e6b8e66fd1841062a4e4621e330
2021-07-28 01:22:23 +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
larrybr
e40875d211 Give sqldiff --visible-controls option to deal with non-graphic text content robustly across platforms
FossilOrigin-Name: 68d2373f5d578cf3aff9d1ac4b1ab3ac00b466e94e1eb516523fc7660dfc0549
2021-07-26 18:28:24 +00:00
drh
3740712677 Enhance the CLI with the ".connection" command that can switch between
up to five different database connections.  Used for manual testing of multiple
database connections in the same process.

FossilOrigin-Name: 54eaf076c05887157179459ab39c2556953f6fef9c1b14f17a8aa74087da3023
2021-07-23 18:43:58 +00:00
drh
c0495e8c9c Set the checkSchema flag if a CREATE TABLE parse fails because the table
already exists, to ensure that the table was not previously deleted by
some other connection.

FossilOrigin-Name: 91bcb9621529b58d28e91a2763eb9eef3951400d5eaef105073258f3dd331872
2021-07-22 21:11:06 +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
c8d214711f Improved robustness of cursor renumbering in the UNION ALL flattener
when operating on vector assignments of an UPDATE FROM.
dbsqlfuzz 417d2b053b9b3c9edaf22dd515564f06999e029c

FossilOrigin-Name: 60695359dc5d3bcba68a68e1842c40f4a01650eb5af408e02fb856fd8245e16d
2021-07-21 15:42:05 +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
b4d9b2b537 Demonstration code to show how NOT NULL and CHECK constraints can be
verified after an ALTER TABLE ADD COLUMN.

FossilOrigin-Name: 039f540373b03af9e0c87499e5e0423eb093d1d343829282a5ac1de2d600b881
2021-07-20 07:35:07 +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
dan
73983658c9 In defensive mode, allow statements that write to shadow tables to be prepared from with virtual-table xSync() calls.
FossilOrigin-Name: c8601d83fbecf84ca7991d339449b380deb5a7620dc84756a91c2880f030b423
2021-07-19 14:00:29 +00:00
mistachkin
05de5048b4 Fix minor spacing issues in the MSVC makefile.
FossilOrigin-Name: d78c272b3966cc1b12bc7e83fbe909a3c517d553a942d7f1c07bddf69f2e2164
2021-07-19 03:38:13 +00:00
drh
ef8344c6a5 Try to omit the ORDER BY clause in subqueries if doing so does not change
the result in any way. See
[forum:/forumpost/2d76f2bcf65d256a|Forum post 2d76f2bcf65d256a] for
details and history.

FossilOrigin-Name: 85ddaf1b59a19cbd9efe7724a163b30c14bafabfaf2cfced07b463e76f73e494
2021-07-16 22:43:00 +00:00
drh
ee612e2a5d Minor comment improvements.
FossilOrigin-Name: 6854b5919beefa43da21ba739e82d583183c8cdfe5dd63e27a810ac1ffe2330b
2021-07-16 20:16:19 +00:00
larrybr
d51a2d8b8f De-typo sqlite3_expanded_sql() doc
FossilOrigin-Name: 56b0f5418dad34d1e83d53741916e2a38a5448369031d959b8a44867774be657
2021-07-16 17:11:21 +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
drh
111c3cc9fb Fix the "main.mk" makefile so that "series.c" is a dependency of "shell.c".
FossilOrigin-Name: ff959917918495ef352ce48c240b1de6da162f2a5e76e37dcc53fa50bce27642
2021-07-16 15:30:19 +00:00
drh
0fb78f0cca Get the "omit ORDER BY in FROM-clause subqueries" optimization working for the
core test cases.

FossilOrigin-Name: e31c5888659ffd4c6d8b68627123df3bbb84bb010b7766b0a74877bf3ba1e52b
2021-07-16 01:19:19 +00:00
mistachkin
e13dfe4b19 By default, do not emit #line directives in the amalgamation.
FossilOrigin-Name: bacfa93677fbe014737fab7dbdb4e7a168a310bc5b914b17896ae2a48435c7b1
2021-07-15 23:34:14 +00:00
drh
bb30123178 Attempt to omit ORDER BY clauses from FROM-clause subqueries if those ORDER BY
clauses do not affect the output.  See
[forum:/forumpost/2d76f2bcf65d256a|forum thread 2d76f2bcf65d256a] for
discussion.  This can help the query flattener in
some cases, resulting in faster query plans.  The current implemention does
not always work.

FossilOrigin-Name: ef97c3e7c3ea2cf1a4db6591328fe7ce3f1d189afc2d578159135824ec89e620
2021-07-15 19:29:43 +00:00
drh
480f5e3e6e Change references to the schema table in sqlite3_analyzer to the new
SQLITE_SCHEMA name.

FossilOrigin-Name: 3beb77d6a792d07ca605ec8e5402b8a305860cba4044fcafeed00b9fa862fa16
2021-07-15 16:39:42 +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
mistachkin
acae2b485e Enhance comments pertaining to the interface linkage / calling convention macros.
FossilOrigin-Name: c378e99250fe06fae8ca40c62185b607f004d6806e07dbb9f964dd849b4e55f8
2021-07-13 22:49:02 +00:00
mistachkin
696555d7b5 Further revisions to #line handling for amalgamation builds.
FossilOrigin-Name: 9a84321229ad499ee0f7c85732c2728afb4476c72073a510401a559dda9be38f
2021-07-13 21:59:22 +00:00
larrybr
06a0ea9a68 Get correct #line tags into amalgamation for other builds too.
FossilOrigin-Name: 999eb80018f1bb8a8ad73483610400faf5fb37b1be446ce30edbf7028340f50b
2021-07-13 20:55:26 +00:00
larrybr
09b2196d97 Get #line tags into amalgamation, subject to configure.
FossilOrigin-Name: 5d81b598a7cd2cea2553fdf6ca38d2f65f0f1b2d5a8eea8a01c1800f68aa2422
2021-07-13 11:59:17 +00:00
larrybr
4902235796 Merge from trunk, rename tool option for its effect
FossilOrigin-Name: 9327f73c1b87fb9ca78e261d16b092763f497bb9c6f9784a33eabdc961b06343
2021-07-13 11:55:07 +00:00
dan
f1cacb76b7 Do not attempt to run Tcl sessions tests unless both SQLITE_ENABLE_PREUPDATE_HOOK and SQLITE_ENABLE_SESSIONS are defined.
FossilOrigin-Name: 385db794477e046b5dde726489375786d7565b113084f6e730efb050b08f9a6e
2021-07-13 11:30:46 +00:00
larrybr
4b1c3eb5f9 Amalgamation has #line directives by default. Minor mksqlite3c.tcl changes
FossilOrigin-Name: ba3eff71973064cbc0ddf51aa822a246c162bbb65387e9523692c60e5340acda
2021-07-13 01:45:04 +00:00
larrybr
a73c306065 Clarify comment on sqlite3.h's interface decaration macros.
FossilOrigin-Name: 7cb09aef49c0b98c0c5e332d953a2eeb71ae9e243b1e37ab1c8ed4af15d46f50
2021-07-09 23:12:42 +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
drh
62f560f805 Enhance the sqlite3_create_function() interfaces to assume a value of
SQLITE_UTF8 is presented with a nonsense value for the preferred encoding.
This is undocumented behavior added for robustness.

FossilOrigin-Name: c1bb5cff527af6a97b025d646581c68ac9b56924ae199f86964026a7bc9724fd
2021-07-09 13:52:01 +00:00
dan
f33e7795b3 Add the usual "#ifdef __cplusplus" magic to header file ext/misc/carray.h. Also update carray.h/carray.c to use SQLITE_API in the usual way.
FossilOrigin-Name: 0f97c2a459bfadc2fe19e710e8845039b4434010656d311074b9594b02d0826a
2021-07-09 11:52:53 +00:00
larrybr
a13c0c73c5 Allow CLI shell build to #include same user-specified header as library build.
FossilOrigin-Name: eb8af9a494fb68c0a1c600b3ac71467645b51b296fc6e2116d7d855319d59a59
2021-07-09 00:12:05 +00:00
mistachkin
b523159f40 Rename optional SQLITE_CUSTOM_INC define to SQLITE_CUSTOM_INCLUDE.
FossilOrigin-Name: 060aec37accae858ced5b081a2ff76dccdd8f8bcefc63d1fe2e7478257c69e76
2021-07-08 23:35:20 +00:00
larrybr
f382e1dc59 Allow library build to #include a user-specified header.
FossilOrigin-Name: 71e6490bbe59939cd15f0094e507dd8a2e167fdd8de675c3ebfeaf528a01f87a
2021-07-08 22:12:27 +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
77ea22300b Fix an issue with the SQLite Expert extension when a column has no
collating sequence.
[forum:/forumpost/78165fa250|Forum post 78165fa250].

FossilOrigin-Name: b1e0c22ec981cf5f8a6597abc6711b1a25019dd51de31129fbc504d3dc743bb4
2021-07-08 12:12:39 +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
7098859031 Fix a harmless compiler warning - duplicate local variable named "pRHS".
FossilOrigin-Name: 5bc05faf279e0c98be83cb6d56f669a60ff515c8244fca6280991ed0dc5e7ae7
2021-07-07 19:40:18 +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
2931a66ece Fix a recently introduced segfault that might occur if a sub-select were used as a term on the RHS of an IN(...) operator for which the LHS is a row-value.
FossilOrigin-Name: f586c06a5d03943db32add4d3d058a5aa09c819870b29cd8b54cf69433a8cdb1
2021-07-07 15:52:44 +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
cc516af4cc Instead of disallowing writes to fts5 tables if there are fts5vocab cursors open on them (commit [c49a6ed7]), abort any fts5vocab queries if the on-disk structure of the fts5 table changes.
FossilOrigin-Name: 9dbdc9001e3258e71ca995fbcdebf66ab95890ded87fa7125c6cb4bd43010aaf
2021-07-07 11:51:03 +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
b9324fea07 Do not allow writes to an fts5 table if there are any open fts5vocab cursors.
FossilOrigin-Name: c49a6ed78a917d4972e048e2a9bbe4d400691f97ce7e022f0e4436ceaed7fb73
2021-07-05 19:01:09 +00:00
drh
a612c1c9bc Add the ATOMIC_INTRINSICS compile-time output output. Move sqlite3Int.h
in front of ctime.c so that default values that are not overridden are
shown in PRAGMA compile-time option output.

FossilOrigin-Name: e306952690bfb140e2c404a74b05ff2d070c487f7e52c62d62a004505fba0e15
2021-07-05 18:37:37 +00:00
dan
0f56f891dd Revert [5204c2c4a7b73a64], restoring the old pre-processor logic for determining the availability of the __atomic_store_n()/__atomic_load_n() primitives.
FossilOrigin-Name: e690abb9e4e189c41182ac813115d55d811135013f5ce94ec0c45a547597f8ad
2021-07-05 17:15:38 +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
drh
e46292a920 Improved rebustness in sqlite3ExprListDup() when it contains a vector assignment
from an UPDATE where the initial term is omitted.  This can happen during a
UNION ALL query flattening while processing a virtual table update in which
the first term of the vector is repeated.
[forum:/forumpost/16ca0e9f32|Forum post 16ca0e9f32].

FossilOrigin-Name: 2547cfe38f8fb35109b3fc5bdfada387fe4b2b8a304156b704ab7f03f1f71198
2021-07-05 02:40:29 +00:00
drh
10f08270e1 Ensure that TK_SELECT_COLUMN Expr nodes always have their iTable field set to
to the number of columns in the vector. This is not strictly necessary. It
just simplifies the state description and make the code easier to reason about.

FossilOrigin-Name: 026f08d4cff19a95e0f38f2ef431cacd65c7c77ed92e30d7f2ded84651f47150
2021-07-05 01:11:26 +00:00
drh
105c4b5ced Fix an incorrect comment on testcase misc1-27.0. No changes to code.
FossilOrigin-Name: 49829ae3229b7c7c7adeaa970a84aebd5157bc93b38fd6d80d86cc03f5fdde6f
2021-07-05 00:07:39 +00:00
drh
4a4e02bc52 Enhance the treeview debugging mechanism so that it correctly deals with
TK_ROW expression nodes.

FossilOrigin-Name: e87fdb6514b6f6775a5a36ca0ec5c920eeaba9e3b842dffa327e970b27cd036d
2021-07-04 22:33:08 +00:00
drh
24384d88d6 Fix a (harmless) typo in a comment. No code changes.
FossilOrigin-Name: d2b9b8daa3b87c3dba1329e2f2f44b60d6b5bb9a49d741045aa20cc7813446b2
2021-07-03 18:57:40 +00:00
drh
5c46a7e555 In the PRAGMA foreign_key_check, ensure that sufficient registers are
allocated for the virtual machine, even if one or more foreign keys reuses
the same column multiple times and has more columns than the table it is part
of.  [forum:/forumpost/a6b0c05277|Forum post a6b0c05277].

FossilOrigin-Name: 68db1ff9c44fa9c37690ce55ad304d4263ba6fac490063d9e08470de6c17cfe6
2021-07-03 02:55:47 +00:00