1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00
Commit Graph

662 Commits

Author SHA1 Message Date
drh
1231b4773d Remove code from the constraint checker that generates virtual column values
with the incorrect time.  Turns out the the regular code for all other
columns works correctly and so the incorrect special-case code is not
actually needed.  Fix for ticket [3ea175512444b0d1].

FossilOrigin-Name: 5b4c0f2ddc6f324e23bbde0ee3d1ab672cfe8ab5044c9b693f4c33cdd75c211e
2019-10-26 23:51:44 +00:00
drh
c34f05cca7 Remove redundant code resulting from a merge error on the previous check-in.
FossilOrigin-Name: 713fe86b8c9f3c9ef8af952019e99ba2f4741326226264de6a66baaeb1803d2a
2019-10-26 18:56:12 +00:00
drh
a88c8c1ae4 Add support for generated columns.
FossilOrigin-Name: b855acf1831943b3914491ed0bc333131321930cab480a5281012a3aebbba492
2019-10-26 18:47:47 +00:00
drh
cbda9c7ac7 Performance optimization on sqlite3GenerateConstraintChecks() - bypass the
loop that checks each column for NOT NULL constraints if it is known in
advance that the table has no NOT NULL constraints.

FossilOrigin-Name: e3c3f4d7872f431a95627d52553101388c1e39458cc7e7f93fc81255f49a89a5
2019-10-26 17:08:06 +00:00
drh
d3c468b758 Clarify some comments and add assert() and testcase() macros to the
replace-trigger recheck logic for ticket [c1e19e12046d23fe]

FossilOrigin-Name: 8c0042bd5ccd83f8794d19cbb1ec7564584f0dce54bfebc0ada00b836aca065f
2019-10-26 16:38:49 +00:00
drh
d901b168b5 Overnight, OSSFuzz helpfully pointed out a potential use-after-free bug in
yesterdays changes, involving continued use of a pointer after the memory
pointed to had been realloc()-ed.  Thanks Google.

FossilOrigin-Name: c422afb507dc875751e6a72e4ba5f4f0793097c0de4533c1600311f689e76ed7
2019-10-26 12:27:55 +00:00
drh
0660884ea0 Add missing VdbeCoverage() macro. Fix an off-by-one error in partial index
handling.  New test cases.  Ticket [c1e19e12046d23fe]

FossilOrigin-Name: 41cc8e3dab998f7efc898d18837ca7fdac94ea3f89954990c5231456bf725fee
2019-10-26 01:43:14 +00:00
drh
a407eccb61 If replace triggers are run during uniqueness checking, then rerun all
uniqueness checks a second time using the ABORT algorithm.
Fix for ticket [c1e19e12046d23fe]

FossilOrigin-Name: fbac0c65d8464b126d385262d176864add55452ec9e3d5eb76ffee06e820cb9c
2019-10-26 00:04:21 +00:00
drh
1b22c1b816 Merge fixes from trunk.
FossilOrigin-Name: 4ec57d88415fa4ea2e99d4a5671074ec6829d6824bc8509d5ae9c978d47d1419
2019-10-24 23:43:32 +00:00
drh
06baba54b4 Correction to check-in [bec5b6d4d083556d] so that it detects *all*
triggers that might perturb the insertion cursor.
Ticket [50c09fc2cf0d91ce].

FossilOrigin-Name: 521f1d36282549488a47a434484a24924ee970d29f05a8ae499b7d536bcd692b
2019-10-24 19:35:26 +00:00
drh
6ab61d7052 Minor adjustments for clarity and test coverage.
FossilOrigin-Name: 30065716878d4058e75eb510b0b27b68e5193d04625eb173210de8061f20f499
2019-10-23 15:47:33 +00:00
drh
ab0992f022 Fix incorrect arguments to testcase() macros.
FossilOrigin-Name: 812467fbf04ce00228a8381a5eee471e4e35cc63184a4538129fcd70b7cec979
2019-10-23 03:53:10 +00:00
drh
e70fa7feba Take the declared column time into account when computing the values for
generated columns, and apply appropriate affinity.

