From: drh Date: Thu, 24 Mar 2011 01:34:03 +0000 (+0000) Subject: The changes to fix [f7b4edece25c9948] mean that the schema is always loaded X-Git-Tag: version-3.7.6~82 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=22645842a4495cf9efd2bf9d1fc7e14ea95a9fd7;p=thirdparty%2Fsqlite.git The changes to fix [f7b4edece25c9948] mean that the schema is always loaded whenever a prepared statement is running. This means that a couple of branches can be eliminated and one operand of OP_ParseSchema can be removed. FossilOrigin-Name: b6e268fce12829f058f1dfa223731ec8479493f8 --- diff --git a/manifest b/manifest index 3e4308ef86..2e7f2553f6 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sa\ssigned/unsigned\scomparison\scompiler\swarning. -D 2011-03-23T22:54:59.680 +C The\schanges\sto\sfix\s[f7b4edece25c9948]\smean\sthat\sthe\sschema\sis\salways\sloaded\nwhenever\sa\sprepared\sstatement\sis\srunning.\s\sThis\smeans\sthat\sa\scouple\sof\nbranches\scan\sbe\seliminated\sand\sone\soperand\sof\sOP_ParseSchema\scan\sbe\sremoved. +D 2011-03-24T01:34:03.589 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -127,7 +127,7 @@ F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c 43302cc4f3de6479b90fa6bb271b65d86333d00e F src/btree.h e2f2cd9933bf30724f53ffa12c4c5a3a864bbd6e F src/btreeInt.h 20f73dc93b1eeb83afd7259fbc6bd7dcf2df7fe4 -F src/build.c 821d4b3c6b1da068a4eb1e9c8c414b75612d34c2 +F src/build.c 6c490fe14dedb094a202f559e3b29a276abffcf8 F src/callback.c 5069f224882cbdccd559f591271d28d7f37745bc F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 52ff72f966cee3087e0138a3ec69371c22be3c01 @@ -234,7 +234,7 @@ F src/update.c 81911be16ece3c3e7716aa18565b4814ec41f8b9 F src/utf.c 1baeeac91707a4df97ccc6141ec0f808278af685 F src/util.c cd997077bad039efc0597eb027c929658f93c018 F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f -F src/vdbe.c 8430780c643bf67d4b5da27f24d6ad39804fdaf4 +F src/vdbe.c e3f37ca0afdd72e883475e2a32a06167df2810d0 F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 F src/vdbeInt.h e1c6254641168507d25b46affb6dfb53c782f553 F src/vdbeapi.c a09ad9164cafc505250d5dd6b69660c960f1308c @@ -242,7 +242,7 @@ F src/vdbeaux.c cfd3f3ac674691ba1166ceb9a2698b0d00b2ef91 F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5 -F src/vtab.c b297e8fa656ab5e66244ab15680d68db0adbec30 +F src/vtab.c e1edca38c4c4310710635bb91bb3c87fdf60f21d F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f @@ -918,14 +918,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P ad4dc7b95f94fc9a5430c1305fb61d9de79b3365 -R 05f42cc00ab3cdb64365c2fe171fc56f +P c81da6f98d89935442c447a51736e11baf5a7bc1 +R 1385a7d5de36b79443cb7c3a0640b642 U drh -Z 644dd0f67efa20295e11832c3a2205f7 +Z 543f2172a6c6f59b12f6f8179ba74ac8 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNinpHoxKgR168RlERAq2dAJ46tn1P78bk+fzSlMu9lZgNt93uXgCfdSxG -aLd6ZyUVGNlmb+6ykQVFcwI= -=8SNl +iD8DBQFNip+OoxKgR168RlERAscyAJwO5weMWphP/4h7v5yG5qbxBwjEmwCfWfm9 +6wa+RAcKUeSlgCixWI85G+0= +=EvNb -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 8f5f55e172..2f7f0db5c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c81da6f98d89935442c447a51736e11baf5a7bc1 \ No newline at end of file +b6e268fce12829f058f1dfa223731ec8479493f8 \ No newline at end of file diff --git a/src/build.c b/src/build.c index e7c56c9ab0..bf3273fc84 100644 --- a/src/build.c +++ b/src/build.c @@ -368,7 +368,7 @@ void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){ len = sqlite3Strlen30(zIdxName); pIndex = sqlite3HashInsert(pHash, zIdxName, len, 0); - if( pIndex ){ + if( ALWAYS(pIndex) ){ if( pIndex->pTable->pIndex==pIndex ){ pIndex->pTable->pIndex = pIndex->pNext; }else{ diff --git a/src/vdbe.c b/src/vdbe.c index b7dfd334fc..43d132f1ba 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4608,14 +4608,10 @@ case OP_CreateTable: { /* out2-prerelease */ break; } -/* Opcode: ParseSchema P1 P2 * P4 * +/* Opcode: ParseSchema P1 * * P4 * ** ** Read and parse all entries from the SQLITE_MASTER table of database P1 -** that match the WHERE clause P4. P2 is the "force" flag. Always do -** the parsing if P2 is true. If P2 is false, then this routine is a -** no-op if the schema is not currently loaded. In other words, if P2 -** is false, the SQLITE_MASTER table is only parsed if the rest of the -** schema is already loaded into the symbol table. +** that match the WHERE clause P4. ** ** This opcode invokes the parser to create a new virtual machine, ** then runs the new virtual machine. It is thus a re-entrant opcode. @@ -4629,14 +4625,7 @@ case OP_ParseSchema: { iDb = pOp->p1; assert( iDb>=0 && iDbnDb ); - /* If pOp->p2 is 0, then this opcode is being executed to read a - ** single row, for example the row corresponding to a new index - ** created by this VDBE, from the sqlite_master table. It only - ** does this if the corresponding in-memory schema is currently - ** loaded. Otherwise, the new index definition can be loaded along - ** with the rest of the schema when it is required. - ** - ** Although the mutex on the BtShared object that corresponds to + /* Although the mutex on the BtShared object that corresponds to ** database iDb (the database containing the sqlite_master table ** read by this instruction) is currently held, it is necessary to ** obtain the mutexes on all attached databases before checking if @@ -4652,7 +4641,7 @@ case OP_ParseSchema: { */ assert( sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) ); sqlite3BtreeEnterAll(db); - if( pOp->p2 || DbHasProperty(db, iDb, DB_SchemaLoaded) ){ + if( ALWAYS(DbHasProperty(db, iDb, DB_SchemaLoaded)) ){ zMaster = SCHEMA_TABLE(iDb); initData.db = db; initData.iDb = pOp->p1; diff --git a/src/vtab.c b/src/vtab.c index e460ee59e3..b9f1e6f348 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -372,7 +372,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ sqlite3VdbeAddOp2(v, OP_Expire, 0, 0); zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName); - sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 1, 0, zWhere, P4_DYNAMIC); + sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC); sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0, pTab->zName, sqlite3Strlen30(pTab->zName) + 1); }