Commit Graph

8362 Commits

Author SHA1 Message Date
drh
fd46ec6476 Fix ON CONFLICT clause processing for NOT NULL constraints of PRIMARY KEY
columns on WITHOUT ROWID tables.
Ticket [f2be158c57aaa8c6]

FossilOrigin-Name: 13abba0941a724eb62455650976b03678e4455b6b3090c84a2ab2f4a7656b4d8
2021-08-18 22:26:51 +00:00
dan
0546027cd7 By default, do not use memory mapping to access the temporary files used for external sorts. The old behaviour (to use memory mapping by default) may be restored by building with SQLITE_ENABLE_SORTER_MMAP defined.
FossilOrigin-Name: 306694dfb462f9d1f128461e7a8f15a0bb9b21fbc696caa1832f4b20749490d1
2021-08-12 14:22:30 +00:00
drh
df67ec08ff Do not apply the push-down optimization to CTE subqueries that will be
reused in other contexts in where the same optimization is unlikely to
be valid.  Fix for the bug reported by
[forum:/forumpost/d496c3d29bc93736|forum post d496c3d29bc93736].

FossilOrigin-Name: a7ce29a6ef2e0362bbc9b23719d936dce07209b2651153c774682f599bbd888e
2021-08-11 13:48:56 +00:00
drh
c2df4d6adb Recognize certain standard datatypes ("INT", "INTEGER", "REAL", "TEXT", and
"BLOB") and if a column has one of those datatypes, store the type part of
the bit-field information in the Column structure to save space.

FossilOrigin-Name: d2da62a9df63036b02dadca3798de9e623c2680b3ef0c37d2b18bb88693afd7f
2021-07-30 23:30:30 +00:00
drh
e48f261ebf If a generated column uses the optional keywords GENERATE ALWAYS, try to avoid
putting those keywords in the typename of the column.
[forum:/forumpost/ff3ffe09251c105b|Forum post ff3ffe09251c105b]

FossilOrigin-Name: 3c954863f45271a3518acf51fd685a641878811fb5cfcbdbad85154aeccdc902
2021-07-30 20:09:08 +00:00
larrybr
1ae057d873 Remove sqldiff --visible-controls option, make it always happen. Add test cases for controls made visible
FossilOrigin-Name: ff74c0cc4cefa5271b12ecfff3f2fd4749852d9d1d01f4ae64a07a26decc001b
2021-07-26 19:49:01 +00:00
drh
55b8b73e74 Fix ALTER TABLE DROP COLUMN so that it generates valid bytecode even when
operating on a corrupt database and using PRAGMA writable_schema=ON.
dbsqlfuzz 5f09e7bcc78b4954d06bf9f2400d7715f48d1fef

FossilOrigin-Name: b65f4f763979ee9e0b943c787609ea22d6f7e01d41dfc1e084ec50a085a3550c
2021-07-22 18:22:51 +00:00
drh
348e002ec9 One of the optimizations of check-in [de9c86c9e4cdb34f] does not work for
terms originating in the ON/USING clause, as demonstrated by
[forum:/forumpost/6cf3bb457c3f4685|forum post 6cf3bb457c3f4685].  This
check-in disables that optimization for ON/USING terms.  Also improve the
TreeView display for the resulting "true"/"false" nodes to show that they
originate from the ON/USING clause.  Add a testcase() to the other optimization
to show that it can still be used for ON/USING terms.

FossilOrigin-Name: 1f6796044008e6f3a61bcf390c0c7eb31947e971f0edada74e7a3a211f8ae76a
2021-07-22 16:07:01 +00:00
drh
74e5a5a703 Run a "PRAGMA quick_check", if necessary, on the modified table after
an ALTER TABLE ADD COLUMN to verify that added NOT NULL or CHECK constraints
are satisfied by existing rows.  Abort the ADD COLUMN if not.
[forum:/forumpost/c04814903d6ec4f7|Forum post c04814903d6ec4f7].

FossilOrigin-Name: e3794997c34f03db2a4ac0ca5b76727d0e031778d92b08eaaf9631689ec3e56d
2021-07-20 16:07:15 +00:00
dan
d59f983501 Avoid a malfunction that could occur if the same correlated column reference appears in both the GROUP BY and the HAVING clause of a sub-select. dbsqlfuzz a779227f721a834df95f4f42d0c31550a1f8b8a2.
FossilOrigin-Name: 1e35cc6d5c2f563c6bb163bb150d7bc6ede4c993efa828af1face3261bf65a2c
2021-07-20 14:57:49 +00:00
drh
0f91a5352b Fix issues in the new ADD COLUMN constraint checking. Add preliminary
test cases.