FossilOrigin-Name: 9e04ba22dfce3998e61331ac229ff543ecccc590284c9dd5def21efbe594fba0
2019-10-22 21:01:34 +00:00
drh
427b96aedf New testcase() macros. Fix a problem with INSERT when the IPK is to the
right of generated columns.

FossilOrigin-Name: 412799fc5527aaca987e4e04b8a4f774dcdb70fb80e3a126dc3a26d48a66935c
2019-10-22 13:01:24 +00:00
drh
6b910364bb Merge changes on trunk into the generated-columns branch.
FossilOrigin-Name: ba123b8c201053d8f9387de38f3513b06f7721b28d79fab8489f96d336105117
2019-10-22 12:02:09 +00:00
drh
2c3de90da1 Add a VdbeCoverage() macro that was omitted from check-in [eea1e7aa57e74c43].
FossilOrigin-Name: cd2317d04c1c4bcf5fe63aa02a6051bdfae8f5566a098e3f45bf9ec1dd0c3ea6
2019-10-21 23:41:56 +00:00
drh
f5f1915d59 Changes to the INSERT logic to make it simpler and faster and so that
it works with generated columns and BEFORE triggers.

FossilOrigin-Name: bc368cb090376d33d3844e3689c4f6bd19eed758e39b878ee67fef93b1c839ea
2019-10-21 01:04:11 +00:00
drh
dd6cc9b52a Work toward getting generated columns to work with triggers. Still more
work to do in this area.

FossilOrigin-Name: 932a37275d7e932f8237d32c8fc6087ed8cd342fe01ef2f7a43c7237ab84c9ac
2019-10-19 18:47:27 +00:00
drh
c5f808d85e Add testcase macros.
FossilOrigin-Name: fb9c9bb284d441bd7aa34c87b6fd8ce57d036c17623d82354154fc6286bdd134
2019-10-19 15:01:52 +00:00
drh
b9bcf7ca60 Refactor names of column index transformation functions, for clarity.
Get generated columns working with ALTER TABLE RENAME COLUMN.

FossilOrigin-Name: 27ab41c9102e7801ff829488fc123a8040da008bef373d6704efbe2f93e1da90
2019-10-19 13:29:10 +00:00
drh
4102deb962 Merge trunk enhancements into the generated-columns branch.
FossilOrigin-Name: 85bc4524d76999080faa4474e8880d2b6a2ac3a7f6a76239af4de1a42f8138c8
2019-10-18 17:47:47 +00:00
drh
8e10d74b21 Get generated columns working for WITHOUT ROWID tables.
FossilOrigin-Name: 9f409649ec4282a47f0a8b079b419f1922e0c24779b297f477ced168d5b7910d
2019-10-18 17:42:47 +00:00
drh
463e76ff8f Get indexes working on virtual columns.
FossilOrigin-Name: 450c48766c8e62653d074c95f69b0576de3880d183a1d1e5992d88b6fce6cc39
2019-10-18 10:05:06 +00:00
drh
9942ef0d95 STORED columns can now reference other STORED columns, in any order, as long
as there are not loops.

FossilOrigin-Name: 0d236698e64b2a4b46f91a25279c406e0bf392fe66116678456f0a034c11d7b4
2019-10-18 02:19:18 +00:00
drh
0b0b3a95d0 In the Table object, change the nVCol field to nNVCol - the number of
non-virtual columns, as that is the quantity that we need most.

FossilOrigin-Name: 4ad66af04a654d92711d2d056ce8f35cd21eac4b99fb8d78be1a314620b6d29e
2019-10-17 18:35:57 +00:00
drh
d4cd292c2a Bug fix with INSERT using an explicit column list on a table with
a non-final STORED column.

