Commit Graph

23917 Commits

Author SHA1 Message Date
drh
0fe7e7d924 Add new interfaces to enable virtual table to process IN operator constraints
all at once, rather than one element at a time.

FossilOrigin-Name: eb84b80e1f6d8c32bf0c9e1731f0233de0160a13f714f766779ae01fdf504e7b
2022-02-01 14:58:29 +00:00
drh
e66532a63b CLI: Take extra care to not split a multi-byte unicode character when doing
wordwrap.

FossilOrigin-Name: 00b1b7020a564976da3237532434e47ccf17eb5d620e6ac45f3e70b5d5739200
2022-02-01 13:17:11 +00:00
drh
ca1776b5f3 CLI: Add the --ww option as an alias for --wordwrap. Improve the wordwrap
algorithm so that it breaks at punctuation if it cannot find space.  Always
wordwrap with --ww even if there is a .width setting for the column.

FossilOrigin-Name: 1b528e31f8c62797e0814568b520c0680ff23a2ee877ca6aa70a167d40ebdf80
2022-02-01 12:28:17 +00:00
larrybr
cc4d55c9cb Add "--wordwrap on/off" option for CLI columnar modes, qwbox shortcut
FossilOrigin-Name: 10dbc278708cd2cce7fef90738082dbe31750d93e44b5fa5413a9a32dae7703a
2022-02-01 02:50:45 +00:00
drh
5aabdaebd5 CLI: In ".mode column" output, if any row contains a newline or wraps, then
put a single blank line in between each pair of rows to provide additional
visual separately.

FossilOrigin-Name: fd42f4c304079356358e606dd96d4b84cf211c4334c586118b99fe9ad20e20ea
2022-02-01 00:00:08 +00:00
drh
47741b8de9 CLI: for columnar output modes, make sure the header is not too big.
Also, improve the help text.

FossilOrigin-Name: 070fae3a09cea675e722340870cb2bee9e1ac96954d3baacfdb7f5400ddb1b20
2022-01-31 22:14:53 +00:00
drh
3769501235 CLI: Fix a problem with tabs in the new qbox mode.
FossilOrigin-Name: ca96ab3ef78479d95e831cacdb80f23c119cbaa77b3821eac7a3f110bfe20cc9
2022-01-31 20:39:27 +00:00
drh
5dce6f96d1 Fix harmless compiler warnings in MSVC.
FossilOrigin-Name: 3ec6141c41a71eea0d96a65aa35c828e4d852d60e090513c312b925d0e257f9a
2022-01-31 16:29:06 +00:00
drh
87fb37efce Do not attempt to limit the number of columns used in a table to a prefix
if the table will be used to construct an automatic index or bloom filter.
dbsqlfuzz 787d9bd73164c6f0c85469e2e48b2aff19af6938.

FossilOrigin-Name: f8766231d2a77bb8b95726b514736d4c2d20b056f7fe60bdbc98ebf5e5b15ae9
2022-01-31 15:59:43 +00:00
drh
e40f28618c CLI: Enhancements to columnar output modes. (See
[forum/forumpost/5b53cd851f66441f9|forum post 5b53cd851] for discussion.)
New output mode "qbox".  New output options "--quote" and "--wrap N".

FossilOrigin-Name: 539cef5214446a7181614793e9cf323e95ba00ba0f888585b14b598dd2ff0808
2022-01-31 14:14:29 +00:00
drh
92ecf306ec Fix an obscure problem in sqlite3_backup_init() caused by
[6a45d8fe8bfbc11a|check-in 6a45d8fe8bfbc11a].  See
[forum:/forumpost/8b39fbf3e7b5c278|forum post 8b39fbf3e7] for
the original bug report.

FossilOrigin-Name: 639fc7633bd740421d6b48617b9f68e6be525107e4049673fe720ea6158a393f
2022-01-31 12:29:14 +00:00
drh
b617219bac CLI: Fix the new ".mode box" output so that it works with unicode characters.
FossilOrigin-Name: 454af48724c78bf8e06379a426e01b1597f56fcc83211ee062ff0dbeb6a140b1
2022-01-31 10:55:50 +00:00
drh
09a39ed522 CLI: For columnar modes ("box", "column", "table", "markdown") the ".width"
is now both the minimum and maximum width of the column.  Text that spans
multiple lines or that contains tabs is properly formatted.  If any part of
the output contains multi-line text, then extra separators are provided between
each row.

FossilOrigin-Name: c10ed4a7fe33fd9330967ab714b1f09ad57c972997160dfc71477e43b905f69c
2022-01-30 21:09:03 +00:00
drh
e229ca0307 Always enable all JSON tests, now that JSON is included by default.
FossilOrigin-Name: 8c9f350182140604a71e11d226acb3f80d1f2b4f75e5c3b55ec8f8a7c02941f3
2022-01-30 11:44:17 +00:00
drh
ddd166a350 Remove a faulty NEVER(). Fix for dbsqlfuzz 4678cf825d27f87c9b8343720121e12cf944b71a
FossilOrigin-Name: d4e402458dd4cadb623a30158eb9ff5f24f011240b3b1bc5b1d6ae3c5b855892
2022-01-30 11:42:56 +00:00
drh
86c756015b Documentation enhancements. No code changes.
FossilOrigin-Name: 312642d982f7861fd4db416e5eb24d863535b3ade40539a32f2dfe3f6fc45d46
2022-01-29 21:41:15 +00:00
drh
665b6b6b35 Add the SQLITE_INDEX_CONSTRAINT_LIMIT and SQLITE_INDEX_CONSTRAINT_OFFSET
constraints to the sqlite3_index_info for the xBestIndex method of virtual
tables.

FossilOrigin-Name: 1e227ad9f413227f767b45b91e5439b82c98a3368fb20643414dab5c0f4818c6
2022-01-28 23:44:27 +00:00
drh
f6f7888622 Add a NEVER() on an unreachable branch.
FossilOrigin-Name: 388926254b9da6169da7267bd4d5a1a66a26576be435c88269ab8db9eaedc079
2022-01-28 23:19:01 +00:00
drh
75863ec11c When nesting Parse objects, make sure the new one has nErr set if there
has been an OOM error.

FossilOrigin-Name: ae088cbc968a565c3e0a8dd74ce150cac4a87978b593a3204f475fa196f1603c
2022-01-28 21:39:29 +00:00
drh
cee5cb484d Include hidden columns of table valued functions that are constrained
by the function arguments in the colUsed bitmask.

FossilOrigin-Name: 8f8cab0d0e219f0c4bc2b8061c0013d90a2a5e598dd6cf420d302dfd1b7cbe11
2022-01-28 19:53:37 +00:00
drh
d0c7baf505 Remove a NEVER() that has become reachable now that we have the
sqlite3_vtab_rhs_value() interface.

FossilOrigin-Name: c4c30df7cd858315359bd9bfa90a07152d87a2301eaec865c5bc1c65e272eec8
2022-01-28 18:43:33 +00:00
drh
0ae56fbdd0 Enable SQLITE_INDEX_CONSTRAINT_LIMIT/OFFSET even if there are vector
comparison operators in the WHERE clause.  Also:  Do not enable
sqlite3_vtab_rhs_value() for LIMIT/OFFSET if the value is negative, as this
violates an invariant on Expr.u.iValue.

FossilOrigin-Name: 140480b3ec5466513b165d4818f1180cff6e4a5edcd47efb54cbff74a7107507
2022-01-28 13:18:40 +00:00
drh
8f2c0b59da Query planner always honors the aConstraintUsage[].omit flag for the
SQLITE_INDEX_CONSTRAINT_OFFSET constraint.

FossilOrigin-Name: 38c5151eb8cc789ad082a1b40d16b2ddb55454219bd685b6e420995af6a15f55
2022-01-27 21:18:14 +00:00
drh
233ba1b8eb Make LIMIT and OFFSET values available to sqlite3_vtab_rhs_value().
FossilOrigin-Name: b2d37c086c87fe4aee013bba4eab26f642207cd2a797fe4888a6ef868884c191
2022-01-27 18:45:26 +00:00
drh
895bab3383 Give the virtual table xBestIndex method access to (some) OFFSET and LIMIT
clauses.

FossilOrigin-Name: 74fa5757ee0a8499bcd6546dac1a3ecc6048ba9cff9e3e574e28e6e82e894a3d
2022-01-27 16:14:50 +00:00
drh
4b51e8bd68 Enforce the restriction that 'unixepoch' only works as the first modifier
after the time-value.  This has been documented since 2004, but has never
actually been enforced before.  Also add new test cases for date/time
functions with evidence marks.

FossilOrigin-Name: 64fa9e8c87179211cec248e6dfd7578502e6e969a19e91a4f0e21ed9b972a6bc
2022-01-27 13:52:01 +00:00
drh
a5c9a70757 Minor adjustment to error handling in sqlite3FinishCoding().
FossilOrigin-Name: a8db69411b0d1275909adeb21027784ada17af24efe3a59ae0ae2a897659ff17
2022-01-25 00:03:25 +00:00
drh
15b01def1e Remove an unnecessary assert() that is sometimes not true following an OOM.
FossilOrigin-Name: e9361d72f362b390a31f667363b01cf9d4b78aa19ed5c97f21afe9da764b89c0
2022-01-24 21:47:00 +00:00
drh
a2417ec75c New dbsqlfuzz cases added to test/fuzzdata8.db.
FossilOrigin-Name: d1fbf63330830c4b9549d0e67f6cdc19fe7a9dc3fcf509795fd1175499fddc82
2022-01-24 20:20:35 +00:00
drh
b32b30930f One of the ALWAYS() macros in the previous check-in could sometimes be
false, following an OOM.  Remove it.  Problem found by dbsqlfuzz.

