]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Remove the OP_SetInsert opcode. (CVS 1443)
authordrh <drh@noemail.net>
Sat, 22 May 2004 21:30:40 +0000 (21:30 +0000)
committerdrh <drh@noemail.net>
Sat, 22 May 2004 21:30:40 +0000 (21:30 +0000)
FossilOrigin-Name: 18e690e405710c9a8010340c01754bbfa3231fe9

manifest
manifest.uuid
src/os_unix.c
src/pragma.c
src/vdbe.c
src/vdbeInt.h
src/vdbeaux.c

index db80390615ca073b903a9716386574711be70b8e..3ed55a440e6d94b6de25decaa9eeb83d0f3294ac 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Move\sbtree_rb.c\sinto\sthe\sattic.\s(CVS\s1442)
-D 2004-05-22T17:46:37
+C Remove\sthe\sOP_SetInsert\sopcode.\s(CVS\s1443)
+D 2004-05-22T21:30:41
 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -42,14 +42,14 @@ F src/os.h ab42f4a7c4c716f26b988e759b6e12085a3bfc67
 F src/os_common.h 744286a27de55c52f1b18921e8d17abbf7fafc0f
 F src/os_mac.c b823874690615ace0dd520d3ad1fe8bfd864b7e0
 F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4
-F src/os_unix.c e93a6858b4ab880ce91cbc95af14975ef53b6369
+F src/os_unix.c 585665eccd31a9bb4dc090bc6b5e29d8d42899f0
 F src/os_unix.h 426e1480f0847a7f8ba22aa9ac5115520875610b
 F src/os_win.c 92b51a38437b98d8aa3ac05b57c71e1d1092e5be
 F src/os_win.h 5d41af24caaef6c13a2d8e2399caa1c57d45c84d
 F src/pager.c 6ff6b906427d4824099140776cb8768f922f3dc5
 F src/pager.h 78a00ac280899bcba1a89dc51585dcae6b7b3253
 F src/parse.y 567718866b94d58a6c7681cc45ba7987771d583a
-F src/pragma.c aeeba7dc5bc32a6f0980e6516cb2a48a50973fab
+F src/pragma.c e14dd3b06cedeadcc027f0b6706b2f53d456a46e
 F src/printf.c ef750e8e2398ca7e8b58be991075f08c6a7f0e53
 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
 F src/select.c 7d77a8bed7eeac23216d42fc1be006fb4352fcdc
@@ -69,10 +69,10 @@ F src/update.c 1a5e9182596f3ea8c7a141e308a3d2a7e5689fee
 F src/utf.c a4640c6a1530b43b651495246349ee0a6eca3038
 F src/util.c 5cbeb452da09cfc7248de9948c15b14d840723f7
 F src/vacuum.c 8734f89742f246abd91dbd3e087fc153bddbfbad
-F src/vdbe.c c1846f4b2938d11250f532b068d7856fd8decd6c
+F src/vdbe.c 316491eb9b02fb6a385ffe8d5256eab40a254171
 F src/vdbe.h 391d5642a83af686f35c228fcd36cb4456d68f44
-F src/vdbeInt.h f40e8048d644c8389cda16f46479376f763d56e6
-F src/vdbeaux.c d3dfb6d40eb1fdf2626896e8b13fe7b50134ff12
+F src/vdbeInt.h e3f2643c62a8d958f760fb307074d1c5d868c9ab
+F src/vdbeaux.c 1e5262696aa32a50ca691a5669f6ed534655a94c
 F src/where.c efe5d25fe18cd7381722457898cd863e84097a0c
 F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
 F test/attach.test cb9b884344e6cfa5e165965d5b1adea679a24c83
@@ -202,7 +202,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 5c61be1c47ac960fba2a642e69a98436ce1cd725
-R 895a23f6e8990fb83852de59938ec75c
+P 4159ef235d780ec941677439e77c6fa96e24997c
+R 5d98176ba2ec77b07a87ae923b3b9934
 U drh
