/ Check-in [01f74b42]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Omit the DB_Locked and DB_Cookie flags. Other minor cleanup. (CVS 1642)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 01f74b420c3f24918c066172e09cebbb22568faf
User & Date: drh 2004-06-19 16:06:11
Context
2004-06-19
17:33
Make sure VdbeFunc entries are initialized before trying to destroy them. Also, unrelated comment changes in build.c. (CVS 1643) check-in: fc3b3a8f user: drh tags: trunk
16:06
Omit the DB_Locked and DB_Cookie flags. Other minor cleanup. (CVS 1642) check-in: 01f74b42 user: drh tags: trunk
15:40
Clear up another zero-length array. This seems to fix the segfault in func-13.4 too. (CVS 1641) check-in: 70680a34 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/attach.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the ATTACH and DETACH commands.
    13     13   **
    14         -** $Id: attach.c,v 1.16 2004/06/19 14:49:12 drh Exp $
           14  +** $Id: attach.c,v 1.17 2004/06/19 16:06:11 drh Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   
    18     18   /*
    19     19   ** This routine is called by the parser to process an ATTACH statement:
    20     20   **
    21     21   **     ATTACH DATABASE filename AS dbname
................................................................................
    55     55       return;
    56     56     }
    57     57   #endif /* SQLITE_OMIT_AUTHORIZATION */
    58     58   
    59     59     zName = sqlite3NameFromToken(pDbname);
    60     60     if( zName==0 ) return;
    61     61     for(i=0; i<db->nDb; i++){
    62         -    if( db->aDb[i].zName && sqlite3StrICmp(db->aDb[i].zName, zName)==0 ){
           62  +    char *z = db->aDb[i].zName;
           63  +    if( z && sqlite3StrICmp(z, zName)==0 ){
    63     64         sqlite3ErrorMsg(pParse, "database %z is already in use", zName);
    64     65         pParse->rc = SQLITE_ERROR;
    65     66         sqliteFree(zFile);
    66     67         return;
    67     68       }
    68     69     }
    69     70   
................................................................................
   129    130   **
   130    131   ** The pDbname argument is the name of the database in the DETACH statement.
   131    132   */
   132    133   void sqlite3Detach(Parse *pParse, Token *pDbname){
   133    134     int i;
   134    135     sqlite *db;
   135    136     Vdbe *v;
          137  +  Db *pDb;
   136    138   
   137    139     v = sqlite3GetVdbe(pParse);
   138    140     sqlite3VdbeAddOp(v, OP_Halt, 0, 0);
   139    141     if( pParse->explain ) return;
   140    142     db = pParse->db;
   141    143     for(i=0; i<db->nDb; i++){
   142         -    if( db->aDb[i].pBt==0 || db->aDb[i].zName==0 ) continue;
   143         -    if( strlen(db->aDb[i].zName)!=pDbname->n ) continue;
   144         -    if( sqlite3StrNICmp(db->aDb[i].zName, pDbname->z, pDbname->n)==0 ) break;
          144  +    pDb = &db->aDb[i];
          145  +    if( pDb->pBt==0 || pDb->zName==0 ) continue;
          146  +    if( strlen(pDb->zName)!=pDbname->n ) continue;
          147  +    if( sqlite3StrNICmp(pDb->zName, pDbname->z, pDbname->n)==0 ) break;
   145    148     }
   146    149     if( i>=db->nDb ){
   147    150       sqlite3ErrorMsg(pParse, "no such database: %T", pDbname);
   148    151       return;
   149    152     }
   150    153     if( i<2 ){
   151    154       sqlite3ErrorMsg(pParse, "cannot detach database %T", pDbname);
................................................................................
   157    160       return;
   158    161     }
   159    162   #ifndef SQLITE_OMIT_AUTHORIZATION
   160    163     if( sqlite3AuthCheck(pParse,SQLITE_DETACH,db->aDb[i].zName,0,0)!=SQLITE_OK ){
   161    164       return;
   162    165     }
   163    166   #endif /* SQLITE_OMIT_AUTHORIZATION */
   164         -  sqlite3BtreeClose(db->aDb[i].pBt);
   165         -  db->aDb[i].pBt = 0;
   166         -  sqliteFree(db->aDb[i].zName);
          167  +  sqlite3BtreeClose(pDb->pBt);
          168  +  pDb->pBt = 0;
          169  +  sqliteFree(pDb->zName);
   167    170     sqlite3ResetInternalSchema(db, i);
   168    171     db->nDb--;
   169    172     if( i<db->nDb ){
   170    173       db->aDb[i] = db->aDb[db->nDb];
   171    174       memset(&db->aDb[db->nDb], 0, sizeof(db->aDb[0]));
   172    175       sqlite3ResetInternalSchema(db, i);
   173    176     }

Changes to src/auth.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the sqlite3_set_authorizer()
    13     13   ** API.  This facility is an optional feature of the library.  Embedded
    14     14   ** systems that do not need this facility may omit it by recompiling
    15     15   ** the library with -DSQLITE_OMIT_AUTHORIZATION=1
    16     16   **
    17         -** $Id: auth.c,v 1.15 2004/06/14 11:35:18 danielk1977 Exp $
           17  +** $Id: auth.c,v 1.16 2004/06/19 16:06:11 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   
    21     21   /*
    22     22   ** All of the code in this file may be omitted by defining a single
    23     23   ** macro.
    24     24   */
................................................................................
    29     29   **
    30     30   ** The access authorization function is be called during the compilation
    31     31   ** phase to verify that the user has read and/or write access permission on
    32     32   ** various fields of the database.  The first argument to the auth function
    33     33   ** is a copy of the 3rd argument to this routine.  The second argument
    34     34   ** to the auth function is one of these constants:
    35     35   **
    36         -**       SQLITE_COPY
    37     36   **       SQLITE_CREATE_INDEX
    38     37   **       SQLITE_CREATE_TABLE
    39     38   **       SQLITE_CREATE_TEMP_INDEX
    40     39   **       SQLITE_CREATE_TEMP_TABLE
    41     40   **       SQLITE_CREATE_TEMP_TRIGGER
    42     41   **       SQLITE_CREATE_TEMP_VIEW
    43     42   **       SQLITE_CREATE_TRIGGER
................................................................................
   146    145     if( rc==SQLITE_IGNORE ){
   147    146       pExpr->op = TK_NULL;
   148    147     }else if( rc==SQLITE_DENY ){
   149    148       if( db->nDb>2 || pExpr->iDb!=0 ){
   150    149         sqlite3ErrorMsg(pParse, "access to %s.%s.%s is prohibited", 
   151    150            zDBase, pTab->zName, zCol);
   152    151       }else{
   153         -      sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited", pTab->zName,zCol);
          152  +      sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited",pTab->zName,zCol);
   154    153       }
   155    154       pParse->rc = SQLITE_AUTH;
   156    155     }else if( rc!=SQLITE_OK ){
   157    156       sqliteAuthBadReturnCode(pParse, rc);
   158    157     }
   159    158   }
   160    159   
................................................................................
   218    217     if( pContext->pParse ){
   219    218       pContext->pParse->zAuthContext = pContext->zAuthContext;
   220    219       pContext->pParse = 0;
   221    220     }
   222    221   }
   223    222   
   224    223   #endif /* SQLITE_OMIT_AUTHORIZATION */
   225         -
   226         -
   227         -

