]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Simplifications to the LockTable opcode. (CVS 4954)
authordrh <drh@noemail.net>
Wed, 2 Apr 2008 16:29:30 +0000 (16:29 +0000)
committerdrh <drh@noemail.net>
Wed, 2 Apr 2008 16:29:30 +0000 (16:29 +0000)
FossilOrigin-Name: 66c5d715bbb732b0861a8a6f994cb4a8f259f2f8

manifest
manifest.uuid
src/btree.c
src/build.c
src/vdbe.c

index 507f466c06254df031e180a8f8bd73830299cd14..b4af9adb510ddd7855290629bf8120f16693a106 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Set\sflags\s=\sMEM_Null\son\sallocation\sfailure\sin\ssqlite3VdbeMemGrow\s(CVS\s4953)
-D 2008-04-02T04:23:32
+C Simplifications\sto\sthe\sLockTable\sopcode.\s(CVS\s4954)
+D 2008-04-02T16:29:31
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in b861627d91df5ee422c54237aa38296954dc0151
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -86,10 +86,10 @@ F src/attach.c bdc75e759ca25a16f4dc7fbdbc6d37ad2561bb24
 F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
 F src/bitvec.c 49817d442e51e4123585f3cf3c2afc293a3c91e2
 F src/btmutex.c 483ced3c52205b04b97df69161fadbf87f4f1ea2
-F src/btree.c 20d51e14297a249408d9cc4bea433e23a72ef125
+F src/btree.c 00cc20be5ca9aabf36a6578d3945294eba2aea95
 F src/btree.h c66cb17c6fffa84a88926dbef173bab4ae692fd4
 F src/btreeInt.h 8a2718652ed9413dc6acbb02a5c5a23a35a6e983
-F src/build.c fb042279457b4908d6f8e6b11855696218ecaa73
+F src/build.c 5d36a6041202a1f3a8b2eee3a631cbce74e5f696
 F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
 F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
 F src/date.c e41ce4513fb0e359dc678d6bddb4ace135fe365d
@@ -174,7 +174,7 @@ F src/update.c 6d5f7728ec254c4a36a06a744f45b232b2eef857
 F src/utf.c 8c94fa10efc78c2568d08d436acc59df4df7191b
 F src/util.c dba9e04121eb17ec4643d6ca231ff859452cf0e2
 F src/vacuum.c 3524411bfb58aac0d87eadd3e5b7cd532772af30
-F src/vdbe.c 1a8f3ececaa93d4932d27ba87946a6907625338c
+F src/vdbe.c 1f8c02fc583df90d20bc638ca07ff0bfb0b4c0e5
 F src/vdbe.h f72201a0657d5f3d6cc008d1f8d9cc65768518c9
 F src/vdbeInt.h 0b96efdeecb0803e504bf1c16b198f87c91d6019
 F src/vdbeapi.c ab6e99f8a6b7fcb82c2c698da7a36762a7593f0a
