]> git.ipfire.org Git - thirdparty/sqlite.git/log
thirdparty/sqlite.git
6 years agoAn early attempt at refactoring Expr expr-simplify-branch1
drh [Sat, 28 Jul 2018 13:37:44 +0000 (13:37 +0000)] 
An early attempt at refactoring Expr

FossilOrigin-Name: fc90a53de7ebca5d4cd3aac40d6e9d001350a932eb99fdaedb6826597c8a973c

6 years agoAdd assert() statements to sqlite3ExprDelete() that prove various symmetry
drh [Sat, 28 Jul 2018 01:30:43 +0000 (01:30 +0000)] 
Add assert() statements to sqlite3ExprDelete() that prove various symmetry
properties of the Expr object that might be exploited to make the Expr object
smaller and faster.

FossilOrigin-Name: 81f25d5c84e4d2d0cd3c6a7c105c7c93d310218feeea4e023dbc32e7e96b2a52

6 years agoImprovements to the parser to increase coverage. Fix the parser so that
drh [Fri, 27 Jul 2018 23:33:16 +0000 (23:33 +0000)] 
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

6 years agoWhen doing a DROP VIEW do not try to delete entries from the sqlite_stat1
drh [Fri, 27 Jul 2018 22:55:58 +0000 (22:55 +0000)] 
When doing a DROP VIEW do not try to delete entries from the sqlite_stat1
table as there are none.

FossilOrigin-Name: 7efdba2bbc8547ee9292a1bbd1e61d38b40d7aabc0860ceba188bdec539f5114

6 years agoMinor grammar changes that help the parser run faster by reducing the
drh [Fri, 27 Jul 2018 22:14:50 +0000 (22:14 +0000)] 
Minor grammar changes that help the parser run faster by reducing the
number of NUL rule reductions.

FossilOrigin-Name: cfd1b00592bd550e444dfc7b6a6a93c77c07b835729c6cc69a4b6361038964ba

6 years agoEnhance Makefile for MSVC to support building the shell tool without using the amalga...
mistachkin [Fri, 27 Jul 2018 20:45:28 +0000 (20:45 +0000)] 
Enhance Makefile for MSVC to support building the shell tool without using the amalgamation.

FossilOrigin-Name: 3d815d83a6805938b87e03ffabe6d71ca2ecfd05052e8e02c6cc5d3c9ea4ddf3

6 years agoThe WHERE-clause constant propagation optimization attempts to use
drh [Fri, 27 Jul 2018 20:37:42 +0000 (20:37 +0000)] 
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

6 years agoReduce the performance cost of the constant propagation optimization to propagate-const-opt
drh [Fri, 27 Jul 2018 20:01:00 +0000 (20:01 +0000)] 
Reduce the performance cost of the constant propagation optimization to
less than 200,000 cycles.

FossilOrigin-Name: 865249de683e6971984a645a30d96f9fcc6f6d9d7af7e269ff68cc3e42e5fe71

6 years agoPerformance improvement to sqlite3ExprCollSeq(). With this change, the
drh [Fri, 27 Jul 2018 18:19:12 +0000 (18:19 +0000)] 
Performance improvement to sqlite3ExprCollSeq().  With this change, the
performance of speed-check.sh is within 400,000 cycles of trunk.

FossilOrigin-Name: a5f86f49b7d9e52546f234f7c3bcbac6b0f78aa55a71c44ca69e21bc31139f3e

6 years agoFaster implementation of sqlite3IsBinary().
drh [Fri, 27 Jul 2018 18:12:40 +0000 (18:12 +0000)] 
Faster implementation of sqlite3IsBinary().

FossilOrigin-Name: be05d0db09f43cc3362c28273463d1d236af737a4f8a494cf1050da07ed0df47

6 years agoOnly run the constant propagation optimization on joins since that is the
drh [Fri, 27 Jul 2018 17:51:20 +0000 (17:51 +0000)] 
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

6 years agoConstant propagation is now restricted to just the WHERE clause. The
drh [Fri, 27 Jul 2018 16:57:11 +0000 (16:57 +0000)] 
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

6 years agoAdd a test case demonstrating the collation problem with constant propagation.
drh [Thu, 26 Jul 2018 23:54:19 +0000 (23:54 +0000)] 
Add a test case demonstrating the collation problem with constant propagation.

FossilOrigin-Name: 50add839fd95665bd67a6ae5de8346fd09e83904bbcbad26fad280dff86d9e93

6 years agoGeneralize the constant propagation optimization so that it applies on every
drh [Thu, 26 Jul 2018 23:47:11 +0000 (23:47 +0000)] 
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

6 years agoIn the unix VFS, give every unixInodeInfo object its own mutex, rather
drh [Thu, 26 Jul 2018 21:48:05 +0000 (21:48 +0000)] 
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

6 years agoInitial implementation of the WHERE-clause constant propagation optimization.
drh [Thu, 26 Jul 2018 21:16:53 +0000 (21:16 +0000)] 
Initial implementation of the WHERE-clause constant propagation optimization.

