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

734 Commits

Author SHA1 Message Date
drh
5cf1b611a2 Further changes to ensure that expressions held in table and index definitions
do not get passed down into code generator logic where they might be modified.

FossilOrigin-Name: f45f5de000834da5b23cdcf12c3f0e3073287756afe06bdb77b95fb65b250258
2020-03-10 18:55:41 +00:00
drh
c84ad31851 There is no need to keep track of the number of changed rows or of the
last-insert-rowid while running VACUUM.

FossilOrigin-Name: a8a7c05b16f6c73ac55c359fbf62cae4a76eb0d105a3c53e9f47cede9fd85916
2020-02-06 20:46:08 +00:00
drh
51f37b2bb8 Cosmetic change to the xfer-optimization to put the OP_RowData opcode closer
to the corresponding OP_Insert opcode.  This makes it slightly easier to read
and understand the code.

FossilOrigin-Name: 0ea2dbfc9088561d62c3456803cb08d357e4e60f1d21f6ed37315564be4957d3
2020-02-03 19:56:51 +00:00
drh
9dce0ef4ca On an INSERT or UPDATE, perform affinity conversions on new data prior to
running CHECK constraints.  Ticket [86ba67afafded936].

FossilOrigin-Name: 1d4f86201dab9a22df9ef8175a7ebf3640e97cdb23a06fb454b4c69bfda3a9af
2020-02-01 21:03:27 +00:00
drh
b9f2e5f777 Minor change for compatibility with the s390 architecture.
FossilOrigin-Name: 04885763c4cd00cbca26d048f2b19316bfc93e8edebeceaa171ebfc6c563d53e
2020-01-28 15:02:23 +00:00
drh
ef9f719d0b Fix #ifdefs so it compiles cleanly with all SQLITE_OMIT compile-time options.
Update compile-time option testing.

FossilOrigin-Name: 7584e4b649d57767aac3906da6b06549d5b772aaa69f469c623ae5da834d54d5
2020-01-17 19:14:08 +00:00
drh
378ca1eab3 Merge the latest enhancements from trunk.
FossilOrigin-Name: bd57e6d923d3b04f0a07aaf18bf389d2b2b7efc7c57e8cb37e6ef910662d8397
2020-01-02 21:41:59 +00:00
drh
3aef2fb1b4 Have the OP_ReleaseReg opcode also invalidate the registers if P5 is non-zero.
FossilOrigin-Name: 937be22106f7e3f08712febd342d6cb81d129f2d5ab24ce80b3a5c3f9bbde54e
2020-01-02 17:46:02 +00:00
drh
6d67aff0e3 Issue OP_ReleaseReg opcodes against the array of registers used to compute
index records after the index record has been computed.

FossilOrigin-Name: e3330861b4deab7c7cc09ad8b936d633c600b9fb4e274801efeaaf94e5c860b4
2020-01-01 01:26:05 +00:00
drh
5f6a2ed7f2 Merge recent enhancements from trunk.
FossilOrigin-Name: 39d55579376906f212271ce9b2d367e3ad029fb173f22c7253312b467970208a
2019-12-31 14:49:10 +00:00
drh
7b14b65d20 Do not allow triggers that run as part of REPLACE conflict resolution
during an UPDATE to modify the the table being updated.  Otherwise, those
triggers might delete content out from under the update operation, leading
to all kinds of problems.  Ticket [314cc133e5ada126]

FossilOrigin-Name: db4b7e1dc399c1f16b827ac087aa37c0815f4b2f41f1ffad59963eead2ab5562
2019-12-29 22:08:20 +00:00
drh
d9670abb58 When an INSERT is receiving content from a SELECT, run an OP_ReleaseReg opcode
at the top of each iteration of the loop in order to prevent spurious
OP_SCopy misuse complaints.  Ticket [de4b04149b9fdeae]

FossilOrigin-Name: 6afadd3b3a40b0ef29fd14fb24c2a4b9479483e5f8b9125ce02d8daae662207f
2019-12-28 01:52:46 +00:00
drh
ad5f157791 Recompute the values for all generated columns after
NOT NULL ON CONFLICT REPLACE constraints fire.
Tickets [37823501c68a09f9] and [5fbc159eeb092130].

FossilOrigin-Name: 4cc12c18860bc4801a407cf45e88e23d3d40391f01a461fbac2cac5f102100e1
2019-12-28 00:36:51 +00:00
drh
d35bdd6c09 Ensure that all ON CONFLICT REPLACE indexes are sorted to the end of the list
of indexes for a table, even for weird cases where the same UNIQUE constraint
occurs twice with the ON CONFLICT REPLACE clause only on the second one.  This
avoids an out-of-order contraint processing problem that can arise due
to the optimization of check-in [469a62ca33081854].

FossilOrigin-Name: 1e3918ca2f2c1cfcfa44249b1d7b847d52cbb8d302a8d4a335c090cfdf22d7a1
2019-12-15 02:49:32 +00:00
drh
41cee66848 Change the name of the Expr.a.zName field to zEName, so that it has a name
that is distinct from other fields and variables and is hence easier to
grep for.

FossilOrigin-Name: d3783357f8fa76c42a86f12b214522f0388c37773c36ab8c5ce0623abbc4436a
2019-12-12 20:22:34 +00:00
drh
b5f6243f6d Set the affinity of regular columns prior to computing the values of
generated columns.  Ticket [d7c3f125c925c522]

FossilOrigin-Name: d47d66e3d360d8aa6203a855228d2bc40d9a00d69c15f5066b7632d8fb1ed2cc
2019-12-10 02:48:41 +00:00
drh
c6b24ab1b1 Do not allow UPSERT of a view.
FossilOrigin-Name: ebf897e861c19e214c57f1e73841b505182202cc8d7d39e24d5a1e5625e26b4a
2019-12-06 01:23:38 +00:00
drh
7dc76d8ba0 Fix an out-of-bounds array reference in the generated column logic.
Problem discovered by valgrind.

FossilOrigin-Name: a0ab42f779b9a96f4e43879210dfaba8fa593de77fc0ec0e2e6f116d9301ea59
2019-11-21 20:10:31 +00:00
drh
1e7c00e695 Fix the xferCompatibleIndex() function so that it recognizes that a PRIMARY KEY
index for a WITHOUT ROWID table is different from a UNIQUE constraint index
on the primary key.  Ticket [302027baf1374498]

FossilOrigin-Name: 34f64f11ca481996b1ff1686bdc5e278946635b6856cd1fe2355fce8e298e0f8
2019-11-07 14:51:24 +00:00
drh
dfa15270c4 Change the way generated columns are computed so that no column is computed
inside branch code that might not be taken.  Ticket [4fc08501f4e56692]

FossilOrigin-Name: 9e07b48934e9a972dcf62e3538b3b21ffa044c553feba0441675ac0bbe13bcb2
2019-11-06 22:19:07 +00:00
drh
b1129c423f Fix the handling of NOT NULL constraint violations for generated columns in
a REPLACE statement.  Ticket [2399f5986134f79c]

FossilOrigin-Name: 77b1c90add514050fe62f22751362fecacd99f9775346cffc60e09c326e64e10
2019-11-06 14:49:43 +00:00
drh
b6d861e523 Add a missing translation from table column numbers to storage table numbers
while processing constraints on an UPDATE statement.
Ticket [9621dd78a024d07a]

FossilOrigin-Name: 361ea81ae8a13e7d2ec4c2412f30e049bb6ee320980d502c86bedc315cdd3bc0
2019-10-29 03:30:26 +00:00
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