FossilOrigin-Name: 11df9187dad0eb33b0f6288b76d74f9700420ec855e8106b0bc71df48c485ad1
2022-01-24 20:16:37 +00:00
drh
1da88b5ce6 Add ALWAYS() macros. Change some existing ALWAYS() into assert(). Other
code simplifications.

FossilOrigin-Name: 4aa27b4fcd1ffd06c38357a87ba3f5776367570439c49652f0903873def0bb23
2022-01-24 19:38:56 +00:00
drh
0c7d3d399d Remove many redundant checks for sqlite3.mallocFailed now that any OOM should
cause Parse.nErr to be non-zero.

FossilOrigin-Name: 1f7fa46126ea33ed30e93186aff3df51068aeb4be6f79a102bfe8c4e44941d71
2022-01-24 16:47:12 +00:00
drh
c692df2784 Make it so that any Parse object is always linked into the database conenction
while it is active.  Hence, an OOM will cause Parse.nErr to be set.

FossilOrigin-Name: 6a45d8fe8bfbc11a5b86d25237e1f8bccfb0f22f3dcaf004ba797aeb57b365ec
2022-01-24 15:34:55 +00:00
larrybr
b5d4473221 Fix testcase for CLI .read recursion.
FossilOrigin-Name: 53d4404458fb6f0b6b2b69c2225d66b39f09099c356ba3c3e990474f14aba31a
2022-01-24 14:01:31 +00:00
drh
3cdb1394b9 Make sure the sqlite3OomFault() routine sets an error in the Parse object
if there is a Parse object active and linked to the database connection.

FossilOrigin-Name: ad7aace761c6b21ba453eaf43c68d985be7cbd5a200fe0d2e27a0c7150f99874
2022-01-24 12:48:54 +00:00
dan
f5bc444077 Ensure that any error encountered while coding a trigger program is transfered to the main Parse structure before it is used with any other routine that might set the error code.
FossilOrigin-Name: 4293656578811b500786335de7cc9ac0d6ccc6fb273b9419a86968a095404c43
2022-01-24 11:25:42 +00:00
larrybr
d48e88e56d Limit CLI input redirect nesting
FossilOrigin-Name: 7a073931752d16ba71f1a606091461e427ca5ccf4d135d3c5141bfdd4e67e2d5
2022-01-24 06:36:16 +00:00
drh
bcba3655ee Add support for the sqlite3_vtab_distinct() interface. Virtual table
implementations can use this API to determine more detail about the ordering
requirements needed by the query plan and perhaps reduce the amount of
work required to compute a correct answer.  This is an optimization
opportunity for the virtual table implementation.  The correct answer should
still be obtained (though perhaps more slowly) even if sqlite3_vtab_distinct()
is ignored.

FossilOrigin-Name: e4caf1e3932b1bd0dea072df7fc9458aed98c84ea397b6948b89292603949c41
2022-01-22 22:28:32 +00:00
drh
68dc8151e0 Bring sqlite3_vtab_distinct() up to spec so that it works as described in the
documentation.

FossilOrigin-Name: 4289edf3c5e32a05b51f232020099b33f6f5e79b0ceca2b96baf1186168d9af6
2022-01-22 20:45:57 +00:00
drh
9b9fc74f2e Iimproved documentation for sqlite3_vtab_distinct(). No changes to code.
FossilOrigin-Name: 7af03f02940b5380ee7375672ca8d0ff68c5f741d0ea206911631f3eb5a78555
2022-01-22 19:19:35 +00:00
drh
57c58b4de8 Omit the WhereLoopBuilder.pOrderBy field, which is no longer needed.
FossilOrigin-Name: a13afc909c8bb643aa154b39ba8c023bae7352d3cd7cfb96be3891fa0e4bc045
2022-01-22 02:52:22 +00:00
drh
ec778d2724 An initial attempt to implement sqlite3_vtab_distinct().
FossilOrigin-Name: d571262d2345bb11e71bef395cf078e5d7303b974b38b4e319adda6194ccc1c5
2022-01-22 00:18:01 +00:00
drh
4d7f335e8b Update evidence marks for the latest changes to the documentation.
FossilOrigin-Name: 19247e919fab9748cae561cb12c4c3c106064390a37e32e724d9a9066cfaff8e
2022-01-21 19:26:18 +00:00
drh
a1c8151bab Fix some of the new date/time function features to comply with the spec.
Update requirement marks.

FossilOrigin-Name: 2f5dc7a9eed89baf6814e9e123354b262c806c853dee1243c93286c564b9aba8
2022-01-21 18:57:30 +00:00
drh
e482fde6ee When computing a vector to be used as a key for an index lookup, do not
check for NULL values and abort until after all key values have been
computed, in case one of the later key values involves some initialization
that is needed by a LEFT JOIN.  Fix for the problem identified by
[forum:/forumpost/ab95010d410a0a55|Forum post ab95010d410a0a55].

FossilOrigin-Name: 4db5217a28ce767fa14ddfe51cf3ca25eceb72079d46a2fc00f7d6b8ae9abe0b
2022-01-21 16:41:11 +00:00
drh
d323a3a515 Add the sqlite3_vtab_rhs_value() interface, allowing the xBestIndex method
of a virtual table to access known values on the right-hand side of
constraint expressions.

FossilOrigin-Name: e19a0b132a641f0e9f3d72586af538b95b4db8665b1555f84bc0a291bf1a4056
2022-01-21 01:00:53 +00:00
drh
991d1085e3 Add requirements marks and tuning.
FossilOrigin-Name: ac951490fd7d5864fe422a80ee8557478e823e79461bec2ee538f57b6733eb5a
2022-01-21 00:38:49 +00:00
drh
bd3a247c73 Test cases for sqlite3_vtab_rhs_value() based on the qpvtab extension.
FossilOrigin-Name: 577d3d66558368c34acab8a9e552957cf3fa054c348f1383a9121de6e8b281b7
2022-01-20 19:00:48 +00:00
drh
fdb6f44fac Enhancements to the qpvtab virtual table to make it more useful for testing
and verification of virtual table interfaces.

FossilOrigin-Name: 850efc4cf3d136fba9173c380e9417b43bb93c050f7eeb85d07fd39a4b1cc6aa
2022-01-20 18:27:54 +00:00
drh
82801a5b72 Initial implementation of the sqlite3_vtab_rhs_value() interface and the
qpvtab extension used for testing the virtual table interface.

FossilOrigin-Name: 0873c76b9b96b66fa9d13ddc8bca126d575ea3352349c7fd648f0c2f75d770f5
2022-01-20 17:10:59 +00:00
drh
f208abdd99 A better and more robust fix for the problem of reading a read-only WAL
mode database with existing -wal and -shm files, replacing [f426874e005e3c23].

FossilOrigin-Name: 71bfd0b57ab197405606b8096b8521d784ff174c4eecf1d9804d38342c03cc80
2022-01-20 14:40:34 +00:00
drh
98bb34c501 Fix harmless scan-build warnings.
FossilOrigin-Name: ab160e8bae3a4fc2067d73fe33542f261652985390fe9b0390a4f9c33a1990bf
2022-01-20 12:58:15 +00:00
drh
d6b44ec32a Fix the ability to read read-only WAL-mode database when -shm is present,
([00ec95fcd02bb415|check-in 00ec95fcd02bb415]) so that it works
for the case of 64K page size.

FossilOrigin-Name: f426874e005e3c23e8a00083b7c201408e072bca413e52bfc436da6483afb0cd
2022-01-20 02:04:53 +00:00
drh
29a7bbffba Fix a test result for alterauth2.test due to the recent fix to authorizer
calls for ALTER TABLE DROP COLUMN.

FossilOrigin-Name: e799a35f2bf85ce43b476738bfbd9b6b378bbf02fa0708dda0deba71dd37f608
2022-01-19 18:31:43 +00:00
drh
85b70e009f Fix ALTER TABLE DROP COLUMN so that it invokes the authorizer. Fix for
[forum:/forumpost/fd82b85947541dec|forum post fd82b85947541dec].

FossilOrigin-Name: aca6c61d79215519fb006af19d9011029df68f195a4ce65aff7a1bf4e36efb94
2022-01-18 16:16:32 +00:00
drh
1f3366cd68 Allow an "IntReal" value to count as a REAL when checking types for
insertion into a generated column on a STRICT table.
[forum:/forumpost/fa012c77796d9399|Forum post fa012c77796d9399].

FossilOrigin-Name: 1ec44d55da2ced1a1b0b78b489caff628652464f5709ee827e35409eb20ea794
2022-01-17 23:37:25 +00:00
drh
14818366c7 Fix incorrect testcase() and assert() macros in json.c. They were not causing
problems.  The assert() was simply unreachable.  The testcase() added an
unreachable condition.

FossilOrigin-Name: 5623497adc8af9950fd79392000a68ba6fdca43594603eadaa7e19c8fb845a7d
2022-01-17 15:23:57 +00:00
drh
5a6f818d84 Never allow the b-tree layers view of the number of pages in the database
file exceed the actual number of pages in the database file, even when
PRAGMA writeable_schema=ON.  This helps with earlier detection of corruption,
and prevents excess memory usage and CPU cycles in some integrity_check ops.

FossilOrigin-Name: 0407c8793700491b8519a649b9624f569b0e7e9b94d0db79d4a08139e0ecdb69
2022-01-17 14:42:38 +00:00
drh
7d44b22d45 Fix test cases so that they all still work even with -DSQLITE_DQS=0.
FossilOrigin-Name: 4883776669ee2f2310ea82b0d6df4d008eebaa7cb252102539cf21a635402ebb
2022-01-16 19:11:13 +00:00
drh
72e30421c8 Fix ALTER TABLE so that it works even when compiled using -DSQLITE_DQS=0.
[forum:/forumpost/3c1a00b66fca81fe|Forum post 3c1a00b66fca81fe].