Changes to src/build.c.

    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **     PRAGMA
    25     25   **
    26         -** $Id: build.c,v 1.225 2004/06/19 14:49:12 drh Exp $
           26  +** $Id: build.c,v 1.226 2004/06/19 16:06:12 drh Exp $
    27     27   */
    28     28   #include "sqliteInt.h"
    29     29   #include <ctype.h>
    30     30   
    31     31   /*
    32     32   ** This routine is called when a new SQL statement is beginning to
    33     33   ** be parsed.  Check to see if the schema for the database needs
    34     34   ** to be read from the SQLITE_MASTER and SQLITE_TEMP_MASTER tables.
    35     35   ** If it does, then read it.
    36     36   */
    37     37   void sqlite3BeginParse(Parse *pParse, int explainFlag){
    38         -  sqlite *db = pParse->db;
    39         -  int i;
    40     38     pParse->explain = explainFlag;
    41         -#if 0
    42         -  if((db->flags & SQLITE_Initialized)==0 && db->init.busy==0 ){
    43         -    int rc = sqlite3Init(db, &pParse->zErrMsg);
    44         -    if( rc!=SQLITE_OK ){
    45         -      pParse->rc = rc;
    46         -      pParse->nErr++;
    47         -    }
    48         -  }
    49         -#endif
    50         -  for(i=0; i<db->nDb; i++){
    51         -    DbClearProperty(db, i, DB_Locked);
    52         -    if( !db->aDb[i].inTrans ){
    53         -      DbClearProperty(db, i, DB_Cookie);
    54         -    }
    55         -  }
    56     39     pParse->nVar = 0;
    57     40   }
    58     41   
    59     42   /*
    60     43   ** This routine is called after a single SQL statement has been
    61     44   ** parsed and a VDBE program to execute that statement has been
    62     45   ** prepared.  This routine puts the finishing touches on the

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.294 2004/06/19 15:22:56 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.295 2004/06/19 16:06:12 drh Exp $
    15     15   */
    16     16   #include "config.h"
    17     17   #include "sqlite3.h"
    18     18   #include "hash.h"
    19     19   #include "parse.h"
    20     20   #include <stdio.h>
    21     21   #include <stdlib.h>
