Commit Graph

19505 Commits

Author SHA1 Message Date
mistachkin
88edc6c72a Set SQLITE_PTRSIZE to 4 when compiling with xlc on 32-bit AIX.
FossilOrigin-Name: d158e5b12eec5b81d54c8f5902a972795423947a21d0212b6cceb2810aa6cc5c
2018-08-24 19:04:08 +00:00
drh
ba3a4072b4 Automatically detect when compiling for AArch64 on windows and set
SQLITE_BYTEORDER to little-endian to avoid compile-time testing.

FossilOrigin-Name: ef6729be85ed106212ed23a024d83b85b709207cf287436c0603a21c659f36ad
2018-08-23 18:56:33 +00:00
dan
79e9d34764 Fix a test case that was failing for SQLITE_ENABLE_STAT4 builds.
FossilOrigin-Name: 1e29fd430dead641c5d92943ce81cf51b3df2f45c5a011bb2eed592efd62e056
2018-08-21 17:03:25 +00:00
drh
f396ecadcd Further attempts to reduce the number of false-positives genenerated by
static analysis tools.

FossilOrigin-Name: 38f9ce6503c4dd05ccdd73463b1784a6df7ed6e5018c29c5874a3681ca34ba54
2018-08-21 12:46:34 +00:00
drh
c4ceea72b7 Fix various harmless warnings generated by static analysis tools.
FossilOrigin-Name: a04a0ea9e30e0ef12bafa0b90b7d1b7764865768bb4a738b0c73a7a3ef9416db
2018-08-21 12:16:33 +00:00
mistachkin
ed5e7722b2 Fix harmless compiler warnings only seen with STAT4 enabled.
FossilOrigin-Name: 6f5e84bafcaf425cb664c7db8179c9c09a13c96aaf057551c04a919ca554d057
2018-08-17 21:14:28 +00:00
drh
3fcef1a3f9 Fix a harmless unused-variable compiler warning that only came up in certain
compile-time configurations.

FossilOrigin-Name: 456842924bb33c0af8af29402f06e5f25b6791f698a0d12a080258b20b0cfb61
2018-08-16 16:24:24 +00:00
drh
d8852095e0 Fix EXPLAIN QUERY PLAN so that it describes IN operators implemented using
a ROWID lookup.

FossilOrigin-Name: 60045fbf52162f15f2e18a4e392e80fab19bdbce242728b5e62b0894eac49dfd
2018-08-16 15:29:40 +00:00
dan
588032fe33 Allow sqlite3_snapshot_open() to be called to change the snapshot after a read
transaction is already open on database.

FossilOrigin-Name: 41399169954f9bef53c3fa89879f39823b80bd127f76cf60abbe24217878a571
2018-08-15 14:03:26 +00:00
drh
8430450674 Fix UPSERT so that it checks the target-constraint first and fires the
DO UPDATE if that constraint is violated regardless of whether or not
other constraints are in violation.  This aligns SQLite behavior with
what PostgreSQL does. Fix for ticket [908f001483982c43cdb476dfb590a1a].

FossilOrigin-Name: 529fb55e3d00472f13446117527b0896827b11e870b581af7fe7cbb7392ef3cd
2018-08-14 15:12:52 +00:00
drh
ef52b36a6b Stop requiring the global VFS mutex to access the unixInodeInfo.pUnused field.
The unixInodeInfo mutex is sufficient.

FossilOrigin-Name: e3ea43dabf099dc2954c23d348638e7b2a8b9122d2994154bc649a2c09260c46
2018-08-13 22:50:34 +00:00
drh
095908e1c7 Take extra precautions to ensure access to unixInodeInfo.pUnused is protected
by all necessary mutexes.

FossilOrigin-Name: 8b1e0010b9e0b548a90087f4d25843d2b40f7e9551722ac587fa925d37b510c2
2018-08-13 20:46:18 +00:00
drh
3e2c842e46 Fix an incorrect comment on the unix-nolock VFS object. No functional
code changes.