FossilOrigin-Name: 092ad64faa4ae93b1e09ccd52159621d619e6817bcb4573331e9053d97f731fd
2022-01-16 15:15:39 +00:00
drh
ddbb3cb5ec Remove code from lemon.c that was made superfluous by
[1b22b42e59793af1|check-in 1b22b42e59793af1] in late 2017.

FossilOrigin-Name: 6d2f95a474a0c196f36317d88557bfb449ce125c1d012fc1844378c450697a05
2022-01-14 23:28:11 +00:00
drh
c4bb999962 Fix a NEVER() in the byte-code engine that can sometimes be true.
Test case in TH3.

FossilOrigin-Name: 7ac91b5339f820f49b0eb52055d42b6a55905444883426caf792fada63079516
2022-01-14 21:34:49 +00:00
larrybr
ce0b5e44b7 For .import schema, quote it as for other identifiers.
FossilOrigin-Name: bff9153ceedcc7be77f2daf5139fee29c2fab742ff1fce49877965423a7d4be3
2022-01-14 16:29:45 +00:00
larrybr
738d7b9fc0 Add --schema S option to .import
FossilOrigin-Name: 38d9dbca166078013a44214c88805fc7cca578976ceed9fc62f5159a38ec96a7
2022-01-13 21:22:54 +00:00
drh
8efc6a8c09 When the result of a subquery is to be stored in a register and that
subquery has an ORDER BY clause and an OFFSET, NULL out the destination
register before starting the ORDER BY so that the register will be set
correctly even if the OFFSET is larger than the number of output rows.
Fix for the problem reported in
[forum:/forumpost/0ec80f12d02acb3f|forum post 0ec80f12d02acb3f].

FossilOrigin-Name: 9282bcde301cee2a5c3c068b5b0b7ce992c155ece894413a6a9a51a81e4133fd
2022-01-12 20:31:14 +00:00
larrybr
04f97602e2 Make tool/mctimec.tcl effect more regular and obvious
FossilOrigin-Name: 02aaa10f34ab17e76feb7b6f79048309536c0794fcb534b934e06f3daedfeaba
2022-01-12 01:42:50 +00:00
drh
c5432c43e8 Fix mkctimec.tcl with the updated compile-time options for JSON.
FossilOrigin-Name: 8ded3f5b0025eb6cc11669c1208681e592862ce352dfff11173dff68daafad30
2022-01-12 00:52:34 +00:00
mistachkin
beacaac2b5 Fix harmless compiler warning seen with MSVC.
FossilOrigin-Name: adebb9d7478d092f16fb0ef7d5246ce152b166479d6f949110b5878b89ea2cec
2022-01-12 00:28:12 +00:00
drh
bbf647e64f Merge the JSON interface into the core. Add -> and ->> operators for JSON
that are compatible with by MySQL and PG.

FossilOrigin-Name: 4cbb3e3efeb40cc41df15e96c7a0c9d6a8c12ca9f2c139ff1b31ea5416735d34
2022-01-11 23:28:12 +00:00
drh
a6c596b194 Remove vestigial traces of json_ntype().
FossilOrigin-Name: 8da07c8b09ff83436a34e539e4cce8ba9524390017ca14f4af8344a12e351550
2022-01-11 22:06:25 +00:00
drh
aa97b57b11 Fix the PG-compatible -> and ->> path parsing.
FossilOrigin-Name: 22d5138315fb77eeea1c7e66ccc4190bcae18d058a99aa37ddd119e54b52f723
2022-01-11 18:01:17 +00:00
drh
875912c246 Fix typo in the json-enhancements.md document.
FossilOrigin-Name: feba24ef774d80ebbaf87a93fc106cb7e482edcc3f237edd4c9d4e918ffb3131
2022-01-10 17:43:54 +00:00
drh
d83c90bd63 Implement the new PG-compliant versions of the -> and ->> operators.
FossilOrigin-Name: 39eff3b9bf1f318d3606d8e5361a2adb2ba8bc1ca2a436ce4f9a204aa4cf20dd
2022-01-10 15:43:13 +00:00
drh
d3c6c3459b New proposal for -> and ->> operators.
FossilOrigin-Name: 1108e12a2244edc6247050a0e9ad25b912bba6c57c71c51c2bc55167a6955175
2022-01-10 13:55:08 +00:00
drh
18ccc5c5ab Typo fix in doc/json-enhancements.md.
FossilOrigin-Name: c3b01d496479b3250a8895c245f79ab43ac469148d163593fea00894db195a37
2022-01-09 20:51:59 +00:00
drh
f2afe4e888 Update the doc/json-enhancements.md document to better explain the features
of this branch.

FossilOrigin-Name: b8ac938f41eff8e5a23037c0e8b035a65e1b9505eca2a601221c195225595788
2022-01-09 20:42:55 +00:00
drh
d3110034dc Do not enclude ENABLE_JSON1 in the compile-time options.
FossilOrigin-Name: 8bf41bc5cb19fcde569ed2c788553a848ebd9c79065bd3d2aa99e5a6bfed9696
2022-01-09 19:44:36 +00:00
drh
cd379b8a53 Merge trunk enhancements into the json-in-core branch.
FossilOrigin-Name: ea755771699dcbffe0ddfd204d42fae9b6e79e107485c725b8eb6caab92aacb8
2022-01-09 19:36:39 +00:00
drh
9d44f18b3c Add a new built-in subtype() function.
FossilOrigin-Name: a25f4ce255c034fc694c33728aedb98289ebccda9c48920829ef780b92b8faee
2022-01-09 16:54:02 +00:00
drh
5622c7f971 Add NEVER() macros to two branches that became unreachable due to
[e199a851e316bd47].

FossilOrigin-Name: 71272caff5874137ad0b1ddfc22ced4bb66e6c97f7868fdae0347a186f589b38
2022-01-08 21:50:00 +00:00
drh
6bcd58572b Add function format() as an alias for printf(), for compatibility with other
systems.

FossilOrigin-Name: 68bffc612c467b2419bf5fe85a8ca16b787003e0e8c11f7c051a879f5865b847
2022-01-08 21:00:38 +00:00
drh
daefcd9e00 Merge the JSON function enhancements from the json-enhancements branch into
json-in-core.

FossilOrigin-Name: e116501c2f0e594eb7a3dd804daa943cc508f32ded3078aed21b695ec83bcd4c
2022-01-08 15:37:13 +00:00
drh
dc60c68cc0 Improved commenting of changes in the json1.c extension.
FossilOrigin-Name: 4d81425e1bf2cff6fa961d0a7936b5f62d3f8ffe9bffea89c1e8b8ddf8fad6f4
2022-01-08 15:05:53 +00:00
drh
4f3557e4c9 Notes on the JSON enhancement proposals.
FossilOrigin-Name: 18160985ea6b2bbf27de25e0f4f3a1ebcdb079a36af039fc06e37a834e49e772
2022-01-07 18:09:56 +00:00
drh
a3f51d7b3e Reverse the meaningn of -> and ->>. ->> raises an error on invalid JSON
but -> does not.  This allows ->> to behave the same as PG and MySQL.

FossilOrigin-Name: 85f8170555ee0d4d28cb7e120a7062e9f64c331a936fdfa29fc0e67224eea7c6
2022-01-07 17:26:40 +00:00
drh
9956c18a81 Change the -> operator to use json_extract(). The ->> operator continues
to use json_nextract().

FossilOrigin-Name: b4c8a62381755b9f1447e10ab95df7209eebda91f9a4583ef1c093a13f6b4725
2022-01-07 17:14:35 +00:00
drh
338b1fde62 New json_nextract() function that works like json_extract() except that it
returns NULL instead of raising an error if the first argument is not
well-formed JSON.  Or if the first argument is not well-formed JSON and
the second argument is '$', then return the first argument quoted.  The
"->" and "->>" operators are converted to use json_nextract().

FossilOrigin-Name: dc00f5286d26524b149de071490320afaa203fec5777b3eb813f07963614861a
2022-01-07 17:08:48 +00:00
drh
a4e4e18494 Add the json_ntype() SQL function. Works like the 1-argument json_type()
except that it returns NULL if the argument is not well-formed JSON, rather
than raising an error.

FossilOrigin-Name: ed9956f5ddca68141eded81d5362847db603257329801622c4eb3b0732112f14
2022-01-07 16:03:00 +00:00
drh
12b9fa979c Accept abbreviated JSON Paths on the right-hand side of the -> and ->> operators.
FossilOrigin-Name: d15410900dccbb7159683c29f640fa321b1e019718827334f5fefe89da623008
2022-01-07 15:47:12 +00:00
drh
d5326c333f Add new binary operators "->" and "->>" to the parser that evaluate to
2-argument SQL functions by the same name.  Add new "->" and "->>" functions
to the JSON extension that are aliases for json_extract().

FossilOrigin-Name: c4e4e3a3fc5da0381ccb7930706e57d7831d87f9c63bafe49ae64117701e1cfe
2022-01-07 14:58:47 +00:00
mistachkin
3c64888253 Add the '-guard:cf' compiler option for Windows 10, per [forum:/forumpost/8d3b4ad694|forum post 8d3b4ad694].
FossilOrigin-Name: 2d6a16caa7d28ad5c766036b2eb6c2020683fcc9389b3c7df2013739929dd36f
2022-01-06 17:13:56 +00:00
drh
9dbf96bd70 An attempt to integrate the JSON functions directly into the SQLite core,
rather than holding them as an extension.

FossilOrigin-Name: 583b47d865fb8d2c9ae4d3a4e70356a8a758978efb0a282f6b19775bf41fb748
2022-01-06 01:40:09 +00:00
drh
10f7365748 Remove two NEVER() macros that can sometimes be true if the database is
corrupt.  dbsqlfuzz 0414d2c18290fc80fd5fb540def7d3e46c1ae9c6.

