Make sure ATTACH and DETACH fail if a transaction is active. (CVS 1633)
FossilOrigin-Name: c49d8bdc3e1172a283f7aaf208fbb9096acd5ab6
This commit is contained in:
parent
f9d64d2c30
commit
92f9a1bbda
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
||||
C Remove\sthe\siCollate\sargument\sfrom\ssqlite3_create_function()\s(CVS\s1632)
|
||||
D 2004-06-19T08:18:08
|
||||
C Make\ssure\sATTACH\sand\sDETACH\sfail\sif\sa\stransaction\sis\sactive.\s(CVS\s1633)
|
||||
D 2004-06-19T09:08:16
|
||||
F Makefile.in d69d53c543518c1572ee0a8e8723d7e00bdb2266
|
||||
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@ -24,7 +24,7 @@ F spec.template a38492f1c1dd349fc24cb0565e08afc53045304b
|
||||
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
|
||||
F sqlite.def ae35f40943ddf25ca7de2439d2beeb06c924ca9c
|
||||
F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
|
||||
F src/attach.c 93b8ecec4a8d7b4e9f2479e2327d90c9d01765e8
|
||||
F src/attach.c 293da1e8e3ea6e9244bb3d744da930606fbb4ab0
|
||||
F src/auth.c 204e1e9c45e64315589bc8b62cba5d9de29b6a3c
|
||||
F src/btree.c 0cf8a52a57a7eb13d50719114ee1fa353e89d7d3
|
||||
F src/btree.h 32f96abef464cf8765b23ca669acfe90d191fcc5
|
||||
@ -55,7 +55,7 @@ F src/pragma.c 42de2b327d17af5167de66744a731f8dae8bbe96
|
||||
F src/printf.c 823b6a5cbedb6971a9e62f5d83204fe9b0be7c1b
|
||||
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
|
||||
F src/select.c 91570af7f13d1c5584f3b711676e1226ee12194e
|
||||
F src/shell.c ca519519dcbbc582f6d88f7d0e7583b857fd3469
|
||||
F src/shell.c 24b641700c9d90f361fcfa4f432c5b4aff704e6d
|
||||
F src/sqlite.h.in c34414b9f5330f875e26a69fe685e38ca45f11b9
|
||||
F src/sqliteInt.h b01c438b31132816d8a4167a45c8b7dab4ff79d4
|
||||
F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
|
||||
@ -70,7 +70,7 @@ F src/trigger.c b05699cf40e99a330649eabfb1cece05ff73e469
|
||||
F src/update.c f9a03233577e0c3d57234d1957963875fc941da2
|
||||
F src/utf.c 3a2596013e4b9582d075ca742de7f067ff7dee95
|
||||
F src/util.c 1b3743413e11cae51a899dc03fa9b829a3a1f160
|
||||
F src/vacuum.c f9561c8095407a970af4e6a304b77c4083433d3e
|
||||
F src/vacuum.c fcb930215a3f6c50087300782555f61ad11dd80c
|
||||
F src/vdbe.c 2a0e908e46ea6822f215cb0f35ec31f5c2832629
|
||||
F src/vdbe.h 46f74444a213129bc4b5ce40124dd8ed613b0cde
|
||||
F src/vdbeInt.h 54af2e00301cde7573b86ea8a9b29a2152e762f7
|
||||
@ -80,7 +80,7 @@ F src/vdbemem.c 9359c53386e070fea9f5403cab0c6f0cfe36496b
|
||||
F src/where.c 6507074d8ce3f78e7a4cd33f667f11e62020553e
|
||||
F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
|
||||
F test/attach.test 3acdffccbf5f78b07746771b9490758718e28856
|
||||
F test/attach2.test a05150eb43cf852599dcc491351c67a060337e4b
|
||||
F test/attach2.test 4462c2e652e3d3ac2a9c86d08eebcd648038ae7d
|
||||
F test/attach3.test c4cc0b806783ce3d860af6b80c947f93ffb14270
|
||||
F test/auth.test a211eab0542ec024b578d771b09242dd9bb1aba3
|
||||
F test/bigfile.test a1101b46528ad7282fb9b323d25da18672a3bd0a
|
||||
@ -225,7 +225,7 @@ F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
|
||||
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
||||
F www/version3.tcl af528563442e3039928f9018327a18157e53a44f
|
||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||
P 61819740fe8916892afe502196bb8b75a51f81e8
|
||||
R cb771500bef1e49c485d208778df70b7
|
||||
P 728d57ff5517a51c3aad4ba95525b1aa2065bd19
|
||||
R 517c1f3b253885c349ae56132b2c980e
|
||||
U danielk1977
|
||||
Z c1b577fd5952e65f94f6b53a7096295b
|
||||
Z 1e7b9e1153ac7c95d463a3ea969f0f7b
|
||||
|
@ -1 +1 @@
|
||||
728d57ff5517a51c3aad4ba95525b1aa2065bd19
|
||||
c49d8bdc3e1172a283f7aaf208fbb9096acd5ab6
|
13
src/attach.c
13
src/attach.c
@ -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;
|
||||
|
@ -12,7 +12,7 @@
|
||||
** This file contains code to implement the "sqlite" command line
|
||||
** utility for accessing SQLite databases.
|
||||
**
|
||||
** $Id: shell.c,v 1.104 2004/06/08 00:39:01 danielk1977 Exp $
|
||||
** $Id: shell.c,v 1.105 2004/06/19 09:08:16 danielk1977 Exp $
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -57,7 +57,7 @@ extern int isatty();
|
||||
** to this database a static variable so that it can be accessed
|
||||
** by the SIGINT handler to interrupt database processing.
|
||||
*/
|
||||
static sqlite *db = 0;
|
||||
static sqlite3 *db = 0;
|
||||
|
||||
/*
|
||||
** True if an interrupt (Control-C) has been received.
|
||||
@ -170,7 +170,7 @@ struct previous_mode_data {
|
||||
** state and mode information.
|
||||
*/
|
||||
struct callback_data {
|
||||
sqlite *db; /* The database */
|
||||
sqlite3 *db; /* The database */
|
||||
int echoOn; /* True to echo input commands */
|
||||
int cnt; /* Number of records displayed so far */
|
||||
FILE *out; /* Write results here */
|
||||
|
@ -14,7 +14,7 @@
|
||||
** Most of the code in this file may be omitted by defining the
|
||||
** SQLITE_OMIT_VACUUM macro.
|
||||
**
|
||||
** $Id: vacuum.c,v 1.22 2004/06/15 11:40:09 danielk1977 Exp $
|
||||
** $Id: vacuum.c,v 1.23 2004/06/19 09:08:16 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@ -217,8 +217,8 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
|
||||
}
|
||||
|
||||
end_of_vacuum:
|
||||
execSql(db, "DETACH vacuum_db;");
|
||||
execSql(db, "ROLLBACK;");
|
||||
execSql(db, "DETACH vacuum_db;");
|
||||
if( zTemp ){
|
||||
sqlite3OsDelete(zTemp);
|
||||
sqliteFree(zTemp);
|
||||
|
@ -12,7 +12,7 @@
|
||||
# focus of this script is testing the ATTACH and DETACH commands
|
||||
# and related functionality.
|
||||
#
|
||||
# $Id: attach2.test,v 1.19 2004/06/19 00:16:31 drh Exp $
|
||||
# $Id: attach2.test,v 1.20 2004/06/19 09:08:16 danielk1977 Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -339,6 +339,30 @@ do_test attach2-5.5 {
|
||||
glob test.db*
|
||||
} {test.db test.db2}
|
||||
|
||||
# Check that a database cannot be ATTACHed or DETACHed during a transaction.
|
||||
do_test attach2-6.1 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
}
|
||||
} {}
|
||||
do_test attach2-6.2 {
|
||||
catchsql {
|
||||
ATTACH 'test3.db' as aux2;
|
||||
}
|
||||
} {1 {cannot ATTACH database within transaction}}
|
||||
|
||||
do_test attach2-6.3 {
|
||||
catchsql {
|
||||
DETACH aux;
|
||||
}
|
||||
} {1 {cannot DETACH database within transaction}}
|
||||
do_test attach2-6.4 {
|
||||
execsql {
|
||||
COMMIT;
|
||||
DETACH aux;
|
||||
}
|
||||
} {}
|
||||
|
||||
db close
|
||||
|
||||
finish_test
|
||||
|
Loading…
Reference in New Issue
Block a user