FossilOrigin-Name: 61b4459ae6a6cc182c11abbc8b1dd629f77beb088d7ccad5e563d8d4769056df
2019-10-17 18:07:22 +00:00
drh
c143114460 Some (but not all) INSERT and UPDATE statements now work for STORED columns.
FossilOrigin-Name: fe7517bf4d360597576ab9aba29627d7926d23f2bbbfb3e7bf4d32761617574c
2019-10-17 17:54:05 +00:00
drh
ae3977a8f3 Fix the xfer optimization for generated columns, so that VACUUM works again.
FossilOrigin-Name: 8f67b89b04622c1509dc102a83be7a80057dc791625804fc2c294089c98b97e4
2019-10-17 16:16:34 +00:00
drh
676fa25a0f Bug fixes so that "make test" once against runs with no errors.
FossilOrigin-Name: 7bfe0f679d8951b3e925bdf549efa0f8d6b514eddeaca69cbfddbd9476cfff5f
2019-10-17 14:21:07 +00:00
drh
ab45fc0413 INSERT with named columns for a table with generated columns.
FossilOrigin-Name: 64db39f92d68d1b9f23e48af35e16b969c38b58041fbe900066eeb3ddb291cef
2019-10-16 22:01:56 +00:00
drh
c27ea2ae8d ALTER TABLE is able to add a VIRTUAL column.
FossilOrigin-Name: 120c6b78cb51532f783014605f1107d40b2e4f54e3852fb1f8f167d0c0b78c69
2019-10-16 20:05:56 +00:00
drh
7e508f1ee2 Simple INSERT and SELECT operations working with VIRTUAL columns.
FossilOrigin-Name: 7f9f90b1b885fa9905b296f2e0fcc9b2341019b42fc839722a93cf60e49a9252
2019-10-16 19:31:46 +00:00
drh
2da8d6fe74 If an AFTER DELETE trigger fires when a conflict row is deleted by REPLACE
conflict resolution, make sure the conflict really has been resolved and that
the trigger did not recreate the row before continuing.
Ticket [a8a4847a2d96f5de]

FossilOrigin-Name: eea1e7aa57e74c4329003f4550168e2aed9e33d2301a3ba84b10781a9cebbc1b
2019-10-16 14:56:03 +00:00
drh
7314495ff8 When the affinity of a table column is INT or REAL, make the affinity of
corresponding index columns NUMERIC.  This increases the precision of
index lookups for large numbers so that it matches the precision of
ordinary comparison operators.  Ticket [40812aea1fde9594]

FossilOrigin-Name: e0d909c740b774d8a46731696e33342be83206cc4a95d07f42fdb3d8cc2d7a8e
2019-08-30 23:56:34 +00:00
dan
9105fd5189 Prevent NULLS FIRST/LAST from being used in CREATE INDEX and other statements.
FossilOrigin-Name: bb9767a287097a615aeb4abdba689b10e1a1c36c016c8e55905b508075e62c86
2019-08-19 17:26:32 +00:00
drh
96fb16eecd Use 0x40 (ASCII '@') instead of 0x00 to mean "no affinity" so that columns
with no affinity can appear in a zero-terminated string.  Use the new
SQLITE_AFF_NONE macro for this new magic number.

