Commit Graph

19522 Commits

Author SHA1 Message Date
dan
dabc268f96 Ensure that CREATE VIEW, TRIGGER or INDEX statements can be edited by ALTER
TABLE RENAME COLUMN even if they use collation-sequences or
user-defined-functions that are not available.

FossilOrigin-Name: 540014efd6a048373313c6cd9413de10d5d7114daf537cf5999ccf3c5c3f9358
2018-08-17 17:18:16 +00:00
dan
0cbb0b11f1 Further progress on updating trigger programs as part of ALTER TABLE RENAME
COLUMN.

FossilOrigin-Name: 3f47222b6e20e1c1ef41c0f7391c8b5c7648e2a2d6013303d155ad59ce27143a
2018-08-16 19:49:16 +00:00
dan
5be60c55e8 (no comment)
FossilOrigin-Name: e272dc2b1c0edab59a40f32c77c81a3e636937280524161eff5669cb0046ad84
2018-08-15 20:28:39 +00:00
dan
356afab163 Fix a problem when renaming an IPK column that is also part of a child key.
FossilOrigin-Name: 6e6a2bfdbbfd4ffc14be88962ff97bf3c626fef9d1a337715d2a4be1a657fb0d
2018-08-14 21:05:35 +00:00
dan
f62e8937ac Fix a problem when renaming an IPK column that is also part of a child key.
FossilOrigin-Name: ad15486022209205c65fb5ffdbe30a7b99379170451e6aff4bab6e90b549d6c7
2018-08-14 21:03:38 +00:00
dan
72238130d0 Merge latest trunk and ALTER TABLE error message improvements into this
branch.

FossilOrigin-Name: 7a45802dafaed3c058f59d1487fe8091e1f309cc5f0a5bcf2579f0bdd8e92d89
2018-08-14 20:40:25 +00:00
drh
af4023de22 Do not allow ALTER TABLE RENAME COLUMN on a virtual table.
FossilOrigin-Name: f6d6b472713c21deace3fd52c0b0b6901d758af043c238f004fabe52b01f730c
2018-08-14 20:38:18 +00:00
dan
987db767d2 Have ALTER TABLE RENAME edit column references in CREATE VIEW statements.
FossilOrigin-Name: db829dc1a2d7afa49798a2fd32d1f070185b23e513416e65d8144fda24f23b50
2018-08-14 20:18:50 +00:00
drh
1595abcda6 Improved error messages when an ALTER TABLE RENAME COLUMN fails due to a
duplicate column name.

FossilOrigin-Name: 37d11b8e8224a8b241ff57b9c4b9499db39dde4ddcb56ff8b03a3d08091a4c11
2018-08-14 19:27:51 +00:00
drh
5550b5eee7 Merge fixes and enhancements from trunk.
FossilOrigin-Name: dff0314b7e7ef2d04375ff21fbf89039bf5f64a9cdca53d7bc7120faacd92c06
2018-08-14 18:12:33 +00:00
dan
689b9d269c Fix ALTER TABLE RENAME COLUMN in cases where the column being renamed is an
IPK declared with a separate PRIMARY KEY clause - "CREATE TABLE x(y INTEGER,
PRIMARY KEY(y))".

FossilOrigin-Name: 32ca8418df8735a6c53e53153f733579e514711f091e4e09ecce83db85fe4d85
2018-08-14 16:18:19 +00:00
drh
8430450674 Fix UPSERT so that it checks the target-constraint first and fires the
DO UPDATE if that constraint is violated regardless of whether or not
other constraints are in violation.  This aligns SQLite behavior with
what PostgreSQL does. Fix for ticket [908f001483982c43cdb476dfb590a1a].

FossilOrigin-Name: 529fb55e3d00472f13446117527b0896827b11e870b581af7fe7cbb7392ef3cd
2018-08-14 15:12:52 +00:00
drh
ef52b36a6b Stop requiring the global VFS mutex to access the unixInodeInfo.pUnused field.
The unixInodeInfo mutex is sufficient.

FossilOrigin-Name: e3ea43dabf099dc2954c23d348638e7b2a8b9122d2994154bc649a2c09260c46
2018-08-13 22:50:34 +00:00
drh
095908e1c7 Take extra precautions to ensure access to unixInodeInfo.pUnused is protected
by all necessary mutexes.