FossilOrigin-Name: 2fb82ad8ebb6434438c0d235b1239444fb08c8711cea2c5a9ed955fedd0acdec

6 years agoFix a buffer overread in fts5.
dan [Wed, 25 Jul 2018 15:25:55 +0000 (15:25 +0000)] 
Fix a buffer overread in fts5.

FossilOrigin-Name: 0e3de8abbb0c7ae64e637776cb055ce79736f99a103e00e44d17a6b091b98c81

6 years agoKeep generated opcode values grouped together when required, even when they do not...
mistachkin [Wed, 25 Jul 2018 15:12:29 +0000 (15:12 +0000)] 
Keep generated opcode values grouped together when required, even when they do not correspond to a token.

FossilOrigin-Name: 6ee2950b272ede475e485bfaa7d413eaa81482fe9dd6452aeeaf95ff7938f7da

6 years agoFix a typo in the documentation for sqlite3_snapshot_get().
dan [Wed, 25 Jul 2018 07:29:20 +0000 (07:29 +0000)] 
Fix a typo in the documentation for sqlite3_snapshot_get().

FossilOrigin-Name: cd9713c9a88cd30887c67f477abbbf8ef90299051a0b9bb52a04cf4132987c9c

6 years agoDo not abort running queries due to a CREATE INDEX statement. Allow them
drh [Tue, 24 Jul 2018 22:02:12 +0000 (22:02 +0000)] 
Do not abort running queries due to a CREATE INDEX statement.  Allow them
to run to completion before being reprepared.  Fix for ticket
[c694113e50321afdf9].

FossilOrigin-Name: 2bd593332da0aade467e7a4ee89e966aa6302f37540a2c5e23671f98a6cb599c

6 years agoAdd missing SQLITE_OMIT_WINDOWFUNC check to the json1 extension.
mistachkin [Tue, 24 Jul 2018 13:57:44 +0000 (13:57 +0000)] 
Add missing SQLITE_OMIT_WINDOWFUNC check to the json1 extension.

FossilOrigin-Name: fe19f8239dc474db0854a0a8ce5189ac4195c736b496f475a59a185e0879b40c

6 years agoReturn an SQLITE_NOMEM error if the locking mutex fails to allocate. separate-lock-mutex
drh [Mon, 23 Jul 2018 22:55:10 +0000 (22:55 +0000)] 
Return an SQLITE_NOMEM error if the locking mutex fails to allocate.

FossilOrigin-Name: 1c94834879be0601ac40ef3c4fb1b140f7737e89af7808f2f1db4ceb3daae19f

6 years agoFirst attempt at reducing mutex contention in the unix VFS by providing
drh [Mon, 23 Jul 2018 21:10:37 +0000 (21:10 +0000)] 
First attempt at reducing mutex contention in the unix VFS by providing
a separate mutex for each unixInodeInfo object.

FossilOrigin-Name: f69afaf00a659cd768a863c5f4a1d527f01187e037240da0ada527cb52c5afe8

6 years agoFix typo of 'SQLITE_OMIT_WINDOWFUNC'.
mistachkin [Mon, 23 Jul 2018 18:53:49 +0000 (18:53 +0000)] 
Fix typo of 'SQLITE_OMIT_WINDOWFUNC'.

FossilOrigin-Name: 8607b84a5c53d8c9218c90802160a3000f1138b1f188e411a3af46253e0a69cc

6 years agoAttempt to improve the documentation for snapshots. No changes to code.
drh [Mon, 23 Jul 2018 18:32:42 +0000 (18:32 +0000)] 
Attempt to improve the documentation for snapshots.  No changes to code.

FossilOrigin-Name: 46dd076af5880e6e9a7de974758b26bc43d0dc074f8143234038fa9cdcc726ee

6 years agoFix the macros used to generate the output of "PRAGMA compile_options" so that
dan [Mon, 23 Jul 2018 10:57:53 +0000 (10:57 +0000)] 
Fix the macros used to generate the output of "PRAGMA compile_options" so that
they handle valid values for the SQLITE_DEFAULT_LOOKASIDE macro (which
contain a "," character).

FossilOrigin-Name: 1cc72845f92198f2f6c1d34957921cd8f5bc82eaccab9f844006993f0b8d7a96

6 years agoFix more harmless compiler warnings seen with MSVC.
mistachkin [Sun, 22 Jul 2018 21:23:19 +0000 (21:23 +0000)] 
Fix more harmless compiler warnings seen with MSVC.

FossilOrigin-Name: edab5666f8470b37e6031dfd80e615b1aab95d1d85ccbe4ece1a813f8b3d4d95

6 years agoAnother minor revision to the 'fulltestonly' set of tests.
mistachkin [Sun, 22 Jul 2018 21:08:35 +0000 (21:08 +0000)] 
Another minor revision to the 'fulltestonly' set of tests.

FossilOrigin-Name: 61f8e2a4c6c146ffba498c8bb40f2b5627fdc14020057eab63b7e900bf88a9ed