FossilOrigin-Name: e8234f6939ccff4c10f741cf66d1c537cfebcbd0d1d79a618a64c755a7f087b5
2019-08-06 14:37:24 +00:00
drh
81506b88b8 One of two options on how to address ticket [61c853857f40da49]. In this
mode, we back out the documentation change of
[https://www.sqlite.org/docsrc/info/07b7749da88d54e5|[07b7749da88d54e5]]
and change the core to work as it has been documented to work since 2017,
rather than how it has actually worked since 2009.

FossilOrigin-Name: 09cd0c0c6e6c963e0039a733876e5149adb3cd10e9b92699fa1dcb0633e997a4
2019-08-05 19:32:06 +00:00
drh
0ce974d122 Adjust requirements marks and add new requirements tests.
FossilOrigin-Name: ebb81dad1f43dac4636cd44d4055d1d4b198c675f73e23c5a2d8d992ae27fe1f
2019-06-12 22:46:04 +00:00
drh
a7c3b93fa6 On an INSERT or UPDATE, generate the new table record prior to running
foreign key checks, in case the foreign key checks changes datatypes on
the registers holding column values.  Proposed fix for ticket
[e63cbcfd3378afe6980d626].

FossilOrigin-Name: 3f1c8051648a341db4dffad66d3b1f9980d8a2b314cb0ce879cb2a10d1779b84
2019-05-07 19:13:42 +00:00
drh
e3bd232e2d Add the ability to override the new corruption detection logic
of the previous checkin, in order to exercise downstream corruption
detection during testing.

FossilOrigin-Name: e859d3184606dd453b9fc4ee388922d7be4b61aad84a66ac82107935ffd56f3a
2019-04-05 16:38:12 +00:00
drh
86223e8d65 In the xfer-optimization, do early detection of when the source and destination
index share the same btree, to avoid a long delay prior to reporting the
database corruption.

FossilOrigin-Name: af1e5873d44d31466023ae145bdfc6b4191eb48b62e5752c6e683bcf571980e7
2019-04-05 15:44:55 +00:00
drh
4e61e88348 Only preserve rowid values for VACUUM INTO. Keep the legacy behavior of
renumbering rowids for ordinary VACUUM.

FossilOrigin-Name: 13a0ea6466b051ea5281865ed5285b8b5a99ec4307f400c5f7b03692723f1cd1
2019-04-04 14:00:23 +00:00
drh
50ef6716d2 Make all ephemeral tables built to hold the RHS of an IN operator be
index-btrees, never table-btrees, regardless of whether or not they are
used as IN_INDEX_LOOP or IN_INDEX_MEMBERSHIP.  That way, the same ephmerial
table can be reused for both cases.

FossilOrigin-Name: c2d50df8fd1a1fdae6226a3e77296ded09b53a74540caedd4868e686a93cbc10
2019-02-22 23:29:56 +00:00
drh
9df385ec3d Always use the symbolic name SQLITE_IDXTYPE_PRIMARYKEY rather than a hard-coded
magic number 2.

FossilOrigin-Name: 55d43adc894a6b1e0f77bf481dad6dd604a0dc0022e72bbf2e3037f97351971e
2019-02-19 13:08:35 +00:00
drh
24bfecab3c Experimental change to VACUUM so that it preserves existing ROWID values.
FossilOrigin-Name: f264015f84de51d74f681ba62a5f26bd859480d93e1eaf9e1018b3e9b4e0bea3
2019-02-07 15:09:44 +00:00
drh
21908b2166 Disable the xfer-optimization if the two tables have the same root page
due to schema corruption.

FossilOrigin-Name: f31b3bd2a6a8aa35a6454f37f3a4b4595e2ad74256cd180439019ab4c6c2059e
2019-01-17 20:19:35 +00:00
drh
04fcef00ee Fix a corner-case for the logic that cause an insert of a NULL into an
INTEGER PRIMARY KEY column to be converted into a valid integer key,
when the NULL results from a CASE expression that lacks an ELSE clause.

FossilOrigin-Name: 9a425051e7ba59e797636f5cf32b5f6efafdb21c8d5300e099b8008b829c1439
2019-01-17 04:40:04 +00:00
drh
6214d93993 Fix an off-by-one error on a Goto in the code generator, that only
causes problems for a REPLACE on an INTEGER PRIMARY KEY in non-debug
builds.  Test case in TH3.

FossilOrigin-Name: e35eb8776ed539afe1d5db099470ab1124d8dd2db73ee5db7c811f8df9a9576e
2019-01-12 16:19:23 +00:00
dan
418454c63f For SQLITE_ENABLE_PREUPDATE_HOOK builds, disable the optimization for a
REPLACE command on a WITHOUT ROWID table with no indexes, triggers or foreign
key constraints that causes SQLite to clobber any existing row without
separately checking for it. This optimization causes SQLite to omit the
expected pre-update-hook callbacks.

FossilOrigin-Name: 6281ef974c0ac7a7133c9e1e04c09fdbd627c019c6ff3227293548caf8283864
2019-01-07 15:57:35 +00:00
drh
b042d92128 Give a meaningful error on an attempt to use UPSERT on a virtual table,
rather than simply not working.

FossilOrigin-Name: fa98748f956cff95fcfda3a513cea4df27aa573ae795a6855c40bfeca661d0b2
2019-01-04 23:39:37 +00:00