FossilOrigin-Name: 90f7c193b42f0d8120a8e429bdea5e1cec5d3f45b901db8fc5a5c2ca3e69cba8
2018-08-13 11:32:07 +00:00
drh
ad9f515f52 Fix the isLikeOrGlob() routine in the WHERE clause processing logic so that
it avoids signed/unsigned character comparisons, as that can lead to an
incorrect answer if the ESCAPE clause is an invalid UTF8 string.  Problem
found by OSSFuzz.

FossilOrigin-Name: 4195a3f8b5d2c2ec63771890c5aa7b5e2de60b9fa2273652730239b8577ae418
2018-08-09 21:45:45 +00:00
drh
d98f53249c When a column must be a constant due to WHERE clause and the value of that
column is being coded as a constant, make sure the affinity is correct.

FossilOrigin-Name: 7404ea83168e6c739ebe8fc5d65bbf0265432ccb35b3418bb0381d74362f7527
2018-08-09 18:36:54 +00:00
mistachkin
6389a7b0ac Minor style improvements.
FossilOrigin-Name: 60bbca2b9a591800cd8e7b374e62d75b1df0e8fd2d2f71f9b4d5fd044da78be0
2018-08-08 20:46:35 +00:00
dan
fa3d4c19a9 Allow sqlite3_snapshot_open() to be called to change the snapshot after a
read transaction is already open on database.

FossilOrigin-Name: 051ac0152048ef52723196c26ca5f2629dafb782aec1c66fc30531bf54335043
2018-08-06 17:12:36 +00:00
drh
f018fd5284 Enhance the edit() function so that it converts text from \r\n back into \n
only if the original unedited copy contained no \r\n values.

FossilOrigin-Name: 20c995d3f0f4de5410962172cb59da0f25edf0c62e199420186cc59ea874e981
2018-08-06 02:08:53 +00:00
drh
5180d683a0 Add the --info option to the fuzzcheck test utility.
FossilOrigin-Name: 1caaaaa70f21fe71fbe0af227eea8d1367870e2575eedf248cc2a0b515783390
2018-08-06 01:39:31 +00:00
drh
24846bc0bf Fix an overzealous assert() statement discovered by OSSFuzz.
FossilOrigin-Name: d9c9fe9f5ad3fc9123ad29ebafcb7f40dcecd448fb7a928bb31bea8181d81ec1
2018-08-06 01:21:53 +00:00
drh
dda7e66d7d Remove the column-cache from the code generator. The column-cache has been
a persistent source of bugs for years and with recent improvements
in the performance of OP_Column, it no longer provides a benefit.  After
the column cache is removed, the binary is almost 2KB smaller and the
speed-check.sh performance test is over 3 million cycles faster.

FossilOrigin-Name: cdff3af7bedc5ebea04bd9b5e2112d3db451a475c18c9a9ebd45f6f3a89a43cb
2018-08-04 20:30:55 +00:00
drh
cfdeeeb966 Remove a testcase() that is no longer reachable without the column cache.
Provide an assert() to help prove that the testcase is no longer reachable.

FossilOrigin-Name: a500893b6f64aced197cd32b79d51a481629a39d45dbcf0f02d65e5451ac4706
2018-08-04 20:12:10 +00:00
drh
36a5d88dde Fix comments that were made obsolete by the removal of the column cache.
FossilOrigin-Name: 2041231d56c7b02b785015ef4d1af260d61326eab1b2a304c17faa3e33f76441
2018-08-04 17:15:56 +00:00
drh
c6ed275fcb Remove more column-cache residue: The OP_SetColTab and OP_VerifyColTab
opcodes and the associated SQLITE_DEBUG_COLUMNCACHE logic.

FossilOrigin-Name: 80236e81cefdf3d3cda3dbdb6de1575c38e4e248cc4b72ca9ee96d3aa0464bfd
2018-08-04 16:54:53 +00:00
drh
8c60719132 Further logic simplifications that flow out of the omission of the column cache.
FossilOrigin-Name: 7d9072b027cc28dd8ecf5e2686d821017997445c15124eebe2839984622af4db
2018-08-04 15:53:55 +00:00
drh
bb9c45b49a Add test cases for the constant expression fix of the previous check-in.
FossilOrigin-Name: 95db5bd9fea86a10c9528dd24841e1370dfdc0bbb5c98b7cbd808a8bc59dd48f
2018-08-04 15:28:12 +00:00
drh
b8b0669065 Ensure that all expressions that are to be evaluated once at the start of
a prepared statement (the Parse.pConstExpr expressions) pass the
sqlite3ExprIsConstantNotJoin() test. It is not sufficient to pass just the
sqlite3ExprIsConstant() test as that would allow through column references
that are bound to constants by the WHERE clause in the constant propagation
optimization.  This fixes a problem discovered by OSSFuzz.

