Commit Graph

43 Commits

Author SHA1 Message Date
drh
731a1aaeb2 Fix an obscure issue with ALTER TABLE RENAME that comes up with triggers
that have UPDATE statements that contain errors.
[forum:/forumpost/ff3840145a|Forum post ff3840145a].

FossilOrigin-Name: c4845a7c5f7f219848d3ee32eef0f9c69ad6dc6e8509da84d612f41e1e05f007
2023-04-13 18:44:59 +00:00
drh
ddfec00de3 First the shadow table mechanism so that it works even if the shadow table
comes before the virtual table in the sqlite_schema table, as can happen
after a VACUUM.

FossilOrigin-Name: 005a8642773556825fe4c5d0b2c12517d35289308a30df0151ef7f080acb0172
2021-11-04 00:51:53 +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
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
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
dan
b56a09079e Fix a problem with running ALTER TABLE against schemas that contain compound SELECT statements with ORDER BY clauses containing one or more references to the second or subsequent component SELECT statements.
FossilOrigin-Name: 587a3044468a40707c714d013cb766d8a4d9eb13bb20871846a0e8c34bea8cf4
2021-06-01 15:37:14 +00:00
dan
be12083bc7 Fix problems with refering to CTEs from within sub-selects in PARTITION BY or ORDER BY clauses of window frame definitions. Also a problem with renaming a column when the schema contains a trigger containing a correlated sub-select within a window frames PARTITION BY or ORDER BY clause.
FossilOrigin-Name: 4c6cd54a8db78e5535912e76856bed4f797261aaca4248c69d2e2452194de297
2021-05-17 16:20:41 +00:00
drh
736d11ed21 Back out the NEVER() inserted by [c7309ed3c7588c7e] because it is reachable
after all.  dbsqlfuzz bc17a306a09329bba0ecc61547077f6178bcf321

FossilOrigin-Name: 20a4f3f12cdd8823d53d91025fa41e284c9f629b1d049eb486ff8dc4a1736e1f
2021-05-01 12:09:36 +00:00
larrybr
ada2323d95 refix altertab.test
FossilOrigin-Name: db032156932fb0dcae5ffb7cbdfb711079daa595713fcb254f09f8ef90c81d95
2021-04-26 20:18:08 +00:00
larrybr
3ff6a5edd9 Skip test when no JSON.
FossilOrigin-Name: 6fcb2438f88a70ed67e19103bfa263a6c98b06962207f153559c9516d8c7b5d5
2021-04-25 23:13:04 +00:00
drh
971ae9f66a Fix testcase altertab-25.1 due to check-in [c7909e8e0d0577c6] disallowing
ALTER TABLE on eponymous virtual tables.

FossilOrigin-Name: 32255e39cbde65492d88177464cee9e10cb20cf3105208416be131e2c89b63e1
2021-04-24 12:20:10 +00:00
dan
f3d5a68461 Fix an assert() in fts5_index.c that may fail if the database records are corrupt.
FossilOrigin-Name: dfadb96edfef1d49e48a659264b9eb8d7f98d95d159d95c92c30dd4ba6c6e739
2021-04-23 11:37:01 +00:00
drh
8210233c7b Revise tests cases to align with the new EXPLAIN QUERY PLAN output.
FossilOrigin-Name: 50fbd532602d2c316813046ed6be8be2991c281eb5f295c4c28520a0de73862c
2021-03-20 15:11:29 +00:00
dan
52a0753152 Add test cases for ALTER TABLE.
FossilOrigin-Name: 9c9ba36e859e330c50ed40ede4b93eeb0a5c3337240465d953a7be9115a81390
2021-03-08 17:22:01 +00:00
dan
936a30598e Fix ALTER TABLE so that it can run even if the schema contains unknown collation sequences.
FossilOrigin-Name: bc4bb9433fed519386511796cce475d74100b8ed707cdbffd8cbdf683b0faf35
2020-10-12 15:27:50 +00:00
drh
e3863b5176 Ensure that the "PRAGMA schema_version" command causes the schema to be
reparsed and reloaded.

