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

Make sure ATTACH and DETACH fail if a transaction is active. (CVS 1633)

FossilOrigin-Name: c49d8bdc3e1172a283f7aaf208fbb9096acd5ab6
This commit is contained in:
danielk1977
2004-06-19 09:08:16 +00:00
parent f9d64d2c30
commit 92f9a1bbda
6 changed files with 52 additions and 17 deletions

View File

@@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to implement the ATTACH and DETACH commands.
**
** $Id: attach.c,v 1.14 2004/06/09 12:30:05 danielk1977 Exp $
** $Id: attach.c,v 1.15 2004/06/19 09:08:16 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -41,6 +41,12 @@ void sqlite3Attach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey)
return;
}
if( !db->autoCommit ){
sqlite3ErrorMsg(pParse, "cannot ATTACH database within transaction");
pParse->rc = SQLITE_ERROR;
return;
}
zFile = 0;
sqlite3SetNString(&zFile, pFilename->z, pFilename->n, 0);
if( zFile==0 ) return;
@@ -149,6 +155,11 @@ void sqlite3Detach(Parse *pParse, Token *pDbname){
sqlite3ErrorMsg(pParse, "cannot detach database %T", pDbname);
return;
}
if( !db->autoCommit ){
sqlite3ErrorMsg(pParse, "cannot DETACH database within transaction");
pParse->rc = SQLITE_ERROR;
return;
}
#ifndef SQLITE_OMIT_AUTHORIZATION
if( sqlite3AuthCheck(pParse,SQLITE_DETACH,db->aDb[i].zName,0,0)!=SQLITE_OK ){
return;