FossilOrigin-Name: 8bc7f84c39f913b0b0f5e9f5fd9d7dd8bda8422248c069712b6992c32c759a83
2018-08-04 15:16:20 +00:00
drh
38ee2d9197 Remove additional traces of the column cache.
FossilOrigin-Name: db6052e9725368736abd19f14f97376582d35d07f543046d39991d767ed29851
2018-08-04 14:30:21 +00:00
drh
02ceed058a Completely remove the column cache logic, which has been a persistent source
of bugs for many years.  We recent enhancements to the performance of the
OP_Column opcode, the removing the column cache actually makes speed-check.sh
run faster.  It also saves about 1,800 bytes of code space.

FossilOrigin-Name: 3f5f60cd7529330209027fdae8129cca420cec1050eae50a7750d0b715b56972
2018-08-03 23:04:16 +00:00
dan
a4b5fb55f3 Fix the handling of sub-queries with LIMIT clauses by the optimization
activated by compile-time symbol SQLITE_COUNTOFVIEW_OPTIMIZATION.

FossilOrigin-Name: 21235d9a41567897418aa12f7bd6dd8d6ee363147527e1d8fbca14fc83e0f2c9
2018-08-03 20:19:52 +00:00
drh
e4fe6d4e62 Fix the OP_SeekRowid opcode so that it has no type-change side-effects on the
key register in P3.  This fixes an obcure problem that arises when doing
equi-joins between a table with a TEXT column against another table with
an INTEGER PRIMARY KEY.  The original problem was discovered when OSSFuzz
created such a query and hit an assert() in OP_VerifyTabCol that was
specifically designed to catch these kinds of errors at run-time.

FossilOrigin-Name: fa94b49e02eb6b8fc4acc220ecc2fabef546c65845696758b25965c26b251ea9
2018-08-03 15:58:07 +00:00
drh
5eae974c48 Improve "PRAGMA vdbe_trace=ON" to always show the key values for the
OP_IdxGT and related opcodes.

FossilOrigin-Name: 0f881955ed173c7c35dfca2d4aeca855858e40bb951e6fb6fedd9a2fff6a5a86
2018-08-03 13:56:26 +00:00
drh
884406b42c In the command-line shell, always exit if realloc() fails.
FossilOrigin-Name: e390023c8e70961661fd9e29674dedacd1b941b6b8d9cd88f8cfa8f787f030f9
2018-07-29 18:56:35 +00:00
drh
f559ed3400 Add a small cost penalty to sorting to bias the query planner in favor of
plans that do not require a final sorting pass.

FossilOrigin-Name: 85b9beb4605eb0cfe2ed063c2a1925186c9e37031f78c875e60a347cce891638
2018-07-28 21:01:55 +00:00
drh
07aded63f4 Do not allow a column reference that is converted into a constant by the
WHERE-clause constant propagation optimization to be moved to the init-time
constant expression list, as the table reference will not work there.
This fixes a problem found by OSSFuzz.

FossilOrigin-Name: d30b2a947313b146f29e2b53f0fd471409fda7938151241d3fb5863614f88999
2018-07-28 16:24:08 +00:00
drh
1fd4e7bb0c Fix an assert() statement that was made obsolete by the constant
propagation enhancement.  Problem discovered by OSSFuzz.

FossilOrigin-Name: e4b4737e348235e196a45e1b71876b82e0cc836e1c5c16ea5f9333b7509b59b8
2018-07-28 14:56:56 +00:00
drh
d2a4401c8a Improved debugging output when the ".selecttrace" option is used in the shell.
FossilOrigin-Name: fcb88dd6b0f248f600c1158907889f6d5fa2c96eb4585221941da4673c6db6eb
2018-07-28 14:34:22 +00:00
drh
954733b386 Improvements to the parser to increase coverage. Fix the parser so that
at least one expresssion is required after PARTITION BY and within the
list of expressions on VALUES().