FossilOrigin-Name: b6a82f3c3b9d89fdf628c7f117b6a4a64383a36c84fe84d47c80e845c9bd8a4f
2022-01-05 21:01:26 +00:00
dan
c6977c1c0d Fix an assert() failure that could follow an OOM when coding a RETURNING trigger. dbsqlfuzz case 5d3e2438f15dc32b473d9f29413157857efa1212.
FossilOrigin-Name: 7ae596dd4a73a09585c5dc9f4faf75d126d0733fc2fb32c1de64126a1088d967
2022-01-05 15:54:02 +00:00
drh
ebc4434e99 Improved handling of OOM errors in sqlite3ExpandReturning().
dbsqlfuzz 1040b720f0bbc3bdcfe7336acffbf71517e3ef82.

FossilOrigin-Name: 33c6b8e94bda12df13b4d2dd782b3120c3628596b86ef531d20b3100bf159b50
2022-01-05 11:49:58 +00:00
larrybr
d0a9a46215 Test .mode quote blob output
FossilOrigin-Name: ef4dcd1080241a62a50eff28ef12c49da0116032f10843aaf048ae7ad3cdfd0e
2022-01-03 19:33:44 +00:00
drh
b248668bc9 Small performance and size optimization to allocateCursor().
FossilOrigin-Name: 23f042669aff535afa6ee9de367656848d01e90a1c9dab9359fa938a615b4195
2022-01-03 01:43:28 +00:00
drh
80d99e19b6 Remove unnecessary assignment operations in the btree search algorithm,
for a small size reduction and performance increase.

FossilOrigin-Name: 01bd266eb682feed901a0995c2232b62d8444d19dbb227095dfbfe8edeaa5d88
2022-01-02 21:53:54 +00:00
drh
5d1bf4f560 In the CLI, fix ".mode quote" output for UTF16 BLOBs.
[forum:/forumpost/b4bfe62fe6|Forum post b4bfe62fe6].

FossilOrigin-Name: 728e9dcc6d211acd787837c41cb62275284b5e02f55bd28bf5a44e233bcb057a
2022-01-02 20:54:33 +00:00
drh
bda4d20080 Do not open a rollback journal file when the journal_mode is OFF, even if
such a file exists on disk. See
[forum/forumpost/ec2a102440|forum post ec2a102440] for a description.  I so
far have been unable to find any harm to come of the problem, other than the
assertion fault when in DEBUG mode.

FossilOrigin-Name: fdf9ed665b2fb07d26f3852bfd2170f2fb56851edd2851d47672116a8ea58463
2022-01-02 19:32:43 +00:00
drh
d0fa3484c6 Improve formatting of an assert(). No functional changes.
FossilOrigin-Name: 4bb78ce8b50af3c6f04ffdf4de4438e61370a73ccfa971479af5d58a0a7e5fbb
2022-01-02 19:10:49 +00:00
drh
29bbc2b51f Performance optimization in btreeParseCellPtr() by unrolling the loop that
decodes the rowid.

FossilOrigin-Name: fef72368a2eef5cb68ffc56e4f01be212d5e3318ebdb56a23ab26e1ef454272e
2022-01-02 16:48:00 +00:00
drh
7e17a3abbe Small performance optimization and size reduction in sqlite3BtreeDelete().
FossilOrigin-Name: da0af4dd9ba4180a16543fac1549fd4ccecdc66dcf6d275f77de21fd80708882
2022-01-02 14:55:43 +00:00
drh
44a5c0257f Clear the cache of triggers used to implement CASCADE foreign key constraints
whenever the schema changes.  Fix for the problem identified by
[forum:/forumpost/2831335356|forum post 2831335356].

FossilOrigin-Name: 5232c9777fe4fb13e1ecfe5b5d644e2c45d0514f95884dbed49a03fb9b67304c
2022-01-02 12:01:03 +00:00
drh
2dfe9664a9 Earlier detection of corruption in sqlite3BtreeDelete(). Fix for
the assertion fault reported by
[forum:/forumpost/9d78389221|forum post 9d78389221].

FossilOrigin-Name: 13e9ff9e84a114374b49986484dbee05953a496f3017dd5089fba6f495a17c40
2022-01-02 11:25:51 +00:00
drh
24a82eadb3 Do not raise an SQLITE_SCHEMA error if in sqlite3Init(). Fix for PoC #2 in
[forum:/forumpost/b03d86f951|forum post b03d86f951].  See TH3 for test
cases.

FossilOrigin-Name: e199a851e316bd471bfc54204b8c250d3ae93b829261214158a2c74acad4093e
2022-01-01 22:55:31 +00:00
dan
4ce289d088 Fix an assert() in pager.c to avoid the possibility of side-effects.
FossilOrigin-Name: 1d1fe03c752267f03f015ada975876f65e2a7b967e19f057b5c73f95d7df8a9c
2022-01-01 20:02:58 +00:00
drh
a6ca90c38c Attempt to fix a harmless compiler warning in FTS5.
FossilOrigin-Name: 8e619c21e2326be1538b60908e7cd211558ec840835c6eb69e768eb190e1fd0b
2022-01-01 19:55:29 +00:00
dan
0f42f71da2 Fix an obscure problem with releasing savepoints stored in an in-memory journal that could cause subsequent savepoint rollback to fail.
FossilOrigin-Name: 73c2b50211d3ae26aeb89976ec7b9fcd7de9f152b283ec7d0809ad18bddc603e
2022-01-01 19:29:50 +00:00
drh
3ea82384ea Remove an obsolete assert() statement that no longer does anything useful
and which is not always true.  Fix for PoC #1 of
[forum:/forumpost/b03d86f951|forum post b03d86f951].

FossilOrigin-Name: c76a4c0b3cb625017ba09c8bccfcf1b5826df6873f1d3705d3345716079d5ec9
2022-01-01 17:21:55 +00:00
drh
3907560848 Fix a faulty assert() statement - adding a CORRUPT_DB term - based on a test
case derived from [562805cf488a455c].  Also add a test case to that prior
issue.

FossilOrigin-Name: 0dd6b5fccd554ebe4c0b081601863acd7b6ea81b51e14b508b23244f2a570e7e
2022-01-01 12:26:01 +00:00
drh
017e363787 Mark the REGEXP operator in the built-in extension as deterministic.
FossilOrigin-Name: e654b57a9fc32021453eed48d1c1bba65c833fb1aac3946567968c877e4cbd10
2021-12-31 22:53:15 +00:00
drh
54bc63815a Simplify the sqlite3RunParser() routine by omitting the third parameter.
Results in a binary that is about 100 bytes smaller and 1.4M cycles faster.

FossilOrigin-Name: 6fb2a1bb0280d6e31291e3fd06bbcbbb28ef5fb27d3898e2327a50ac738ae1f3
2021-12-31 19:20:42 +00:00
mistachkin
c158c07a22 Fix harmless compiler warnings in the shell.
FossilOrigin-Name: f3ea36d79b6aa95470bf13e8d4ed5250a6b19bc16032b29e4dcdfc49b47a1edf
2021-12-31 19:08:20 +00:00
mistachkin
2b5fbb2836 Fix harmless compiler warnings seen with MSVC.
FossilOrigin-Name: a9bfb621091b6d92d1caeb69134d3809d9e0b43fe764608c5995db277ac785be
2021-12-31 18:26:50 +00:00
drh
16118265ca Performance optimization and size reduction in sqlite3RunParser().
FossilOrigin-Name: 41ee2bac5731d8434322e92abba580f7c759a137e576dd286fe01ab23fc440ea
2021-12-31 17:54:48 +00:00
drh
b296ab6f6a Move the pTriggerPrg and pCleanup elements of the Parse object up into the
section of that object that is persisted across calls to sqlite3NestedParse().
This fixes a memory leak
[forum:/info/24bd1fef7e9323ef|reported in forum post 24bd1fef7e9323ef].

FossilOrigin-Name: 562805cf488a455cdc57adcb110fef9b5416d813d5eaeabacd28bccb76d7f39d
2021-12-31 16:37:46 +00:00
drh
9aff824090 Remove unnecessary conditionals around the ORDER BY resolver calls in
multiSelectOrderBy().

FossilOrigin-Name: f2887e018be71bc406526935c7e99e42f12fc5d1d1c65a89dc2b9bfbca01d43d
2021-12-30 17:46:15 +00:00
drh
e1961c55c3 When constructing the sqlite3_index_info object for the xBestIndex method
of a virtual table, omit constant trims from the ORDER BY clause, as they
will always be in the correct order.

FossilOrigin-Name: 524c2b87d74c8cad6fb377aed7275788d61beafe61e675480de732519987102c
2021-12-30 17:36:54 +00:00
drh
66306d86ab When a table has an INTEGER PRIMARY KEY ON CONFLICT REPLACE and some other
uniqueness constraint, and it participates in an upsert on that other
constraint, ensure that code that checks for conflicts on the INTEGER PRIMARY
KEY is well-formed.  Fix for the problem reported by
[forum:/forumpost/06b16b8b29f8c8c3|forum post 06b16b8b29f8c8c3].

FossilOrigin-Name: 2f09b51b1ff37bf98f958564cc1224968caa7e33147e6666b5c1ba20b2a7813b
2021-12-30 02:38:43 +00:00
drh
38cebe07bb When implementing a multi-way compound SELECT using merge, try to balance
the merge tree.

FossilOrigin-Name: bb8522fe0dc54282ec13672eba9b44ee08f9cb55c1663f1699a61bf96ec1fd04
2021-12-30 00:37:11 +00:00
drh
092ba22cca Minor changes to shell1.test test results to account for the new feature
of the shell that points to the specific part of the input line where the
error occurs.