6 years agoFix harmless compiler warning.
mistachkin [Sun, 22 Jul 2018 20:24:38 +0000 (20:24 +0000)] 
Fix harmless compiler warning.

FossilOrigin-Name: ead4762dfcd284127e60483e14f88aa4f4f034c2e1efb68a150359ba8f307776

6 years agoIn the Win32 VFS, when truncating a file, unmap it first.
mistachkin [Sun, 22 Jul 2018 06:25:35 +0000 (06:25 +0000)] 
In the Win32 VFS, when truncating a file, unmap it first.

FossilOrigin-Name: 21510a66dce4d0843ccfe20f092a01f5a52563ef244a94f1d5d2563305cab925

6 years agoRemove an unused branch in the FK logic. dropViewNoStat
drh [Sun, 22 Jul 2018 00:45:11 +0000 (00:45 +0000)] 
Remove an unused branch in the FK logic.

FossilOrigin-Name: 523ff77925f1da361cf31e3fc82bcb1708ed356a2391430ab14ef620c9bf2327

6 years agoIn 'resetdb.test', close a database prior to trying to delete it.
mistachkin [Sat, 21 Jul 2018 23:15:55 +0000 (23:15 +0000)] 
In 'resetdb.test', close a database prior to trying to delete it.

FossilOrigin-Name: 45137053a511b976f5447b0668e3f3a636785d242f44b110a1107898e847e95e

6 years agoWhen dropping a view, skip trying to delete from 'sqlite_stat*'.
mistachkin [Fri, 20 Jul 2018 20:56:22 +0000 (20:56 +0000)] 
When dropping a view, skip trying to delete from 'sqlite_stat*'.

FossilOrigin-Name: 2f5be3a2ddf469bd1b37b9e357545ce872b90c479a07094de2101d0a43ad70a4

6 years agoChange the SQLITE_Stat34 bit of the optimization test-control so that it
drh [Fri, 20 Jul 2018 19:24:02 +0000 (19:24 +0000)] 
Change the SQLITE_Stat34 bit of the optimization test-control so that it
prevents STAT4 data from being used but allows it to be loaded into the
Index objects.  This permits STAT4 to be turned on and off on a per-statement
basis.

FossilOrigin-Name: 489f3caf5dcc8cace20a0da58ceb32fdea5770ba570fa3c9f712cd35e726846a

6 years agoNew checked in PRAGMA integrity_check to validate the autovacuum settings
drh [Fri, 20 Jul 2018 15:44:09 +0000 (15:44 +0000)] 
New checked in PRAGMA integrity_check to validate the autovacuum settings
in the header.

FossilOrigin-Name: a4663f09c91d1381a831f61a2b8e8a113eb6083932c4aea2ad0c011ece1418c5

6 years agoEnhanced detection of problems on the freelist and on overflow list in
drh [Fri, 20 Jul 2018 13:39:28 +0000 (13:39 +0000)] 
Enhanced detection of problems on the freelist and on overflow list in
PRAGMA integrity_check.

FossilOrigin-Name: 11e58f5b37d99848978007d834d187c262d904eb9d58924742e028d7cb324e64

6 years agoAvoid a branch in the commit logic that is unreachable when compiled
drh [Thu, 19 Jul 2018 15:27:35 +0000 (15:27 +0000)] 
Avoid a branch in the commit logic that is unreachable when compiled
without SQLITE_ENABLE_BATCH_ATOMIC_WRITE.

FossilOrigin-Name: 271b8980c3bcd0403a40aec26681ec111be1d88d2d5d35199a85a10f09ad6920

6 years agoAllow the VACUUM following SQLITE_DBCONFIG_RESET_DATABASE to proceed even
drh [Thu, 19 Jul 2018 14:40:41 +0000 (14:40 +0000)] 
Allow the VACUUM following SQLITE_DBCONFIG_RESET_DATABASE to proceed even
if the write-version in the header indicates that the database file is not
writable.

FossilOrigin-Name: 3dca8b9d5ab1f35f17fc527d8f2a20b6bac989d1406c883d5b4d6719953ef6b4

6 years agoExperimental fix for resetting databases that have been deemed read-only due exp-dbreset-fix
dan [Thu, 19 Jul 2018 11:44:02 +0000 (11:44 +0000)] 
Experimental fix for resetting databases that have been deemed read-only due
to a corrupt "read-version" header field.

FossilOrigin-Name: e2394002d02754bb45d56e805df9bc5a2ef0d14e5d94262c1f8ab7643bc27c8f

6 years agoAdd the SQLITE_FCNTL_DATA_VERSION file control
drh [Wed, 18 Jul 2018 19:09:07 +0000 (19:09 +0000)] 
Add the SQLITE_FCNTL_DATA_VERSION file control

FossilOrigin-Name: a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60ad069f

6 years agoFix a harmless compiler warning in the pager. Enhance the docs for
drh [Wed, 18 Jul 2018 17:37:51 +0000 (17:37 +0000)] 
Fix a harmless compiler warning in the pager.  Enhance the docs for
sqlite3_changes() and sqlite3_total_changes() to refer to the data_version
pragma.

