]> git.ipfire.org Git - thirdparty/sqlite.git/log
thirdparty/sqlite.git
6 years agoMerge latest trunk with this branch. mutexfree-shmlock
dan [Mon, 24 Dec 2018 15:15:21 +0000 (15:15 +0000)] 
Merge latest trunk with this branch.

FossilOrigin-Name: 606b1ead24eb5293d19542105bf2db64c9b1a76840a90a8f2c982146d76c007e

6 years agoChange the way a comparison used to detect corrupt databases in fts3 is done
dan [Mon, 24 Dec 2018 13:34:36 +0000 (13:34 +0000)] 
Change the way a comparison used to detect corrupt databases in fts3 is done
to avoid potential pointer overflow in 32-bit builds.

FossilOrigin-Name: 95a9a39ff784b960b62dd6298e722a620ba3f9c8b76839a49bbef35d7bc84a8e

6 years agoSplit the code generation for the RHS of IN operators and for SELECT and
drh [Sun, 23 Dec 2018 21:27:29 +0000 (21:27 +0000)] 
Split the code generation for the RHS of IN operators and for SELECT and
EXISTS expressions into two separate subroutines, because there is now little
commonality between those to functions. This is intended to help make the
code easier to read and maintain.

FossilOrigin-Name: 2b6494b1509f0d0189f98aa34c990eee99c775ff57826e79b2c5b0a12b4c97ad

6 years agoImprove the coverage of wal.c provided by the "coverage-wal" test permutation.
dan [Sat, 22 Dec 2018 20:32:28 +0000 (20:32 +0000)] 
Improve the coverage of wal.c provided by the "coverage-wal" test permutation.

FossilOrigin-Name: 6231485114eb07b258cd0e6e163ca05f7e9cf5664e071808fcb1329b33e4c4f5

6 years agoCatch another case of a corrupted structure record in fts5.
dan [Sat, 22 Dec 2018 19:54:17 +0000 (19:54 +0000)] 
Catch another case of a corrupted structure record in fts5.

FossilOrigin-Name: fb17fea4b9779fbd3adb6ff9500da83a6ca4fa7cba379aa70074e4328814a7f2

6 years agoChange a faulty assert() in fts5 that could fail on a corrupt db to an if() statement.
dan [Sat, 22 Dec 2018 19:09:46 +0000 (19:09 +0000)] 
Change a faulty assert() in fts5 that could fail on a corrupt db to an if() statement.

FossilOrigin-Name: 1daaba9fb46706af8ed0669a661c304df999a69cf639d29d93208f422c515d8c

6 years agoFix one more instance of excess whitespace in test result strings.
drh [Sat, 22 Dec 2018 16:14:45 +0000 (16:14 +0000)] 
Fix one more instance of excess whitespace in test result strings.

FossilOrigin-Name: c064964deb0b7220ba784f07ca9c603680f3c8bb936d56ab4eca1962beac1359

6 years agoRemove unnecessary whitespace from testcase result strings.
drh [Sat, 22 Dec 2018 15:46:23 +0000 (15:46 +0000)] 
Remove unnecessary whitespace from testcase result strings.

FossilOrigin-Name: ad70f03ceda74163903d247a975666b35fae722a27c48dd3efd31c1164b5627e

6 years agoFix an assert() in fts5 that could fail with a corrupt database.
dan [Sat, 22 Dec 2018 15:21:31 +0000 (15:21 +0000)] 
Fix an assert() in fts5 that could fail with a corrupt database.

FossilOrigin-Name: 83935b950619855fb3bf05486091804ac2a61fb993c6ec826c89f943264fabc3

6 years agoFix a "jump or move depends on uninitialized value" valgrind error that could
dan [Sat, 22 Dec 2018 13:34:52 +0000 (13:34 +0000)] 
Fix a "jump or move depends on uninitialized value" valgrind error that could
occur in fts5 when dealing with a corrupt database.

FossilOrigin-Name: 3518c09b944c92974939b1de244401afd34de5d9aa75050e5ad55581a94e1e71

6 years agoAvoid a left-shift of a negative value (undefined behaviour) when dealing with a...
dan [Sat, 22 Dec 2018 09:39:06 +0000 (09:39 +0000)] 
Avoid a left-shift of a negative value (undefined behaviour) when dealing with a corrupt database in
fts3.

FossilOrigin-Name: b851d12474035328df8354c7da8d81bc78833c8c704153f9f573c19b47a8487e

6 years agoFix cut-and-paste error in test file fts4umlaut.test.
dan [Sat, 22 Dec 2018 07:16:42 +0000 (07:16 +0000)] 
Fix cut-and-paste error in test file fts4umlaut.test.

FossilOrigin-Name: cad5da1bf5f65ad87d97b72e9a84081fde455ba4085e79943fdf6c0144b1ef83

6 years agoDo not all REPLACE to sneak a NULL value into a NOT NULL column. Detect that
drh [Sat, 22 Dec 2018 01:13:25 +0000 (01:13 +0000)] 
Do not all REPLACE to sneak a NULL value into a NOT NULL column.  Detect that
situation and ABORT instead.  Fix for ticket [e6f1f2e34dceeb1ed61531c7e98].

