Index: src/attach.c ================================================================== --- src/attach.c +++ src/attach.c @@ -9,14 +9,15 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code used to implement the ATTACH and DETACH commands. ** -** $Id: attach.c,v 1.55 2007/03/24 16:45:05 danielk1977 Exp $ +** $Id: attach.c,v 1.56 2007/03/27 14:44:51 drh Exp $ */ #include "sqliteInt.h" +#ifndef SQLITE_OMIT_ATTACH /* ** Resolve an expression that was part of an ATTACH or DETACH statement. This ** is slightly different from resolving a normal SQL expression, because simple ** identifiers are treated as strings, not possible column names or aliases. ** @@ -349,18 +350,21 @@ ** ATTACH p AS pDbname KEY pKey */ void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){ codeAttach(pParse, SQLITE_ATTACH, "sqlite_attach", 3, p, p, pDbname, pKey); } +#endif /* SQLITE_OMIT_ATTACH */ /* ** Register the functions sqlite_attach and sqlite_detach. */ void sqlite3AttachFunctions(sqlite3 *db){ +#ifndef SQLITE_OMIT_ATTACH static const int enc = SQLITE_UTF8; sqlite3CreateFunc(db, "sqlite_attach", 3, enc, db, attachFunc, 0, 0); sqlite3CreateFunc(db, "sqlite_detach", 1, enc, db, detachFunc, 0, 0); +#endif } /* ** Initialize a DbFixer structure. This routine must be called prior ** to passing the structure to one of the sqliteFixAAAA() routines below. Index: src/parse.y ================================================================== --- src/parse.y +++ src/parse.y @@ -12,11 +12,11 @@ ** This file contains SQLite's grammar for SQL. Process this file ** using the lemon parser generator to generate C code that runs ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** -** @(#) $Id: parse.y,v 1.215 2007/02/02 12:44:37 drh Exp $ +** @(#) $Id: parse.y,v 1.216 2007/03/27 14:44:51 drh Exp $ */ // All token codes are small integers with #defines that begin with "TK_" %token_prefix TK_ @@ -888,12 +888,14 @@ cmd ::= DROP INDEX ifexists(E) fullname(X). {sqlite3DropIndex(pParse, X, E);} ///////////////////////////// The VACUUM command ///////////////////////////// // %ifndef SQLITE_OMIT_VACUUM +%ifndef SQLITE_OMIT_ATTACH cmd ::= VACUUM. {sqlite3Vacuum(pParse);} cmd ::= VACUUM nm. {sqlite3Vacuum(pParse);} +%endif SQLITE_OMIT_ATTACH %endif SQLITE_OMIT_VACUUM ///////////////////////////// The PRAGMA command ///////////////////////////// // %ifndef SQLITE_OMIT_PRAGMA @@ -1016,25 +1018,26 @@ sqlite3DropTrigger(pParse,X,NOERR); } %endif !SQLITE_OMIT_TRIGGER //////////////////////// ATTACH DATABASE file AS name ///////////////////////// +%ifndef SQLITE_OMIT_ATTACH cmd ::= ATTACH database_kw_opt expr(F) AS expr(D) key_opt(K). { sqlite3Attach(pParse, F, D, K); } +cmd ::= DETACH database_kw_opt expr(D). { + sqlite3Detach(pParse, D); +} + %type key_opt {Expr *} %destructor key_opt {sqlite3ExprDelete($$);} key_opt(A) ::= . { A = 0; } key_opt(A) ::= KEY expr(X). { A = X; } database_kw_opt ::= DATABASE. database_kw_opt ::= . - -//////////////////////// DETACH DATABASE name ///////////////////////////////// -cmd ::= DETACH database_kw_opt expr(D). { - sqlite3Detach(pParse, D); -} +%endif SQLITE_OMIT_ATTACH ////////////////////////// REINDEX collation ////////////////////////////////// %ifndef SQLITE_OMIT_REINDEX cmd ::= REINDEX. {sqlite3Reindex(pParse, 0, 0);} cmd ::= REINDEX nm(X) dbnm(Y). {sqlite3Reindex(pParse, &X, &Y);} Index: src/test1.c ================================================================== --- src/test1.c +++ src/test1.c @@ -11,11 +11,11 @@ ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.230 2007/03/26 22:05:02 drh Exp $ +** $Id: test1.c,v 1.231 2007/03/27 14:44:51 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include @@ -3755,10 +3755,16 @@ #ifdef SQLITE_OMIT_ANALYZE Tcl_SetVar2(interp, "sqlite_options", "analyze", "0", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "analyze", "1", TCL_GLOBAL_ONLY); #endif + +#ifdef SQLITE_OMIT_ATTACH + Tcl_SetVar2(interp, "sqlite_options", "attach", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "attach", "1", TCL_GLOBAL_ONLY); +#endif #ifdef SQLITE_OMIT_AUTHORIZATION Tcl_SetVar2(interp, "sqlite_options", "auth", "0", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "auth", "1", TCL_GLOBAL_ONLY); @@ -4014,11 +4020,11 @@ Tcl_SetVar2(interp, "sqlite_options", "utf16", "0", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "utf16", "1", TCL_GLOBAL_ONLY); #endif -#ifdef SQLITE_OMIT_VACUUM +#if defined(SQLITE_OMIT_VACUUM) || defined(SQLITE_OMIT_ATTACH) Tcl_SetVar2(interp, "sqlite_options", "vacuum", "0", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "vacuum", "1", TCL_GLOBAL_ONLY); #endif Index: src/vacuum.c ================================================================== --- src/vacuum.c +++ src/vacuum.c @@ -12,17 +12,17 @@ ** This file contains code used to implement the VACUUM command. ** ** Most of the code in this file may be omitted by defining the ** SQLITE_OMIT_VACUUM macro. ** -** $Id: vacuum.c,v 1.67 2007/03/06 16:03:56 danielk1977 Exp $ +** $Id: vacuum.c,v 1.68 2007/03/27 14:44:51 drh Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" #include "os.h" -#ifndef SQLITE_OMIT_VACUUM +#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH) /* ** Execute zSql on database db. Return an error code. */ static int execSql(sqlite3 *db, const char *zSql){ sqlite3_stmt *pStmt; @@ -269,6 +269,6 @@ sqliteFree( zSql ); sqlite3ResetInternalSchema(db, 0); return rc; } -#endif /* SQLITE_OMIT_VACUUM */ +#endif /* SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */ Index: src/vdbe.c ================================================================== --- src/vdbe.c +++ src/vdbe.c @@ -41,11 +41,11 @@ ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.593 2007/03/27 13:36:37 drh Exp $ +** $Id: vdbe.c,v 1.594 2007/03/27 14:44:51 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include #include "vdbeInt.h" @@ -4509,11 +4509,11 @@ } break; } -#ifndef SQLITE_OMIT_VACUUM +#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH) /* Opcode: Vacuum * * * ** ** Vacuum the entire database. This opcode will cause other virtual ** machines to be created and run. It may not be called from within ** a transaction. Index: tool/mkkeywordhash.c ================================================================== --- tool/mkkeywordhash.c +++ tool/mkkeywordhash.c @@ -13,11 +13,11 @@ static const char zHdr[] = "/***** This file contains automatically generated code ******\n" "**\n" "** The code in this file has been automatically generated by\n" "**\n" - "** $Header: /home/drh/sqlite/trans/cvs/sqlite/sqlite/tool/mkkeywordhash.c,v 1.25 2007/02/21 16:44:33 drh Exp $\n" + "** $Header: /home/drh/sqlite/trans/cvs/sqlite/sqlite/tool/mkkeywordhash.c,v 1.26 2007/03/27 14:44:52 drh Exp $\n" "**\n" "** The code in this file implements a function that determines whether\n" "** or not a given identifier is really an SQL keyword. The same thing\n" "** might be implemented more directly using a hand-written hash table.\n" "** But by using this automatically generated code, the size of the code\n" @@ -112,11 +112,11 @@ #ifdef SQLITE_OMIT_TRIGGER # define TRIGGER 0 #else # define TRIGGER 0x00002000 #endif -#ifdef SQLITE_OMIT_VACUUM +#if defined(SQLITE_OMIT_VACUUM) || defined(SQLITE_OMIT_ATTACH) # define VACUUM 0 #else # define VACUUM 0x00004000 #endif #ifdef SQLITE_OMIT_VIEW