FossilOrigin-Name: 4c70ea5b0e2a512c6a46ac1f14397720e8c8556875701e78c30b19f850c24f55

6 years agoIf an SQLITE_IOERR error is encountered as part of an atomic commit on an F2FS file...
dan [Tue, 17 Jul 2018 14:01:55 +0000 (14:01 +0000)] 
If an SQLITE_IOERR error is encountered as part of an atomic commit on an F2FS file-system, retry the commit in legacy journal mode.

FossilOrigin-Name: 2e0357c2ed30927921cd17129e348a18a6f3fd086d1fc0a42756036b321a084d

6 years agoFix for builds without SQLITE_ENABLE_BATCH_ATOMIC_WRITE. exp-retry-atomic-commit
dan [Tue, 17 Jul 2018 13:55:08 +0000 (13:55 +0000)] 
Fix for builds without SQLITE_ENABLE_BATCH_ATOMIC_WRITE.

FossilOrigin-Name: b10ec14ef7edcc5d7b0ad298c8230d1eca5508e8cf673fbbc97a0928b76c92fb

6 years agoAdd new file doc/F2FS.txt, containing notes on the way SQLite uses the F2FS atomic...
dan [Mon, 16 Jul 2018 20:44:00 +0000 (20:44 +0000)] 
Add new file doc/F2FS.txt, containing notes on the way SQLite uses the F2FS atomic commit feature.

FossilOrigin-Name: 59efb1bfaba12742379aae45c8c796ca539f089af9e553a3a55d6899a9c583c8

6 years agoMinor simplification to sqlite3RollbackAll().
drh [Mon, 16 Jul 2018 11:32:59 +0000 (11:32 +0000)] 
Minor simplification to sqlite3RollbackAll().

FossilOrigin-Name: 432fdc221550b3cca4140b1ae411da22201f689c30c72c5472dfdbc79bec9d90

6 years agoIf an SQLITE_IOERR error is encountered as part of an atomic commit on an F2FS
dan [Sat, 14 Jul 2018 20:25:13 +0000 (20:25 +0000)] 
If an SQLITE_IOERR error is encountered as part of an atomic commit on an F2FS
file-system, retry the commit in legacy journal mode.

FossilOrigin-Name: 1c41250f67ac5de423b0426ef2ab8fe3303278a270225920033933ca9609592a

6 years agoRemove an unused function declaration from fts5.
dan [Fri, 13 Jul 2018 20:28:54 +0000 (20:28 +0000)] 
Remove an unused function declaration from fts5.

FossilOrigin-Name: 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb36212426b1

6 years agoAdd the "categories" option to the unicode61 tokenizer in fts5.
dan [Fri, 13 Jul 2018 19:52:43 +0000 (19:52 +0000)] 
Add the "categories" option to the unicode61 tokenizer in fts5.

FossilOrigin-Name: 80d2b9e635e3100f90cffdcffa5b5038da6fbbfccc9f5777c59a4ae760d4cb62

6 years agoAdd a test-control to disable the skip-scan optimization.
dan [Thu, 12 Jul 2018 19:14:39 +0000 (19:14 +0000)] 
Add a test-control to disable the skip-scan optimization.

FossilOrigin-Name: 650a3fe03d61068e06f3097878a777ca8ed713a769444cdb3f8be7d1e19a0b83

6 years agoAdd a test case to check that SQLITE_DBCONFIG_RESET_DATABASE can be used with
dan [Thu, 12 Jul 2018 11:28:42 +0000 (11:28 +0000)] 
Add a test case to check that SQLITE_DBCONFIG_RESET_DATABASE can be used with
wal mode databases even if there are active readers.

FossilOrigin-Name: 6145f5b3bacdee8f377892ac8b885941336c4cc543052f6373e21c1f99e1eca8

6 years agoOn an UPSERT when the order of constraint checks is rearranged, make sure
drh [Wed, 11 Jul 2018 13:34:24 +0000 (13:34 +0000)] 
On an UPSERT when the order of constraint checks is rearranged, make sure
that the affinity transformations on the inserted content occur before
any of the constraint checks.  Fix for ticket [79cad5e4b2e219dd197242e9e5f4e].

FossilOrigin-Name: d120c45f3dc79f67afed0e44e5133569f784bc6792b15f5d79529deac2d13072

6 years agoAdjustments to VdbeCoverage macros to deal with byte-code branches that
drh [Wed, 11 Jul 2018 03:27:52 +0000 (03:27 +0000)] 
Adjustments to VdbeCoverage macros to deal with byte-code branches that
can never be taken in some directions.

FossilOrigin-Name: b170c0092b1d0c47dd700843f0c870e51181939607a897fbcae55a58042160f9

6 years agoRemove incorrect ALWAYS() macros from the window function logic.
drh [Tue, 10 Jul 2018 23:31:17 +0000 (23:31 +0000)] 
Remove incorrect ALWAYS() macros from the window function logic.