FossilOrigin-Name: db8d1d12f5c1673404b2afb5426d5ea3afe3b69d01f8f2bc47ffdf70684fdf24

6 years agoThe OP_Eq and OP_Ne operators have a special P5 value SQLITE_NOTNULL that
drh [Sat, 22 Dec 2018 00:34:30 +0000 (00:34 +0000)] 
The OP_Eq and OP_Ne operators have a special P5 value SQLITE_NOTNULL that
asserts that the values are not null.  Except that is not always true for
a corrupt database.  Adjust the assert() and add a testcase() to make this
point clear.

FossilOrigin-Name: a3fdb2c78d23b94d68dc08126b22d03152ac6068496a42402cdfb336cd4a7e33

6 years agoUpdate the dbtotxt utility program so that it does not output characters that
drh [Fri, 21 Dec 2018 22:11:37 +0000 (22:11 +0000)] 
Update the dbtotxt utility program so that it does not output characters that
are special to TCL, thus making the output of dbtotxt easier to insert into
test scripts.

FossilOrigin-Name: 48438bb35b48955a1df83ef90f0ef6c9cfed0b16d2e938f36d74ad9d53b4b5b4

6 years agoImproved detection of shadow table corruption in RTREE.
drh [Fri, 21 Dec 2018 22:08:59 +0000 (22:08 +0000)] 
Improved detection of shadow table corruption in RTREE.

FossilOrigin-Name: b39bf4356e6bcf1d8442721d6cbbfe06caba01325104fb469da8fe69e1f623a2

6 years agoAdd new sqlite3_prepare_v3() flag SQLITE_PREPARE_NO_VTAB, for
dan [Fri, 21 Dec 2018 20:18:06 +0000 (20:18 +0000)] 
Add new sqlite3_prepare_v3() flag SQLITE_PREPARE_NO_VTAB, for
preparing statements that are not allowed to use any virtual tables.
Use this to prevent circular references in triggers on virtual table
shadow tables from causing resource leaks.

FossilOrigin-Name: da587d18575ac06a6b65fec1d106f0cc65bc10f493ca6c6b99117a2162d15a52

6 years agoUse SQLITE_PREPARE_NO_VTAB in rtree as well. prepare-no-vtab
dan [Fri, 21 Dec 2018 19:55:20 +0000 (19:55 +0000)] 
Use SQLITE_PREPARE_NO_VTAB in rtree as well.

FossilOrigin-Name: 82a2ae7132964eab0dfad9a8314a399ffd3b72366b35e1767df6452125dd1d80

6 years agoAdd tests for the use of SQLITE_PREPARE_NO_VTAB in fts5.
dan [Fri, 21 Dec 2018 19:30:18 +0000 (19:30 +0000)] 
Add tests for the use of SQLITE_PREPARE_NO_VTAB in fts5.

FossilOrigin-Name: 1999612010e310fc2430d1f00076f69fade0c66d202771dbb0f3d5597ac0a03c

6 years agoAdd new sqlite3_prepare_v3() flag SQLITE_PREPARE_NO_VTAB, for preparing
dan [Fri, 21 Dec 2018 19:29:11 +0000 (19:29 +0000)] 
Add new sqlite3_prepare_v3() flag SQLITE_PREPARE_NO_VTAB, for preparing
statements that are not allowed to use any virtual tables. Use this to prevent
circular references in triggers on virtual table shadow tables from causing
resource leaks.

FossilOrigin-Name: 25666e3d03950caf753295cdb55df162e07dbcf6840b05875c6e0b127c469ecb

6 years agoIn FTS3, avoid calling memcpy() with a NULL source pointer, even if the
drh [Fri, 21 Dec 2018 18:51:27 +0000 (18:51 +0000)] 
In FTS3, avoid calling memcpy() with a NULL source pointer, even if the
transfer amount is zero bytes.

FossilOrigin-Name: 1abb83d29a06308c96bea379311b390240347c5f81824749348d18ad75840c96

6 years agoThe fts4umlaut.test module requires FTS5, so do not try to run it without that
drh [Fri, 21 Dec 2018 18:50:43 +0000 (18:50 +0000)] 
The fts4umlaut.test module requires FTS5, so do not try to run it without that
module.

FossilOrigin-Name: dee3ae900129d39d69aff3ec6187376be100803ee6170bbf39529f37b4253260

6 years agoFix the node hash function in RTREE to ensure that it always returns a
drh [Fri, 21 Dec 2018 18:17:35 +0000 (18:17 +0000)] 
Fix the node hash function in RTREE to ensure that it always returns a
non-negative value.

FossilOrigin-Name: 0bf4c70a6849da74797e8616a4f3730492ad02882ae67a0fe0f3b3cc3f1043b4

6 years agoFix a potential NULL-pointer deference in RTREE due to corrupt shadow tables.
drh [Fri, 21 Dec 2018 17:51:30 +0000 (17:51 +0000)] 
Fix a potential NULL-pointer deference in RTREE due to corrupt shadow tables.

FossilOrigin-Name: 1fdd3604eef880414682e9e6f74d714520fe1c63f267ec4da752d2dc1da6bf72