-Z 284f15852c16971e78cc98172c48c47f
+Z 9374b217aab3cb0d12f84dd869677fb1
index a6c0d10056230e5aa0a9227b87f19dce0a2063ea..8f8f6c41413046217c6aeed026c7375da9dfd8bf 100644 (file)
@@ -1 +1 @@
-4159ef235d780ec941677439e77c6fa96e24997c
\ No newline at end of file
+18e690e405710c9a8010340c01754bbfa3231fe9
\ No newline at end of file
index e6c6f31595325240067efe398d6fe606c68f33d2..c2a3679b7db4d33502a90eb4bb056a869f10331c 100644 (file)
@@ -811,7 +811,9 @@ int sqlite3OsSleep(int ms){
 ** Static variables used for thread synchronization
 */
 static int inMutex = 0;
+#ifdef SQLITE_UNIX_THREADS
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
 
 /*
 ** The following pair of routine implement mutual exclusion for
index 47b0a172780240152c607b5e3200bf163ee94232..c13b445ec0514cb022cf1886aa68d75c9a855a1c 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file contains code used to implement the PRAGMA command.
 **
-** $Id: pragma.c,v 1.27 2004/05/20 22:16:29 drh Exp $
+** $Id: pragma.c,v 1.28 2004/05/22 21:30:41 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -574,31 +574,6 @@ void sqlite3Pragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){
       { OP_ColumnName,  0, 1,        "integrity_check"},
     };
 
-    /* Code to do an BTree integrity check on a single database file.
-    */
-    static VdbeOpList checkDb[] = {
-      { OP_SetInsert,   0, 0,        "1"},
-      { OP_Integer,     0, 0,        0},    /* 1 */
-      { OP_OpenRead,    0, MASTER_ROOT, 0},
-      { OP_SetNumColumns,0,5,        0},    /* sqlite_master has 5 cols */
-
-      { OP_Rewind,      0, 8,        0},    /* 4 */
-      { OP_Column,      0, 3,        0},    /* 5 */
-      { OP_SetInsert,   0, 0,        0},
-      { OP_Next,        0, 5,        0},    /* 7 */
-      { OP_IntegrityCk, 0, 0,        0},    /* 8 */
-      { OP_Dup,         0, 1,        0},
-      { OP_String,      0, 0,        "ok"},
-      { OP_Eq,          0, 13,       0},    /* 11 */
-      { OP_MemIncr,     0, 0,        0},
-      { OP_String,      0, 0,        "*** in database "},
-      { OP_String,      0, 0,        0},    /* 14 */
-      { OP_String,      0, 0,        " ***\n"},
-      { OP_Pull,        3, 0,        0},
-      { OP_Concat,      4, 1,        0},
-      { OP_Callback,    1, 0,        0},
-    };
-
     /* Code that appears at the end of the integrity check.  If no error
     ** messages have been generated, output OK.  Otherwise output the
     ** error message
@@ -617,16 +592,30 @@ void sqlite3Pragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){
     /* Do an integrity check on each database file */
     for(i=0; i<db->nDb; i++){
       HashElem *x;
+      int cnt = 0;
 
       /* Do an integrity check of the B-Tree
       */
-      addr = sqlite3VdbeAddOpList(v, ArraySize(checkDb), checkDb);
-      sqlite3VdbeChangeP1(v, addr+1, i);
-      sqlite3VdbeChangeP2(v, addr+4, addr+8);
-      sqlite3VdbeChangeP2(v, addr+7, addr+5);
-      sqlite3VdbeChangeP2(v, addr+8, i);
-      sqlite3VdbeChangeP2(v, addr+11, addr+ArraySize(checkDb));
-      sqlite3VdbeChangeP3(v, addr+14, db->aDb[i].zName, P3_STATIC);
+      for(x=sqliteHashFirst(&db->aDb[i].tblHash); x; x=sqliteHashNext(x)){
+        Table *pTab = sqliteHashData(x);
+        Index *pIdx;
+        sqlite3VdbeAddOp(v, OP_Integer, pTab->tnum, 0);
+        cnt++;
+        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
+          sqlite3VdbeAddOp(v, OP_Integer, pIdx->tnum, 0);
+          cnt++;
+        }
+      }
+      sqlite3VdbeAddOp(v, OP_IntegrityCk, cnt, i);
+      sqlite3VdbeAddOp(v, OP_Dup, 0, 1);
+      addr = sqlite3VdbeOp3(v, OP_String, 0, 0, "ok", P3_STATIC);
+      sqlite3VdbeAddOp(v, OP_Eq, 0, addr+6);
+      sqlite3VdbeOp3(v, OP_String, 0, 0,
+         sqlite3MPrintf("*** in database %s ***\n", db->aDb[i].zName),
+         P3_DYNAMIC);
+      sqlite3VdbeAddOp(v, OP_Pull, 1, 0);
+      sqlite3VdbeAddOp(v, OP_Concat, 2, 1);
+      sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
 
       /* Make sure all the indices are constructed correctly.
       */
index fb655f039a5aea221ca925b7988823f66c368183..602c238b6f0bdf5a6b0b0d30665bb3e8e0f8aaad 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.319 2004/05/22 11:09:30 drh Exp $
+** $Id: vdbe.c,v 1.320 2004/05/22 21:30:41 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -1562,8 +1562,8 @@ case OP_Callback: {
   p->resOnStack = 1;
 
   azArgv[i] = 0;
-  p->nCallback++;
   p->azResColumn = azArgv;
+  p->nCallback++;
   assert( p->nResColumn==pOp->p1 );
   p->popStack = pOp->p1;
   p->pc = pc + 1;
@@ -4469,16 +4469,15 @@ case OP_CreateTable: {
   break;
 }
 
-/* Opcode: IntegrityCk P1 P2 *
+/* Opcode: IntegrityCk * P2 *
 **
 ** Do an analysis of the currently open database.  Push onto the
 ** stack the text of an error message describing any problems.
 ** If there are no errors, push a "ok" onto the stack.
 **
-** P1 is the index of a set that contains the root page numbers
-** for all tables and indices in the main database file.  The set
-** is cleared by this opcode.  In other words, after this opcode
-** has executed, the set will be empty.
+** The root page numbers of all tables in the database are integer
+** values on the stack.  This opcode pulls as many integers as it
+** can off of the stack and uses those numbers as the root pages.
 **
 ** If P2 is not zero, the check is done on the auxiliary database
 ** file, not the main database file.
@@ -4488,26 +4487,22 @@ case OP_CreateTable: {
 case OP_IntegrityCk: {
   int nRoot;
   int *aRoot;
-  int iSet = pOp->p1;
-  Set *pSet;
   int j;
-  HashElem *i;
   char *z;
 
-  assert( iSet>=0 && iSet<p->nSet );
-  pTos++;
-  pSet = &p->aSet[iSet];
-  nRoot = sqliteHashCount(&pSet->hash);
-  aRoot = sqliteMallocRaw( sizeof(int)*(nRoot+1) );
+  for(nRoot=0; &pTos[-nRoot]>=p->aStack; nRoot++){
+    if( (pTos[-nRoot].flags & MEM_Int)==0 ) break;
+  }
+  assert( nRoot>0 );
+  aRoot = sqliteMallocRaw( sizeof(int*)*(nRoot+1) );
   if( aRoot==0 ) goto no_mem;
-  for(j=0, i=sqliteHashFirst(&pSet->hash); i; i=sqliteHashNext(i), j++){
-    i64 root64;
-    sqlite3atoi64((char*)sqliteHashKey(i), &root64);
-    aRoot[j] = root64;
+  for(j=0; j<nRoot; j++){
+    Mem *pMem = &pTos[-j];
+    aRoot[j] = pMem->i;
   }
   aRoot[j] = 0;
-  sqlite3HashClear(&pSet->hash);
-  pSet->prev = 0;
+  popStack(&pTos, nRoot);
+  pTos++;
   z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p2].pBt, aRoot, nRoot);
   if( z==0 || z[0]==0 ){
     if( z ) sqliteFree(z);
@@ -5256,37 +5251,6 @@ case OP_AggNext: {
   break;
 }
 
-/* Opcode: SetInsert P1 * P3
-**
-** If Set P1 does not exist then create it.  Then insert value
-** P3 into that set.  If P3 is NULL, then insert the top of the
-** stack into the set.
-*/
-case OP_SetInsert: {
-  int i = pOp->p1;
-  if( p->nSet<=i ){
-    int k;
-    Set *aSet = sqliteRealloc(p->aSet, (i+1)*sizeof(p->aSet[0]) );
-    if( aSet==0 ) goto no_mem;
-    p->aSet = aSet;
-    for(k=p->nSet; k<=i; k++){
-      sqlite3HashInit(&p->aSet[k].hash, SQLITE_HASH_BINARY, 1);
-    }
-    p->nSet = i+1;
-  }
-  if( pOp->p3 ){
-    sqlite3HashInsert(&p->aSet[i].hash, pOp->p3, strlen(pOp->p3)+1, p);
-  }else{
-    assert( pTos>=p->aStack );
-    Stringify(pTos);
-    sqlite3HashInsert(&p->aSet[i].hash, pTos->z, pTos->n, p);
-    Release(pTos);
-    pTos--;
-  }
-  if( sqlite3_malloc_failed ) goto no_mem;
-  break;
-}
-
 /* Opcode: Vacuum * * *
 **
 ** Vacuum the entire database.  This opcode will cause other virtual
@@ -5371,7 +5335,7 @@ default: {
           fprintf(p->trace, " r:%g", pTos[i].r);
         }else{
           char zBuf[100];
-          prettyPrintMem(pTos, zBuf, 100);
+          prettyPrintMem(&pTos[i], zBuf, 100);
           fprintf(p->trace, " ");
           fprintf(p->trace, zBuf);
         }
index 93405952321e549d09fdf1c7cdbf9f8d446460c4..579742394581ae8a6038fdf865c1e26a43a56057 100644 (file)
@@ -285,8 +285,6 @@ struct Vdbe {
   int nMem;               /* Number of memory locations currently allocated */
   Mem *aMem;              /* The memory locations */
   Agg agg;                /* Aggregate information */
-  int nSet;               /* Number of sets allocated */
-  Set *aSet;              /* An array of sets */
   int nCallback;          /* Number of callbacks invoked so far */
   Keylist *pList;         /* A list of ROWIDs */
   int keylistStackDepth;  /* The size of the "keylist" stack */
@@ -343,4 +341,3 @@ int sqlite3VdbeRowCompare(void*,int,const void*,int, const void*);
 int sqlite3VdbeExec(Vdbe*);
 int sqlite3VdbeList(Vdbe*);
 int sqlite3VdbeSetEncoding(Mem *, u8);
-
index c91d7a70a3471b22311aa146a6d51582b38a9222..abc278a8ea162df04996bf15951c3447edbffd8d 100644 (file)
@@ -923,14 +923,6 @@ static void Cleanup(Vdbe *p){
   }
   p->nLineAlloc = 0;
   sqlite3VdbeAggReset(&p->agg);
-  if( p->aSet ){
-    for(i=0; i<p->nSet; i++){
-      sqlite3HashClear(&p->aSet[i].hash);
-    }
-  }
-  sqliteFree(p->aSet);
-  p->aSet = 0;
-  p->nSet = 0;
   if( p->keylistStack ){
     int ii;
     for(ii = 0; ii < p->keylistStackDepth; ii++){