FossilOrigin-Name: 94ac51cc4e7fdf484214e1936fc96104b96134632a8eb99558b3af743ac8bb8b

6 years agoAdd VdbeModuleComment()s on the three main code generators for window
drh [Tue, 10 Jul 2018 22:24:14 +0000 (22:24 +0000)] 
Add VdbeModuleComment()s on the three main code generators for window
functions.

FossilOrigin-Name: f7c239e959004cb90dc8537ab2e1fca5f26ef21f4f6f3dfd743a05a55e705090

6 years agoMinor comment changes. Add ALWAYS() macros on some unreachable branches
drh [Tue, 10 Jul 2018 20:50:27 +0000 (20:50 +0000)] 
Minor comment changes.  Add ALWAYS() macros on some unreachable branches
in the xStep() methods of built-in window functions.

FossilOrigin-Name: f2057542cf6860badb4ae6b1a0df94a78d5b2661dabf16f5705b3f8236521bea

6 years agoIdentify Select objects within a single statement using small sequential
drh [Tue, 10 Jul 2018 19:48:35 +0000 (19:48 +0000)] 
Identify Select objects within a single statement using small sequential
integers rather than "0x%p".  This is more readable and yields the same result
on successive runs.

FossilOrigin-Name: a7cdc5bc85e0edfcc38f920c2ce91599bcbfdb49522d88b08c64596546d13881

6 years agoModify tests in window3.test to be tolerant of rounding errors when comparing
dan [Tue, 10 Jul 2018 18:50:01 +0000 (18:50 +0000)] 
Modify tests in window3.test to be tolerant of rounding errors when comparing
floating point values.

FossilOrigin-Name: 7c26c443e7f6455ca7f11f640e42285b42d95c9ae5f2e19e9c066d6d9cdcceb2

6 years agoFix a problem with using scalar sub-selects in window function queries.
dan [Tue, 10 Jul 2018 17:26:12 +0000 (17:26 +0000)] 
Fix a problem with using scalar sub-selects in window function queries.

FossilOrigin-Name: 687fe532c274265ca77451f97829743fcb8a714d0f6b1ceb9a147ab9babdc5b5

6 years agoFurther improvements to bytecode branch testing. Fix cases where the
drh [Tue, 10 Jul 2018 17:10:44 +0000 (17:10 +0000)] 
Further improvements to bytecode branch testing.  Fix cases where the
macros said a branch could not be taken when in fact it could be.  Alter
some window function branch coverage macros to indicate that comparison
operands cannot be NULL.

FossilOrigin-Name: 76e42b7071a71137c0da4f10db4e653ae94a89b56e95cd3f036bff08c9500d08

6 years agoEnhancements and improved documentation to the byte-code branch coverage
drh [Tue, 10 Jul 2018 16:04:04 +0000 (16:04 +0000)] 
Enhancements and improved documentation to the byte-code branch coverage
testing logic.  Provide new macros that allow the code to specify that
some branch instructions can never take the NULL path and that the OP_Jump
opcode is only interested in equal/not-equal.  The
SQLITE_TESTCTRL_VDBE_COVERAGE file control callback now works slightly
differently (it provides the callback with a bitmask of the branch action,
rather than an integer).

FossilOrigin-Name: cd2da7e1ba4e78e68ccf65d4969df963c1e3085930e74419450bda2799381e05

6 years agoFix a harmless warning about comment formatting in the previous
drh [Tue, 10 Jul 2018 07:39:23 +0000 (07:39 +0000)] 
Fix a harmless warning about comment formatting in the previous
check-in.  Simplify the ORDER BY dereferencing logic so that it avoids
unreachable branches.

FossilOrigin-Name: 0f6ec605e131ab3d53b9df32af0a3207146a9abbd22dcabd6ef050b92f96735d

6 years agoAssert that if two functions compare equal in every other way, then they
drh [Tue, 10 Jul 2018 07:25:42 +0000 (07:25 +0000)] 
Assert that if two functions compare equal in every other way, then they
must both have OVER clauses, or neither has an OVER clause.  Use this fact
to simplify expression comparison.

FossilOrigin-Name: 52559ad58ce412af40f1f34e80bfe9fadc6a93f3ca0cfaf69f94d615bbb99831

6 years agoEnhance the sqlite3ExprCompare() routine so that it knows to compare the
drh [Tue, 10 Jul 2018 06:47:07 +0000 (06:47 +0000)] 
Enhance the sqlite3ExprCompare() routine so that it knows to compare the
OVER clause of window functions.

FossilOrigin-Name: 0a7649afebc9349bf44a0e3588e81ab595ea85be1c70de08859ea76a7b271f62

6 years agoEnhance the TreeView mechanism so that it shows the window function
drh [Tue, 10 Jul 2018 06:32:53 +0000 (06:32 +0000)] 
Enhance the TreeView mechanism so that it shows the window function
data structures as part of the abstract syntax tree.

