Add hooks on each attached database connection for storing auxiliary
information. Add the USING clause to ATTACH. (CVS 1232) FossilOrigin-Name: 800c11f4bce014a07110eb539992a609e6418406
This commit is contained in:
parent
3054efee07
commit
4d189ca48f
22
manifest
22
manifest
@ -1,5 +1,5 @@
|
||||
C All\sREPLACE\sINTO\ssyntax\sinside\sof\striggers.\s\sTicket\s#610.\s(CVS\s1231)
|
||||
D 2004-02-12T17:28:13
|
||||
C Add\shooks\son\seach\sattached\sdatabase\sconnection\sfor\sstoring\sauxiliary\ninformation.\s\sAdd\sthe\sUSING\sclause\sto\sATTACH.\s(CVS\s1232)
|
||||
D 2004-02-12T18:46:39
|
||||
F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b
|
||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@ -21,12 +21,12 @@ F publish.sh fe03c30027c68d610a1b51c282feb24def55ce93
|
||||
F spec.template a38492f1c1dd349fc24cb0565e08afc53045304b
|
||||
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
|
||||
F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
|
||||
F src/attach.c 4a0a3c0885fec11a0a199a8031694d08925d0a27
|
||||
F src/attach.c b01db0d3211f673d8e670abf7eaad04591d40d14
|
||||
F src/auth.c c59ad0dab501888f8b1fccc25e2f5965d2265116
|
||||
F src/btree.c c325d46f0aa815d73358bf2e044dab23f645c214
|
||||
F src/btree.h 41cb3ff6ebc3f6da2d0a074e39ff8c7a2287469f
|
||||
F src/btree_rb.c 32b2cb4285c0fbd53b89de021637b63d52257e54
|
||||
F src/build.c 05ee0d69c7379ef3e20121b2197bfb8865003371
|
||||
F src/build.c 2a02df7931cb0ea153c1e29324292cd943d4f73c
|
||||
F src/copy.c 9e47975ea96751c658bcf1a0c4f0bb7c6ee61e73
|
||||
F src/date.c c9d2bfd40b1c95f8f97d53a5eba981d7167c7b61
|
||||
F src/delete.c 0778fe05df0a1d62ac27fd1a3dba237c186ff4d1
|
||||
@ -36,20 +36,20 @@ F src/func.c cbc5edd10c82a5193b9ca0726873328be445e6c1
|
||||
F src/hash.c 9b56ef3b291e25168f630d5643a4264ec011c70e
|
||||
F src/hash.h 3247573ab95b9dd90bcca0307a75d9a16da1ccc7
|
||||
F src/insert.c 01f66866f35c986eab4a57373ca689a3255ef2df
|
||||
F src/main.c 79e303dc172579549f9921b4bfe94e0a8cb96722
|
||||
F src/main.c b5d68e856c1575a15284adb394889e6e6fc43362
|
||||
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
|
||||
F src/os.c f5fc4954725b2fcd852979f2746085fe8ca27710
|
||||
F src/os.h 250a3789be609adfee5c5aa20137ce8683276f24
|
||||
F src/pager.c 29ddad4dd454f0aaa98e2bcd327710ab9f02f833
|
||||
F src/pager.h 82332878799280145639a48d88cdb4058925e3f6
|
||||
F src/parse.y eb3af3b6e6ddd2b8023953180eddb88039eb99a9
|
||||
F src/parse.y 1e311dc6aae9261f8641abca9328dd6193083753
|
||||
F src/pragma.c 89d62c31c6f0a43376fe8d20549b87a6d30c467a
|
||||
F src/printf.c 84e4ea4ba49cbbf930e95e82295127ad5843ae1f
|
||||
F src/random.c 775913e0b7fbd6295d21f12a7bd35b46387c44b2
|
||||
F src/select.c a3a203f9b68c899ac69dbc5fa11cd649fd8acd06
|
||||
F src/shell.c c1c7242ede2af46044378d36d2c533e98fd59fb8
|
||||
F src/sqlite.h.in 1798588cab21ebf9fac3aad7fc1539b396c1f91d
|
||||
F src/sqliteInt.h f03de87717569619884830b1833eca2b257fc675
|
||||
F src/sqliteInt.h c45fbae6278407111d7a00aa9280ddc0f51344ad
|
||||
F src/table.c d845cb101b5afc1f7fea083c99e3d2fa7998d895
|
||||
F src/tclsqlite.c c4174ecb406810435b6670f6e470e39424c52804
|
||||
F src/test1.c 56e9a156df3ad5e4e98df776776e963effc727f7
|
||||
@ -104,7 +104,7 @@ F test/lock.test 3d1855ba930732566f569d680e828656bd5b7f5c
|
||||
F test/main.test 6a851b5992c4881a725a3d9647e629199df8de9d
|
||||
F test/malloc.test 7ba32a9ebd3aeed52ae4aaa6d42ca37e444536fd
|
||||
F test/memdb.test 6ece25c7c0e6500199d3662607a3edca081abb2a
|
||||
F test/memleak.test a18e6810cae96d2f6f5136920267adbefc8e1e90
|
||||
F test/memleak.test 4d5d374c8ea1fc5ac634aed58cac1047848ce65e
|
||||
F test/minmax.test 6680b8d79b9b6e026a476ebfb91f310f7774568e
|
||||
F test/misc1.test 0b98d493b0cf55cb5f53e1f3df8107c166eecb5a
|
||||
F test/misc2.test 10c2ce26407d37411b96273e552d5095393732be
|
||||
@ -184,7 +184,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
|
||||
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
|
||||
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
|
||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||
P 74b234264ba2910ebd38e7b7ebbc369108a235cb
|
||||
R 8051cc03a6a9028391110c6d16f628b3
|
||||
P a6b862a9db6d409a53cc13e7008b27d4848b5509
|
||||
R 4700f1562b7f9bc806f5774fe67321dc
|
||||
U drh
|
||||
Z b906184cf6ae67b6bcaab0c8e43b04f2
|
||||
Z 2597b11ff4d9a3579abdb5d4741c34dc
|
||||
|
@ -1 +1 @@
|
||||
a6b862a9db6d409a53cc13e7008b27d4848b5509
|
||||
800c11f4bce014a07110eb539992a609e6418406
|
20
src/attach.c
20
src/attach.c
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file contains code used to implement the ATTACH and DETACH commands.
|
||||
**
|
||||
** $Id: attach.c,v 1.9 2004/01/20 11:54:03 drh Exp $
|
||||
** $Id: attach.c,v 1.10 2004/02/12 18:46:39 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
** The pFilename and pDbname arguments are the tokens that define the
|
||||
** filename and dbname in the ATTACH statement.
|
||||
*/
|
||||
void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname){
|
||||
void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey){
|
||||
Db *aNew;
|
||||
int rc, i;
|
||||
char *zFile, *zName;
|
||||
@ -91,6 +91,22 @@ void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname){
|
||||
if( rc ){
|
||||
sqliteErrorMsg(pParse, "unable to open database: %s", zFile);
|
||||
}
|
||||
#if SQLITE_HAS_CODEC
|
||||
{
|
||||
extern int sqliteCodecAttach(sqlite*, int, void*, int);
|
||||
char *zKey = 0;
|
||||
int nKey;
|
||||
if( pKey && pKey->z && pKey->n ){
|
||||
sqliteSetNString(&zKey, pKey->z, pKey->n, 0);
|
||||
sqliteDequote(zKey);
|
||||
nKey = strlen(zKey);
|
||||
}else{
|
||||
zKey = 0;
|
||||
nKey = 0;
|
||||
}
|
||||
sqliteCodecAttach(db, db->nDb-1, zKey, nKey);
|
||||
}
|
||||
#endif
|
||||
sqliteFree(zFile);
|
||||
db->flags &= ~SQLITE_Initialized;
|
||||
if( pParse->nErr ) return;
|
||||
|
16
src/build.c
16
src/build.c
@ -23,7 +23,7 @@
|
||||
** ROLLBACK
|
||||
** PRAGMA
|
||||
**
|
||||
** $Id: build.c,v 1.165 2004/02/11 09:46:31 drh Exp $
|
||||
** $Id: build.c,v 1.166 2004/02/12 18:46:39 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@ -280,10 +280,18 @@ void sqliteResetInternalSchema(sqlite *db, int iDb){
|
||||
** schema hash tables and therefore do not have to make any changes
|
||||
** to any of those tables.
|
||||
*/
|
||||
for(i=0; i<db->nDb; i++){
|
||||
struct Db *pDb = &db->aDb[i];
|
||||
if( pDb->pBt==0 ){
|
||||
if( pDb->pAux && pDb->xFreeAux ) pDb->xFreeAux(pDb->pAux);
|
||||
pDb->pAux = 0;
|
||||
}
|
||||
}
|
||||
for(i=j=2; i<db->nDb; i++){
|
||||
if( db->aDb[i].pBt==0 ){
|
||||
sqliteFree(db->aDb[i].zName);
|
||||
db->aDb[i].zName = 0;
|
||||
struct Db *pDb = &db->aDb[i];
|
||||
if( pDb->pBt==0 ){
|
||||
sqliteFree(pDb->zName);
|
||||
pDb->zName = 0;
|
||||
continue;
|
||||
}
|
||||
if( j<i ){
|
||||
|
13
src/main.c
13
src/main.c
@ -14,7 +14,7 @@
|
||||
** other files are for internal use by SQLite and should not be
|
||||
** accessed by users of the library.
|
||||
**
|
||||
** $Id: main.c,v 1.148 2004/02/12 15:31:21 drh Exp $
|
||||
** $Id: main.c,v 1.149 2004/02/12 18:46:39 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@ -552,13 +552,10 @@ void sqlite_close(sqlite *db){
|
||||
}
|
||||
db->magic = SQLITE_MAGIC_CLOSED;
|
||||
for(j=0; j<db->nDb; j++){
|
||||
if( db->aDb[j].pBt ){
|
||||
sqliteBtreeClose(db->aDb[j].pBt);
|
||||
db->aDb[j].pBt = 0;
|
||||
}
|
||||
if( j>=2 ){
|
||||
sqliteFree(db->aDb[j].zName);
|
||||
db->aDb[j].zName = 0;
|
||||
struct Db *pDb = &db->aDb[j];
|
||||
if( pDb->pBt ){
|
||||
sqliteBtreeClose(pDb->pBt);
|
||||
pDb->pBt = 0;
|
||||
}
|
||||
}
|
||||
sqliteResetInternalSchema(db, 0);
|
||||
|
@ -14,7 +14,7 @@
|
||||
** the parser. Lemon will also generate a header file containing
|
||||
** numeric codes for all of the tokens.
|
||||
**
|
||||
** @(#) $Id: parse.y,v 1.108 2004/02/12 17:28:13 drh Exp $
|
||||
** @(#) $Id: parse.y,v 1.109 2004/02/12 18:46:39 drh Exp $
|
||||
*/
|
||||
%token_prefix TK_
|
||||
%token_type {Token}
|
||||
@ -880,9 +880,12 @@ cmd ::= DROP TRIGGER nm(X) dbnm(D). {
|
||||
}
|
||||
|
||||
//////////////////////// ATTACH DATABASE file AS name /////////////////////////
|
||||
cmd ::= ATTACH database_kw_opt ids(F) AS nm(D). {
|
||||
sqliteAttach(pParse, &F, &D);
|
||||
cmd ::= ATTACH database_kw_opt ids(F) AS nm(D) key_opt(K). {
|
||||
sqliteAttach(pParse, &F, &D, &K);
|
||||
}
|
||||
%type key_opt {Token}
|
||||
key_opt(A) ::= USING ids(X). { A = X; }
|
||||
key_opt(A) ::= . { A.z = 0; A.n = 0; }
|
||||
|
||||
database_kw_opt ::= DATABASE.
|
||||
database_kw_opt ::= .
|
||||
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.210 2004/02/11 09:46:33 drh Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.211 2004/02/12 18:46:39 drh Exp $
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "sqlite.h"
|
||||
@ -254,6 +254,8 @@ struct Db {
|
||||
Hash aFKey; /* Foreign keys indexed by to-table */
|
||||
u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */
|
||||
u16 flags; /* Flags associated with this database */
|
||||
void *pAux; /* Auxiliary data. Usually NULL */
|
||||
void (*xFreeAux)(void*); /* Routine to free pAux */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -1207,7 +1209,7 @@ void sqliteDeferForeignKey(Parse*, int);
|
||||
# define sqliteAuthContextPush(a,b,c)
|
||||
# define sqliteAuthContextPop(a) ((void)(a))
|
||||
#endif
|
||||
void sqliteAttach(Parse*, Token*, Token*);
|
||||
void sqliteAttach(Parse*, Token*, Token*, Token*);
|
||||
void sqliteDetach(Parse*, Token*);
|
||||
int sqliteBtreeFactory(const sqlite *db, const char *zFilename,
|
||||
int mode, int nPg, Btree **ppBtree);
|
||||
|
@ -10,7 +10,7 @@
|
||||
#***********************************************************************
|
||||
# This file runs all tests.
|
||||
#
|
||||
# $Id: memleak.test,v 1.2 2003/02/26 13:52:52 drh Exp $
|
||||
# $Id: memleak.test,v 1.3 2004/02/12 18:46:39 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -41,6 +41,14 @@ set EXCLUDE {
|
||||
btree2.test
|
||||
trans.test
|
||||
}
|
||||
if {[sqlite -has-codec]} {
|
||||
lappend EXCLUDE \
|
||||
attach.test \
|
||||
attach2.test \
|
||||
auth.test \
|
||||
format3.test \
|
||||
version.test
|
||||
}
|
||||
if {[llength $argv]>0} {
|
||||
set FILELIST $argv
|
||||
set argv {}
|
||||
|
Loading…
Reference in New Issue
Block a user