FossilOrigin-Name: d4870c08893ea9984b1fa1c3a7d04893ad5ed4a2130e9287d169a306cc8ef0a4
2021-12-29 13:32:36 +00:00
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
9ebe43c120 Add the sqlite3_error_offset() interface. Use it to enhance error reporting
in the CLI.

FossilOrigin-Name: 416602a85101c2cd1705eb5306a8933e54cb05ae1562400395ec2769173dec01
2021-12-29 04:13:37 +00:00
drh
44c44cd7c5 Make .read's help tell of piped input
FossilOrigin-Name: 155c3e9c7ccd6fd644cc64b027cf460112c491e5f9202dd76cefe2000936ad80
2021-12-29 04:10:49 +00:00
drh
412a59f56e Change an assert() in FTS3 into assert_fts3_nc(), since it is a harmless
condition that can occur when processing a corrupt database file.

FossilOrigin-Name: e773d6219bded9a5dfa9930882682dadaa7f1c6be344dbde904c9477a89f2d2c
2021-12-29 04:10:03 +00:00
drh
9169d0cb0f Fix the build-breaker bug in test1.c introduced by check-in [7fa20ca4c09ab024].
FossilOrigin-Name: 5f804da1820c98e7ff5c377e57e30b5154844b92ce622ed2ff888fe2c887e1ca
2021-12-29 04:08:11 +00:00
larrybr
a2ba25b508 Make .read's help tell of piped input
FossilOrigin-Name: e4ddcd8aa582c1130c34e9f05cd3e5f96ebf03c97a36c09ca442e3612fee4a20
2021-12-28 05:08:38 +00:00
drh
d66d5c2d35 Change an assert() in FTS3 into assert_fts3_nc(), since it is a harmless
condition that can occur when processing a corrupt database file.

FossilOrigin-Name: c03205aee9015fd886b8db02c8190899cee699255ca370f939e547deaf5ba9e8
2021-12-25 23:59:54 +00:00
drh
a98c868a10 Add the sqlite3_error_offset() interface. Use it to enhance error reporting
in the CLI.

FossilOrigin-Name: 7fa20ca4c09ab0249de0363691541fa836120ec277e72feb0e1516b9bfbdd97a
2021-12-25 00:26:51 +00:00
drh
5cec7e1a5f One minor change for an exceptional case in sqlite3_error_offset().
FossilOrigin-Name: c93609a8b9dc2e656bb4360138606e269fd323469f7666dbc3bbc699e431313e
2021-12-25 00:19:46 +00:00
drh
f62641e91c Add the sqlite3_error_offset() interface. Use it in the CLI to provide
better context for error messages.

FossilOrigin-Name: b518ce77439852759bc0901071f36d622b1314c9bf3d29c279dfcc405188b975
2021-12-24 20:22:13 +00:00
drh
c320e062a3 Fix a minor problem in the CLI introduced by [d156123885abe6bf], apparently.
FossilOrigin-Name: 37e6e10f4364f556c7503c80408fc62895cdccdd0372fb2b63aaca02c3a1ee30
2021-12-24 19:44:11 +00:00
drh
ceeb04bf90 Raise an error if a schema name is attached to the table-alias name of a
subquery or view.  See
[forum:/forumpost/021a33600b|forum post 021a33600b] for the bug report.

FossilOrigin-Name: 8af8c153f8c3fe16db1c2280571e005838c4ea3c48929ad7660a1686e49ed255
2021-12-24 13:30:22 +00:00
drh
b131bf7039 Reduce the size of the compiled binary by a couple of hundred bytes by
using a thigher packing of a transformation table in date.c.
Suggested by [forum:/forumpost/4f6efbb2a9|forum post 4f6efbb2a9].

FossilOrigin-Name: c75ba4fa644d338d22813c17172b9975411fe6197e07fd584e3209e3beb78036
2021-12-23 00:16:06 +00:00
drh
8b6dfc474b Update the README.md to instruct the user to remove the final comment line
from the "manifest" file before using it to compute the check-in hash.

FossilOrigin-Name: 7b4f9d95a95f685ea4ee045e43c67b1a5c70e908e357b0b41d522699255663ce
2021-12-21 16:59:45 +00:00
drh
f3c33c6235 In the json1 extension, which compiling it separately, ensure that either
SQLITE_DEBUG macro or the NDEBUG macro is set prior to including assert.h.
If neither macro is defined, then assert() statement do generate code but
VVA() statements do not, and that is a deadly combination.
[forum:/forumpost/858dee399e|forum post 858dee399e]

FossilOrigin-Name: d9f814a6402ca7fd999bbb847dc354b52ab9b97cae0c932344584d26c9430f24
2021-12-20 23:46:44 +00:00
dan
62e9c352eb Remove old script ext/fts3/mkfts3amal.tcl, as it doesn't work.
FossilOrigin-Name: 9e33ee24b3793b3d7faf7421279d16217f8b09b1e92bfdc771f902f2f1e1b7d6
2021-12-20 17:00:42 +00:00
drh
b6592f6563 Improved documentation for the sqlite3_vtab_collation() interface.
FossilOrigin-Name: 826f84a92d3b1f760560bff72c911a2c664737820af0c9114eb3494df7b8e878
2021-12-17 23:56:43 +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
fe46317e26 In the CLI, omit the ".oom" command (only available in debug builds) and
disable the experimental ".expert" commmand in --safe mode.

FossilOrigin-Name: 5cda1f7da885afdfda8683c59e78fec8da1a05c7a4fde573e89db5f872fcfb20
2021-12-16 17:57:21 +00:00
drh
621a5e0c47 New defenses against OOM and corrupt database problems in the CLI.
FossilOrigin-Name: 5c9fd7fde16d8e335488b8bf5c691961d2636201b034d1f29d25de8708de291d
2021-12-16 17:35:27 +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
61fd4b9c3d Fix a memory leak in the CLI that occurs after an error in the ".open" command.
FossilOrigin-Name: d156123885abe6bf23c3530de99be257f82ef85b89fbe019568ac60fa1ed5bb7
2021-12-16 14:59:25 +00:00
drh
b71a485386 Fix harmless compiler warning in the new Bloom filter logic.
FossilOrigin-Name: 9406d95d3fbaf0d8e65623adb790845f78a7456fb32aafd7fa4f74eda2f2dacc
2021-12-16 14:36:36 +00:00
drh
e0adf60241 Improved robustness against OOM in the expert extension.
FossilOrigin-Name: e732c429bafeffaf7e0f458213089c073c262a39eabb41b291e5006078ca7f98
2021-12-16 14:26:16 +00:00
drh
511b118dd2 Fix a potential NULL pointer dereference in the CLI logic for printing the
schema of virtual tables.

FossilOrigin-Name: fe44ebf6be47e1c7f2458297669dbd2b882a31595ea8759f7e8bb024ffc44d11
2021-12-16 13:56:04 +00:00
drh
e3e2565daa Add more tests for OOM conditions in the CLI.
FossilOrigin-Name: b6fa402d159b2475a7b99ef6a5180d7bf800f90afe28cea726d346d071405045
2021-12-16 13:29:28 +00:00
drh
8a95d3d433 Simplify the generation of the sqlite3_index_info object during query planning
for virtual tables.

FossilOrigin-Name: 241dc0428a6e0238c57e2449e98ea60047e777e29c83a4ebe6da16f7cba40e19
2021-12-15 20:48:15 +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
06164b2340 Omit the return value from sqlite3VdbeSerialGet() for a size reduction
and performance improvement.

FossilOrigin-Name: 788e79f881d443fc1b3a213a7ba4f19bfd245e96c15bb21fcb6bffd92c4320b8
2021-12-14 00:36:09 +00:00
drh
7f8f659260 Small performance optimization and code size reduction in moveToRoot().
FossilOrigin-Name: cdcde00b2d68eeb35c472fdfd4c4508551f6722054394b43cc97eaf01ad7181d
2021-12-13 19:59:55 +00:00
drh
4f2006ddec Add NEVER() on an unreachable branch in the Bloom filter pull-down logic.
FossilOrigin-Name: 471070462593faba865d8d05ee89161b340145351e2fa0bfbaa766d974e932d6
2021-12-13 18:53:10 +00:00
drh
c5860af006 Fix an off-by-one error in the Bloom filter pulldown logic, found by OSSFuzz.
Also fix over-length source code lines in the immediate vicinity.

FossilOrigin-Name: 027626521c02be06ef61e8229bde49d20cb3f1cb600c4cb127c5f139b9de8858
2021-12-13 18:43:46 +00:00
drh
089a9ff48a Remove unused code.
FossilOrigin-Name: b98b24f26518fb362e776bbaef80910bed66b654239e7c76d4b234033ef4174b
2021-12-13 00:02:59 +00:00
drh
dc56dc93a5 Do not allow early evaluation of Bloom filters that use the IN operator as
the machinery to deal with the IN operator is not available.
dbsqlfuzz 5b51c247518278f79a45cea978702e86e86cd4f9.

FossilOrigin-Name: 799db7cb2e0d73031182d26a0e5919368f9f9823df81cb2863bfe79eca344f5c
2021-12-11 17:10:58 +00:00
drh
ef95d5583b Factor out the logic that does quoting for the SQL quote() function, so that
it might be reused for other purposes.

FossilOrigin-Name: 8e98ba1eeb1a5a61b7cb2de337ef8bca3d07494266a50d62b9c6bc60ad0a955f
2021-12-10 21:01:24 +00:00
drh
27a9e1f615 Rename the internal routine constructBloomFilter() to
sqlite3ConstructBloomFilter(). OSSFuzz is reporting a crash with a garbled
stack that we cannot reproduce. Perhaps the original "constructBloomFilter()"
name is colliding with some internal name used by OSSFuzz. We'll see if this
rename clears the problem.