FossilOrigin-Name: 48434ad3fa9504c063d812d119bc8f622548fd02b3d478ff247b11474c4ce5db
2021-07-20 08:23:54 +00:00
drh
53fa02507b It does not work to deserialized into TEMP, so do not allow it. The
sqlite3_deserialize() routine now returns SQLITE_ERROR if you try.

FossilOrigin-Name: 18068cc60698d4944a9d682cdf34b14b4d4b32f043f8d584dbf41c2bb5ac6220
2021-07-20 02:02:24 +00:00
mistachkin
f5b70d06ea Fix compilation of 'threadtest3' for some older versions of MSVC.
FossilOrigin-Name: b5ede6a68891820bd5b6d051b1b641bc1cd49104cad2466db184134d14f58f5b
2021-07-20 00:18:22 +00:00
drh
de3246176b More precision in comparing integers and floating point values while
processing the integer primary key for OP_SeekGE and similar.
[forum:/forumpost/2bdb86a068|Forum post 2bdb86a068].

FossilOrigin-Name: f9c6426de3b413ff8fcf04a00931ca5f123f996c572b35181af114afa8d811d7
2021-07-19 20:52:31 +00:00
dan
bb2d2a50f9 Updates so that "threadtest3[.exe]" can be built for windows with MSVC.
FossilOrigin-Name: 4ce585fb07274284e3add6adcb66ed06e4b109584704d1ec7152bf43ca8d5d85
2021-07-19 16:49:13 +00:00
drh
e46ec734c7 Modify the generate_series() table-valued functions so that its first
argument (the START value) is required.  Throw an error if that argument
is not supplied.  In this was the series.c loadable extension can be used
as a demonstration of how to code an xBestIndex function to require certain
parameters.  Compile with -DZERO_ARGUMENT_GENERATE_SERIES to obtain the
legacy behavior.

FossilOrigin-Name: 459d85a2898d6a53f43b4ad48d2f39edd1bbe37a4f97426a5d666c39c52576a4
2021-07-16 17:04:17 +00:00
dan
20235e56f7 Fix a use-after-free error in ioerr.test caused by an error in test code.
FossilOrigin-Name: 1594056aab068b9fae82f6b885828c7127d9bedcc37c4340486e32791bc87c7a
2021-07-14 21:18:31 +00:00
dan
8eed584786 Fix an assert() that might fail if sqlite3_create_function_v2() is invoked with NULL xStep and xFinal callbacks and a non-NULL xDestroy.
FossilOrigin-Name: ab1550a608684b6b9104b555a975482cfabca5053b7d7dcc60d63a0e3a8d707d
2021-07-09 14:59:12 +00:00
dan
bd24e8faa3 Preserve and return to the user any error message returned by a failed xConnect() call on an eponymous virtual table that prevents a query from being compiled.
FossilOrigin-Name: bbbbeb59a6a14b94dcbaf218cbcfbd39feba4a1df5b37c0e1a955391393eeec4
2021-07-08 18:29:25 +00:00
drh
9d41caf361 Fix a harmless compiler warning in the "fuzzcheck" test program.
FossilOrigin-Name: 8c432642572c8c4b7251f413def0725b3b8e9e7fe10230aa0aabe86b58e5902d
2021-07-07 19:44:32 +00:00
drh
4f16ff9d06 Follow-up to [68db1ff9c44fa9c3]: The number of registers needed by
PRAGMA foreign_key_check was increased too late for an assert() deep
down inside of sqlite3ExprCode().  So move the size increase a little
earlier.
[forum:/forumpost/79c9e4797d|Forum post 79c9e4797d].

FossilOrigin-Name: 7072404ad0267b8ee774b2804ea59ea28e29316521d76d76a701595e51d1be97
2021-07-07 16:48:24 +00:00
dan
74777f994d Improve the error message in cases where there is a row-value on the LHS of an IN() operator, the RHS is a list (not a sub-select) and at least one element of the list is not a row-value with the correct number of elements.
FossilOrigin-Name: 6b22f4e71dbc14c887ebbda67095b5faaa8079cac87cd4ab5a2ae90c71cd9633
2021-07-07 13:53:55 +00:00
dan
9289f5103d Handle "<vector> IN (<vector>, <vector> ...)" in the same way as "<vector> IN (VALUES(<vector>, <vector>, ...)".
FossilOrigin-Name: 981d230ece98ce89502dab02aa44f73699a9d0e4fce3e9e9dfd47444a5a9990f
2021-07-06 20:44:32 +00:00
dan
5daf69e5f4 Allow sub-queries in the FROM clause of an UPDATE...FROM statement to access the object being updated without using an alias, as is required in the parent query.
FossilOrigin-Name: 740cb43025449b7d7b47a97ad00885e54b7701cbcb14f4a50c7523022e3936d5
2021-07-05 11:27:13 +00:00
drh
e46292a920 Improved rebustness in sqlite3ExprListDup() when it contains a vector assignment
from an UPDATE where the initial term is omitted.  This can happen during a
UNION ALL query flattening while processing a virtual table update in which
the first term of the vector is repeated.
[forum:/forumpost/16ca0e9f32|Forum post 16ca0e9f32].