FossilOrigin-Name: 02204f8b246c868846f39bd44f2e3bc0fab0275aa09ef3a0e5a8e3d58f484ca8
2018-07-27 23:33:16 +00:00
drh
cf8e0861a2 When doing a DROP VIEW do not try to delete entries from the sqlite_stat1
table as there are none.

FossilOrigin-Name: 7efdba2bbc8547ee9292a1bbd1e61d38b40d7aabc0860ceba188bdec539f5114
2018-07-27 22:55:58 +00:00
drh
550a33091b Minor grammar changes that help the parser run faster by reducing the
number of NUL rule reductions.

FossilOrigin-Name: cfd1b00592bd550e444dfc7b6a6a93c77c07b835729c6cc69a4b6361038964ba
2018-07-27 22:14:50 +00:00
mistachkin
1f237e3f52 Enhance Makefile for MSVC to support building the shell tool without using the amalgamation.
FossilOrigin-Name: 3d815d83a6805938b87e03ffabe6d71ca2ecfd05052e8e02c6cc5d3c9ea4ddf3
2018-07-27 20:45:28 +00:00
drh
2d475e80bd The WHERE-clause constant propagation optimization attempts to use
transitive laws to replace column values with constants in the WHERE
clause in order to help to query planner make more aggressive optimizations.

FossilOrigin-Name: f4229707ac08d66c5b0f53483ce17a63f5ac40a21922f66c3408e1b6fda3a7c2
2018-07-27 20:37:42 +00:00
drh
9cbf4f3550 Reduce the performance cost of the constant propagation optimization to
less than 200,000 cycles.

FossilOrigin-Name: 865249de683e6971984a645a30d96f9fcc6f6d9d7af7e269ff68cc3e42e5fe71
2018-07-27 20:01:00 +00:00
drh
e081d73c46 Performance improvement to sqlite3ExprCollSeq(). With this change, the
performance of speed-check.sh is within 400,000 cycles of trunk.

FossilOrigin-Name: a5f86f49b7d9e52546f234f7c3bcbac6b0f78aa55a71c44ca69e21bc31139f3e
2018-07-27 18:19:12 +00:00
drh
bcd15938ae Faster implementation of sqlite3IsBinary().
FossilOrigin-Name: be05d0db09f43cc3362c28273463d1d236af737a4f8a494cf1050da07ed0df47
2018-07-27 18:12:40 +00:00
drh
7810ab6464 Only run the constant propagation optimization on joins since that is the
only scenario where it is useful.  This saves prepare time for the common
case of a simple query.

FossilOrigin-Name: 598d608359005b13fa1151c6c69f2fd12ef3ab7f563a035fc4a6f3c569dc6c67
2018-07-27 17:51:20 +00:00
drh
efad2e2366 Constant propagation is now restricted to just the WHERE clause. The
mechanism is changed to take affinity and collation into account.  This
seems to give correct answers.  But the search for constant propagation
costs 4 million cycles in the speed test.

FossilOrigin-Name: 82c67efb723dba387964f690cd459b420e59e3367d9589016597a76531596391
2018-07-27 16:57:11 +00:00
drh
7de7602eb7 Add a test case demonstrating the collation problem with constant propagation.
FossilOrigin-Name: 50add839fd95665bd67a6ae5de8346fd09e83904bbcbad26fad280dff86d9e93
2018-07-26 23:54:19 +00:00
drh
24e1116e0f Generalize the constant propagation optimization so that it applies on every
WHERE close, not just those that contain a subquery.  This then demonstrates
that the current implementation is inadequate since it does not take into
account collating sequences.

FossilOrigin-Name: 57eb2abd5b270d65be5e0f138f0d46899fa6091df3ba20b0ea7ef04244a15d48
2018-07-26 23:47:11 +00:00
drh
ce705305b5 In the unix VFS, give every unixInodeInfo object its own mutex, rather
than using the global VFS mutex, to improve concurrency in cases where there
are many threads operating on separate database files.

FossilOrigin-Name: 22f47cf430827c50634794a5a33987511bb71492c0dd1f6466a0c5b779d0521b
2018-07-26 21:48:05 +00:00