FossilOrigin-Name: 403e7312dd9a3fe493a21aceb82e387d6f152622d66c1b403c881597713e8cc3
2021-12-10 17:36:16 +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
5a4ac1cc30 Remove unused code and fix comments. Final cleanup before merging.
FossilOrigin-Name: ce42039f5647b1f276acf5d9911528ecb47df1544a587def72c8cd6b2f664289
2021-12-09 19:42:52 +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
59285ed788 Add ".mode off" and ".mode count" to the CLI.
FossilOrigin-Name: 1eefd957ff35e961685db565f7ef116c566a04574c5bedad7298b3cc69dd72d2
2021-12-09 16:26:45 +00:00
drh
5d88be8f48 Add ".mode off" and ".mode count" to the CLI.
FossilOrigin-Name: b11f4d080aa9e6f694e2ec401e871f42bf25997e8e8bf77fa9b6014a50466e3c
2021-12-09 16:17:43 +00:00
drh
92704681a1 New test cases added to test/fuzzdata8.db
FossilOrigin-Name: 7046877006259a0073cca4ddb4541321d373c462eac9924be26b5ae224075732
2021-12-09 14:15:39 +00:00
drh
15561b916d Do not attempt to reprepare a prepared statement that returns SQLITE_SCHEMA
if there was an OOM.  This enhancement supercedes check-in
[fee469925231d074].

FossilOrigin-Name: 94fdbeffaf501daf30dc7fae7cef5c2bfdb3a9b055562adfc04374a9fc899c8d
2021-12-09 14:09:47 +00:00
drh
7e910f6422 Add SQLITE_TESTCTRL_LOGEST and enhance the LogEst utility program.
Improvements to testability of bloom filters.

FossilOrigin-Name: 88b43d798cc5aa59855e92d3e658aee9f0a5def6ffbc5db77af048d75ecdf8cc
2021-12-09 01:28:15 +00:00
larrybr
969c46486c Clarity tweak for date.c
FossilOrigin-Name: db58b2def014bdb146751110488a088767530ca2557baf73d6181a2558bbe6d3
2021-12-08 20:36:08 +00:00
drh
fb82caf0be Improvements on the decision of whether or not to use a Bloom filter.
FossilOrigin-Name: 0fb2a4e08f518cb38ea3edc6a084d1e4874fd622ba3cf9101b49b3e7dc1a3f2b
2021-12-08 19:50:45 +00:00
drh
46658d7f9a Enhance the sqlite3SrcListAppendFromTerm() routine so that it sets the
Parser error on an OOM, causing an earlier unwind of the stack.

FossilOrigin-Name: fee469925231d074c17b948605143cfbb2e9595851a797995e7331f1ab2a61ca
2021-12-08 18:50:30 +00:00
drh
c491a25631 Merge the WhereClause fix from trunk
FossilOrigin-Name: d3250256772e3348abe887c0ca3550a6647cce3804c9456a9d0112aea7ee1c46
2021-12-08 16:15:41 +00:00
drh
132f96fc75 In the WhereClause object, do not assume that all TERM_VIRTUAL terms appear
at the end of the list, because that is no longer true.  Instead, keep a
separate nBase count that is the size of the list excluding the tail of
virtual terms.  Use nBase instead of nTerm when scanning terms that are not
virtual.  Add assert()s to validate correctness of WhereClause.

FossilOrigin-Name: 6024682ca467fa4fe49608772b0bbfa2f8a419b32cebfa715941073c8b29da49
2021-12-08 16:07:22 +00:00
drh
761d64b73b Do not generate a Bloom filter if it cannot be used prior to the next seek,
as that leads to a misleading EXPLAIN QUERY PLAN.

FossilOrigin-Name: 2739ed5192058fbcc816ecbc252be687efc606e038bfcd6cf71194a3f4f5684e
2021-12-07 22:37:50 +00:00
drh
3bd7cd736d Improved EXPLAIN QUERY PLAN output for Bloom filters.
FossilOrigin-Name: 00070e1fff6aec3d7c7b121f2b02bbca38a1664aca9afc3fb7e293f07fd1704f
2021-12-06 23:07:59 +00:00
drh
23d41e63f2 Add SQLITE_STMTSTATUS_FILTER_HIT and _MISS for tracking the effectiveness
of Bloom filters.

FossilOrigin-Name: 24ba535d200fc8a99dd8e66c6d100b5f6ae442098bafb152008429398eefe3e7
2021-12-06 21:45:31 +00:00
drh
50fb7e09b4 Omit the OP_FilterInit opcode. Use OP_Blob to initialize each Bloom filter
instead.  Size the Bloom filter based on sqlite_stat1 size estimates rather
than a run-time measurement for improved testability.

FossilOrigin-Name: 8a9036ee617a6ad93bfe827b0789773c49d3d45b085cb76fa4b9b20a41b79b97
2021-12-06 20:16:53 +00:00
drh
8c1c3e5e37 Merge trunk fixes into the bloom-filter branch.
FossilOrigin-Name: edacf8034dc6bd892038c220c480ea512dbb4005db2a6b1f8e679e8a4929c6ed
2021-12-06 19:11:31 +00:00
dan
c436b3056d Fix an OOB read that could occur in fts5 when processing corrupt records.
FossilOrigin-Name: bb9b1a15f7e80483162049dfd981d059dc69d03348b521f7ac164a8cd3ae3cc4
2021-12-06 18:57:02 +00:00
drh
f6a4ef144e Do not allow SQLITE_LIMIT_LENGTH to be set lower than 1 as an
SQLITE_LIMIT_LENGTH of 0 causes lots of unnecessary problems for
users of the sqlite3_str object.

FossilOrigin-Name: 8fd5b8ec4ab9b5554d27f25a4638d56e347eab78b60900f24b15a815d3731330
2021-12-06 15:40:24 +00:00
drh
38ed1ceb5a Do not allow certain dangerous ".testctrl" commands in safe mode.
FossilOrigin-Name: 080e72d119b836c49916201bf135445aa7d53cefe40a47437a93448c4d0f41cd
2021-12-06 15:24:36 +00:00
drh
39addd0a3f Fix SQLITE_TESTCTRL_IMPOSTER so that it is a harmless no-op if the schema
parameter is invalid.

FossilOrigin-Name: 2d9a45ab10aaad681e11d639195430c0988b6ca1b96db6bf0b31b889e88a5430
2021-12-06 15:08:30 +00:00
drh
5baaf40af1 Attempt to vary the size of Bloom filters based on an estimate of how many
keys the filter will hold.

FossilOrigin-Name: a7adcf69088cba4b86cc5731a45c9a5263af4355bc0a38f5225cab421c915f7f
2021-12-06 13:07:28 +00:00
drh
6ae49e67cc Run as many Bloom filters as possible before index lookups.
FossilOrigin-Name: 06f6fefd67086896bc49272c6319545ff6c6792f18babe23aced27b60b032119
2021-12-05 20:19:47 +00:00
drh
35685d3e5e Try to run all Bloom filters before any Seeks. This gives a small performance
gain on the Star-Schema Benchmark.

FossilOrigin-Name: 5be2470f8755ef454f813c880e659bdbf82f2396be9320cf3079cd4ca8e81a19
2021-12-05 00:45:55 +00:00
drh
fecbf0a179 Miscellaneous cleanup of the new Bloom-filter code.
FossilOrigin-Name: 201b6dd875b0ae2bbc9969b098e88abfc09e37b59e857decd41f2dcbeeb13e01
2021-12-04 21:11:18 +00:00
drh
067c60cfc9 Add VdbeCoverage() macros. Adjust the Bloom-filter hash function so that it
correctly deals with zero-blobs.

FossilOrigin-Name: 629ee2e3e3125bfd2af435c6713d49e46691213ad15db0a5e93a63a77f1130c2
2021-12-04 18:45:08 +00:00
drh
770dade262 Apply the Bloom filter only on those terms of an index that have equality
constraints.

FossilOrigin-Name: a70429596a3c6a413b03118b0d800521b3526d99dcf88a48acc3189b51518d82
2021-12-04 14:24:30 +00:00
drh
19ce9aafdb Add the "WITH BLOOM FILTER" clause to the EXPLAIN QUERY PLAN output for
cases were a Bloom filter is used.

FossilOrigin-Name: 8e078c0e404fe4b3661dd4a11a992a8914c99e2a144cecc417421cbd68fa08cc
2021-12-04 13:52:08 +00:00
drh
fa35f5c5a7 First attempt to use Bloom filters to optimize star-schema queries.
FossilOrigin-Name: 28161fba9bcde5ae4b36b22d766c881b795af111a3a323c90f6149d0fea9297d
2021-12-04 13:43:57 +00:00
drh
7439d3580c Merge the sqlite3WhereBegin() simplification from trunk.
FossilOrigin-Name: 41ba2dfdd3a18671fc78d60935a16fa50f36af3d6481eff2ca9fba88e7093997
2021-12-03 19:10:17 +00:00
drh
70b403b667 Factor the noop-join-elimination optimization out of the sqlite3WhereBegin()
routine and into a separate "no-inline" subroutine, in order to reduce the
complexity of sqlite3WhereBegin() and thereby encourage C compilers to
inline sqlite3WhereCodeOneLoopStart().

FossilOrigin-Name: 6225e9abcb0261fefca4a26530524ffc449f937f8ae1ece718af2c3c3d73d78d
2021-12-03 18:53:53 +00:00
drh
2b05905521 Merge recent trunk enhancements into the bloom-filter branch.
FossilOrigin-Name: 11d97fb8be6b5155f38df130d7e828edd0f381e32f651458939b1cb9cb973fff
2021-12-03 16:02:05 +00:00
drh
60a8e1b43c Fix exprAnalyze() after recent performance enhancements so that it is able
to handle IF_NULL_ROW opcode correctly, again.