................................................................................
   304    304   #define DbHasAnyProperty(D,I,P)  (((D)->aDb[I].flags&(P))!=0)
   305    305   #define DbSetProperty(D,I,P)     (D)->aDb[I].flags|=(P)
   306    306   #define DbClearProperty(D,I,P)   (D)->aDb[I].flags&=~(P)
   307    307   
   308    308   /*
   309    309   ** Allowed values for the DB.flags field.
   310    310   **
   311         -** The DB_Locked flag is set when the first OP_Transaction or OP_Checkpoint
   312         -** opcode is emitted for a database.  This prevents multiple occurances
   313         -** of those opcodes for the same database in the same program.  Similarly,
   314         -** the DB_Cookie flag is set when the OP_VerifyCookie opcode is emitted,
   315         -** and prevents duplicate OP_VerifyCookies from taking up space and slowing
   316         -** down execution.
   317         -**
   318    311   ** The DB_SchemaLoaded flag is set after the database schema has been
   319    312   ** read into internal hash tables.
   320    313   **
   321    314   ** DB_UnresetViews means that one or more views have column names that
   322    315   ** have been filled out.  If the schema changes, these column names might
   323    316   ** changes and so the view will need to be reset.
   324    317   */
   325         -#define DB_Locked          0x0001  /* OP_Transaction opcode has been emitted */
   326         -#define DB_Cookie          0x0002  /* OP_VerifyCookie opcode has been emiited */
   327         -#define DB_SchemaLoaded    0x0004  /* The schema has been loaded */
   328         -#define DB_UnresetViews    0x0008  /* Some views have defined column names */
          318  +#define DB_SchemaLoaded    0x0001  /* The schema has been loaded */
          319  +#define DB_UnresetViews    0x0002  /* Some views have defined column names */
   329    320   
   330    321   #if 0
   331    322   /*
   332    323   ** Possible values for the Db.textEnc field.
   333    324   */
   334    325   #define TEXT_Utf8          1
   335    326   #define TEXT_Utf16le       2