FossilOrigin-Name: 27d4a9a7b530c77a5b2593d1a5232b10746da9906f8d12890de7a8fbd7270256
2020-07-01 16:19:14 +00:00
dan
4db7ab53f9 Do not suppress errors when resolving references in an ORDER BY clause belonging to a compound SELECT within a view or trigger within ALTER TABLE. Fix for ticket [a10a14e9b4ba2].
FossilOrigin-Name: 684293882c302600e112cf52553c19d84fdb31663d96e5dd7f8ac17dda00a026
2020-04-03 11:52:59 +00:00
dan
fb99e388ec Fix a case when a pointer might be used after being freed in the ALTER TABLE code. Fix for [4722bdab08cb1].
FossilOrigin-Name: d09f8c3621d5f7f8c6d99d7d82bcaa8421855b3f470bea2b26c858106382b906
2020-04-03 11:20:40 +00:00
drh
0990c415f6 Fix a problem with ALTER TABLE for views that have a nested FROM clause.
Ticket [f50af3e8a565776b].

FossilOrigin-Name: c431b3fd8fd0f6a6974bba3e9366b0430ec003d570e7ce70ceefbcff5fe4b6fa
2020-02-23 17:34:45 +00:00
drh
171c50ec38 New test-only SQL functions: implies_nonnull_row(), expr_compare(), and
expr_implies_expr().  The SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control
is modified to toggle internal function access on and off for a single
database connection.

FossilOrigin-Name: 473892a8eceacf24d57fd0c72ff2a0b8be4e0d75e0af7a30bdb24fbc3b453601
2020-01-01 15:43:30 +00:00
drh
527cbd4a10 Do not allow CREATE TABLE or CREATE VIEW of an object with a name that looks
like a shadow table name.

FossilOrigin-Name: 6aef58b629d89955f85f65191ba2be67b2adfac4f0327fe9a7141cb2705dbc00
2019-11-16 14:15:19 +00:00
drh
d0c51d1a04 Do not allow shadow tables to be dropped in defensive mode.
FossilOrigin-Name: 70390bbca49e706649ca5b7c031f0baf416fc38798c17e5f3b73746b3e66e3b5
2019-11-16 12:04:38 +00:00
drh
175b8f06f7 Remove support for STAT3. The sqlite_stat3 tables are ignored, if they
exist.  STAT4 continues to work as it always has, and as it is a superset of
STAT3 is the recommended replacement.

FossilOrigin-Name: 1e17ea2fd1df4ad49138c787c8fe3207dd0c25c93f9001d52a9b69f8c12e841c
2019-08-08 15:24:17 +00:00
dan
f9b0c45161 Fix a problem with renaming an INTEGER PRIMARY KEY column of a WITHOUT ROWID table using ALTER TABLE.
FossilOrigin-Name: 91f701d39852ef1ddb29d1527d1520867c5efea110333315c55d8b08084384e7
2019-05-06 16:15:28 +00:00
dan
65455fc682 Fix a problem with renaming a table that starts with "sqlite". Fix for ticket [f00d7b65].
FossilOrigin-Name: a2ead8aa4517b63cda7bf84464326e9cb5e228224caa603568c0e04ea44e6588
2019-04-19 16:34:22 +00:00
dan
397a78d4a1 In defensive mode, do not allow shadow tables to be renamed using ALTER TABLE.
FossilOrigin-Name: 23e200da5cfbde0798e67cd9e016e4a1cd73b67981e1af841493fcd123d8f547
2018-12-18 20:31:14 +00:00
drh
eea8eb6d04 Do not allow direct access to internal-use SQL functions such as
sqlite_rename_column() and sqlite3_rename_table() except when the
new SQLITE_TESTCTRL_INTERNAL_FUNCTIONS flag is set.

FossilOrigin-Name: 6e1330545e7b74fe5f1f20751a3425e2788441485fc07fcb7626e448c72027ce
2018-11-26 18:09:15 +00:00
drh
6ab91a7a7a Add the SQLITE_DEFAULT_DEFENSIVE compile-time option. Fix up test cases
so that they work with DEFENSIVE enabled.

FossilOrigin-Name: 3212733cb6d1a59516d67a86df7c7b1d2456a1b2e5d7080c26b0e87b2609c65d
2018-11-07 02:17:01 +00:00
dan
5351e884aa Fix a problem with ALTER TABLE commands when the schema features an INSTEAD of
trigger that uses NEW.* or OLD.*.