FossilOrigin-Name: 8029e6bab508bf0b8ec1df00a829c5d4de2a84d66dc56b9ff03da879ceef7788
2021-12-03 15:48:42 +00:00
drh
11e4fdb948 Fix unreachable branches resulting from prior optimizations.
FossilOrigin-Name: f3d6853ee80be2dc6d7236d98b850beb0e1931a624d4f5b194c8db742cde7ec5
2021-12-03 14:57:05 +00:00
drh
fd4bf7746b Fix an over-length source code line in build.c. No logic changes.
FossilOrigin-Name: b9db5c5fc618a36d70ea2aced9c96094d665935b5c15a987013334f1bd79eb00
2021-12-03 14:43:49 +00:00
drh
2f0bc1d41b Performance optimization in the B-Tree cursor allocator btreeCursor(), making
it about 800K CPU cycles faster in speedtest1, and reducing the executable
size by about 100 bytes.

FossilOrigin-Name: 9df939716ace8cfe60340bbe83fc52d452ea40c29c856c588f9a1b8973282391
2021-12-03 13:42:41 +00:00
drh
65a3c8508d Optimizations to exprAnalyze() and sqlite3WhereExprUsage() save about 1.5
million CPU cycles for speedtest1, and result in a smaller binary.

FossilOrigin-Name: 1f2252e65dc5847c82246fab87dcad035bf594ba7c45362de87a009b7ebcf2d6
2021-12-02 18:15:16 +00:00
drh
daebb0f9a0 Move the TK_IS token so that it is adjacent to the TK_IN token, as this
allows the C compiler to optimize better, resulting in a slightly smaller
and faster executable.

FossilOrigin-Name: 8832fa9088414a8d285a457a4effad0b7d610a87ca73cfb5c5812e784649761e
2021-12-02 14:28:36 +00:00
dan
1872c5bd43 In the shell tool, avoid modifying internal data structures until after the arguments to ".open" have been parsed.
FossilOrigin-Name: fcc509d325dabe06275e7804183bb8b4ba6470a45b443bc8292eecd0974e6367
2021-12-02 14:16:30 +00:00
drh
cbb7746caa Remove an unnecessary branch from exprAnalyze(), resulting in a small
performance gain.

FossilOrigin-Name: 3312be1db3519074393573265459f6a1eeabce541a9ef4d93689529ea2b8f739
2021-12-02 13:45:10 +00:00
drh
cdd9050396 Small performance optimization in sqlite3WhereClauseClear().
FossilOrigin-Name: 080b35e62e5c6bb4ea162bc75232b81e54da5e3e01e762127e228400e8afef1d
2021-12-02 12:55:05 +00:00
drh
844a89b518 More small performance optimizations for sqlite3WhereGetMask().
FossilOrigin-Name: 3de2c557d915d1b4a9b0e540d5e80ffb243e7123d0ec65c5052f4d6f1cce56b2
2021-12-02 12:34:05 +00:00
drh
dae2a10934 Small performance optimization in sqlite3WhereGetMask().
FossilOrigin-Name: 7edec54ab045c0493fc5d27d47d7bf0e08d3b0b298f428646fd3f0ee24dfcade
2021-12-02 04:00:45 +00:00
drh
79ab384121 Small performance enhancement for whereScanInit().
FossilOrigin-Name: ed84e124c6097b756ca687ac64df7ee801d14b16c835f1a9e8b336f785157d85
2021-12-02 02:22:35 +00:00
drh
9b3bfa00cd Performance improvement in query planning.
FossilOrigin-Name: ca59533bbb7f21d7b39dee7999d3f36ac516f8c75b2203039beeb2852ada42d4
2021-12-02 01:30:16 +00:00
drh
879ac4d673 Merge trunk fixes into the bloom-filter branch.
FossilOrigin-Name: 0864bfbf079a98beaa484911edb17c3dc728e78eca231d4247b282fd824cc098
2021-12-01 21:07:05 +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
2db144c33b Add a Bloom filter to the automatic-index mechanism.
FossilOrigin-Name: 50ac4de1d7cbb586ea7969e1ae80ea8b021e194edc2fa7db19374b4ee9369bee
2021-12-01 16:31:02 +00:00
dan
4baf43ff64 Add the "static" qualifier to some internal functions in code for various SQLite extensions.
FossilOrigin-Name: 8c986782547211098eb0e4e722eda0097421223af279381373d0055211b5e9d2
2021-12-01 11:03:50 +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
78679a4950 Merge in the proposed date/time function enhancements: (1) Add the
unixepoch() function, (2) the 'auto' modifier and (3) the 'julianday' modifier.

FossilOrigin-Name: 19c51b46e4095ee28badb10f4e08bbd330bda320c9a8806e93b8fc60ba211a2e
2021-11-29 18:09:54 +00:00
drh
4a0a98d3fd Bump the version number up to 3.38.0 in order to begin the next development
cycle.

FossilOrigin-Name: 8ad1fcaa1b734e32d8d67c4cca7a23d2b9717ae5c7c2c5ad5a3411a503ee23ae
2021-11-29 17:55:12 +00:00
drh
1312a9c908 Add the unixepoch() function and the 'auto' and 'julianday' modifiers.
FossilOrigin-Name: 559fdc0aa76f4c207f99f7b0cee42043b402dc388165817529d9963b115a798c
2021-11-29 17:23:27 +00:00
drh
6df8c0cd3b Following a prior error, an ALWAYS() in sqlite3ExprCanBeNull() might be false.
dbsqlfuzz 5dbec6678a20e7595a34dfdd869a3b9722b3ca43.

FossilOrigin-Name: 4e207401acce1bdc17025f2d55bd94234b435e286cd43e1eda03b6949a2a91d3
2021-11-28 19:54:38 +00:00
drh
315e3122c3 Version 3.37.0
FossilOrigin-Name: bd41822c7424d393a30e92ff6cb254d25c26769889c1499a18a0b9339f5d6c8a
2021-11-27 14:13:22 +00:00
drh
14851b9a14 Fix a harmless comment typo.
FossilOrigin-Name: 7c567338ae4dd31097e9ae5c693b84369c35c5a52534797e8186b4be7297ba78
2021-11-27 12:03:51 +00:00
drh
855a165fec Add platform "Darwin-arm64" to test/releasetest_data.tcl.
FossilOrigin-Name: 1d5c9aacb8ab6349935561cc12734cf348c12c86e4663ddc7af113b3ed0f6186
2021-11-26 20:26:37 +00:00
drh
913306a53a Improved defenses against integer overflow when computing the size of a
memory allocations.  No bugs were fixed here.  But perhaps future bugs will
be prevented.

FossilOrigin-Name: eb878c01f317f09e8ef6b1bd2ec8d6d5cd6ce0bdfe9da7fa7d92d2047cc9d9e4
2021-11-26 17:10:18 +00:00
drh
e574a9233c Fixes to internal comments. No changes to code or documentation.
FossilOrigin-Name: 1489b196ce82cddf7360aff6c89219ca25e666187f0f5ff6419ba3b504cdef8d
2021-11-26 15:08:55 +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
622bd63c33 Update Makefile.msc to support target "tcltest" in the same way as the autoconf build system.
FossilOrigin-Name: 0f131b92252afc95c8c2d160d4be9ac2a737a610ee355efcd819f1af3bae3c56
2021-11-24 11:33:01 +00:00
drh
b0906b6088 Changes a test pattern for RBU so that it works regardless of whether newer
TCL versions are used.

FossilOrigin-Name: 5a9921c92ade9e13c3e49c50325c96e3264f3ad352a187387a960783a68bc9d3
2021-11-23 22:28:09 +00:00
drh
7907d372bc Fix a compiler warning in the dbserialize method of the TCL interface.
FossilOrigin-Name: ba71d030fef4cd4251dc882acc6897dbf9aaba498652900c491b082add87404f
2021-11-23 12:59:25 +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
drh
9f9bdf9345 Fix the build for SQLITE_OMIT_CTE.
FossilOrigin-Name: d7ef96bae459f800241483fe8784552d18ee7f92f408f6453ac687de5530bbb9
2021-11-22 13:35:40 +00:00
drh
156d44104a In the previous check-in, do not overwrite the SQLITE_CORRUPT signal with
an SQLITE_OK before exiting fts3auxNextMethod().

FossilOrigin-Name: 396688ae5c10b9e7df1c76a3c6f548abf7a7ddad50c25fb23e194201dbb2e857
2021-11-22 12:59:44 +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
drh
a51e60079f Small performance increase and size reduction for sqlite3ExprCompare().
This change also handles some corner cases without the need for ALWAYS().

FossilOrigin-Name: d814ba6effc7c5b021ff625b57371627f3ee326687c508da99f78bc164386b7e
2021-11-19 19:11:58 +00:00
dan
d9137e3be0 Fix a benign data race in os_unix.c that might trouble tsan and similar tools.
FossilOrigin-Name: 95806ac1dabe4598170061d903ae30f09bafac149ff6696963a7e056ac846cdb
2021-11-19 14:02:43 +00:00
drh
5e90794b67 Minor tweaks to the way auxiliary tools are built, to make it easier to
customize the builds without having to alter the code.

