Commit Graph

30 Commits

Author SHA1 Message Date
dan
37f3ac8faa Change things so that SQLITE_OMIT_VIRTUALTABLE implies SQLITE_OMIT_ALTER_TABLE.
FossilOrigin-Name: 2f7c946c5f25a858167f5193ca06e53310394c8cff15426ab8a1327a1ec835fd
2021-10-01 20:39:50 +00:00
drh
eb61630b40 Fix a potential NULL pointer deference in the LIKE optimization. The
problem was introduced by the addition of generated columns
in check-in [b855acf1831943b3] (SQLite version 3.31.0, 2020-01-22).
Reported by Wang Ke in
[forum/forumpost/699b44b3ee|forum post 699b44b3ee].

FossilOrigin-Name: b9417d400f4585004f434837022709f818044d5844fe208fe01595a6b226ef7d
2021-09-07 15:41:25 +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
drh
b8fec21983 Fix generated columns so that they play well with upsert.
See the [https://sqlite.org/forum/forumpost/73b9a8ccfb|forum post]
by "iffycan" for details.

FossilOrigin-Name: fa9d93cf32fac4b86044acf5d1b9ea2f36e964ed7142cf1d270986c9ef3fb766
2020-06-29 20:26:50 +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
d3ee3ad12f An UPDATE of a table that is indexed by a constant virtual column that uses
the one-pass optimization might cause the table seek to be omitted before
reaching row DELETE/INSERT.  Fix this by coding an extra OP_Column in that
circumstance.  Ticket [ec8abb025e78f40c]

FossilOrigin-Name: e54560495926fbb8a2ce829c677a2dd0066e46b7a8d4ada9d8a34a3426959836
2019-12-26 23:16:18 +00:00
drh
ed0c34857a Do not try to access a generated column through an index if the collating
sequence for the generated column is non-standard.
Part 2 of ticket [e0a8120553f4b082]

FossilOrigin-Name: 056bb8dcbdc45989c5c6e86d2966200062e3c01c382ec52aae37c828104b4496
2019-12-20 22:46:41 +00:00
drh
67b9ba1732 Apply real affinity to generated columns of type REAL that are extract from
an index.  Ticket [e0a8120553f4b082]

FossilOrigin-Name: 728ad39e3bd07a2503a95c68ed5bbc3f28fd97551d59f12a5fab25dc68227e99
2019-12-20 20:45:02 +00:00
drh
4dad7ed532 When a table is part of a LEFT JOIN and should be a completely NULL row due to
the semantics of a LEFT JOIN, make sure any generated columns on that row
evaluate to NULL.  Ticket [3b84b42943644d6f]

FossilOrigin-Name: 0271491438ad2a985aeff355173a8d0f1e5813954c82147bc68cb26cca5804c8
2019-12-16 16:52:22 +00:00
drh
7e3f135c62 When a generated column expression is initially parsed, if it contains errors
convert the expression to a simple NULL.  This prevents additional pieces of
the expression tree that are allocated from lookaside from leaking into the
schema, where lookaside allocations are not allowed.

FossilOrigin-Name: a89b38605661e36d192df1d074383b704b34a959fcbc169837c0d4f6848f3208
2019-12-14 19:55:31 +00:00
drh
99670abb82 Do not set OP_Column flags on the instructions generated by
sqlite3ExprCodeGetColumn() if the opcode generated is not really an
OP_Column, which might happen if the column is virtual.
Fix for ticket [b439bfcfb7deedc6]

FossilOrigin-Name: 2401e04730a156aa48787b91af4e516406cb7635145e430be62fd16481816237
2019-12-14 17:43:37 +00:00
drh
0824d5b9a5 The previous check-in was not quite correct, and introduced a new problem
with the USING clause.  Use this version instead.

FossilOrigin-Name: ed28aaa4851202111a502f883ca06359d89b25bba4055c29d7bce2b501cfcc68
2019-12-09 18:22:17 +00:00
drh
926f796e8f Ensure that the SrcList_item.colUsed field is set correctly (set to have a
1 for all columns of the table) when a generated column appears in the USING
clause of a join.

FossilOrigin-Name: 1923efb283e8840fa7436eb20b9d2174ef7cace1690d3b97b572a0db2048b8e3
2019-12-09 17:14:48 +00:00
drh
ebd70eedd5 Fix the NOT NULL verification logic in PRAGMA integrity_check so that it
works for generated columns whose value is the result of a comparison operator.
Ticket [bd8c280671ba44a7]

FossilOrigin-Name: f3b39c71b88cb6721f443de56cdce4c08252453a5e340b00a2bd88dc10c42400
2019-12-09 15:52:07 +00:00
drh
7fe2fc0dcb Fix a problem with foreign keys and generated columns discovered by
Manuel Rigger.

FossilOrigin-Name: 27c0fdab1ba4d4993b164eb4b777c63e82aa247c3fa406121dc8ed94970a0b35
2019-12-07 00:22:18 +00:00
drh
f68bf5fbe6 Fix an incorrect NEVER() macro.
FossilOrigin-Name: 96b6a76da09a94182414ec1a56da91728c37329d2b55f889e433054ca21605ce
2019-12-04 03:31:29 +00:00
drh
cd30064bd5 Add all fuzz-test cases received from Yongheng Chen and Rui Zhong. Also
fix a minor problem in gencol1.test cases.

FossilOrigin-Name: ac080432b480062507452d3cdbe6c0f759e6f95b65d9862e0462017405ab2b8e
2019-11-21 20:24:04 +00:00
drh
522ebfa7ce Whenever a generated column is used, assume that all columns are used.
FossilOrigin-Name: 6601da58032d18ae00b466c0f2077fb2b1ecd84225b56e1787724bea478eedc9
2019-11-21 19:37:00 +00:00
drh
57f7ece784 Fix a problem that comes up when using generated columns that evaluate to a
constant in an index and then making use of that index in a join.

FossilOrigin-Name: 8b12e95fec7ce6e0de82a04ca3dfcf1a8e62e233b7382aa28a8a9be6e862b1af
2019-11-21 18:28:44 +00:00
drh
4e8e533bf7 Restore generated column loop detection logic that was incorrectly removed
from the previous check-in [9e07b48934e9a972].  This fixes ticket
[299b50ba812d8e54]

FossilOrigin-Name: 104a2beb57037f9353ffa77096aae0eb64e4682e667f31623bfd3d064dd8d881
2019-11-07 02:32:54 +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
4fb24c82cd Fix the OP_DeferredSeek index-to-table column map in P4 so that it works
with generated columns.  Ticket [ce22a07731530118]

FossilOrigin-Name: 36c11ad51fe9ab1bde0b98d0ea9b8588e07d168cd8027486749372894941ad93
2019-11-06 17:31:18 +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
1a9082f6d7 Omit the optimization that reduces the column-count on rowid-table cursors
when the table has generated columns, because we do not know what columns the
generator expressions might try to access.

FossilOrigin-Name: e6c96ed91e7a96d2bd30ea9df132644ac02d5a321a62f81f8f3984a8e49ed94b
2019-11-01 15:19:24 +00:00
drh
f09a14fbc3 Add missing column translations to foreign key logic.
Ticket [c28a01da72f8957c]

FossilOrigin-Name: bc6a43e7ee6353b9ef3dea4309c77e170a1c798eefcfaa7636bf5a93e51c47ee
2019-11-01 12:14:30 +00:00
drh
ff37c40787 Correctly generate pre-UPDATE content for virtual columns that are used
by foreign key constraints.  Ticket [b9befa4b83a660cc]

FossilOrigin-Name: 40d3282ec285d9f724f6548283f48b601510cf5284da17485723fd650a68f436
2019-10-31 20:54:20 +00:00
drh
29974f7b91 Add a few simple TCL test cases for generated columns. (Full test coverage
of the generated column logic is provided separately by TH3.)

FossilOrigin-Name: acedb5c7f7dc1d68bef62098d42ca59e1be7a5083bb03dc07c03b9f9d817158b
2019-10-31 17:13:17 +00:00
drh
04307c8a3f Ignore differences in Expr.op2 in sqlite3ExprCompare() in cases where it
does matter.  Ticket [1d2a8efc6c3a595a].

FossilOrigin-Name: 329820673a12ff6a6c8759f40989d4ccf272441064b0366a5f491695b55ad0e9
2019-10-31 13:16:26 +00:00