FossilOrigin-Name: a2c0e1bec0d8a6f982572c4c5a8166319b8db0fe586057f7900f0ab72af6554e

6 years agoNew VDBE comments and coverage macros.
drh [Tue, 10 Jul 2018 05:11:03 +0000 (05:11 +0000)] 
New VDBE comments and coverage macros.

FossilOrigin-Name: a9a307265b0626b3e9df69534c8eacf18413ea31784c9d931eadcff515d3dd84

6 years agoFixes for various harmless compiler warnings.
drh [Mon, 9 Jul 2018 22:49:01 +0000 (22:49 +0000)] 
Fixes for various harmless compiler warnings.

FossilOrigin-Name: 5023b1b85b883a716a5da673740b6effe214ee0490f4ca45f161bb8b04784366

6 years agoAdd a comment to restriction (6) of the push-down optimization. No changes
drh [Mon, 9 Jul 2018 20:58:43 +0000 (20:58 +0000)] 
Add a comment to restriction (6) of the push-down optimization.  No changes
to code.

FossilOrigin-Name: 0c8a2f257fb71b2b053c4a2028db063e92dd9ff585a17fa22a70f9223fb11e75

6 years agoAdd an ALWAYS() around a branch in sqlite3BtreeSkipNext() that we believe
drh [Mon, 9 Jul 2018 20:41:39 +0000 (20:41 +0000)] 
Add an ALWAYS() around a branch in sqlite3BtreeSkipNext() that we believe
must always be true.

FossilOrigin-Name: 12be361a532df0c22a7e4d97658b82a69b1a205d4cca8d092b9e6b7790c1ee40

6 years agoAvoid leaving view-definitions with an incomplete set of column names/types in
dan [Mon, 9 Jul 2018 18:55:44 +0000 (18:55 +0000)] 
Avoid leaving view-definitions with an incomplete set of column names/types in
the in-memory schema if an OOM strikes while allocating the same.

FossilOrigin-Name: 1ddbb5372e7ea8407369b88698b3fb922b62dcac72be633a17bd0e41baa369f4

6 years agoAdd a couple of OOM tests.
dan [Mon, 9 Jul 2018 18:11:52 +0000 (18:11 +0000)] 
Add a couple of OOM tests.

FossilOrigin-Name: 50de2a0d2d96b6b5b8de7ac6277d60859a8d9a56f6a792950734386bb9f10b79

6 years agoRemove redundant branches in window function processing.
drh [Mon, 9 Jul 2018 17:33:24 +0000 (17:33 +0000)] 
Remove redundant branches in window function processing.

FossilOrigin-Name: 8fdaf3f37e5ddac9b7337a50f32f5d2bcdd64780797f08cfd3fccfa95819edfe

6 years agoSimplification to the grammar rules for window functions. Fix a memory
drh [Mon, 9 Jul 2018 16:24:00 +0000 (16:24 +0000)] 
Simplification to the grammar rules for window functions.  Fix a memory
leak that can follow an OOM while parsing a comma-separated list of
window definitions.

FossilOrigin-Name: a568f9c9db594f3b194c6e870305c9d6f2392ce6bc8ac00e9688883e97560fff

6 years agoThrow an error if the second argument passed to nth_value() is not a positive
dan [Mon, 9 Jul 2018 13:31:18 +0000 (13:31 +0000)] 
Throw an error if the second argument passed to nth_value() is not a positive
integer.

FossilOrigin-Name: 1a06e57a0b4279fa580c7ff4f152645f005794aaf86eeabf694637b7da11f763

6 years agoFix a bad assert() in window.c.
dan [Mon, 9 Jul 2018 06:51:36 +0000 (06:51 +0000)] 
Fix a bad assert() in window.c.

FossilOrigin-Name: fe8aaf0c806413965f50a03e34b5fdfaaa8b09dc0af73f41e830f7b664bd1ced

6 years agoSimplification to the logic that detects misuse of the application-defined
drh [Mon, 9 Jul 2018 02:37:12 +0000 (02:37 +0000)] 
Simplification to the logic that detects misuse of the application-defined
function creation interfaces.

FossilOrigin-Name: 8f21d778450e1e5d2bc7f109d614fe018eb3d228b0bfc91cd3c6a5204415998f

6 years agoDuring WITHOUT ROWID table creation, if the sqlite3CreateTable() call fails
drh [Mon, 9 Jul 2018 02:02:09 +0000 (02:02 +0000)] 
During WITHOUT ROWID table creation, if the sqlite3CreateTable() call fails
due to an authorizer denying the INSERT into the sqlite_master table, then
detect this fact and abort the CREATE TABLE early, to avoid an assertion
fault.

FossilOrigin-Name: 164b1641e346994f0b9f91261c3cbc86b68e1c96cc401b78e48e186e26916abe

7 years agoIdentify specific FuncDef objects for window functions using the pointer to
drh [Sun, 8 Jul 2018 01:02:26 +0000 (01:02 +0000)] 
Identify specific FuncDef objects for window functions using the pointer to
the function name (FuncDef.zName) rather than the pointer to the xStep method.
This allows xStep method pointer to be replaced with a single noopStepFunc()
procedure, and thus save having lots of different no-op step functions.