6 years agoPrevent an infinite loop in rtree that can result from a corrupt shadow table.
drh [Fri, 21 Dec 2018 16:53:58 +0000 (16:53 +0000)] 
Prevent an infinite loop in rtree that can result from a corrupt shadow table.

FossilOrigin-Name: 085667180b230587abb82abfdd14da8859e23620994d5cf152236b64c756dd04

6 years agoFix the RTree extension so that it correctly ignores constraints that it
drh [Fri, 21 Dec 2018 15:13:49 +0000 (15:13 +0000)] 
Fix the RTree extension so that it correctly ignores constraints that it
does not understand, even if they are against a dimension column.

FossilOrigin-Name: ed8531e57596f0d5911a05a26d5ae61e1eccfaadee49219d7f6e212cac288238

6 years agoIn RTREE, turn an assert() into an if() because the condition can
drh [Fri, 21 Dec 2018 13:30:34 +0000 (13:30 +0000)] 
In RTREE, turn an assert() into an if() because the condition can
sometimes be false when dealing with a corrupt database.

FossilOrigin-Name: 99bce4358beb5dbaba47048ee2eec5c376dcd86e5b1462238a37ea4c5f3d77db

6 years agoRemove an assert() that could fail on a corrupt db from fts3_write.c.
dan [Fri, 21 Dec 2018 11:53:43 +0000 (11:53 +0000)] 
Remove an assert() that could fail on a corrupt db from fts3_write.c.

FossilOrigin-Name: 4cdcda408a4edcd2845584ddef64f0efdd2b4cc030afbc05fc2b8b555c69d3f6

6 years agoDo not set the Cursor.seekOp test variable in the OP_NotExists opcode.
drh [Thu, 20 Dec 2018 22:08:32 +0000 (22:08 +0000)] 
Do not set the Cursor.seekOp test variable in the OP_NotExists opcode.
This is a change to test logic only and does not affect deliverable builds.

FossilOrigin-Name: 98f343077887c4d3fc2ca3bbc7f20c80ec37b0e521d70af9c986ab80bb2c7903

6 years agoFix a bug in the code that detects self-referencing rows as part of foreign
dan [Thu, 20 Dec 2018 17:32:33 +0000 (17:32 +0000)] 
Fix a bug in the code that detects self-referencing rows as part of foreign
key processing. Fix for [50d2a6c2].

FossilOrigin-Name: 16fff05347f42fe9fa0f3150290b98b59a9bb921e49dc07ca397aa1de7a7e17d