FossilOrigin-Name: c52f457e56eb9d573eb67093731eb231aaf6fd6dbdc397e6f948b82736fbe3ab
2018-10-01 07:04:12 +00:00
dan
0208337c16 Add extra test for the fix on this branch. Also fix a
pointer-compare-after-free problem that occurs in similar cases.

FossilOrigin-Name: 1856ea63b3186c2c8fa716ffe01c731397bdbbc3fbb56dc72ad0686cb7f152ca
2018-09-17 08:27:23 +00:00
dan
b2802128d6 Add extra test case to altertab.test.
FossilOrigin-Name: 64c3ee3c255e4630ccd5002116d66fd2af6b12dbdd4a3bee5ed413c3ef87d33a
2018-09-07 18:56:31 +00:00
dan
d5e6fef2a1 Fix a problem with renaming a non-temp table that has at least one temp
trigger and shares its name with a temp table.

FossilOrigin-Name: ceb60bd7e5f2a0a4247bff476fc6468227305467339ae0c24591be9d2b14bdde
2018-09-07 15:50:31 +00:00
dan
c50f75df96 Fix a problem with ALTER TABLE when there are views or triggers in the schema
that contain "<expr> IS NULL" expressions.

FossilOrigin-Name: 91aab32e71fcb924e24c02d5f0901f7a474760fc993a7e7436e667512cf5d3c3
2018-09-06 18:56:36 +00:00
dan
1041a6a817 Fix a problem in ALTER TABLE with SQLITE_OMIT_VIRTUALTABLE builds.
FossilOrigin-Name: fa835145e63749e06e04bd50ff992afaeae05dcdd1df597d13911f944e62076b
2018-09-06 17:47:09 +00:00
dan
7ea1edb703 Fix test script problems causing SQLITE_OMIT_VIRTUALTABLE builds to fail.
FossilOrigin-Name: 37ad064e5f5704cf345d23b38b3f6d627fbcf20dbb78c8a91e96c9704760a1b8
2018-09-06 17:23:08 +00:00
dan
1d85c6bf48 Ensure that the tbl_name column in the sqlite_temp_master table is updated
correctly as part of a RENAME TABLE operation.

FossilOrigin-Name: ffecfca511718e39e0003b380d5113755b8a11405a5bd80cc04503d9557f0842
2018-09-06 16:01:37 +00:00
dan
5921f2b9e7 Fix some test script errors. And an incorrect assert() in fts5.
FossilOrigin-Name: f804336f083d8d26314bb1ba34cec427675065a67cbe2bf00bb42e40752aeb33
2018-09-05 17:45:17 +00:00
dan
65372fa963 Improve the error messages emitted by RENAME TABLE.
FossilOrigin-Name: 6805b5900df5e6d3329cbad2660875ebe4069efe37b19575f527d153dc0882a1
2018-09-03 20:05:15 +00:00
dan
143df55d24 Add another test case to altertab.test.
FossilOrigin-Name: 828e8849faed85812c03215b00a2ba34cbb00dfa4d4afdcbd11300ba7fcf9743
2018-09-01 20:38:42 +00:00
dan
b87a9a8a5e Fix a problem with renaming a column in a table that has a temp trigger that
references another attached database.

FossilOrigin-Name: 336b8a0923bf65b7a2c35811cb6dec0e262a0b31e534d2a6ab093d2afdb05c1f
2018-09-01 20:23:28 +00:00
dan
9d324823a8 Test the schema after renaming a table. Ensure that temp database triggers and
views are updated when renaming a column.

FossilOrigin-Name: f3c27d916d4837f8fc3dd812bd004535f04c7a53bd2a0a2419613275f48bec76
2018-08-30 20:03:44 +00:00
dan
0ccda96867 Fix an ALTER TABLE problem with processing temp schema views and triggers.
FossilOrigin-Name: 72cfb1be29971d91a164f1d4f20cb054de68960a0bd547630bcd1160565971c5
2018-08-30 16:26:48 +00:00
dan
c9461ecc28 Extend RENAME TABLE to edit triggers and views. Still buggy.
FossilOrigin-Name: 01308bae3acf33f78b5bb90892085eab340df093aafc17e6ccf6a7d6cf324897
2018-08-29 21:00:16 +00:00