1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Omit the DB_Locked and DB_Cookie flags. Other minor cleanup. (CVS 1642)

FossilOrigin-Name: 01f74b420c3f24918c066172e09cebbb22568faf
This commit is contained in:
drh
2004-06-19 16:06:10 +00:00
parent f92c7ff74a
commit 124b27e654
6 changed files with 27 additions and 54 deletions

View File

@@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to implement the ATTACH and DETACH commands.
**
** $Id: attach.c,v 1.16 2004/06/19 14:49:12 drh Exp $
** $Id: attach.c,v 1.17 2004/06/19 16:06:11 drh Exp $
*/
#include "sqliteInt.h"
@@ -59,7 +59,8 @@ void sqlite3Attach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey)
zName = sqlite3NameFromToken(pDbname);
if( zName==0 ) return;
for(i=0; i<db->nDb; i++){
if( db->aDb[i].zName && sqlite3StrICmp(db->aDb[i].zName, zName)==0 ){
char *z = db->aDb[i].zName;
if( z && sqlite3StrICmp(z, zName)==0 ){
sqlite3ErrorMsg(pParse, "database %z is already in use", zName);
pParse->rc = SQLITE_ERROR;
sqliteFree(zFile);
@@ -133,15 +134,17 @@ void sqlite3Detach(Parse *pParse, Token *pDbname){
int i;
sqlite *db;
Vdbe *v;
Db *pDb;
v = sqlite3GetVdbe(pParse);
sqlite3VdbeAddOp(v, OP_Halt, 0, 0);
if( pParse->explain ) return;
db = pParse->db;
for(i=0; i<db->nDb; i++){
if( db->aDb[i].pBt==0 || db->aDb[i].zName==0 ) continue;
if( strlen(db->aDb[i].zName)!=pDbname->n ) continue;
if( sqlite3StrNICmp(db->aDb[i].zName, pDbname->z, pDbname->n)==0 ) break;
pDb = &db->aDb[i];
if( pDb->pBt==0 || pDb->zName==0 ) continue;
if( strlen(pDb->zName)!=pDbname->n ) continue;
if( sqlite3StrNICmp(pDb->zName, pDbname->z, pDbname->n)==0 ) break;
}
if( i>=db->nDb ){
sqlite3ErrorMsg(pParse, "no such database: %T", pDbname);
@@ -161,9 +164,9 @@ void sqlite3Detach(Parse *pParse, Token *pDbname){
return;
}
#endif /* SQLITE_OMIT_AUTHORIZATION */
sqlite3BtreeClose(db->aDb[i].pBt);
db->aDb[i].pBt = 0;
sqliteFree(db->aDb[i].zName);
sqlite3BtreeClose(pDb->pBt);
pDb->pBt = 0;
sqliteFree(pDb->zName);
sqlite3ResetInternalSchema(db, i);
db->nDb--;
if( i<db->nDb ){

View File

@@ -14,7 +14,7 @@
** systems that do not need this facility may omit it by recompiling
** the library with -DSQLITE_OMIT_AUTHORIZATION=1
**
** $Id: auth.c,v 1.15 2004/06/14 11:35:18 danielk1977 Exp $
** $Id: auth.c,v 1.16 2004/06/19 16:06:11 drh Exp $
*/
#include "sqliteInt.h"
@@ -33,7 +33,6 @@
** is a copy of the 3rd argument to this routine. The second argument
** to the auth function is one of these constants:
**
** SQLITE_COPY
** SQLITE_CREATE_INDEX
** SQLITE_CREATE_TABLE
** SQLITE_CREATE_TEMP_INDEX
@@ -150,7 +149,7 @@ void sqlite3AuthRead(
sqlite3ErrorMsg(pParse, "access to %s.%s.%s is prohibited",
zDBase, pTab->zName, zCol);
}else{
sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited", pTab->zName,zCol);
sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited",pTab->zName,zCol);
}
pParse->rc = SQLITE_AUTH;
}else if( rc!=SQLITE_OK ){
@@ -222,6 +221,3 @@ void sqlite3AuthContextPop(AuthContext *pContext){
}
#endif /* SQLITE_OMIT_AUTHORIZATION */

View File

@@ -23,7 +23,7 @@
** ROLLBACK
** PRAGMA
**
** $Id: build.c,v 1.225 2004/06/19 14:49:12 drh Exp $
** $Id: build.c,v 1.226 2004/06/19 16:06:12 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -35,24 +35,7 @@
** If it does, then read it.
*/
void sqlite3BeginParse(Parse *pParse, int explainFlag){
sqlite *db = pParse->db;
int i;
pParse->explain = explainFlag;
#if 0
if((db->flags & SQLITE_Initialized)==0 && db->init.busy==0 ){
int rc = sqlite3Init(db, &pParse->zErrMsg);
if( rc!=SQLITE_OK ){
pParse->rc = rc;
pParse->nErr++;
}
}
#endif
for(i=0; i<db->nDb; i++){
DbClearProperty(db, i, DB_Locked);
if( !db->aDb[i].inTrans ){
DbClearProperty(db, i, DB_Cookie);
}
}
pParse->nVar = 0;
}

View File

@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.294 2004/06/19 15:22:56 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.295 2004/06/19 16:06:12 drh Exp $
*/
#include "config.h"
#include "sqlite3.h"
@@ -308,13 +308,6 @@ struct Db {
/*
** Allowed values for the DB.flags field.
**
** The DB_Locked flag is set when the first OP_Transaction or OP_Checkpoint
** opcode is emitted for a database. This prevents multiple occurances
** of those opcodes for the same database in the same program. Similarly,
** the DB_Cookie flag is set when the OP_VerifyCookie opcode is emitted,
** and prevents duplicate OP_VerifyCookies from taking up space and slowing
** down execution.
**
** The DB_SchemaLoaded flag is set after the database schema has been
** read into internal hash tables.
**
@@ -322,10 +315,8 @@ struct Db {
** have been filled out. If the schema changes, these column names might
** changes and so the view will need to be reset.
*/
#define DB_Locked 0x0001 /* OP_Transaction opcode has been emitted */
#define DB_Cookie 0x0002 /* OP_VerifyCookie opcode has been emiited */
#define DB_SchemaLoaded 0x0004 /* The schema has been loaded */
#define DB_UnresetViews 0x0008 /* Some views have defined column names */
#define DB_SchemaLoaded 0x0001 /* The schema has been loaded */
#define DB_UnresetViews 0x0002 /* Some views have defined column names */
#if 0
/*