6 years agoFix a segfault caused by using the RAISE function incorrectly (library now
dan [Thu, 20 Dec 2018 15:04:38 +0000 (15:04 +0000)] 
Fix a segfault caused by using the RAISE function incorrectly (library now
returns an error instead of crashing).

FossilOrigin-Name: ddf06db702761d663119d508afe21d7dfebe963d576bb42fc2f2024205ab86f8

6 years agoIn defensive mode, do not allow shadow tables to be renamed using ALTER TABLE.
dan [Tue, 18 Dec 2018 20:31:14 +0000 (20:31 +0000)] 
In defensive mode, do not allow shadow tables to be renamed using ALTER TABLE.

FossilOrigin-Name: 23e200da5cfbde0798e67cd9e016e4a1cd73b67981e1af841493fcd123d8f547

6 years agoMove variable declaration to address compilation issue (C89).
mistachkin [Mon, 17 Dec 2018 22:19:57 +0000 (22:19 +0000)] 
Move variable declaration to address compilation issue (C89).

FossilOrigin-Name: d64f248da3ce7762fe2c17fbc83f7bea9ffca73723bb3ad0982a85320839da90

6 years agoFix errors in comments in fts5.h.
dan [Sat, 15 Dec 2018 07:12:34 +0000 (07:12 +0000)] 
Fix errors in comments in fts5.h.

FossilOrigin-Name: 4002790d9418289f3e090c694f651a89d8f523119c8ce2f396999b0387148241

6 years agoFix harmless compiler warnings.
drh [Fri, 14 Dec 2018 18:11:02 +0000 (18:11 +0000)] 
Fix harmless compiler warnings.

FossilOrigin-Name: 27221c69901d2b4546167639c4a3c8f54b2e18820f1346870fa26b7c919027db

6 years agoFix possible integer overflow while running PRAGMA integrity_check on a
drh [Fri, 14 Dec 2018 17:57:01 +0000 (17:57 +0000)] 
Fix possible integer overflow while running PRAGMA integrity_check on a
database file with a badly corrupted freelist.

FossilOrigin-Name: 395599116d801324f0763e59bc5e2fc8622aa5b7572e0c1c9a982efbb3cc8280

6 years agoBack out the expansion of the temporary buffer size from
drh [Fri, 14 Dec 2018 16:20:54 +0000 (16:20 +0000)] 
Back out the expansion of the temporary buffer size from
[32754ca6f86da816] and replace it with an explicit test for buffer
overreads.

FossilOrigin-Name: 8ba3d9f38090c4bbbcffba1930e5c26f69ff61f49b72a4a5a59253d37341380f

6 years agoAvoid a buffer overread in ptrmapPutOvflPtr() that can occurs in a
drh [Fri, 14 Dec 2018 16:00:38 +0000 (16:00 +0000)] 
Avoid a buffer overread in ptrmapPutOvflPtr() that can occurs in a
corrupt database file that has large entries and uses autovacuum.

FossilOrigin-Name: f8b781cf41800e9f61a1c5376404a97e76a2bbbcaa17396d42be62f731363947

6 years agoFix a harmless compiler warning in Sessions.
drh [Fri, 14 Dec 2018 13:47:17 +0000 (13:47 +0000)] 
Fix a harmless compiler warning in Sessions.

FossilOrigin-Name: fc9791ea987352e3e1322fbb7f833c23b402432af8249f9d397c6f7456788637

6 years agoExpand the size of the temporary page used during btree rebalancing by a
drh [Fri, 14 Dec 2018 13:35:48 +0000 (13:35 +0000)] 
Expand the size of the temporary page used during btree rebalancing by a
few bytes, to avoid problems with small buffer overreads that can occur
on corrupted database files.

FossilOrigin-Name: 32754ca6f86da8165e274f98f35fc3df3aebd273e9da08387e2d0c3c89abda0f

6 years agoWhen saving the position of a cursor at the b-tree layer, allocate a few extra
dan [Fri, 14 Dec 2018 13:18:35 +0000 (13:18 +0000)] 
When saving the position of a cursor at the b-tree layer, allocate a few extra
bytes at the end of the buffer used to save the key. Otherwise, if the key is
corrupt, the code that restores the cursor position may overread the buffer by a
little.

FossilOrigin-Name: 160b1e31c0f27257c06c2987af9ec3a64abfacb2150325b72e8ccd3d217b5baa

6 years agoFix a problem with bytecode generation when a query involves two or more
drh [Fri, 14 Dec 2018 11:16:52 +0000 (11:16 +0000)] 
Fix a problem with bytecode generation when a query involves two or more
indexes on expressions connected by OR.
Ticket [d96eba87698a428c1ddd0790ea04]

FossilOrigin-Name: 7e4ed8b5c2047b69bbb037497111e56e465a4d9f8afca3b337f9ac744471dc4a

6 years agoPosible fix for [d96eba87]. tkt-d96eba87
dan [Fri, 14 Dec 2018 08:40:11 +0000 (08:40 +0000)] 
Posible fix for [d96eba87].

FossilOrigin-Name: 89a25abfcd069aebdf817890e5c27f46de3000fb858ae01029e4528f9d677567

6 years agoFix a bug in fuzzcheck that cause it to overlook a pointer-map bug that was
drh [Fri, 14 Dec 2018 03:16:17 +0000 (03:16 +0000)] 
Fix a bug in fuzzcheck that cause it to overlook a pointer-map bug that was
trigger by the fuzzcheck test data, and also fix the pointer-map bug.

FossilOrigin-Name: cc42dd15100db28a9796254f69a4e367ea5eae29f546be055017cf3e12aa66ba

6 years agoDetect when an attempt is made to write to a pointer map page that is also fuzzcheck-fix
drh [Fri, 14 Dec 2018 03:14:18 +0000 (03:14 +0000)] 
Detect when an attempt is made to write to a pointer map page that is also
being used as a btree page and report corruption.

FossilOrigin-Name: 3036fd71ac7063359b04a0ed54a6c63a380eb7ff75cd29ed27486d4259066aee

6 years agoFix a bug in the custom in-memory VFS used by fuzzcheck. This bug masks
drh [Fri, 14 Dec 2018 02:29:56 +0000 (02:29 +0000)] 
Fix a bug in the custom in-memory VFS used by fuzzcheck.  This bug masks
other bugs that should have caused some existing fuzzdata7.db entries to
fail, and so this fix is initially on a branch until those other bugs can
be repaired.

FossilOrigin-Name: e0994e99955cf11f23dba029b5ed7f150f467887558848d5f03510e2fb5855f9

6 years agoFix the dbtotxt decoder in the CLI so that it ignores excess bytes.
drh [Thu, 13 Dec 2018 22:58:52 +0000 (22:58 +0000)] 
Fix the dbtotxt decoder in the CLI so that it ignores excess bytes.

FossilOrigin-Name: 18740bd448887d618fafee0b5a7c004aa2f2632244f7d29e2428772baa36b828

6 years agodbfuzz2 found a NEVER() that is sometimes true.
drh [Thu, 13 Dec 2018 21:52:18 +0000 (21:52 +0000)] 
dbfuzz2 found a NEVER() that is sometimes true.

FossilOrigin-Name: 1201615cbbd3070158ea5fab3d2c8c95f41b25d6da096a44cb9257a7b7405efc

6 years agoAdd extra tests for database corruption inside the defragmentPage() routine,
drh [Thu, 13 Dec 2018 21:11:22 +0000 (21:11 +0000)] 
Add extra tests for database corruption inside the defragmentPage() routine,
as dbfuzz2 has found ways for corruption to leak into that point.  Add test
cases in fuzzdata7.db.

FossilOrigin-Name: 997b65117f8c12dba5fb85434fde9765cdb0d2a49cc3e31979abba3e21350086

6 years agoFix a problem in sqlite3BtreeDelete() in which deleting an entry from a
drh [Thu, 13 Dec 2018 21:05:45 +0000 (21:05 +0000)] 
Fix a problem in sqlite3BtreeDelete() in which deleting an entry from a
corrupt database can leave a btree page with zero cells.

FossilOrigin-Name: 682053d1e603c21b8085c39db618a39b23ec8d2c4d822fd19634db0e03038ea2

6 years agoAdd the "decode_hexdb" TCL command to testfixture. Add the dbfuzz001.test
drh [Thu, 13 Dec 2018 20:49:43 +0000 (20:49 +0000)] 
Add the "decode_hexdb" TCL command to testfixture.  Add the dbfuzz001.test
module to demonstration how to use decode_hexdb to deserialize a dbtotxt
database description for use in a corruption test.

FossilOrigin-Name: 1f583c53f3b7318c69f6e235934d97ef9493278feeab0837217076d7d071c35b

6 years agoFix the CLI to keep proper track of input line numbers for use in error
drh [Thu, 13 Dec 2018 18:59:30 +0000 (18:59 +0000)] 
Fix the CLI to keep proper track of input line numbers for use in error
messages, even after processing in-line hex database inputs using
".open --hexdb".

FossilOrigin-Name: 7ffa9858162774cba03a565a7b65135d9e8bfea726af1a29de6898f66c4b1261

6 years agoFix the CLI so that the ".open --hexdb" command works even if it is contained
drh [Thu, 13 Dec 2018 18:30:01 +0000 (18:30 +0000)] 
Fix the CLI so that the ".open --hexdb" command works even if it is contained
in a subscript that is read using ".read".

FossilOrigin-Name: 67a87399b8ad8f1ce3052ee3159906f5c6df3d7b5691b3acac856bd2f1c82088

6 years agoMerge the dbtotxt enhancement from trunk. dbfuzz2-cases
drh [Thu, 13 Dec 2018 15:52:31 +0000 (15:52 +0000)] 
Merge the dbtotxt enhancement from trunk.

FossilOrigin-Name: b386fce9a23e628dce7362dcca2904b8d0af6da58a6fe6eb7f12f058a8363e49

6 years agoAdd the "dbtotxt" utility program and the ability to read "dbtotxt" output
drh [Thu, 13 Dec 2018 15:06:26 +0000 (15:06 +0000)] 
Add the "dbtotxt" utility program and the ability to read "dbtotxt" output
as a deserialized input database in the CLI, using the --hexdb option to
the ".open" command.

FossilOrigin-Name: e3bf1d3ea5f748c5142c2403813fdace5aedc1fc68f0dcd5eae40a2fe763fedb

6 years agoInclude OPTS in the build of dbfuzz2.
drh [Thu, 13 Dec 2018 12:37:13 +0000 (12:37 +0000)] 
Include OPTS in the build of dbfuzz2.

FossilOrigin-Name: eac9c0c49650b008951318a2225b932709a0a8dffbb01ed57684c40357b2e25c

6 years agoFix the Makefile so that it honors CFLAGS when building sessionfuzz.
drh [Thu, 13 Dec 2018 12:28:01 +0000 (12:28 +0000)] 
Fix the Makefile so that it honors CFLAGS when building sessionfuzz.

FossilOrigin-Name: 54231ac4ca506e6c34c31bc02bb8d3db22f14e1b01679bc70529b165d7dabb83

6 years agoNew database corruption test cases discovered by dbfuzz2. The new cases
drh [Thu, 13 Dec 2018 03:36:13 +0000 (03:36 +0000)] 
New database corruption test cases discovered by dbfuzz2.  The new cases
have been added to test/fuzzdata7.db, but have not yet all been fixed,
so tests will not currently pass.

FossilOrigin-Name: b4210d320c6426d2838d4cc08709fdfd015c1c95fcad9a5f9e8fd390c23b9fad

6 years agoFix another problem found by Matthew Denton's new fuzzer.
drh [Wed, 12 Dec 2018 21:34:17 +0000 (21:34 +0000)] 
Fix another problem found by Matthew Denton's new fuzzer.

FossilOrigin-Name: 2b690dbdffe144bd69ca0aa291c230faf3d9d73f7a2985d50f016fe54003f9a9

6 years agoRemove an ALWAYS() from a branch that is not always taken. The test case
drh [Wed, 12 Dec 2018 20:11:23 +0000 (20:11 +0000)] 
Remove an ALWAYS() from a branch that is not always taken.  The test case
found by OSSFuzz has been added to TH3.

FossilOrigin-Name: 5c7dab85535ac42c021977dbd4a39cef5a72e3d9dccff1c5ca5570a1780516cd

6 years agoOSSFuzz found a case where an assert() inside sqlite3ExprCompare() can be
drh [Wed, 12 Dec 2018 11:23:40 +0000 (11:23 +0000)] 
OSSFuzz found a case where an assert() inside sqlite3ExprCompare() can be
true.  Test case added to TH3.

FossilOrigin-Name: 23b62fb160d86dc9d9073bcc714601f5b7695f96abd893eafecf4b2e565b87f2

6 years agoSmall performance improvement in sqlite3_step().
drh [Tue, 11 Dec 2018 12:51:46 +0000 (12:51 +0000)] 
Small performance improvement in sqlite3_step().

FossilOrigin-Name: d1db8d5894450b24bb0335983503d9bbf6cc48a0ae4b83291283fb2d32b6b25b

6 years agoSmall performance improvement in the sqlite3_bind() family of interfaces.
drh [Tue, 11 Dec 2018 12:20:41 +0000 (12:20 +0000)] 
Small performance improvement in the sqlite3_bind() family of interfaces.

FossilOrigin-Name: 1dc0c3df32572f09265fc73eeaa0748159e0e9523b9b2d6768b834a29c909968

6 years agoFurther refinements to the sqlite3_normalized_sql() interface. TH3 now
drh [Mon, 10 Dec 2018 20:01:40 +0000 (20:01 +0000)] 
Further refinements to the sqlite3_normalized_sql() interface.  TH3 now
gives 100% MC/DC on that interface.

FossilOrigin-Name: c96bf6cca220e363b099455ce35195ce7e89d374a52dc787f56e7b11e587bced

6 years agoRefactor the sqlite3_normalized_sql() implementation.
drh [Mon, 10 Dec 2018 18:15:44 +0000 (18:15 +0000)] 
Refactor the sqlite3_normalized_sql() implementation.

FossilOrigin-Name: 06e955e5d2b857b9ce94a73fb174b620c101bdb160842f9a0e958bdb48e8c987

6 years agoMake SQLITE_MFS_NSHARD a compile time setting.
dan [Mon, 10 Dec 2018 16:52:31 +0000 (16:52 +0000)] 
Make SQLITE_MFS_NSHARD a compile time setting.

FossilOrigin-Name: b9a741519055a8560ec1d0ab7d0c15ff8db53e740011825506cd2ede11c956f0

6 years agoFix issues with the new normalizer. normalize-refactor
drh [Mon, 10 Dec 2018 16:49:33 +0000 (16:49 +0000)] 
Fix issues with the new normalizer.

FossilOrigin-Name: 057d7d40c56b7416a59a79cb627b2b3e5837eca2d6dbcb50127baaadf1941f51

6 years agoRefactor the sqlite3_normalized_sql() implementation. This is a
drh [Mon, 10 Dec 2018 16:00:57 +0000 (16:00 +0000)] 
Refactor the sqlite3_normalized_sql() implementation. This is a
work-in-progress. There are still issues.

FossilOrigin-Name: a4c890b0af9786295e6df05022009d8946550adb873535c610be805c2b7a4083

6 years agoAdd extra tests to shmlock.test (direct testing of xShmLock methods).
dan [Mon, 10 Dec 2018 15:51:05 +0000 (15:51 +0000)] 
Add extra tests to shmlock.test (direct testing of xShmLock methods).

FossilOrigin-Name: d2c785f94cc6b704ce29147399e2c473fd0f4ff377f1379bd29178bf6d127c1a

6 years agoRework the SQLITE_MUTEXFREE_SHMLOCK code to reduce contention.
dan [Mon, 10 Dec 2018 15:24:29 +0000 (15:24 +0000)] 
Rework the SQLITE_MUTEXFREE_SHMLOCK code to reduce contention.

FossilOrigin-Name: d9157dd176a2d18c6e02a2a0c7e16cef2da43bf44be9765e0363f34aebad23e9

6 years agoAvoid a mutex in-and-out in unixShmBarrier() on this branch. Use
dan [Mon, 10 Dec 2018 09:45:38 +0000 (09:45 +0000)] 
Avoid a mutex in-and-out in unixShmBarrier() on this branch. Use
__sync_synchronize() instead.

FossilOrigin-Name: a8c5fd86ce1d9b5815f82106f2e44797b743bbb3c44aee5f835ce8d278caf8f7

6 years agoFix a problem with using "<db>-vacuum" (the default) as the state database
dan [Mon, 10 Dec 2018 08:41:32 +0000 (08:41 +0000)] 
Fix a problem with using "<db>-vacuum" (the default) as the state database
when resuming an RBU vacuum.

FossilOrigin-Name: c878d741733a897d47a1a0b57b454bc9095ce302b48cc01089336d5d20e2a24c

6 years agoAdd support for the VACUUM INTO command.
drh [Mon, 10 Dec 2018 01:48:29 +0000 (01:48 +0000)] 
Add support for the VACUUM INTO command.

FossilOrigin-Name: 77f150b8b46761f4f62f9d8926c10a95a70589a4525393fc16b321bd98c083a7

6 years agoFix the shell1.test test for the new format of the .backup command. vacuum-into
drh [Mon, 10 Dec 2018 00:41:28 +0000 (00:41 +0000)] 
Fix the shell1.test test for the new format of the .backup command.

FossilOrigin-Name: 9748d7995bc1dd632d66d2d326048d50e29c6f5e6993d5a6294d14421d2cb72f

6 years agoMerge fixes from trunk.
drh [Mon, 10 Dec 2018 00:40:43 +0000 (00:40 +0000)] 
Merge fixes from trunk.

FossilOrigin-Name: ab1e58fac9e3f9d7d90cefb39f8f145d211d38ec0cb393208c4531cc646056c1

6 years agoNew test case for ticket [1d958d90596593a77420e59].
drh [Sun, 9 Dec 2018 18:55:05 +0000 (18:55 +0000)] 
New test case for ticket [1d958d90596593a77420e59].

FossilOrigin-Name: b7bf3c9832bde26b359f4d58ebcf7788c500586d311387d022192ed65a126252

6 years agoDo not use a partial index as a table scan in an IN operator.
drh [Sat, 8 Dec 2018 20:30:31 +0000 (20:30 +0000)] 
Do not use a partial index as a table scan in an IN operator.
Fix for ticket [1d958d90596593a77420e59].

FossilOrigin-Name: 15bc915dd7ae25bfdfbe357c3792db3639799e4d121c6b5b24297af2d6d7129e

6 years agoAdd the --async option to the ".backup" command in the CLI.
drh [Sat, 8 Dec 2018 01:09:14 +0000 (01:09 +0000)] 
Add the --async option to the ".backup" command in the CLI.

FossilOrigin-Name: 7b6a605b1883dfcbe237b0a58f6f0c233a109e88b521c3b3d97198526c8a0317

6 years agoAllow the INTO clause of VACUUM to be a text-valued expression.
drh [Sat, 8 Dec 2018 00:43:08 +0000 (00:43 +0000)] 
Allow the INTO clause of VACUUM to be a text-valued expression.

FossilOrigin-Name: af172b53b46759f491f522356e14c5e2374d3f25ec70fbc1e100cadded8f9b22

6 years agoDo not allow VACUUM INTO into a file that already exists.
drh [Fri, 7 Dec 2018 23:48:41 +0000 (23:48 +0000)] 
Do not allow VACUUM INTO into a file that already exists.

FossilOrigin-Name: 92f70e0fa3c9de7fde046f11cc0a7c2800511bb5ace8e68c845133931607616e

6 years agoMerge the VACUUM simplification from trunk.
drh [Fri, 7 Dec 2018 20:40:12 +0000 (20:40 +0000)] 
Merge the VACUUM simplification from trunk.

FossilOrigin-Name: 93d92a0a5d21a1856316c0205ecaa253691b6e5349b552d43027005676d14820

6 years agoRemove a line of code from VACUUM that is no longer needed, due to the
drh [Fri, 7 Dec 2018 20:26:29 +0000 (20:26 +0000)] 
Remove a line of code from VACUUM that is no longer needed, due to the
change that allows ATTACH to run within a transaction.

FossilOrigin-Name: a92c398fc5df142ff1459c1be4a6832f2219bc7fabe5789535be3bbd41a4269b

6 years agoPrototype implementation for the VACUUM INTO command.
drh [Fri, 7 Dec 2018 17:28:28 +0000 (17:28 +0000)] 
Prototype implementation for the VACUUM INTO command.

FossilOrigin-Name: 036e3320a4af36c1311b25b2e504b0079c8b33df8ad7b7e5fddad07150e6f87d

6 years agoFix the sqlite3_normalized_sql() interface so that it renders
drh [Fri, 7 Dec 2018 16:32:11 +0000 (16:32 +0000)] 
Fix the sqlite3_normalized_sql() interface so that it renders
double-quoted string literals as "?".

FossilOrigin-Name: 0d8e150434bbd179696f1ffe71d1e06cb3d43e6468496c7e481fca8486387bad

6 years agoFix dbfuzz2.c so that it works with -DSQLITE_OMIT_INIT
drh [Fri, 7 Dec 2018 03:01:07 +0000 (03:01 +0000)] 
Fix dbfuzz2.c so that it works with -DSQLITE_OMIT_INIT

FossilOrigin-Name: 9ad796a8822f1b7e1e99b73c2cc5be59dbfd85e9c27f3e795c29a2c002c611d1

6 years agoFix the sqlite3ExprDup() function so that it correctly duplicates the
drh [Fri, 7 Dec 2018 01:56:26 +0000 (01:56 +0000)] 
Fix the sqlite3ExprDup() function so that it correctly duplicates the
Window object list on a Select that contains window functions.  Fix
for ticket [f09fcd17810f65f717].

FossilOrigin-Name: db5ed2268eda2e6c1df15cd8df4176463d89103b8fda33ba9a0604f0d92bd4da

6 years agoPerformance improvement: Avoid using sqlite3WalkerSelectExpr() ticket-f09fcd17810f
drh [Thu, 6 Dec 2018 22:12:18 +0000 (22:12 +0000)] 
Performance improvement:  Avoid using sqlite3WalkerSelectExpr()
and sqlite3WalkerSelectFrom() twice, so that the compiler will in-line their
implementation.

FossilOrigin-Name: 2b9258b8b0342330ebe8c22b59ec276fd042a05547d15b24fdf29e16280868de

6 years agoFix the sqlite3ExprDup() routine so that it makes complete duplications of
drh [Thu, 6 Dec 2018 22:04:19 +0000 (22:04 +0000)] 
Fix the sqlite3ExprDup() routine so that it makes complete duplications of
subqueries containing window functions.

FossilOrigin-Name: 940174543e87184a0278fcd02e8a096a11510174d9c1d65d21878819790ddaff

6 years agoNew test case that still hits an assertion fault, just to prove that the
drh [Thu, 6 Dec 2018 19:56:20 +0000 (19:56 +0000)] 
New test case that still hits an assertion fault, just to prove that the
previous checkin merely made the problem more obscure and did not completely
fix it.

FossilOrigin-Name: a9a3b532643b5f106509bb29c3e6bc9d41ec5b2da5a0cd4067898f376eb626a2

6 years agoSimplify the query flattener so that it does not duplicate the WHERE clause
drh [Thu, 6 Dec 2018 19:15:36 +0000 (19:15 +0000)] 
Simplify the query flattener so that it does not duplicate the WHERE clause
of subquery that is being incorporated into the outer query - copies it
directly.  This is more efficient.  And it also fixes the specific test case
show for ticket [f09fcd17810f65f71789525] but it does not resolve the more
general problem that sqlite3ExprDup() does not correctly duplicate expressions
that contain subqueries with window functions.

FossilOrigin-Name: f1b18d44ff855573542c1947a42d4025dff54cacc13dac14d044521762ea9736

6 years agoExperiment with using an atomic CPU primitive instead of a mutex for
dan [Thu, 6 Dec 2018 18:58:58 +0000 (18:58 +0000)] 
Experiment with using an atomic CPU primitive instead of a mutex for
intra-process locking with the unix-excl VFS.

FossilOrigin-Name: 8f4cb9dd3396bcaaf85dcdb4e3ae3c96f28a4d71d72665c4abf7c221370be626

6 years agoWhen masking bits off of sqlite3.flags, make sure the mask is 64 bits
drh [Thu, 6 Dec 2018 17:06:02 +0000 (17:06 +0000)] 
When masking bits off of sqlite3.flags, make sure the mask is 64 bits
in size so as not to accidentally mask of high-order bits.

FossilOrigin-Name: 53d3b169d8e1892163526caff2c843302c92e280fdeff6831e23a9bb15b82be3

6 years agoWhen saving off the value of sqlite3.flags, take care to preserve all 64
drh [Thu, 6 Dec 2018 16:50:55 +0000 (16:50 +0000)] 
When saving off the value of sqlite3.flags, take care to preserve all 64
bits.

FossilOrigin-Name: 9c6dbcfab5952cf4e54de30cf9cee48f988b91a35dc3f04d64d6d994dd84a076

6 years agoIssue a warning whenever a double-quoted string literal is used.
drh [Thu, 6 Dec 2018 16:11:14 +0000 (16:11 +0000)] 
Issue a warning whenever a double-quoted string literal is used.

FossilOrigin-Name: ac9ad5043026b30394812457e1535df2759aea0d4510029561e92e386672796f

6 years agoInvoking the sqlite3_trace() or sqlite3_trace_v2() interfaces cancels
drh [Thu, 6 Dec 2018 03:59:25 +0000 (03:59 +0000)] 
Invoking the sqlite3_trace() or sqlite3_trace_v2() interfaces cancels
any sqlite3_profile() that is running.

FossilOrigin-Name: ec63d3506bd429560077f82a4c5ed9d189780789fe1c134fff4f3b8733be1a3f

6 years agoRemove the unused pColHash field from the Table object.
drh [Thu, 6 Dec 2018 02:01:17 +0000 (02:01 +0000)] 
Remove the unused pColHash field from the Table object.

FossilOrigin-Name: 3a2c047989facc3461c63a2f9eed412014c951035a80da47c52a70139fb552de

6 years agoFix a potential NULL pointer dereference that can occur in ALTER TABLE
drh [Thu, 6 Dec 2018 01:53:12 +0000 (01:53 +0000)] 
Fix a potential NULL pointer dereference that can occur in ALTER TABLE
following an OOM.  Test case in TH3.

FossilOrigin-Name: ea50815bf80ab0d36891518f209acbcd3d6d8d84529741bffd4e841874c78aff

6 years agoFix a missing mutex in the sqlite3_normalized_sql() interface when it is
drh [Thu, 6 Dec 2018 01:08:58 +0000 (01:08 +0000)] 
Fix a missing mutex in the sqlite3_normalized_sql() interface when it is
called on a prepared statement that did not previously have a computed
normalization of the input SQL.

FossilOrigin-Name: 1a1a59c6c570879c8f318bbc132103c0285088ba233dd8c32e049b86419347b0

6 years agoGet rid of the hash table used to track IN operators in the
drh [Wed, 5 Dec 2018 23:56:02 +0000 (23:56 +0000)] 
Get rid of the hash table used to track IN operators in the
sqlite3_normalized_sql() implementation.  Use simple integer variables
instead.

FossilOrigin-Name: 272dc74fd0304d6a28aaa8798d13e2f950c1a24d92d17519e3c32aef86714586

6 years agoThe sqlite3_normalized_sql() interface should not be transforming quoted
drh [Wed, 5 Dec 2018 23:45:46 +0000 (23:45 +0000)] 
The sqlite3_normalized_sql() interface should not be transforming quoted
identifier names into wildcards.  Fix this, and at the same time simplify
the code substantially.

FossilOrigin-Name: e8540377ec66fa5f9ae3c93bedb5c094057698199c37fc211f7ea95429e815e4