FossilOrigin-Name: 2547cfe38f8fb35109b3fc5bdfada387fe4b2b8a304156b704ab7f03f1f71198
2021-07-05 02:40:29 +00:00
drh
105c4b5ced Fix an incorrect comment on testcase misc1-27.0. No changes to code.
FossilOrigin-Name: 49829ae3229b7c7c7adeaa970a84aebd5157bc93b38fd6d80d86cc03f5fdde6f
2021-07-05 00:07:39 +00:00
drh
5c46a7e555 In the PRAGMA foreign_key_check, ensure that sufficient registers are
allocated for the virtual machine, even if one or more foreign keys reuses
the same column multiple times and has more columns than the table it is part
of.  [forum:/forumpost/a6b0c05277|Forum post a6b0c05277].

FossilOrigin-Name: 68db1ff9c44fa9c37690ce55ad304d4263ba6fac490063d9e08470de6c17cfe6
2021-07-03 02:55:47 +00:00
drh
dd51365408 Put ALWAYS() on a branch that is always true due to [d4097364c511709b].
Fix a testcase precondition associated with the same check-in.

FossilOrigin-Name: 55e2fbebb0a2c9991feef46f31e79b82a24de272aae836bf4d3c06ee06ef1a70
2021-07-02 12:25:30 +00:00
drh
4d466698a2 Fix a harmless assertion fault discovered by
[https://oss-fuzz.com/testcase-detail/5517690440646656|OSSFuzz].  The
assertion fault is harmless because the assert() checks a condition that
that is harmless if false and the assert() is disabled in production
builds.

FossilOrigin-Name: 79443aabe1db8cc2ff9537fde0dac0e858eae3f3848ee9cc1b8fba47b824bf08
2021-07-02 12:08:12 +00:00
dan
b9248ef5c7 Allow unqualified "rowid" references to be used in join queries, provided that only one of the source objects has a rowid.
FossilOrigin-Name: d4097364c511709b1874881a0c036640777d1f724165416adf6f53a41f8c6e40
2021-07-01 18:19:17 +00:00
dan
cf1e25566b When generating data for a RETURNING clause, avoid assuming cursor number 0 is available for use.
FossilOrigin-Name: 4b2c59acce6ff1bb6c9c04c45c80945ae23a26588718cc20635d60f7497adabb
2021-06-28 15:25:17 +00:00
drh
4422b3a646 The OP_ReopenIdx opcode should clear the cursor if the cursor is being
reused.  This prevents leaving the cursor in an initialized state which
could cause problems for a subsequent OP_SeekScan opcode.
Fix for ticket [6dcbfd11cf666e21] and the OP_SeekScan optimization
of check-in [4a43430fd23f8835].

FossilOrigin-Name: d4bf5243f2bf0a2bc77ad12f3e1e4797cb62f2745f9d54eee5f675c3b5f80880
2021-06-25 14:48:24 +00:00
dan
a261c02d44 Fix a problem handling ORDER BY terms of the form "ORDER BY likely(<integer>)" within window frames.
FossilOrigin-Name: 710f75b98bb4ac5bfdfa745c1de832dd1e4d9fb387da52b2f0d1353613f5cdc3
2021-06-23 11:12:48 +00:00
dan
2c7188732d Add the sqlite3_changes64() and sqlite3_total_changes64() API functions.
FossilOrigin-Name: 48fdec22c966003f5577e0bf52906ef90df11e4e395723a646304e67ed976f37
2021-06-22 18:32:05 +00:00
dan
020c4f3830 Fix a problem causing sqlite3_changes() to return an incorrect value following a "DELETE FROM tbl" command on an intkey table (because internal b+tree cells were being included in the count).
FossilOrigin-Name: f662ff4746aaa43e63e20710b8cbfeeceab3183e953ac1685c41846d2e9d124c
2021-06-22 18:06:23 +00:00
drh
4d2c20331a Load recent dbsqlfuzz cases into test/fuzzdata8.db.
FossilOrigin-Name: a766bba0eead47e9ff24b6afd152a7fbd331261e04dd76feb9510585a08c5786
2021-06-20 22:52:51 +00:00
dan
755708538d Omit a handful of tests from pager1.test when testing SQLITE_ENABLE_ZIPVFS builds.
FossilOrigin-Name: c3036c28259c1375cd2c480c9ca0ce7f9aa1e952be4f110dde49b2b7d72a43b7
2021-06-16 18:58:01 +00:00
drh
cbe83495ee Adjustments to requirement markings in comments. No changes to code.
FossilOrigin-Name: be00e45b723adf64bc78927dc12de3116fd04912a52e5c105a52f235c57698f5
2021-06-16 12:26:01 +00:00
drh
972da42749 Prevent an infinite loop in the trim() SQL function if the second argument
is a carefully malformed UTF8 string.

FossilOrigin-Name: 829343c26ed7b87fafc70de3369625209bad91e79bb7ca2946d5c8d61cc1c3c4
2021-06-15 14:34:21 +00:00
drh
93fd5420d0 In the authorizer, use SQLITE_DROP_INDEX, not SQLITE_DROP_TEMP_INDEX
when dropping an index in an attached database.

FossilOrigin-Name: e5a5acd6006133c5da4a7dd79726dbaa41c0d60ebeda890f848a6aafe5f9ef70
2021-06-14 20:41:20 +00:00
dan
ac67f56726 Fix an ALTER TABLE problem with handling infinite loops of CTEs in the database schema.
FossilOrigin-Name: c09d90eec2a49b948c60971294d146db5c82438855cd3fa48ddc3d2e6b44c26c
2021-06-14 20:08:48 +00:00
dan
09612a5bb8 Fix a test script problem in corruptN.test.
FossilOrigin-Name: 3ddfe9ae55e6d0d922fbc209768b2ac4a4792f0f63af9a8fb53d66a4b8f1d94b
2021-06-14 14:52:27 +00:00
drh
21571a94c1 An index on the expression "likely(X)" should store the true value of X,
even if X is a real number with no fractional part.  The optimization of
storing some REAL indexed values as INT (see [10d851353c2abead]) should
be omitted for index columns that are expressions.
[forum:/forumpost/3b940c437a|Forum post 3b940c437a].

FossilOrigin-Name: 791473bc6677c2ae76f558082a4b43ca1eaf9895b76624d5b55d58f2af898ff3
2021-06-14 14:00:09 +00:00
drh
de5f21d0a8 Avoid allocating oversized column names in the sqllimit1.test module.
FossilOrigin-Name: 7068f1f69b4feef49260e80902e6bdae47c21a0daa16c96ed1a0984dd1f14cdc
2021-06-14 11:20:30 +00:00
drh
0d08402f34 The opcode that preceeds OP_SeekScan is usually OP_IdxGT but can sometimes
be OP_IdxGE.  Adjust asserts accordingly.  Follow-up to
[9a2ab6092d644fc3].  dbsqlfuzz e41762333a4d6e90a49e628f488d0873b2dba4c5

FossilOrigin-Name: d6803ed8dc4b1eb4d4dc100728acb4a4aa1479732f0fcb94eb23b7f7702ef65c
2021-06-13 19:14:14 +00:00
drh
35e6cd09f2 Reapply two recent ALTER TABLE error checks that turned out to be necessary
after all.  dbsqlfuzz fc5a9deefda00dda914748985155a6d4c44174e5.

FossilOrigin-Name: 230fedd923c87741d20caf55f29e8464cc6df344536f9b89331e0a0059a926f7
2021-06-11 13:18:56 +00:00
dan
d03d3a9b74 Fix a crash in new ALTER TABLE code that could follow an OOM.
FossilOrigin-Name: 6f1f2a0a9cd75ca43b81cc325296b843ccefe6f8040da8f2e873f49928423f10
2021-06-11 12:14:58 +00:00
dan
26d61e5adf Fix problems with ALTER TABLE and schemas that contain views with some recursive CTEs, or CTEs that reference other CTEs.
FossilOrigin-Name: 8b1f9a51e962cd9a5593a1ecf4da6c86e34c4f9ff96ffcea0fb421880c8836cb
2021-06-11 11:14:24 +00:00
drh
18f9be897d Remove two assert()s in FTS5 that checks for database corruption right before
actual code does the same check.
dbsqlfuzz 9680db8f5338cb9b6060eb3a02d984555d4472e3.

FossilOrigin-Name: f3f82967b2e9fd4168d86300138ac4bbcd6ffd7a3ff5ecf20acdc29e5356ac3b
2021-06-08 23:46:59 +00:00
dan
822810b95a Avoid a buffer overread in fts3 that could occur when handling corrupt data structures.
FossilOrigin-Name: 45f459d2fa4be97d9bbb970efbc0b5d40efaf93f52ed111fd0fcdc572c24327b
2021-06-08 12:15:56 +00:00