FossilOrigin-Name: 8b1e0010b9e0b548a90087f4d25843d2b40f7e9551722ac587fa925d37b510c2
2018-08-13 20:46:18 +00:00
dan
5496d6a25a Edit the WHEN and UPDATE OF clauses of trigger programs as part of ALTER TABLE
RENAME COLUMN.

FossilOrigin-Name: 5fdb6b0aafba727139e1937ef5950e4434a77f95a10fc46f8010ca2de3922326
2018-08-13 17:14:26 +00:00
drh
0a1cc223bd Make the sqlite_rename_column() SQL function resistant to problems caused
by OOMs and/or malformed parameters submitted by hostile application code.
Also add additional comments to the RENAME COLUMN logic.

FossilOrigin-Name: 87743ddef11749b4017d60abc297abfd673e02a26a2ae45ffec861327578aa30
2018-08-13 17:02:26 +00:00
drh
4a2c747c4c Fix legacy comments on Token. Begin commenting the new ALTER TABLE RENAME
COLUMN code.  Fix a memory leak in the sqlite_rename_column() SQL function.

FossilOrigin-Name: 32edc8920376aabb84ebe1900eaa9512d23f1b44d6459e4916dc6b07db66e27c
2018-08-13 15:09:48 +00:00
drh
5fc22cdfde Fix issues with ALTER TABLE RENAME COLUMN associated with OOM errors.
FossilOrigin-Name: 0b28dd5c2e4908d5e49eaedd359492e46de8af3bf84120f4683b3ea906882fbf
2018-08-13 13:43:11 +00:00
drh
3e2c842e46 Fix an incorrect comment on the unix-nolock VFS object. No functional
code changes.

FossilOrigin-Name: 90f7c193b42f0d8120a8e429bdea5e1cec5d3f45b901db8fc5a5c2ca3e69cba8
2018-08-13 11:32:07 +00:00
drh
3a9a76b70a Add the "atrc" test program. "Atrc" is short for "ALTER TABLE RENAME COLUMN".
See the header comment on the program itself for further information.

FossilOrigin-Name: ed64a55a2242408ac0b889b330cf91d38a954399b75c6ebe71232613b864c70b
2018-08-11 20:46:54 +00:00
dan
404c3ba0d6 If the new column name in an ALTER TABLE RENAME COLUMN statement is quoted,
then also use quotes for the column name in the edited SQL statements.

FossilOrigin-Name: ca5184a25f9150540a3e401ef67df0606efa7a294d70e3fa5edad9854003eb36
2018-08-11 20:38:33 +00:00
dan
b0c7920d86 Avoid an assert() sometimes triggered by ALTER TABLE RENAME COLUMN in non-debug builds.
FossilOrigin-Name: 520c1c75dae5e3f4695fcdf0aad5fb9f492f0e528b5fbb49d5d3b5fc02762f47
2018-08-11 18:34:25 +00:00
dan
a8762ae27c Fix a bug causing ALTER TABLE RENAME COLUMN to fail when renaming an IPK
column that is used in a CHECK constraint.

FossilOrigin-Name: 6595c8811f13719d0aed8041abc7e1cade41c57427bcbf3503e2e42408eaa03b
2018-08-11 17:49:23 +00:00
dan
872165f260 Fix a bug causing all ALTER TABLE RENAME COLUMN commands to fail if ANALYZE
had been run on the database. Also prevent the user from renaming the columns
of system tables.

FossilOrigin-Name: ca644a2877c26561f8fb3b3feb74a070cd46621acb105577f04bc936c9b72a95
2018-08-11 17:34:38 +00:00
dan
e325ffed04 Reload the entire schema after renaming a column in order to ensure that the
schema for any tables for which parent key definitions were changed are
reloaded.