FossilOrigin-Name: 410e13b0e0fb6e040808f076014d55ecf2b541c5439b4fd53c5bdcb8d800098e

7 years agoSimplifications to the implementation of the sum() SQL function.
drh [Sat, 7 Jul 2018 20:55:16 +0000 (20:55 +0000)] 
Simplifications to the implementation of the sum() SQL function.

FossilOrigin-Name: a8b13002378fc4ef0b41c367b44b67bf2b28b6624303c087a3c6d657b5bfe32e

7 years agoFix another problem with reusing LSM cursors for range scans.
dan [Sat, 7 Jul 2018 20:26:30 +0000 (20:26 +0000)] 
Fix another problem with reusing LSM cursors for range scans.

FossilOrigin-Name: ae3fc7652f27ba0a86f4c26f64c2e148d9496a5edb7f54dc9980edd91c326e4f

7 years agoFix the JSON extension so that it can be compiled separately from the
drh [Sat, 7 Jul 2018 20:23:46 +0000 (20:23 +0000)] 
Fix the JSON extension so that it can be compiled separately from the
amalgamation.

FossilOrigin-Name: 4b8cfe7bfe5f049eb4607fd480429fcd2060e691891d8bffc9917f13fa373988

7 years agoFix an LSM problem caused by using the same cursor for equality and range
dan [Sat, 7 Jul 2018 20:13:32 +0000 (20:13 +0000)] 
Fix an LSM problem caused by using the same cursor for equality and range
scans.

FossilOrigin-Name: f05bead371d41ca5beef1f82e4c920c90e2eb9cd9fd537a5c91973bf9bd4eedb

7 years agoAdd ALWAYS() macros on results of sqlite3_aggregate_context() calls in
drh [Sat, 7 Jul 2018 19:47:21 +0000 (19:47 +0000)] 
Add ALWAYS() macros on results of sqlite3_aggregate_context() calls in
xInverse() implements, since they can never fail.

FossilOrigin-Name: fdef2a921d451c66ca535021d08af3ec1ab53283da2d2979378a799fd8731ef9

7 years agoAdd an assert() to help verify that OP_AggInverse is never called on an
drh [Sat, 7 Jul 2018 19:36:04 +0000 (19:36 +0000)] 
Add an assert() to help verify that OP_AggInverse is never called on an
accumulator that has not previously been processed by OP_AggStep.

FossilOrigin-Name: 4213889103fa37f3f11802aea81989522048a0752820603dd556f612128ddfee

7 years agoAdd missing VdbeCoverage() macro to window.c.
dan [Sat, 7 Jul 2018 17:38:49 +0000 (17:38 +0000)] 
Add missing VdbeCoverage() macro to window.c.

FossilOrigin-Name: 63f4d306ba19f6ba900a7d7480ccaa3d1e4a204e7c82bf5eb2e4bd849ef3a22f

7 years agoFix a problem with the handling of NULL values in the min() window function.
dan [Sat, 7 Jul 2018 17:30:44 +0000 (17:30 +0000)] 
Fix a problem with the handling of NULL values in the min() window function.

FossilOrigin-Name: b76f35b09235d44dc3d176377bbb9c18b7cdc9392800103ff53c54730a427a5c

7 years agoTry to improve the error messages for misformed frame specifications in
drh [Fri, 6 Jul 2018 17:19:20 +0000 (17:19 +0000)] 
Try to improve the error messages for misformed frame specifications in
window definitions.

FossilOrigin-Name: 927b95a0812787bcb3c28d1a0ea94717dc2cc60f6d480623f0c7cbce0c546fc9

7 years agoAlso disallow non-constant expressions in "<expr> PRECEDING" or "<expr>
dan [Fri, 6 Jul 2018 14:31:26 +0000 (14:31 +0000)] 
Also disallow non-constant expressions in "<expr> PRECEDING" or "<expr>
FOLLOWING" clauses.

FossilOrigin-Name: a6dffecc6b35c618cc5e5a06892765bdbec587dcd0ae8686c231a21516e38eab

7 years agoEnsure an error is returned if the user specifies an unsupported frame type.
dan [Fri, 6 Jul 2018 14:15:49 +0000 (14:15 +0000)] 
Ensure an error is returned if the user specifies an unsupported frame type.

FossilOrigin-Name: 0f3f8fcde1a535bcf93e23a68d2411c21785d8c0cac1f9481a06e7225755cdbc

7 years agoPrevent "UNBOUNDED FOLLOWING" from being used as the starting boundary of a
dan [Fri, 6 Jul 2018 13:48:09 +0000 (13:48 +0000)] 
Prevent "UNBOUNDED FOLLOWING" from being used as the starting boundary of a
window-frame. And "UNBOUNDED PRECEDING" from being used as the ending
boundary.

