Allow an ALTER TABLE RENAME COLUMN to proceed even if the schema contains a

virtual table for which the module is unavailable.

FossilOrigin-Name: 7b72b2360a70eb1f788b3c4d745967dfedb2c80af6b2e146ba940a3741fd51a1
This commit is contained in:
dan 2018-08-17 18:08:28 +00:00
parent dabc268f96
commit 499b825487
4 changed files with 46 additions and 26 deletions

View File

@ -1,5 +1,5 @@
C Ensure\sthat\sCREATE\sVIEW,\sTRIGGER\sor\sINDEX\sstatements\scan\sbe\sedited\sby\sALTER\nTABLE\sRENAME\sCOLUMN\seven\sif\sthey\suse\scollation-sequences\sor\nuser-defined-functions\sthat\sare\snot\savailable.
D 2018-08-17T17:18:16.131
C Allow\san\sALTER\sTABLE\sRENAME\sCOLUMN\sto\sproceed\seven\sif\sthe\sschema\scontains\sa\nvirtual\stable\sfor\swhich\sthe\smodule\sis\sunavailable.
D 2018-08-17T18:08:28.458
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 0a3a6c81e6fcb969ff9106e882f0a08547014ba463cb6beca4c4efaecc924ee6
@ -432,7 +432,7 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
F src/alter.c c16b42be9a598c48d6869082f74c8391641dc31a4ba85811997b8b80c0e3ce4c
F src/alter.c c81f6d8d4f07ba89b2aa237bf8aaa4cb63b43b716eec8291f70eeea145a66a09
F src/analyze.c 3dc6b98cf007b005af89df165c966baaa48e8124f38c87b4d2b276fe7f0b9eb9
F src/attach.c 4bd5b92633671d3e8ce431153ebb1893b50335818423b5373f3f27969f79769a
F src/auth.c 32a5bbe3b755169ab6c66311c5225a3cd4f75a46c041f7fb117e0cbb68055114
@ -599,7 +599,7 @@ F test/alter.test b820ab9dcf85f8e3a65bc8326accb2f0c7be64ef
F test/alter2.test 7ea05c7d92ac99349a802ef7ada17294dd647060
F test/alter3.test 4d79934d812eaeacc6f22781a080f8cfe012fdc3
F test/alter4.test b6d7b86860111864f6cddb54af313f5862dda23b
F test/altercol.test 4597bd06c5dc25ce7509ce2b8a18f3ddb76b0e42fd2505e0efd603d3178e4cfb
F test/altercol.test cac9395932f9fa18b3c074559c33c557352db5d0fdf81aec28b1513828cb855f
F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc
F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f
F test/analyze.test b3a9c67d00e1df7588a5b7be9a0292899f94fe8cac1f94a017277474ca2e59df
@ -1756,7 +1756,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 3f47222b6e20e1c1ef41c0f7391c8b5c7648e2a2d6013303d155ad59ce27143a
R 074dd33a01022ba2b3a74f6795cf4991
P 540014efd6a048373313c6cd9413de10d5d7114daf537cf5999ccf3c5c3f9358
R f20218c0b275f1c838232dab3f0beae8
U dan
Z 478b06e640e2a3d3de9b75cbb89dcb88
Z 4df0525d7f8fcece703661753e166268

View File

@ -1 +1 @@
540014efd6a048373313c6cd9413de10d5d7114daf537cf5999ccf3c5c3f9358
7b72b2360a70eb1f788b3c4d745967dfedb2c80af6b2e146ba940a3741fd51a1

View File

@ -845,7 +845,8 @@ void sqlite3AlterRenameColumn(
sqlite3NestedParse(pParse,
"UPDATE \"%w\".%s SET "
"sql = sqlite_rename_column(sql, %Q, %Q, %d, %Q, %d) "
"WHERE name NOT LIKE 'sqlite_%%' AND (type != 'index' OR tbl_name = %Q)",
"WHERE name NOT LIKE 'sqlite_%%' AND (type != 'index' OR tbl_name = %Q)"
" AND sql NOT LIKE 'create virtual%%'",
zDb, MASTER_NAME,
zDb, pTab->zName, iCol, zNew, bQuote,
pTab->zName

View File

@ -334,23 +334,36 @@ do_execsql_test 8.4.5 {
# More triggers.
#
proc do_rename_column_test {tn old new lSchema} {
reset_db
set lSorted [list]
foreach sql $lSchema {
execsql $sql
lappend lSorted [string trim $sql]
for {set i 0} {$i < 2} {incr i} {
# DROP all tables and views in database.
set sql "SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1"
foreach nm [db eval $sql] { db eval "DROP TABLE $nm" }
set sql "SELECT name FROM sqlite_master WHERE type='view' ORDER BY 1"
foreach nm [db eval $sql] { db eval "DROP VIEW $nm" }
set lSorted [list]
foreach sql $lSchema {
execsql $sql
lappend lSorted [string trim $sql]
}
set lSorted [lsort $lSorted]
do_execsql_test $tn.$i.1 {
SELECT sql FROM sqlite_master WHERE sql!='' ORDER BY 1
} $lSorted
if {0 && $i==1} {
db close
sqlite3 db test.db
}
do_execsql_test $tn.$i.2 "ALTER TABLE t1 RENAME $old TO $new"
do_execsql_test $tn.$i.3 {
SELECT sql FROM sqlite_master ORDER BY 1
} [string map [list $old $new] $lSorted]
}
set lSorted [lsort $lSorted]
do_execsql_test $tn.1 {
SELECT sql FROM sqlite_master WHERE sql!='' ORDER BY 1
} $lSorted
do_execsql_test $tn.2 "ALTER TABLE t1 RENAME $old TO $new"
do_execsql_test $tn.3 {
SELECT sql FROM sqlite_master ORDER BY 1
} [string map [list $old $new] $lSorted]
}
foreach {tn old new lSchema} {
@ -397,7 +410,7 @@ reset_db
foreach {tn old new lSchema} {
1 _x_ _xxx_ {
{ CREATE TABLE t1(a, b, _x_) }
{ CREATE VIEW v1 AS SELECT a, b, _x_ FROM t1 WHERE _x_='abc' COLLATE xyz }
{ CREATE VIEW s1 AS SELECT a, b, _x_ FROM t1 WHERE _x_='abc' COLLATE xyz }
}
2 _x_ _xxx_ {
@ -409,7 +422,13 @@ foreach {tn old new lSchema} {
{ CREATE TABLE t1(a, b, _x_) }
{ CREATE VIEW v1 AS SELECT a, b, _x_ FROM t1 WHERE _x_ = unicode(1, 2, 3) }
}
4 _x_ _xxx_ {
{ CREATE TABLE t1(a, b, _x_) }
{ CREATE VIRTUAL TABLE e1 USING echo(t1) }
}
} {
register_echo_module db
do_rename_column_test 10.$tn $old $new $lSchema
}