FossilOrigin-Name: f4497b0136e9fcb1121a834c86f84eeaf8f1e7d3157d409484e086bcef3487f1
2018-08-11 13:40:20 +00:00
dan
5da06d3d7e Ensure the schema cookie is changed when a column is renamed.
FossilOrigin-Name: 2dec9ea4ab1779d00bb22add0aa9a8536661d8abc9f4c2fb8628e04d4cd84326
2018-08-10 20:19:34 +00:00
drh
ad866a1e00 Fix harmless compiler warnings.
FossilOrigin-Name: 9564d7008c3fd804401a5da6ea342c6f4261db14e9f994d1a38883358a7c6f8c
2018-08-10 19:33:09 +00:00
dan
6fe7f23fa9 When a column is renamed, update any references to it in REFERENCES clauses
that belong to other tables.

FossilOrigin-Name: 191079bd4f774528a1e39b71b4a4ce7859dee0edf0ce72e4b6968ae889dc35c8
2018-08-10 19:19:33 +00:00
dan
7364fb1d04 Merge latest trunk changes with this branch.
FossilOrigin-Name: c355a8370782aa70f155ee956fa0faec7f45d7c483c442b169b63c5f0a988fd3
2018-08-10 15:27:55 +00:00
dan
e9a2fa3182 Fix a problem with renaming columns on tables with REFERENCES clauses that
specify a large number of columns.

FossilOrigin-Name: d48f7bbdf4a1686c25e634a8dec6ead88bf2866fee94ed8e5058f830363424a8
2018-08-10 14:23:41 +00:00
drh
ad9f515f52 Fix the isLikeOrGlob() routine in the WHERE clause processing logic so that
it avoids signed/unsigned character comparisons, as that can lead to an
incorrect answer if the ESCAPE clause is an invalid UTF8 string.  Problem
found by OSSFuzz.

FossilOrigin-Name: 4195a3f8b5d2c2ec63771890c5aa7b5e2de60b9fa2273652730239b8577ae418
2018-08-09 21:45:45 +00:00
dan
cf8f289542 Experimental implementation of ALTER TABLE ... RENAME COLUMN. Still buggy.
FossilOrigin-Name: fa0fc01eb48a864f0a3d43f9b805d5ed2e530846ee0c34fcbc2eabd9e5696277
2018-08-09 20:47:01 +00:00
drh
d98f53249c When a column must be a constant due to WHERE clause and the value of that
column is being coded as a constant, make sure the affinity is correct.

FossilOrigin-Name: 7404ea83168e6c739ebe8fc5d65bbf0265432ccb35b3418bb0381d74362f7527
2018-08-09 18:36:54 +00:00
mistachkin
6389a7b0ac Minor style improvements.
FossilOrigin-Name: 60bbca2b9a591800cd8e7b374e62d75b1df0e8fd2d2f71f9b4d5fd044da78be0
2018-08-08 20:46:35 +00:00
drh
f018fd5284 Enhance the edit() function so that it converts text from \r\n back into \n
only if the original unedited copy contained no \r\n values.

FossilOrigin-Name: 20c995d3f0f4de5410962172cb59da0f25edf0c62e199420186cc59ea874e981
2018-08-06 02:08:53 +00:00
drh
5180d683a0 Add the --info option to the fuzzcheck test utility.
FossilOrigin-Name: 1caaaaa70f21fe71fbe0af227eea8d1367870e2575eedf248cc2a0b515783390
2018-08-06 01:39:31 +00:00
drh
24846bc0bf Fix an overzealous assert() statement discovered by OSSFuzz.
FossilOrigin-Name: d9c9fe9f5ad3fc9123ad29ebafcb7f40dcecd448fb7a928bb31bea8181d81ec1
2018-08-06 01:21:53 +00:00
drh
dda7e66d7d Remove the column-cache from the code generator. The column-cache has been
a persistent source of bugs for years and with recent improvements
in the performance of OP_Column, it no longer provides a benefit.  After
the column cache is removed, the binary is almost 2KB smaller and the
speed-check.sh performance test is over 3 million cycles faster.

FossilOrigin-Name: cdff3af7bedc5ebea04bd9b5e2112d3db451a475c18c9a9ebd45f6f3a89a43cb
2018-08-04 20:30:55 +00:00
drh
cfdeeeb966 Remove a testcase() that is no longer reachable without the column cache.
Provide an assert() to help prove that the testcase is no longer reachable.