FossilOrigin-Name: e51fdf66a24c27ba6491391fffcc88fc5ca2ae79cfc4ab769a149b19c394e308

7 years agoRemove some bad assert() statements from the implementations of window
dan [Fri, 6 Jul 2018 13:25:02 +0000 (13:25 +0000)] 
Remove some bad assert() statements from the implementations of window
functions percent_rank() and cume_dist().

FossilOrigin-Name: 443f0c286f1659937fd61b4ef2de17d0d015369e5ff5249a9e0c3d0ee4925158

7 years agoReturn an error if DISTINCT is used with a window-function (.i.e.
dan [Fri, 6 Jul 2018 07:42:42 +0000 (07:42 +0000)] 
Return an error if DISTINCT is used with a window-function (.i.e.
"count(DISTINCT <expr>) OVER (...)".

FossilOrigin-Name: d59bcc8eea4fcf0ee3c2263d31ee42f9f26c28434d2f0045f2d3329f18791d1c

7 years agoUse separate opcodes, OP_AggValue and OP_AggInverse, for the new callbacks
drh [Thu, 5 Jul 2018 21:22:57 +0000 (21:22 +0000)] 
Use separate opcodes, OP_AggValue and OP_AggInverse, for the new callbacks
associated with Window Functions, for improved readability of EXPLAIN
output.

FossilOrigin-Name: fa6538050938ffeb042fbee31512514d6d3ace514b2a3dfd8365bbeb13f35a78

7 years agoUpdate the recipe for resetting a database using
dan [Thu, 5 Jul 2018 20:33:06 +0000 (20:33 +0000)] 
Update the recipe for resetting a database using
SQLITE_DBCONFIG_RESET_DATABASE.

FossilOrigin-Name: c43dd23fb00f7e0b6274de435d8e31f6a4cb74c3e86e8313a5098ff089e27574

7 years agoGet the json_group_array() and json_group_object() SQL functions working
drh [Thu, 5 Jul 2018 20:05:29 +0000 (20:05 +0000)] 
Get the json_group_array() and json_group_object() SQL functions working
as window functions.

FossilOrigin-Name: 916cdc83f5a45e0b6f61c52ff5fde70d54bcd0dfaa4a32f9ac709fe0ddbb480b

7 years agoReturn an error if a "RANGE" window-frame uses "<expr> PRECEDING" or "<expr>
dan [Thu, 5 Jul 2018 18:34:53 +0000 (18:34 +0000)] 
Return an error if a "RANGE" window-frame uses "<expr> PRECEDING" or "<expr>
FOLLOWING".

FossilOrigin-Name: 786c87ba4150509e141baab32c51e64bbd3ce323735e0f47d65ed54d14215bc4

7 years agoFix a problem in the xInverse method of window-function group_concat(1).
dan [Thu, 5 Jul 2018 18:19:29 +0000 (18:19 +0000)] 
Fix a problem in the xInverse method of window-function group_concat(1).

FossilOrigin-Name: 73391283101288251fe5d030ba12bcdabe8a781d41086afe3564c58c05d0fd5c

7 years agoFix the .dump command in the command-line shell so that it does not show
drh [Thu, 5 Jul 2018 17:35:46 +0000 (17:35 +0000)] 
Fix the .dump command in the command-line shell so that it does not show
extraneous SELECT statements when ".echo on" is enabled.

FossilOrigin-Name: 11763cac33fa809bcf0294d1a381394fcf860b020b51fff81217ee709ba99272

7 years agoIn wal mode, if a "BEGIN EXCLUSIVE" command (or any other command that
dan [Thu, 5 Jul 2018 17:16:55 +0000 (17:16 +0000)] 
In wal mode, if a "BEGIN EXCLUSIVE" command (or any other command that
upgrades from no transaction directly to a write transaction) hits an
SQLITE_BUSY_SNAPSHOT error, change the error code to SQLITE_BUSY to indicate
to the caller that the condition may be transient.

FossilOrigin-Name: e6108047cb136119d8ed19af010a669ed9750b4e7f991ccabc9e3d15774eda31

7 years agoFix a typo inside an assert() statement introduced by the previous commit. exp-busy-snapshot-fix
dan [Thu, 5 Jul 2018 17:03:43 +0000 (17:03 +0000)] 
Fix a typo inside an assert() statement introduced by the previous commit.

FossilOrigin-Name: e3357728472d5e57db6d7eef0ce008bdee071b5b07b60e242f383440eebe85bd

7 years agoIn wal mode, if a "BEGIN EXCLUSIVE" command (or any other command that
dan [Thu, 5 Jul 2018 15:46:55 +0000 (15:46 +0000)] 
In wal mode, if a "BEGIN EXCLUSIVE" command (or any other command that
upgrades from no transaction directly to a write transaction) hits an
SQLITE_BUSY_SNAPSHOT error, change the error code to SQLITE_BUSY to indicate
to the caller that the condition may be transient.

FossilOrigin-Name: 221ff63e7902226ebf728bb7442727420636831163708f360724506ce9487ab6