aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2003-06-03 01:47:11 +0000
committerdrh <drh@noemail.net>2003-06-03 01:47:11 +0000
commit4312db55d95877907bff257c95c41d463494de7c (patch)
treec9950495671dae76665e292ed3ca25b62925e410 /src
parent1aa4965ae36182dea6f85117afd4db195b451f50 (diff)
downloadsqlite-4312db55d95877907bff257c95c41d463494de7c.tar.gz
sqlite-4312db55d95877907bff257c95c41d463494de7c.zip
Additional testing of the ATTACH command with bug fixes for the new problems
that the tests found. (CVS 998) FossilOrigin-Name: 3e8889d7ce5e99fc855526fc1bb62ddbe282bfc5
Diffstat (limited to 'src')
-rw-r--r--src/attach.c8
-rw-r--r--src/sqliteInt.h4
-rw-r--r--src/trigger.c16
3 files changed, 16 insertions, 12 deletions
diff --git a/src/attach.c b/src/attach.c
index 77be3bcf9..d8901187b 100644
--- a/src/attach.c
+++ b/src/attach.c
@@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to implement the ATTACH and DETACH commands.
**
-** $Id: attach.c,v 1.4 2003/05/31 16:21:12 drh Exp $
+** $Id: attach.c,v 1.5 2003/06/03 01:47:11 drh Exp $
*/
#include "sqliteInt.h"
@@ -148,6 +148,7 @@ int sqliteFixInit(
if( iDb<0 || iDb==1 ) return 0;
db = pParse->db;
assert( db->nDb>iDb );
+ pFix->pParse = pParse;
pFix->zDb = db->aDb[iDb].zName;
pFix->zType = zType;
pFix->pName = pName;
@@ -182,8 +183,9 @@ int sqliteFixSrcList(
pList->a[i].zDatabase = sqliteStrDup(zDb);
}else if( sqliteStrICmp(pList->a[i].zDatabase,zDb)!=0 ){
sqliteErrorMsg(pFix->pParse,
- "%s %.*s cannot reference objects in database %s",
- pFix->zType, pFix->pName->n, pFix->pName->z, pList->a[i].zDatabase);
+ "%s %z cannot reference objects in database %s",
+ pFix->zType, sqliteStrNDup(pFix->pName->z, pFix->pName->n),
+ pList->a[i].zDatabase);
return 1;
}
if( sqliteFixSelect(pFix, pList->a[i].pSelect) ) return 1;
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index e25145d2a..4ab58d0cf 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.190 2003/06/02 23:14:13 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.191 2003/06/03 01:47:11 drh Exp $
*/
#include "config.h"
#include "sqlite.h"
@@ -904,7 +904,7 @@ struct Trigger {
IdList *pColumns; /* If this is an UPDATE OF <column-list> trigger,
the <column-list> is stored here */
int foreach; /* One of TK_ROW or TK_STATEMENT */
- Token *pNameToken; /* Token containing zName. Use during parsing only */
+ Token nameToken; /* Token containing zName. Use during parsing only */
TriggerStep *step_list; /* Link list of trigger program steps */
Trigger *pNext; /* Next trigger associated with the table */
diff --git a/src/trigger.c b/src/trigger.c
index eec48e0ff..97891b2cb 100644
--- a/src/trigger.c
+++ b/src/trigger.c
@@ -54,6 +54,7 @@ void sqliteBeginTrigger(
char *zName = 0; /* Name of the trigger */
sqlite *db = pParse->db;
int iDb; /* When database to store the trigger in */
+ DbFixer sFix;
/* Check that:
** 1. the trigger name does not already exist.
@@ -64,12 +65,13 @@ void sqliteBeginTrigger(
*/
if( sqlite_malloc_failed ) goto trigger_cleanup;
assert( pTableName->nSrc==1 );
- assert( pTableName->a[0].zDatabase==0 );
- if( pParse->initFlag ){
- pTableName->a[0].zDatabase = db->aDb[pParse->iDb].zName;
+ if( pParse->initFlag
+ && sqliteFixInit(&sFix, pParse, pParse->iDb, "trigger", pName)
+ && sqliteFixSrcList(&sFix, pTableName)
+ ){
+ goto trigger_cleanup;
}
tab = sqliteSrcListLookup(pParse, pTableName);
- pTableName->a[0].zDatabase = 0;
if( !tab ){
goto trigger_cleanup;
}
@@ -138,7 +140,7 @@ void sqliteBeginTrigger(
nt->pWhen = sqliteExprDup(pWhen);
nt->pColumns = sqliteIdListDup(pColumns);
nt->foreach = foreach;
- nt->pNameToken = pName;
+ sqliteTokenCopy(&nt->nameToken,pName);
assert( pParse->pNewTrigger==0 );
pParse->pNewTrigger = nt;
@@ -170,11 +172,10 @@ void sqliteFinishTrigger(
pStepList->pTrig = nt;
pStepList = pStepList->pNext;
}
- if( sqliteFixInit(&sFix, pParse, nt->iDb, "trigger", nt->pNameToken)
+ if( sqliteFixInit(&sFix, pParse, nt->iDb, "trigger", &nt->nameToken)
&& sqliteFixTriggerStep(&sFix, nt->step_list) ){
goto triggerfinish_cleanup;
}
- nt->pNameToken = 0;
/* if we are not initializing, and this trigger is not on a TEMP table,
** build the sqlite_master entry
@@ -366,6 +367,7 @@ void sqliteDeleteTrigger(Trigger *pTrigger){
sqliteFree(pTrigger->table);
sqliteExprDelete(pTrigger->pWhen);
sqliteIdListDelete(pTrigger->pColumns);
+ if( pTrigger->nameToken.dyn ) sqliteFree((char*)pTrigger->nameToken.z);
sqliteFree(pTrigger);
}