FossilOrigin-Name: a500893b6f64aced197cd32b79d51a481629a39d45dbcf0f02d65e5451ac4706
2018-08-04 20:12:10 +00:00
drh
36a5d88dde Fix comments that were made obsolete by the removal of the column cache.
FossilOrigin-Name: 2041231d56c7b02b785015ef4d1af260d61326eab1b2a304c17faa3e33f76441
2018-08-04 17:15:56 +00:00
drh
c6ed275fcb Remove more column-cache residue: The OP_SetColTab and OP_VerifyColTab
opcodes and the associated SQLITE_DEBUG_COLUMNCACHE logic.

FossilOrigin-Name: 80236e81cefdf3d3cda3dbdb6de1575c38e4e248cc4b72ca9ee96d3aa0464bfd
2018-08-04 16:54:53 +00:00
drh
8c60719132 Further logic simplifications that flow out of the omission of the column cache.
FossilOrigin-Name: 7d9072b027cc28dd8ecf5e2686d821017997445c15124eebe2839984622af4db
2018-08-04 15:53:55 +00:00
drh
bb9c45b49a Add test cases for the constant expression fix of the previous check-in.
FossilOrigin-Name: 95db5bd9fea86a10c9528dd24841e1370dfdc0bbb5c98b7cbd808a8bc59dd48f
2018-08-04 15:28:12 +00:00
drh
b8b0669065 Ensure that all expressions that are to be evaluated once at the start of
a prepared statement (the Parse.pConstExpr expressions) pass the
sqlite3ExprIsConstantNotJoin() test. It is not sufficient to pass just the
sqlite3ExprIsConstant() test as that would allow through column references
that are bound to constants by the WHERE clause in the constant propagation
optimization.  This fixes a problem discovered by OSSFuzz.

FossilOrigin-Name: 8bc7f84c39f913b0b0f5e9f5fd9d7dd8bda8422248c069712b6992c32c759a83
2018-08-04 15:16:20 +00:00
drh
38ee2d9197 Remove additional traces of the column cache.
FossilOrigin-Name: db6052e9725368736abd19f14f97376582d35d07f543046d39991d767ed29851
2018-08-04 14:30:21 +00:00
drh
02ceed058a Completely remove the column cache logic, which has been a persistent source
of bugs for many years.  We recent enhancements to the performance of the
OP_Column opcode, the removing the column cache actually makes speed-check.sh
run faster.  It also saves about 1,800 bytes of code space.

FossilOrigin-Name: 3f5f60cd7529330209027fdae8129cca420cec1050eae50a7750d0b715b56972
2018-08-03 23:04:16 +00:00
dan
a4b5fb55f3 Fix the handling of sub-queries with LIMIT clauses by the optimization
activated by compile-time symbol SQLITE_COUNTOFVIEW_OPTIMIZATION.

FossilOrigin-Name: 21235d9a41567897418aa12f7bd6dd8d6ee363147527e1d8fbca14fc83e0f2c9
2018-08-03 20:19:52 +00:00
drh
e4fe6d4e62 Fix the OP_SeekRowid opcode so that it has no type-change side-effects on the
key register in P3.  This fixes an obcure problem that arises when doing
equi-joins between a table with a TEXT column against another table with
an INTEGER PRIMARY KEY.  The original problem was discovered when OSSFuzz
created such a query and hit an assert() in OP_VerifyTabCol that was
specifically designed to catch these kinds of errors at run-time.

FossilOrigin-Name: fa94b49e02eb6b8fc4acc220ecc2fabef546c65845696758b25965c26b251ea9
2018-08-03 15:58:07 +00:00
drh
5eae974c48 Improve "PRAGMA vdbe_trace=ON" to always show the key values for the
OP_IdxGT and related opcodes.

FossilOrigin-Name: 0f881955ed173c7c35dfca2d4aeca855858e40bb951e6fb6fedd9a2fff6a5a86
2018-08-03 13:56:26 +00:00
drh
884406b42c In the command-line shell, always exit if realloc() fails.
FossilOrigin-Name: e390023c8e70961661fd9e29674dedacd1b941b6b8d9cd88f8cfa8f787f030f9
2018-07-29 18:56:35 +00:00