FossilOrigin-Name: 90b06b6f42918852cfb15258be462c6bed260c6a618b86fa9084bac72fa2f58f
2021-11-18 20:56:59 +00:00
dan
826ec6013c Fix a performance regression in rtree introduced by the previous commit.
FossilOrigin-Name: 7f42b8e1a25c0830fe81e4668318998af595826784a50780a5c1c0b4d95a2482
2021-11-18 20:11:31 +00:00
dan
895c807a6d Fix a problem slowing down the handling of == constraints in the rtree module.
FossilOrigin-Name: 509027e964f28efca088a41fe32f01c38316f7a919de63a8835e3bc7c3fb0787
2021-11-18 19:15:40 +00:00
drh
9cd0c3d4c5 Improve CSV quoting in the CLI using the strstr() function.
FossilOrigin-Name: b7927bf91049c903730a280484bbcdcdedc259a31fbcc3d3b0c7d046ec321633
2021-11-18 15:40:05 +00:00
drh
e41d30ffdd Fix an obscure problem associated with quoting of CSV output in the CLI.
FossilOrigin-Name: 38a9b660214c06aa6650c6bb11a429a8c74c09f1e0e5c18d691e36de4af7af71
2021-11-18 13:25:31 +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
drh
9dc718856f Strengthen the sticky-CORRUPT idea of check-in [3feb0f1c3840904d] by
automatically changing the first COMMIT after an SQLITE_CORRUPT error into
a ROLLBACK.

FossilOrigin-Name: bd66ab8a1bc3c43a57c7caff5f54545b0feb0177f1f51492f30d308c123c43ba
2021-11-15 19:10:13 +00:00
drh
3ce76a0bbb Small performance optimization in sqlite3VdbeHalt().
FossilOrigin-Name: 9e1ecf438cb01d3d76950bcce1b3e4df29bedbb8176c8cede27e66f8e53e2098
2021-11-15 18:50:02 +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
5b001cc25d Improved context shown for the "ABORT-due-to-error" output line when using
"PRAGMA vdbe_debug=on" in an SQLITE_DEBUG build.

FossilOrigin-Name: c7776369bcd0dbeb418b14d5dc681a81ee426234cc3f4f79a3c899d7892e1560
2021-11-15 13:22:42 +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
146121f5cb Improved handling of OOM while reallocating a column name to add type
information.  dbsqlfuzz 5a195b4233649e49e0aa34f1b743ca192d85b198

FossilOrigin-Name: 5995dd4de4997c43b43befc1281ef6378f33f781134c7f368299d64db2344f1d
2021-11-12 14:39:49 +00:00
drh
9135ebb7db Make sure the rowid value returned by the VUpdate opcode is always initialized.
FossilOrigin-Name: 150b5be5d5771485f521e3a58312596ecdcd35f3a0ae9d42d88bb99348a197c4
2021-11-11 23:52:44 +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
3ab4ffce1f New assert() statements to help prove correct usage of VdbeCursor objects.
FossilOrigin-Name: 7cee62f77a9e7c3cf886f136e75a93c3bbbb88e48b66035883bea5503d9fc03c
2021-11-11 11:23:08 +00:00
drh
34e71830de Load new test cases into test/fuzzdata8.db
FossilOrigin-Name: 8b53ffe99df6f5443bd22a9d95433819eb44c7e8f044c2f3e9d52661741d5612
2021-11-10 15:23:00 +00:00
drh
46c425b4dd Make SQLITE_CORRUPT sticky: If a CORRUPT error is returned, all subsequent
write statements within the same transaction also fail early with
SQLITE_CORRUPT.

FossilOrigin-Name: 3feb0f1c3840904d28fc9a61262820e2b9b764addc1dd178aecc2cd0f952042c
2021-11-10 10:59:10 +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
drh
4e86aa86ea Fix lempar.c so that Lemon can compile with NDEBUG defined.
[forum:/forumpost/f331adca0b|Forum post f331adca0b]

FossilOrigin-Name: ba4fb51853fbcb8c142a350b4db0d59153f28ba0a63ad9a2d6fea7096d3dd544
2021-11-09 01:48:15 +00:00
drh
90cf38be63 Refactor the code that figures out which SELECT in a cascade of nested queries
a particular aggregate function belongs to.  This fixes the problem
reported by [forum:/forumpost/c7cc2aa3546e39c1|forum post c7cc2aa3546e39c1].
New test cases in dbsqlfuzz and th3.

FossilOrigin-Name: 74aec5dd1df95b5635f4da1f13753f113ea1d61de3dc3a1523ba51089c1900e4
2021-11-08 23:24:00 +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
drh
7b108e4cfd Add ALWAYS() to a branch made unreachable by the previous check-in.
FossilOrigin-Name: 0dc963f63aebc42960125f96865029f16b3f6867126aab350da12882505edb82
2021-11-06 20:25:29 +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
6821575ed8 Add the rbu_exclusive_checkpoint query parameter to RBU.
FossilOrigin-Name: c2d33ea9d81975b27fe157d698033e7c01569cc0aa6178b7f0c43afbfba4a9e2
2021-11-05 22:35:09 +00:00
drh
64d5b1ca27 New test cases for rbu_exclusive_checkpoint query parameter.
FossilOrigin-Name: 00285ff10c771066876896b28cd5185ec3792166b00702326954ef6678f19da8
2021-11-05 22:23:17 +00:00
drh
c18e022f15 Update an assert() statement to conform to the changes of the previous check-in.
FossilOrigin-Name: b5c668cac831425fd3e370142f9ea501bf2ca1c77c3eb0c5b8f0a574f7667b3c
2021-11-05 19:52: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
1182e2ac7d If the target database URI passed to sqlite3rbu_open() is contains the option "rbu_exclusive_checkpoint=1", hold an exclusive lock for the duration of any incremental checkpoint operation.
FossilOrigin-Name: 7cb77296a22a87e7ed4c3544792f0204f704f01f384590c32c256bec4517c9bc
2021-11-05 19:04:01 +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
drh
608af68ad3 Use the FTS_CORRUPT_VTAB macro rather than a direct call to
sqlite3Fts3Corrupt() in [2fad2a89527757b3] so that the build works
in all cases.

FossilOrigin-Name: 029c59cdf9e7dbb431f5d110bc69c3597458edc9b6b009b2e91422de705a19fa
2021-11-05 12:34:06 +00:00
drh
a1c4c3c187 Remove an incorrect NEVER() reported at
[forum:/forumpost/5bbabfb7ce|forum post 5bbabfb7ce].  Also use this
opportunity to improve the isSimpleCount() function with better formatting,
an expanded header comment, and some extra assert() and textcase() macros.

FossilOrigin-Name: 2927185be81a5aa0dce70dd06040d05c2816a4d18b5094a6f709732cfd6968dc
2021-11-05 11:52:33 +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
a1d35da5f1 Fix typo in the sqlite3ext.h file.
[forum:/forumpost/63802db4ce|forum post 63802db4ce]

FossilOrigin-Name: d4a48ee0c28def416f75eb7840ba6462389e3f97e0dc02287bf1a726c8642f04
2021-11-04 15:17:42 +00:00
drh
a4a871c286 Show the preferred schema table names in the output of "PRAGMA table_list".
FossilOrigin-Name: 9147390d9885a37a62edc1058f313434627f1b59965c890877d2cb119e355c78
2021-11-04 14:04:20 +00:00
drh
06b7281c94 Change a branch made unreachable by the previous check-in into an assert().
FossilOrigin-Name: 685a987c9afd1c30629c36f1ffb5e349eb2e26182837523036b916c6f81632c4
2021-11-04 11:34:04 +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
0b97189c49 Remove two incorrect assert() statements added by a check-in from earlier
today.

FossilOrigin-Name: 3206edff947b9edb485466f05b2baadf725d798229630c7e83e88c0b9ae278ca
2021-11-03 16:35:23 +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
5f29c602aa Correctly handle SeekScan on an IN operator of the middle term of an index
when the right-most term is a range constraint.
Fix for ticket [5981a8c041a3c2f3].

FossilOrigin-Name: aa24660e76681d164b1948621d3dbd0f620c72c6bca636d35a9eed73ab7593fa
2021-11-02 22:24:19 +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
drh
61a8ad7cf9 Ensure that ALTER TABLE RENAME recognizes OOM errors while parsing
dependent triggers and handles them appropriately.
dbsqlfuzz 53e245eee15d3f19639d773048aa955c30708785.

FossilOrigin-Name: 1d9004cd015073853ce0ca811a68ea5411733eedee993b97a38a42ba139d7590
2021-11-02 17:55:01 +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
dan
a12a40c3f0 Add #ifdef logic to os_unix.c so that it builds with SQLITE_OMIT_WAL defined.
FossilOrigin-Name: 948c2cb2a2f44ba069cfbf5e9a57e56964f3a40db57459bb439bea9c3bd9f211
2021-11-02 11:09:24 +00:00
drh
0c0fb9cf80 Fix a minor typo in a comment.
FossilOrigin-Name: 06a5bf4348d3125bb5407fe9b7d451800b113a91fd1a9dff7d840e2317a7284d
2021-11-02 10:54:39 +00:00
drh
1cd6042f90 Add recent dbsqlfuzz cases to test/fuzzdata8.db.
FossilOrigin-Name: 8c3f2536d2853acef05c4e8c07f301abb0687402c56ded5ff8614e79fb049423
2021-11-02 10:47:20 +00:00
dan
76c3ae6848 Fix a broken assert() in fts5 that could fail if the snippet() function were used with a query phrase containing 0 tokens on a detail=none or detail=col table.
FossilOrigin-Name: 0a5b94b99cf45df759a59cb5fc62da111ca33f8c2614769a81930d72b51f093a
2021-11-02 07:32:13 +00:00
larrybr
8f09f4b264 Add globbing option to shell's .archive command.
FossilOrigin-Name: 13fb74ac5e7578ab612af2ccc8147569d60dc35af84f496bcc5d648d223d6d6e
2021-11-02 00:18:11 +00:00
larrybr
719506f9af zap trailing whitespace
FossilOrigin-Name: f2a908e9c86efb11bb179ce7121f0d510f952284891abfa69517b773fd88324c
2021-11-01 22:33:20 +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