@@ -621,7 +621,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P e84ff57b6217afa84d60547dcc3a270b5e116818
-R 95e2b93a8ea0781361c08c3a2bd00060
-U mlcreech
-Z 9bfc93788b7cbc8f268a5810ac95123b
+P 846f9739d3e288dc81e40f5bfab046bd80bb22b2
+R b5b81be90c9f85b4a5bfa0dee7823251
+U drh
+Z 7b266a6dff6de99012c6173c0f15f9bd
index f78958eb71b0490de11c310900f4ea51b829bf9b..55666cb651be614c7003a1666e16bc24a2f008c0 100644 (file)
@@ -1 +1 @@
-846f9739d3e288dc81e40f5bfab046bd80bb22b2
\ No newline at end of file
+66c5d715bbb732b0861a8a6f994cb4a8f259f2f8
\ No newline at end of file
index 2f14070622b04c28c8f9882c891a7aeecbe21d0a..52ff5789d0a7f4425e4db525596361b85df98202 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.448 2008/03/29 16:01:04 drh Exp $
+** $Id: btree.c,v 1.449 2008/04/02 16:29:31 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
@@ -7075,13 +7075,17 @@ int sqlite3BtreeSchemaLocked(Btree *p){
 */
 int sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){
   int rc = SQLITE_OK;
-  u8 lockType = (isWriteLock?WRITE_LOCK:READ_LOCK);
-  sqlite3BtreeEnter(p);
-  rc = queryTableLock(p, iTab, lockType);
-  if( rc==SQLITE_OK ){
-    rc = lockTable(p, iTab, lockType);
+  if( p->sharable ){
+    u8 lockType = READ_LOCK + isWriteLock;
+    assert( READ_LOCK+1==WRITE_LOCK );
+    assert( isWriteLock==0 || isWriteLock==1 );
+    sqlite3BtreeEnter(p);
+    rc = queryTableLock(p, iTab, lockType);
+    if( rc==SQLITE_OK ){
+      rc = lockTable(p, iTab, lockType);
+    }
+    sqlite3BtreeLeave(p);
   }
-  sqlite3BtreeLeave(p);
   return rc;
 }
 #endif
index a75b2149a1009e79e88abaf37b1f59579fd40b6d..a18414fbaf390687510fd87381f0b37ff6d73d20 100644 (file)
@@ -22,7 +22,7 @@
 **     COMMIT
 **     ROLLBACK
 **
-** $Id: build.c,v 1.478 2008/04/01 03:27:39 drh Exp $
+** $Id: build.c,v 1.479 2008/04/02 16:29:31 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -111,10 +111,8 @@ static void codeTableLocks(Parse *pParse){
   for(i=0; i<pParse->nTableLock; i++){
     TableLock *p = &pParse->aTableLock[i];
     int p1 = p->iDb;
-    if( p->isWriteLock ){
-      p1 = -1*(p1+1);
-    }
-    sqlite3VdbeAddOp4(pVdbe, OP_TableLock, p1, p->iTab, 0, p->zName, P4_STATIC);
+    sqlite3VdbeAddOp4(pVdbe, OP_TableLock, p1, p->iTab, p->isWriteLock,
+                      p->zName, P4_STATIC);
   }
 }
 #else
index b9e2d1aa4125f8be855e4676b8774f77bbed2ed6..1eb35f0ae52021c3392fbc3bc0a346f63cf7d0ca 100644 (file)
@@ -43,7 +43,7 @@
 ** in this file for details.  If in doubt, do not deviate from existing
 ** commenting and indentation practices when changing or adding code.
 **
-** $Id: vdbe.c,v 1.724 2008/04/01 00:36:10 drh Exp $
+** $Id: vdbe.c,v 1.725 2008/04/02 16:29:31 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -4402,16 +4402,14 @@ case OP_Expire: {
 }
 
 #ifndef SQLITE_OMIT_SHARED_CACHE
-/* Opcode: TableLock P1 P2 * P4 *
+/* Opcode: TableLock P1 P2 P3 P4 *
 **
 ** Obtain a lock on a particular table. This instruction is only used when
 ** the shared-cache feature is enabled. 
 **
-** If P1 is not negative, then it is the index of the database
-** in sqlite3.aDb[] and a read-lock is required. If P1 is negative, a 
-** write-lock is required. In this case the index of the database is the 
-** absolute value of P1 minus one (iDb = abs(P1) - 1;) and a write-lock is
-** required. 
+** If P1 is  the index of the database in sqlite3.aDb[] of the database
+** on which the lock is acquired.  A readlock is obtained if P3==0 or
+** a write lock if P3==1.
 **
 ** P2 contains the root-page of the table to lock.
 **
@@ -4420,12 +4418,10 @@ case OP_Expire: {
 */
 case OP_TableLock: {
   int p1 = pOp->p1; 
-  u8 isWriteLock = (p1<0);
-  if( isWriteLock ){
-    p1 = (-1*p1)-1;
-  }
+  u8 isWriteLock = pOp->p3;
   assert( p1>=0 && p1<db->nDb );
   assert( (p->btreeMask & (1<<p1))!=0 );
+  assert( isWriteLock==0 || isWriteLock==1 );
   rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);
   if( rc==SQLITE_LOCKED ){
     const char *z = pOp->p4.z;