Do not initialize eponymous virtual tables when parsing the schema. This can happen if the db is corrupt.

FossilOrigin-Name: cb8c41aa20bb351c4c712ed7a3617187ceeb0905ede1e6f561bc1d89f31c95ea
This commit is contained in:
dan 2021-04-26 14:09:48 +00:00
parent 3ff6a5edd9
commit bb0eec438d
4 changed files with 36 additions and 14 deletions

View File

@ -1,5 +1,5 @@
C Skip\stest\swhen\sno\sJSON.
D 2021-04-25T23:13:04.410
C Do\snot\sinitialize\seponymous\svirtual\stables\swhen\sparsing\sthe\sschema.\sThis\scan\shappen\sif\sthe\sdb\sis\scorrupt.
D 2021-04-26T14:09:48.640
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -487,7 +487,7 @@ F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
F src/btree.c 054bd037a6b759eb5d6af7916df8226972f6a852514aee8110022ddac10aaf7f
F src/btree.h 096cc53baa58be22b02c896d1cf933c38cfc6d65f9253c1367ece8cc88a24de5
F src/btreeInt.h 7bc15a24a02662409ebcd6aeaa1065522d14b7fda71573a2b0568b458f514ae0
F src/build.c 45889a1ac425eb7d60113ce65a519c55c5d5d01f2a9e978ab1467f8653bb57eb
F src/build.c f4072218dacf42f45b733d1a9a98b3a4d7b8c676a7e5d8ff17d70b60aff687ae
F src/callback.c d0b853dd413255d2e337b34545e54d888ea02f20da5ad0e63585b389624c4a6c
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c 2a322b9a3d75771fb4d99e0702851f4f68dda982507a0f798eefb0712969a410
@ -801,7 +801,7 @@ F test/corruptJ.test 4d5ccc4bf959464229a836d60142831ef76a5aa4
F test/corruptK.test 5b4212fe346699831c5ad559a62c54e11c0611bdde1ea8423a091f9c01aa32af
F test/corruptL.test df132ba9ffd6fa15038380b4154998b9904ab8f1ea78400d7da53c920cb3b13d
F test/corruptM.test 7d574320e08c1b36caa3e47262061f186367d593a7e305d35f15289cc2c3e067
F test/corruptN.test 352c8f006b46130c27c06d4894c0919123308440473d699ec796b9c04f828ad8
F test/corruptN.test 7a8a8399f57cdc6a189f275230300ccbb2b31a5aea8399070251beeebe2cc02b
F test/cost.test b11cdbf9f11ffe8ef99c9881bf390e61fe92baf2182bad1dbe6de59a7295c576
F test/count.test 5364003488249957750a5f15ee42ca1cd7b100b1131c2dc71fff266a1250bf55
F test/countofview.test e17d6e6688cf74f22783c9ec6e788c0790ee4fbbaee713affd00b1ac0bb39b86
@ -1914,7 +1914,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 506333742103c1f440db5da819a36f3b518f7b49e94a7b74419b02bbcadc5a78
R a3adb437018949e904deac97f67bdced
U larrybr
Z a369a5f1b7d7ca6da895ee1e87f6f32e
P 6fcb2438f88a70ed67e19103bfa263a6c98b06962207f153559c9516d8c7b5d5
R 4aa43db253eb81fd5ee71cacf2798ab6
U dan
Z 0aa56f60b5e694663814cab953c70c9d

View File

@ -1 +1 @@
6fcb2438f88a70ed67e19103bfa263a6c98b06962207f153559c9516d8c7b5d5
cb8c41aa20bb351c4c712ed7a3617187ceeb0905ede1e6f561bc1d89f31c95ea

View File

@ -438,7 +438,7 @@ Table *sqlite3LocateTable(
/* If zName is the not the name of a table in the schema created using
** CREATE, then check to see if it is the name of an virtual table that
** can be an eponymous virtual table. */
if( pParse->disableVtab==0 ){
if( pParse->disableVtab==0 && db->init.busy==0 ){
Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
pMod = sqlite3PragmaVtabRegister(db, zName);

View File

@ -182,13 +182,35 @@ sqlite3 db test.db
breakpoint
do_catchsql_test 3.1 {
PRAGMA writable_schema = 1;
PRAGMA vdbe_trace = 1;
REPLACE INTO x1 VALUES(5, 2, 3);
} {1 {database disk image is malformed}}
explain_i {
REPLACE INTO x1 VALUES(5, 2, 3);
}
#-------------------------------------------------------------------------
reset_db
db func strreplace strreplace
proc strreplace {orig a b} {
string map [list $a $b] $orig
}
do_execsql_test 4.0 {
CREATE TABLE t1(a, b);
CREATE INDEX t1a ON t1(a);
CREATE INDEX t1b ON t1(b);
PRAGMA writable_schema = 1;
UPDATE sqlite_schema
SET sql = strreplace(sql, 't1', 'json_each')
WHERE type='index';
}
db close
sqlite3 db test.db
do_execsql_test 4.1 {
PRAGMA writable_schema = 1;
SELECT * FROM t1
}