Ensure that "main" can always be used to refer to the main database, even if it has been renamed using SQLITE_DBCONFIG_MAINDBNAME.
FossilOrigin-Name: 682b426f5658254e63dff02c960b557fb33cb3e944fdd14faa0aa9988af7269a
This commit is contained in:
commit
31f170f396
@ -37,6 +37,9 @@ proc squish {txt} {
|
||||
|
||||
proc do_setup_rec_test {tn setup sql res} {
|
||||
reset_db
|
||||
if {[info exists ::set_main_db_name]} {
|
||||
dbconfig_maindbname_icecube db
|
||||
}
|
||||
db eval $setup
|
||||
uplevel [list do_rec_test $tn $sql $res]
|
||||
}
|
||||
@ -76,6 +79,10 @@ foreach {tn setup} {
|
||||
}
|
||||
}
|
||||
3 {
|
||||
if {[info commands sqlite3_expert_new]==""} { continue }
|
||||
set ::set_main_db_name 1
|
||||
}
|
||||
4 {
|
||||
if {![file executable $CLI]} { continue }
|
||||
|
||||
proc do_rec_test {tn sql res} {
|
||||
@ -336,7 +343,7 @@ proc do_candidates_test {tn sql res} {
|
||||
|
||||
|
||||
reset_db
|
||||
do_execsql_test 4.0 {
|
||||
do_execsql_test 5.0 {
|
||||
CREATE TABLE t1(a, b);
|
||||
CREATE TABLE t2(c, d);
|
||||
|
||||
@ -346,7 +353,7 @@ do_execsql_test 4.0 {
|
||||
WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t2 SELECT (i-1)/20, (i-1)/5 FROM s;
|
||||
}
|
||||
do_candidates_test 4.1 {
|
||||
do_candidates_test 5.1 {
|
||||
SELECT * FROM t1,t2 WHERE (b=? OR a=?) AND (c=? OR d=?)
|
||||
} {
|
||||
CREATE INDEX t1_idx_00000062 ON t1(b); -- stat1: 100 20
|
||||
@ -355,14 +362,14 @@ do_candidates_test 4.1 {
|
||||
CREATE INDEX t2_idx_00000064 ON t2(d); -- stat1: 100 5
|
||||
}
|
||||
|
||||
do_candidates_test 4.2 {
|
||||
do_candidates_test 5.2 {
|
||||
SELECT * FROM t1,t2 WHERE a=? AND b=? AND c=? AND d=?
|
||||
} {
|
||||
CREATE INDEX t1_idx_000123a7 ON t1(a, b); -- stat1: 100 50 17
|
||||
CREATE INDEX t2_idx_0001295b ON t2(c, d); -- stat1: 100 20 5
|
||||
}
|
||||
|
||||
do_execsql_test 4.3 {
|
||||
do_execsql_test 5.3 {
|
||||
CREATE INDEX t1_idx_00000061 ON t1(a); -- stat1: 100 50
|
||||
CREATE INDEX t1_idx_00000062 ON t1(b); -- stat1: 100 20
|
||||
CREATE INDEX t1_idx_000123a7 ON t1(a, b); -- stat1: 100 50 16
|
||||
|
39
manifest
39
manifest
@ -1,5 +1,5 @@
|
||||
C Change\sa\sbitfield\sin\ssqlite3_stmt\sinto\san\sunsigned\scharacter,\sfor\sslightly\nsmaller\scode\sand\sbetter\sperformance.
|
||||
D 2020-03-21T15:07:27.669
|
||||
C Ensure\sthat\s"main"\scan\salways\sbe\sused\sto\srefer\sto\sthe\smain\sdatabase,\seven\sif\sit\shas\sbeen\srenamed\susing\sSQLITE_DBCONFIG_MAINDBNAME.
|
||||
D 2020-03-21T15:41:55.795
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -48,7 +48,7 @@ F ext/async/sqlite3async.c 0f3070cc3f5ede78f2b9361fb3b629ce200d7d74
|
||||
F ext/async/sqlite3async.h f489b080af7e72aec0e1ee6f1d98ab6cf2e4dcef
|
||||
F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3
|
||||
F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4
|
||||
F ext/expert/expert1.test e2afc53a27610e8251e44c7f961806607a5490ff204b3db342740d558e052662
|
||||
F ext/expert/expert1.test 2e10ff875c31c9e6fc5e324767624181273859771fe34c5daeeadf3f2974a4f7
|
||||
F ext/expert/sqlite3expert.c 3da865f2286433588260f41e796422c611bceaca3a0bbf9139a619cf7d062c19
|
||||
F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b
|
||||
F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72
|
||||
@ -467,7 +467,7 @@ F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
|
||||
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
||||
F src/alter.c f48a4423c8f198d7f1ae4940f74b606707d05384ac79fb219be8e3323af2a2de
|
||||
F src/analyze.c 831bb090988477a00d3b4c000746e1b0454dcc93b10b793e6ebe1c47f25d193a
|
||||
F src/attach.c fa5addce233a2bb2dfdefeee3b37000e154c47214d3269cab1bb331416e330db
|
||||
F src/attach.c eb2835b8287ece726ac7962a42f82c5e6228c06f8f7a04968a59516767ed4da3
|
||||
F src/auth.c a3d5bfdba83d25abed1013a8c7a5f204e2e29b0c25242a56bc02bb0c07bf1e06
|
||||
F src/backup.c 5e617c087f1c2d6005c2ec694ce80d6e16bc68d906e1b1c556d7c7c2228b636b
|
||||
F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
|
||||
@ -475,13 +475,13 @@ F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
|
||||
F src/btree.c 7271a120a66dfd12edcee942443fcd7b3860514a5621cb26a374781af1462117
|
||||
F src/btree.h 6111552f19ed7a40f029cf4b33badc6fef9880314fffd80a945f0b7f43ab7471
|
||||
F src/btreeInt.h dee1a1d0c621524e006bb260bd6b66d5d1867da6fe38cba9ad7b6a9bb9c0c175
|
||||
F src/build.c 406645db37154920075d90a4ea3c47f33d5f5b6e0769010a54ea8247ee433c1a
|
||||
F src/build.c 3d22f21c4701f62c1a191c6b6d17552fb1b593fe9a97c0613cca05ab104a9a51
|
||||
F src/callback.c d0b853dd413255d2e337b34545e54d888ea02f20da5ad0e63585b389624c4a6c
|
||||
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
|
||||
F src/ctime.c 6a77ec9e0eb87aea929e002c816298907e337094a7b556898ae2d1e6be209f90
|
||||
F src/date.c 6c408fdd2e9ddf6e8431aba76315a2d061bea2cec8fbb75e25d7c1ba08274712
|
||||
F src/dbpage.c 8a01e865bf8bc6d7b1844b4314443a6436c07c3efe1d488ed89e81719047833a
|
||||
F src/dbstat.c 33fc9838b5b9fba07f9ab9e9aba956f0afeeb1af0037a98d984fdc2f698c64fd
|
||||
F src/dbstat.c 793deaf88a0904f88285d93d6713c636d55ede0ffd9f08d10f4ea825531d367f
|
||||
F src/delete.c 11000121c4281c0bce4e41db29addfaea0038eaa127ece02557c9207bc3e541d
|
||||
F src/expr.c ed718ee2206166c9c2fc4fe89eadb1f369318aeb8645e06033566b387970fb9a
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
@ -529,14 +529,14 @@ F src/pragma.h 9473160d220416456b40f27323bb4b316d4e4e08ffbf8bf88c5f7045d49c38e5
|
||||
F src/prepare.c 8d4d6c8aa6afefc48027c54b41cdf134b4d6bc2fc4badbe483ad7fd9e1728a28
|
||||
F src/printf.c 9be6945837c839ba57837b4bc3af349eba630920fa5532aa518816defe42a7d4
|
||||
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
|
||||
F src/resolve.c 38e3a5636f5bdc92e3683e4cafbba6418c0aa15e0d89ca5b28bd0b621dbb80bf
|
||||
F src/resolve.c 0529815271886204fe0eb4b03a662434664f214a5d904408bda5a3c75c3683d2
|
||||
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
|
||||
F src/select.c cb7588bfe9e1a900801e5ca345296b32b85ded0d57b2f277a9962294eb4c7aa2
|
||||
F src/shell.c.in f76590931c0cbbfef347f44f81ade6b335f80c46bc6e59b8b6114383a8df30e0
|
||||
F src/sqlite.h.in 802957feeb249ede54f8dfe99b72aa19e70a0b7737969c46e625dc2f9f2d42b0
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 9c5269260409eb3275324ccace6a13a96f4ad330c708415f70ca6097901ff4ee
|
||||
F src/sqliteInt.h 3ccd2aedc57f61009285c4fa7ca1d75b380a48b5168f9605c10c86a7be62156c
|
||||
F src/sqliteInt.h 3e15c159d5f2348e705e0c841c795b4a7f1ec14d129bd79d7c5bc228fa4d57fd
|
||||
F src/sqliteLimit.h 95cb8479ca459496d9c1c6a9f76b38aee12203a56ce1092fe13e50ae2454c032
|
||||
F src/status.c 9ff2210207c6c3b4d9631a8241a7d45ab1b26a0e9c84cb07a9b5ce2de9a3b278
|
||||
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
|
||||
@ -597,7 +597,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
||||
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
|
||||
F src/tokenize.c 7b17f6e2f20f6cbcb0b215025a86b7457c38451fc7622f705e553d7a488c572d
|
||||
F src/treeview.c f78cd9cd79a889e70cd98bd6edd4a464c421452da833e65e987d97d8c41f71fe
|
||||
F src/trigger.c a40d50e88bd3355f1d2a73f0a3b2d6b42eae26ca4219001b82ef0d064439badc
|
||||
F src/trigger.c 4ada1037cc99777f647a882cdacbd1a4deb6567b69daf02946286401b88cdc04
|
||||
F src/update.c 3eb778c42155d944377a4ee5e440b04520f07094804ed6ce63d2528f619614d9
|
||||
F src/upsert.c 2920de71b20f04fe25eb00b655d086f0ba60ea133c59d7fa3325c49838818e78
|
||||
F src/utf.c 95fb6e03a5ca679045c5adccd05380f0addccabef5911abddcb06af069500ab7
|
||||
@ -666,7 +666,7 @@ F test/atof1.test 1ccfc96a6888566597b83d882c81b3c04258dc39317e8c1cec89ba481eaa2f
|
||||
F test/atomic.test 065a453dde33c77ff586d91ccaa6ed419829d492dbb1a5694b8a09f3f9d7d061
|
||||
F test/atomic2.test b6863b4aa552543874f80b42fb3063f1c8c2e3d8e56b6562f00a3cc347b5c1da
|
||||
F test/atrc.c ec92d56d8fbed9eb3e11aaf1ab98cf7dd59e69dae31f128013f1d97e54e7dfed
|
||||
F test/attach.test 21bce8681f780a8d631a5ec7ecd0d849bfe84611257b038ae4ffeccc609d8a4e
|
||||
F test/attach.test d42862c72fef3d54367d962d41dcfb5363442a4a1bd898c22ae950cea1aa0dd3
|
||||
F test/attach2.test 256bd240da1835fb8408dd59fb7ef71f8358c7a756c46662434d11d07ba3a0ce
|
||||
F test/attach3.test c59d92791070c59272e00183b7353eeb94915976
|
||||
F test/attach4.test aa05b1d8218b24eba5a7cccf4f224f514ba57ba705c9267f09d2bb63fed0eea1
|
||||
@ -828,10 +828,10 @@ F test/e_blobclose.test 4b3c8c60c2171164d472059c73e9f3c1844bb66d
|
||||
F test/e_blobopen.test e95e1d40f995056f6f322cd5e1a1b83a27e1a145
|
||||
F test/e_blobwrite.test f87ff598b67af5b3ec002a8d83e804dc8d23808e88cf0080c176612fc9ffce14
|
||||
F test/e_changes.test fd66105385153dbf21fdb35eb8ef6c3e1eade579
|
||||
F test/e_createtable.test 1c602347e73ab80b11b9fa083f47155861aaafcff8054aac9e0b76d0df33b0a7
|
||||
F test/e_createtable.test ea27082d6f84df61e1d9e383f3fd79220418856a4a8afc41af75d458b8e7ac33
|
||||
F test/e_delete.test ab39084f26ae1f033c940b70ebdbbd523dc4962e
|
||||
F test/e_droptrigger.test 3cd080807622c13e5bbb61fc9a57bd7754da2412
|
||||
F test/e_dropview.test 21ce09c361227ddbc9819a5608ee2700c276bdd5
|
||||
F test/e_dropview.test 74e405df7fa0f762e0c9445b166fe03955856532e2bb234c372f7c51228d75e7
|
||||
F test/e_expr.test 328d2d7c84f8e53e942a13eac771b337bcdfcf4c3569324001868b5639f3c857
|
||||
F test/e_fkey.test 2febb2084aef9b0186782421c07bc9d377abf067c9cb4efd49d9647ae31f5afe
|
||||
F test/e_fts3.test 17ba7c373aba4d4f5696ba147ee23fd1a1ef70782af050e03e262ca187c5ee07
|
||||
@ -1173,7 +1173,7 @@ F test/misc4.test 10cd6addb2fa9093df4751a1b92b50440175dd5468a6ec84d0386e78f087db
|
||||
F test/misc5.test c4aeaa0fa28faa08f2485309c38db4719e6cd1364215d5687a5b96d340a3fa58
|
||||
F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
|
||||
F test/misc7.test 4f21954012e4eb0a923c54a311f38c81bf6798ccdd7b51584db46d4007f63daa
|
||||
F test/misc8.test 8fb0f31d7a8aed484d759773ab8ad12ec746a477f4a67394a4af0e677494c3ca
|
||||
F test/misc8.test 8782708f4c8a459591c3e8fe1215bd2048bffb4024b3df249e9b9ed407dc61ed
|
||||
F test/misuse.test 9e7f78402005e833af71dcab32d048003869eca5abcaccc985d4f8dc1d86bcc7
|
||||
F test/mjournal.test 28a08d5cb5fb5b5702a46e19176e45e964e0800d1f894677169e79f34030e152
|
||||
F test/mmap1.test fb04e0c10492455007624ade884ca0c8852ff3e4e11d95408f9709ca2ef7f626
|
||||
@ -1232,7 +1232,7 @@ F test/parser1.test 6ccdf5e459a5dc4673d3273dc311a7e9742ca952dd0551a6a6320d27035c
|
||||
F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
|
||||
F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
|
||||
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
|
||||
F test/permutations.test 8587800fe1a0eb01456a3f4500b821e54e3347e78acf11dbf05f4990530f6cee
|
||||
F test/permutations.test c83339862d72b6272f957905205f874e6eefdbad2823380452c4f0128fd3d906
|
||||
F test/pg_common.tcl 222a1bad1c41c308fa366313cd7b51b3be7e9b21c8736a421b974ac941693b54
|
||||
F test/pragma.test 59becdfd720b80d463ab750f69f7118fde10dfd556aa5d554f3bf6b7e5ea7533
|
||||
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
|
||||
@ -1415,7 +1415,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
|
||||
F test/temptable2.test d2940417496e2b9548e01d09990763fbe88c316504033256d51493e1f1a5ce6a
|
||||
F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637
|
||||
F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc
|
||||
F test/tester.tcl abba168acd7f01dbfa3ffdbf402d151eb97e8a824d9208e845ab34c194441483
|
||||
F test/tester.tcl fd9d134a7cc4e31b307ad028a195f51cdcf556fc620d74b680515562f0137f25
|
||||
F test/thread001.test b61a29dd87cf669f5f6ac96124a7c97d71b0c80d9012746072055877055cf9ef
|
||||
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
|
||||
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
|
||||
@ -1860,7 +1860,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P aa92f9b95f95d40cc58910da87168a5bd440f71deb072dc651bb15936315786c
|
||||
R b1a402197c3dd747d332863aba643c9a
|
||||
U drh
|
||||
Z 5b9ced2a7dd596cf0ffa6b2f623acefa
|
||||
P 0d4d3c642494ad494b4ec937215eaf833158e62e5ae59ed981d6b546220c13b8 a85c63daa640e02fdfd891a05a1a09e848c9621a5dd6e112338451008623ecbb
|
||||
R 5b8a0ae99cc89cbebf501a334996a4cc
|
||||
T +closed a85c63daa640e02fdfd891a05a1a09e848c9621a5dd6e112338451008623ecbb
|
||||
U dan
|
||||
Z 8b468ce05910eb5b50c49ff125dc587c
|
||||
|
@ -1 +1 @@
|
||||
0d4d3c642494ad494b4ec937215eaf833158e62e5ae59ed981d6b546220c13b8
|
||||
682b426f5658254e63dff02c960b557fb33cb3e944fdd14faa0aa9988af7269a
|
37
src/attach.c
37
src/attach.c
@ -45,6 +45,17 @@ static int resolveAttachExpr(NameContext *pName, Expr *pExpr)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return true if zName points to a name that may be used to refer to
|
||||
** database iDb attached to handle db.
|
||||
*/
|
||||
int sqlite3DbIsNamed(sqlite3 *db, int iDb, const char *zName){
|
||||
return (
|
||||
sqlite3StrICmp(db->aDb[iDb].zDbSName, zName)==0
|
||||
|| (iDb==0 && sqlite3StrICmp("main", zName)==0)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
** An SQL user-function registered to do the work of an ATTACH statement. The
|
||||
** three arguments to the function come directly from an attach statement:
|
||||
@ -117,9 +128,8 @@ static void attachFunc(
|
||||
goto attach_error;
|
||||
}
|
||||
for(i=0; i<db->nDb; i++){
|
||||
char *z = db->aDb[i].zDbSName;
|
||||
assert( z && zName );
|
||||
if( sqlite3StrICmp(z, zName)==0 ){
|
||||
assert( zName );
|
||||
if( sqlite3DbIsNamed(db, i, zName) ){
|
||||
zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName);
|
||||
goto attach_error;
|
||||
}
|
||||
@ -272,7 +282,7 @@ static void detachFunc(
|
||||
for(i=0; i<db->nDb; i++){
|
||||
pDb = &db->aDb[i];
|
||||
if( pDb->pBt==0 ) continue;
|
||||
if( sqlite3StrICmp(pDb->zDbSName, zName)==0 ) break;
|
||||
if( sqlite3DbIsNamed(db, i, zName) ) break;
|
||||
}
|
||||
|
||||
if( i>=db->nDb ){
|
||||
@ -465,12 +475,29 @@ int sqlite3FixSrcList(
|
||||
int i;
|
||||
const char *zDb;
|
||||
struct SrcList_item *pItem;
|
||||
sqlite3 *db = pFix->pParse->db;
|
||||
const char *zAlt = 0;
|
||||
|
||||
if( NEVER(pList==0) ) return 0;
|
||||
|
||||
/* If zDb refers to the main database and the main database has been
|
||||
** renamed using DBCONFIG_MAINDBNAME, then items in pList may be
|
||||
** qualified using "main" or the new name as the database name. Set
|
||||
** zAlt to point to the alternative (alternative to zDb) name in this
|
||||
** case. */
|
||||
zDb = pFix->zDb;
|
||||
if( sqlite3StrICmp(db->aDb[0].zDbSName, zDb)==0 ){
|
||||
zAlt = "main";
|
||||
}else if( sqlite3StrICmp("main", zDb)==0 ){
|
||||
zAlt = db->aDb[0].zDbSName;
|
||||
}
|
||||
|
||||
for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
|
||||
if( pFix->bTemp==0 ){
|
||||
if( pItem->zDatabase && sqlite3StrICmp(pItem->zDatabase, zDb) ){
|
||||
if( pItem->zDatabase
|
||||
&& sqlite3StrICmp(pItem->zDatabase, zDb)
|
||||
&& sqlite3_stricmp(pItem->zDatabase, zAlt)
|
||||
){
|
||||
sqlite3ErrorMsg(pFix->pParse,
|
||||
"%s %T cannot reference objects in database %s",
|
||||
pFix->zType, pFix->pName, pItem->zDatabase);
|
||||
|
@ -315,7 +315,7 @@ Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){
|
||||
while(1){
|
||||
for(i=OMIT_TEMPDB; i<db->nDb; i++){
|
||||
int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */
|
||||
if( zDatabase==0 || sqlite3StrICmp(zDatabase, db->aDb[j].zDbSName)==0 ){
|
||||
if( zDatabase==0 || sqlite3DbIsNamed(db, j, zDatabase) ){
|
||||
assert( sqlite3SchemaMutexHeld(db, j, 0) );
|
||||
p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);
|
||||
if( p ) return p;
|
||||
@ -437,7 +437,7 @@ Index *sqlite3FindIndex(sqlite3 *db, const char *zName, const char *zDb){
|
||||
int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */
|
||||
Schema *pSchema = db->aDb[j].pSchema;
|
||||
assert( pSchema );
|
||||
if( zDb && sqlite3StrICmp(zDb, db->aDb[j].zDbSName) ) continue;
|
||||
if( zDb && sqlite3DbIsNamed(db, j, zDb)==0 ) continue;
|
||||
assert( sqlite3SchemaMutexHeld(db, j, 0) );
|
||||
p = sqlite3HashFind(&pSchema->idxHash, zName);
|
||||
if( p ) break;
|
||||
|
@ -238,6 +238,7 @@ static int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
|
||||
i = 0;
|
||||
if( iSchema>=0 ){
|
||||
pIdxInfo->aConstraintUsage[iSchema].argvIndex = ++i;
|
||||
pIdxInfo->aConstraintUsage[iSchema].omit = 1;
|
||||
pIdxInfo->idxNum |= 0x01;
|
||||
}
|
||||
if( iName>=0 ){
|
||||
|
@ -252,6 +252,12 @@ static int lookupName(
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( i==db->nDb && sqlite3StrICmp("main", zDb)==0 ){
|
||||
/* This branch is taken when the main database has been renamed
|
||||
** using SQLITE_DBCONFIG_MAINDBNAME. */
|
||||
pSchema = db->aDb[0].pSchema;
|
||||
zDb = db->aDb[0].zDbSName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4395,6 +4395,7 @@ void sqlite3DeferForeignKey(Parse*, int);
|
||||
# define sqlite3AuthContextPush(a,b,c)
|
||||
# define sqlite3AuthContextPop(a) ((void)(a))
|
||||
#endif
|
||||
int sqlite3DbIsNamed(sqlite3 *db, int iDb, const char *zName);
|
||||
void sqlite3Attach(Parse*, Expr*, Expr*, Expr*);
|
||||
void sqlite3Detach(Parse*, Expr*);
|
||||
void sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);
|
||||
|
@ -580,7 +580,7 @@ void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){
|
||||
assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) );
|
||||
for(i=OMIT_TEMPDB; i<db->nDb; i++){
|
||||
int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */
|
||||
if( zDb && sqlite3StrICmp(db->aDb[j].zDbSName, zDb) ) continue;
|
||||
if( zDb && sqlite3DbIsNamed(db, j, zDb)==0 ) continue;
|
||||
assert( sqlite3SchemaMutexHeld(db, j, 0) );
|
||||
pTrigger = sqlite3HashFind(&(db->aDb[j].pSchema->trigHash), zName);
|
||||
if( pTrigger ) break;
|
||||
|
@ -148,10 +148,8 @@ do_test attach-1.14 {
|
||||
ATTACH 'test.db' as db9;
|
||||
}
|
||||
} {1 {database db9 is already in use}}
|
||||
do_test attach-1.15 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as main;
|
||||
}
|
||||
do_catchsql_test attach-1.15 {
|
||||
ATTACH 'test.db' as main;
|
||||
} {1 {database main is already in use}}
|
||||
ifcapable tempdb {
|
||||
do_test attach-1.16 {
|
||||
@ -160,10 +158,8 @@ ifcapable tempdb {
|
||||
}
|
||||
} {1 {database temp is already in use}}
|
||||
}
|
||||
do_test attach-1.17 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as MAIN;
|
||||
}
|
||||
do_catchsql_test attach-1.17 {
|
||||
ATTACH 'test.db' as MAIN;
|
||||
} {1 {database MAIN is already in use}}
|
||||
do_test attach-1.18 {
|
||||
catchsql {
|
||||
@ -231,6 +227,7 @@ do_test attach-1.26 {
|
||||
}
|
||||
} {1 {cannot detach database main}}
|
||||
|
||||
|
||||
ifcapable tempdb {
|
||||
do_test attach-1.27 {
|
||||
catchsql {
|
||||
|
@ -395,17 +395,19 @@ do_createtable_tests 1.2.2 {
|
||||
4 {CREATE TABLE auxb.xyz(z)} {}
|
||||
}
|
||||
drop_all_tables
|
||||
do_createtable_tests 1.3 -tclquery {
|
||||
unset -nocomplain X
|
||||
array set X [table_list]
|
||||
list $X(main) $X(temp) $X(auxa) $X(auxb)
|
||||
} {
|
||||
1 "CREATE TABLE main.abc(a, b, c)" {abc {} {} {}}
|
||||
2 "CREATE TABLE main.t1(a, b, c)" {{abc t1} {} {} {}}
|
||||
3 "CREATE TABLE temp.tmp(a, b, c)" {{abc t1} tmp {} {}}
|
||||
4 "CREATE TABLE auxb.tbl(x, y)" {{abc t1} tmp {} tbl}
|
||||
5 "CREATE TABLE auxb.t1(k, v)" {{abc t1} tmp {} {t1 tbl}}
|
||||
6 "CREATE TABLE auxa.next(c, d)" {{abc t1} tmp next {t1 tbl}}
|
||||
if {[permutation]!="maindbname"} {
|
||||
do_createtable_tests 1.3 -tclquery {
|
||||
unset -nocomplain X
|
||||
array set X [table_list]
|
||||
list $X(main) $X(temp) $X(auxa) $X(auxb)
|
||||
} {
|
||||
1 "CREATE TABLE main.abc(a, b, c)" {abc {} {} {}}
|
||||
2 "CREATE TABLE main.t1(a, b, c)" {{abc t1} {} {} {}}
|
||||
3 "CREATE TABLE temp.tmp(a, b, c)" {{abc t1} tmp {} {}}
|
||||
4 "CREATE TABLE auxb.tbl(x, y)" {{abc t1} tmp {} tbl}
|
||||
5 "CREATE TABLE auxb.t1(k, v)" {{abc t1} tmp {} {t1 tbl}}
|
||||
6 "CREATE TABLE auxa.next(c, d)" {{abc t1} tmp next {t1 tbl}}
|
||||
}
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-18895-27365 If the "TEMP" or "TEMPORARY" keyword occurs
|
||||
@ -413,13 +415,15 @@ do_createtable_tests 1.3 -tclquery {
|
||||
# temp database.
|
||||
#
|
||||
drop_all_tables
|
||||
do_createtable_tests 1.4 -tclquery {
|
||||
unset -nocomplain X
|
||||
array set X [table_list]
|
||||
list $X(main) $X(temp) $X(auxa) $X(auxb)
|
||||
} {
|
||||
1 "CREATE TEMP TABLE t1(a, b)" {{} t1 {} {}}
|
||||
2 "CREATE TEMPORARY TABLE t2(a, b)" {{} {t1 t2} {} {}}
|
||||
if {[permutation]!="maindbname"} {
|
||||
do_createtable_tests 1.4 -tclquery {
|
||||
unset -nocomplain X
|
||||
array set X [table_list]
|
||||
list $X(main) $X(temp) $X(auxa) $X(auxb)
|
||||
} {
|
||||
1 "CREATE TEMP TABLE t1(a, b)" {{} t1 {} {}}
|
||||
2 "CREATE TEMPORARY TABLE t2(a, b)" {{} {t1 t2} {} {}}
|
||||
}
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-23976-43329 It is an error to specify both a
|
||||
@ -436,30 +440,34 @@ do_createtable_tests 1.5.1 -error {
|
||||
4 "CREATE TEMPORARY TABLE main.xxx(x)" {}
|
||||
}
|
||||
drop_all_tables
|
||||
do_createtable_tests 1.5.2 -tclquery {
|
||||
unset -nocomplain X
|
||||
array set X [table_list]
|
||||
list $X(main) $X(temp) $X(auxa) $X(auxb)
|
||||
} {
|
||||
1 "CREATE TEMP TABLE temp.t1(a, b)" {{} t1 {} {}}
|
||||
2 "CREATE TEMPORARY TABLE temp.t2(a, b)" {{} {t1 t2} {} {}}
|
||||
3 "CREATE TEMP TABLE TEMP.t3(a, b)" {{} {t1 t2 t3} {} {}}
|
||||
4 "CREATE TEMPORARY TABLE TEMP.xxx(x)" {{} {t1 t2 t3 xxx} {} {}}
|
||||
if {[permutation]!="maindbname"} {
|
||||
do_createtable_tests 1.5.2 -tclquery {
|
||||
unset -nocomplain X
|
||||
array set X [table_list]
|
||||
list $X(main) $X(temp) $X(auxa) $X(auxb)
|
||||
} {
|
||||
1 "CREATE TEMP TABLE temp.t1(a, b)" {{} t1 {} {}}
|
||||
2 "CREATE TEMPORARY TABLE temp.t2(a, b)" {{} {t1 t2} {} {}}
|
||||
3 "CREATE TEMP TABLE TEMP.t3(a, b)" {{} {t1 t2 t3} {} {}}
|
||||
4 "CREATE TEMPORARY TABLE TEMP.xxx(x)" {{} {t1 t2 t3 xxx} {} {}}
|
||||
}
|
||||
}
|
||||
|
||||
# EVIDENCE-OF: R-31997-24564 If no schema name is specified and the TEMP
|
||||
# keyword is not present then the table is created in the main database.
|
||||
#
|
||||
drop_all_tables
|
||||
do_createtable_tests 1.6 -tclquery {
|
||||
unset -nocomplain X
|
||||
array set X [table_list]
|
||||
list $X(main) $X(temp) $X(auxa) $X(auxb)
|
||||
} {
|
||||
1 "CREATE TABLE t1(a, b)" {t1 {} {} {}}
|
||||
2 "CREATE TABLE t2(a, b)" {{t1 t2} {} {} {}}
|
||||
3 "CREATE TABLE t3(a, b)" {{t1 t2 t3} {} {} {}}
|
||||
4 "CREATE TABLE xxx(x)" {{t1 t2 t3 xxx} {} {} {}}
|
||||
if {[permutation]!="maindbname"} {
|
||||
do_createtable_tests 1.6 -tclquery {
|
||||
unset -nocomplain X
|
||||
array set X [table_list]
|
||||
list $X(main) $X(temp) $X(auxa) $X(auxb)
|
||||
} {
|
||||
1 "CREATE TABLE t1(a, b)" {t1 {} {} {}}
|
||||
2 "CREATE TABLE t2(a, b)" {{t1 t2} {} {} {}}
|
||||
3 "CREATE TABLE t3(a, b)" {{t1 t2 t3} {} {} {}}
|
||||
4 "CREATE TABLE xxx(x)" {{t1 t2 t3 xxx} {} {} {}}
|
||||
}
|
||||
}
|
||||
|
||||
drop_all_tables
|
||||
|
@ -126,37 +126,37 @@ do_execsql_test 3.1.0 { SELECT * FROM temp.v1 } {{a temp} {b temp}}
|
||||
do_execsql_test 3.1.1 { DROP VIEW temp.v1 } {}
|
||||
do_catchsql_test 3.1.2 { SELECT * FROM temp.v1 } {1 {no such table: temp.v1}}
|
||||
do_test 3.1.3 { list_all_views } {main.v1 main.v2 aux.v1 aux.v2 aux.v3}
|
||||
do_test 3.1.4 { list_all_data } $databasedata
|
||||
do_test 3.1.4 { string compare [list_all_data] $databasedata } 0
|
||||
|
||||
do_execsql_test 3.2.0 { SELECT * FROM v1 } {{a main} {b main}}
|
||||
do_execsql_test 3.2.1 { DROP VIEW v1 } {}
|
||||
do_catchsql_test 3.2.2 { SELECT * FROM main.v1 } {1 {no such table: main.v1}}
|
||||
do_test 3.2.3 { list_all_views } {main.v2 aux.v1 aux.v2 aux.v3}
|
||||
do_test 3.2.4 { list_all_data } $databasedata
|
||||
do_test 3.2.4 { string compare [list_all_data] $databasedata } 0
|
||||
|
||||
do_execsql_test 3.3.0 { SELECT * FROM v2 } {{a main} {b main}}
|
||||
do_execsql_test 3.3.1 { DROP VIEW v2 } {}
|
||||
do_catchsql_test 3.3.2 { SELECT * FROM main.v2 } {1 {no such table: main.v2}}
|
||||
do_test 3.3.3 { list_all_views } {aux.v1 aux.v2 aux.v3}
|
||||
do_test 3.3.4 { list_all_data } $databasedata
|
||||
do_test 3.3.4 { string compare [list_all_data] $databasedata } 0
|
||||
|
||||
do_execsql_test 3.4.0 { SELECT * FROM v1 } {{a aux} {b aux}}
|
||||
do_execsql_test 3.4.1 { DROP VIEW v1 } {}
|
||||
do_catchsql_test 3.4.2 { SELECT * FROM v1 } {1 {no such table: v1}}
|
||||
do_test 3.4.3 { list_all_views } {aux.v2 aux.v3}
|
||||
do_test 3.4.4 { list_all_data } $databasedata
|
||||
do_test 3.4.4 { string compare [list_all_data] $databasedata } 0
|
||||
|
||||
do_execsql_test 3.4.0 { SELECT * FROM aux.v2 } {{a aux} {b aux}}
|
||||
do_execsql_test 3.4.1 { DROP VIEW aux.v2 } {}
|
||||
do_catchsql_test 3.4.2 { SELECT * FROM aux.v2 } {1 {no such table: aux.v2}}
|
||||
do_test 3.4.3 { list_all_views } {aux.v3}
|
||||
do_test 3.4.4 { list_all_data } $databasedata
|
||||
do_execsql_test 3.5.0 { SELECT * FROM aux.v2 } {{a aux} {b aux}}
|
||||
do_execsql_test 3.5.1 { DROP VIEW aux.v2 } {}
|
||||
do_catchsql_test 3.5.2 { SELECT * FROM aux.v2 } {1 {no such table: aux.v2}}
|
||||
do_test 3.5.3 { list_all_views } {aux.v3}
|
||||
do_test 3.5.4 { string compare [list_all_data] $databasedata } 0
|
||||
|
||||
do_execsql_test 3.5.0 { SELECT * FROM v3 } {{a aux} {b aux}}
|
||||
do_execsql_test 3.5.1 { DROP VIEW v3 } {}
|
||||
do_catchsql_test 3.5.2 { SELECT * FROM v3 } {1 {no such table: v3}}
|
||||
do_test 3.5.3 { list_all_views } {}
|
||||
do_test 3.5.4 { list_all_data } $databasedata
|
||||
do_execsql_test 3.6.0 { SELECT * FROM v3 } {{a aux} {b aux}}
|
||||
do_execsql_test 3.6.1 { DROP VIEW v3 } {}
|
||||
do_catchsql_test 3.6.2 { SELECT * FROM v3 } {1 {no such table: v3}}
|
||||
do_test 3.6.3 { list_all_views } {}
|
||||
do_test 3.6.4 { string compare [list_all_data] $databasedata } 0
|
||||
|
||||
# EVIDENCE-OF: R-25558-37487 If the specified view cannot be found and
|
||||
# the IF EXISTS clause is not present, it is an error.
|
||||
@ -179,11 +179,11 @@ do_dropview_tests 5 -repair {
|
||||
dropview_reopen_db
|
||||
} -tclquery {
|
||||
list_all_views
|
||||
expr {[list_all_views] == "main.v1 main.v2 temp.v1 aux.v1 aux.v2 aux.v3"}
|
||||
#expr {[list_all_views] == "main.v1 main.v2 temp.v1 aux.v1 aux.v2 aux.v3"}
|
||||
} {
|
||||
1 "DROP VIEW IF EXISTS xx" 1
|
||||
2 "DROP VIEW IF EXISTS main.xx" 1
|
||||
3 "DROP VIEW IF EXISTS temp.v2" 1
|
||||
1 "DROP VIEW IF EXISTS xx" "main.v1 main.v2 temp.v1 aux.v1 aux.v2 aux.v3"
|
||||
2 "DROP VIEW IF EXISTS main.xx" "main.v1 main.v2 temp.v1 aux.v1 aux.v2 aux.v3"
|
||||
3 "DROP VIEW IF EXISTS temp.v2" "main.v1 main.v2 temp.v1 aux.v1 aux.v2 aux.v3"
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,9 +132,9 @@ dbconfig_maindbname_icecube db
|
||||
do_execsql_test misc8-4.2 {
|
||||
SELECT name FROM icecube.sqlite_master;
|
||||
} {t1}
|
||||
do_execsql_test misc8-4.3 {
|
||||
PRAGMA database_list;
|
||||
} {/0 icecube .* 2 aux2/}
|
||||
do_test misc8-4.3 {
|
||||
regexp {0 icecube .* 2 aux2} [db eval {PRAGMA database_list}]
|
||||
} 1
|
||||
|
||||
|
||||
|
||||
|
@ -1075,6 +1075,16 @@ test_suite "sorterref" -prefix "" -description {
|
||||
autoinstall_test_functions
|
||||
}
|
||||
|
||||
test_suite "maindbname" -prefix "" -description {
|
||||
Run the "veryquick" test suite with SQLITE_DBCONFIG_MAINDBNAME used to
|
||||
set the name of database 0 to "icecube".
|
||||
} -files [
|
||||
test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \
|
||||
*fts5corrupt* *fts5big* *fts5aj*
|
||||
] -dbconfig {
|
||||
dbconfig_maindbname_icecube $::dbhandle
|
||||
}
|
||||
|
||||
# End of tests
|
||||
#############################################################################
|
||||
|
||||
|
@ -782,6 +782,9 @@ proc do_test {name cmd expected} {
|
||||
output2 "\nError: $result"
|
||||
fail_test $name
|
||||
} else {
|
||||
if {[permutation]=="maindbname"} {
|
||||
set result [string map [list [string tolower ICECUBE] main] $result]
|
||||
}
|
||||
if {[regexp {^[~#]?/.*/$} $expected]} {
|
||||
# "expected" is of the form "/PATTERN/" then the result if correct if
|
||||
# regular expression PATTERN matches the result. "~/PATTERN/" means
|
||||
|
Loading…
Reference in New Issue
Block a user