Index: src/build.c ================================================================== --- src/build.c +++ src/build.c @@ -21,11 +21,11 @@ ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** PRAGMA ** -** $Id: build.c,v 1.160 2003/09/06 22:18:08 drh Exp $ +** $Id: build.c,v 1.161 2003/11/27 00:48:58 drh Exp $ */ #include "sqliteInt.h" #include /* @@ -732,11 +732,11 @@ if( pParse->db->file_format>=1 && zType && sqliteStrICmp(zType, "INTEGER")==0 ){ pTab->iPKey = iCol; pTab->keyConf = onError; }else{ - sqliteCreateIndex(pParse, 0, 0, pList, onError, 0, 0, 0); + sqliteCreateIndex(pParse, 0, 0, pList, onError, 0, 0); pList = 0; } primary_key_exit: sqliteIdListDelete(pList); @@ -1535,24 +1535,24 @@ Parse *pParse, /* All information about this parse */ Token *pName, /* Name of the index. May be NULL */ SrcList *pTable, /* Name of the table to index. Use pParse->pNewTable if 0 */ IdList *pList, /* A list of columns to be indexed */ int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ - int isTemp, /* True if this is a temporary index */ Token *pStart, /* The CREATE token that begins a CREATE TABLE statement */ Token *pEnd /* The ")" that closes the CREATE INDEX statement */ ){ Table *pTab; /* Table to be indexed */ Index *pIndex; /* The index to be created */ char *zName = 0; int i, j; Token nullId; /* Fake token for an empty ID list */ DbFixer sFix; /* For assigning database names to pTable */ + int isTemp; /* True for a temporary index */ sqlite *db = pParse->db; if( pParse->nErr || sqlite_malloc_failed ) goto exit_create_index; - if( !isTemp && pParse->initFlag + if( pParse->initFlag && sqliteFixInit(&sFix, pParse, pParse->iDb, "index", pName) && sqliteFixSrcList(&sFix, pTable) ){ goto exit_create_index; } @@ -1573,24 +1573,22 @@ sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName, " may not be indexed", 0); pParse->nErr++; goto exit_create_index; } - if( !isTemp && pTab->iDb>=2 && pParse->initFlag==0 ){ + if( pTab->iDb>=2 && pParse->initFlag==0 ){ sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName, - " may not have non-temporary indices added", 0); + " may not have indices added", 0); pParse->nErr++; goto exit_create_index; } if( pTab->pSelect ){ sqliteSetString(&pParse->zErrMsg, "views may not be indexed", 0); pParse->nErr++; goto exit_create_index; } - if( pTab->iDb==1 ){ - isTemp = 1; - } + isTemp = pTab->iDb==1; /* ** Find the name of the index. Make sure there is not already another ** index or table with the same name. ** @@ -1637,12 +1635,11 @@ */ #ifndef SQLITE_OMIT_AUTHORIZATION { const char *zDb = db->aDb[pTab->iDb].zName; - assert( isTemp==0 || isTemp==1 ); - assert( pTab->iDb==pParse->iDb || isTemp==1 ); + assert( pTab->iDb==pParse->iDb || isTemp ); if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){ goto exit_create_index; } i = SQLITE_CREATE_INDEX; if( isTemp ) i = SQLITE_CREATE_TEMP_INDEX; 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.103 2003/09/30 01:54:14 drh Exp $ +** @(#) $Id: parse.y,v 1.104 2003/11/27 00:48:58 drh Exp $ */ %token_prefix TK_ %token_type {Token} %default_type {Token} %extra_argument {Parse *pParse} @@ -175,11 +175,11 @@ // UNIQUE constraints. // ccons ::= NULL onconf. ccons ::= NOT NULL onconf(R). {sqliteAddNotNull(pParse, R);} ccons ::= PRIMARY KEY sortorder onconf(R). {sqliteAddPrimaryKey(pParse,0,R);} -ccons ::= UNIQUE onconf(R). {sqliteCreateIndex(pParse,0,0,0,R,0,0,0);} +ccons ::= UNIQUE onconf(R). {sqliteCreateIndex(pParse,0,0,0,R,0,0);} ccons ::= CHECK LP expr RP onconf. ccons ::= REFERENCES nm(T) idxlist_opt(TA) refargs(R). {sqliteCreateForeignKey(pParse,0,&T,TA,R);} ccons ::= defer_subclause(D). {sqliteDeferForeignKey(pParse,D);} ccons ::= COLLATE id(C). { @@ -222,11 +222,11 @@ conslist ::= tcons. tcons ::= CONSTRAINT nm. tcons ::= PRIMARY KEY LP idxlist(X) RP onconf(R). {sqliteAddPrimaryKey(pParse,X,R);} tcons ::= UNIQUE LP idxlist(X) RP onconf(R). - {sqliteCreateIndex(pParse,0,0,X,R,0,0,0);} + {sqliteCreateIndex(pParse,0,0,X,R,0,0);} tcons ::= CHECK expr onconf. tcons ::= FOREIGN KEY LP idxlist(FA) RP REFERENCES nm(T) idxlist_opt(TA) refargs(R) defer_subclause_opt(D). { sqliteCreateForeignKey(pParse, FA, &T, TA, R); sqliteDeferForeignKey(pParse, D); @@ -699,16 +699,16 @@ expritem(A) ::= expr(X). {A = X;} expritem(A) ::= . {A = 0;} ///////////////////////////// The CREATE INDEX command /////////////////////// // -cmd ::= CREATE(S) temp(T) uniqueflag(U) INDEX nm(X) +cmd ::= CREATE(S) uniqueflag(U) INDEX nm(X) ON nm(Y) dbnm(D) LP idxlist(Z) RP(E) onconf(R). { SrcList *pSrc = sqliteSrcListAppend(0, &Y, &D); if( U!=OE_None ) U = R; if( U==OE_Default) U = OE_Abort; - sqliteCreateIndex(pParse, &X, pSrc, Z, U, T, &S, &E); + sqliteCreateIndex(pParse, &X, pSrc, Z, U, &S, &E); } %type uniqueflag {int} uniqueflag(A) ::= UNIQUE. { A = OE_Abort; } uniqueflag(A) ::= . { A = OE_None; } Index: src/sqliteInt.h ================================================================== --- src/sqliteInt.h +++ src/sqliteInt.h @@ -9,11 +9,11 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.202 2003/11/11 23:30:36 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.203 2003/11/27 00:48:58 drh Exp $ */ #include "config.h" #include "sqlite.h" #include "hash.h" #include "vdbe.h" @@ -1099,11 +1099,11 @@ SrcList *sqliteSrcListAppend(SrcList*, Token*, Token*); void sqliteSrcListAddAlias(SrcList*, Token*); void sqliteSrcListAssignCursors(Parse*, SrcList*); void sqliteIdListDelete(IdList*); void sqliteSrcListDelete(SrcList*); -void sqliteCreateIndex(Parse*,Token*,SrcList*,IdList*,int,int,Token*,Token*); +void sqliteCreateIndex(Parse*,Token*,SrcList*,IdList*,int,Token*,Token*); void sqliteDropIndex(Parse*, SrcList*); void sqliteAddKeyType(Vdbe*, ExprList*); void sqliteAddIdxKeyType(Vdbe*, Index*); int sqliteSelect(Parse*, Select*, int, int, Select*, int, int*); Select *sqliteSelectNew(ExprList*,SrcList*,Expr*,ExprList*,Expr*,ExprList*, Index: test/auth.test ================================================================== --- test/auth.test +++ test/auth.test @@ -10,11 +10,11 @@ #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # -# $Id: auth.test,v 1.10 2003/06/06 19:00:42 drh Exp $ +# $Id: auth.test,v 1.11 2003/11/27 00:49:23 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -265,19 +265,24 @@ } {0 {}} do_test auth-1.34 { execsql {SELECT * FROM t2} } {1 2 3} -do_test auth-1.35 { +do_test auth-1.35.1 { proc auth {code arg1 arg2 arg3 arg4} { if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { return SQLITE_DENY } return SQLITE_OK } catchsql {SELECT * FROM t2} } {1 {access to t2.b is prohibited}} +do_test auth-1.35.2 { + execsql {ATTACH DATABASE 'test.db' AS two} + catchsql {SELECT * FROM two.t2} +} {1 {access to two.t2.b is prohibited}} +execsql {DETACH DATABASE two} do_test auth-1.36 { proc auth {code arg1 arg2 arg3 arg4} { if {$code=="SQLITE_READ" && $arg1=="t2" && $arg2=="b"} { return SQLITE_IGNORE } Index: test/trigger2.test ================================================================== --- test/trigger2.test +++ test/trigger2.test @@ -58,11 +58,10 @@ {CREATE TABLE tbl (a INTEGER PRIMARY KEY, b);} {CREATE TEMPORARY TABLE tbl (a INTEGER PRIMARY KEY, b);} {CREATE TABLE tbl (a, b PRIMARY KEY);} {CREATE TABLE tbl (a, b); CREATE INDEX tbl_idx ON tbl(b);} {CREATE TEMP TABLE tbl (a, b); CREATE INDEX tbl_idx ON tbl(b);} - {CREATE TABLE tbl (a, b); CREATE TEMP INDEX tbl_idx ON tbl(b);} } { incr ii catchsql { DROP INDEX tbl_idx; } catchsql { DROP TABLE rlog;