aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2011-06-03 20:11:17 +0000
committerdrh <drh@noemail.net>2011-06-03 20:11:17 +0000
commit5d9c9da6e847e7111fc93c592576edaff5ad8cdf (patch)
tree514f181119aab4e443cf92f438851c98ac627366 /src
parent68f2a57698780de49312cdb0f11732c521955d60 (diff)
downloadsqlite-5d9c9da6e847e7111fc93c592576edaff5ad8cdf.tar.gz
sqlite-5d9c9da6e847e7111fc93c592576edaff5ad8cdf.zip
Create and use a function especially for adding the ParseSchema opcode.
This gives a small reduction in code and a small performance increase. FossilOrigin-Name: 957b2ab67c6185f0e1062593d237de5c434a38bf
Diffstat (limited to 'src')
-rw-r--r--src/alter.c4
-rw-r--r--src/build.c9
-rw-r--r--src/trigger.c5
-rw-r--r--src/vdbe.h1
-rw-r--r--src/vdbeaux.c21
-rw-r--r--src/vtab.c2
6 files changed, 24 insertions, 18 deletions
diff --git a/src/alter.c b/src/alter.c
index aa3fa929f..fb6d89de6 100644
--- a/src/alter.c
+++ b/src/alter.c
@@ -358,14 +358,14 @@ static void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){
/* Reload the table, index and permanent trigger schemas. */
zWhere = sqlite3MPrintf(pParse->db, "tbl_name=%Q", zName);
if( !zWhere ) return;
- sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC);
+ sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
#ifndef SQLITE_OMIT_TRIGGER
/* Now, if the table is not stored in the temp database, reload any temp
** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined.
*/
if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){
- sqlite3VdbeAddOp4(v, OP_ParseSchema, 1, 0, 0, zWhere, P4_DYNAMIC);
+ sqlite3VdbeAddParseSchemaOp(v, 1, zWhere);
}
#endif
}
diff --git a/src/build.c b/src/build.c
index afe208932..97758cbcb 100644
--- a/src/build.c
+++ b/src/build.c
@@ -1619,8 +1619,8 @@ void sqlite3EndTable(
#endif
/* Reparse everything to update our internal data structures */
- sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0,
- sqlite3MPrintf(db, "tbl_name='%q'",p->zName), P4_DYNAMIC);
+ sqlite3VdbeAddParseSchemaOp(v, iDb,
+ sqlite3MPrintf(db, "tbl_name='%q'", p->zName));
}
@@ -2817,9 +2817,8 @@ Index *sqlite3CreateIndex(
if( pTblName ){
sqlite3RefillIndex(pParse, pIndex, iMem);
sqlite3ChangeCookie(pParse, iDb);
- sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0,
- sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName),
- P4_DYNAMIC);
+ sqlite3VdbeAddParseSchemaOp(v, iDb,
+ sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));
sqlite3VdbeAddOp1(v, OP_Expire, 0);
}
}
diff --git a/src/trigger.c b/src/trigger.c
index 0f3f5bad3..6242de5e6 100644
--- a/src/trigger.c
+++ b/src/trigger.c
@@ -301,9 +301,8 @@ void sqlite3FinishTrigger(
pTrig->table, z);
sqlite3DbFree(db, z);
sqlite3ChangeCookie(pParse, iDb);
- sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, sqlite3MPrintf(
- db, "type='trigger' AND name='%q'", zName), P4_DYNAMIC
- );
+ sqlite3VdbeAddParseSchemaOp(v, iDb,
+ sqlite3MPrintf(db, "type='trigger' AND name='%q'", zName));
}
if( db->init.busy ){
diff --git a/src/vdbe.h b/src/vdbe.h
index 56f9eb51c..e66ee3024 100644
--- a/src/vdbe.h
+++ b/src/vdbe.h
@@ -172,6 +172,7 @@ int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);
int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);
int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);
int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp);
+void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1);
void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2);
void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3);
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index 8181f01aa..447ba57a1 100644
--- a/src/vdbeaux.c
+++ b/src/vdbeaux.c
@@ -156,13 +156,6 @@ int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){
pOp->p3 = p3;
pOp->p4.p = 0;
pOp->p4type = P4_NOTUSED;
- p->expired = 0;
- if( op==OP_ParseSchema ){
- /* Any program that uses the OP_ParseSchema opcode needs to lock
- ** all btrees. */
- int j;
- for(j=0; j<p->db->nDb; j++) sqlite3VdbeUsesBtree(p, j);
- }
#ifdef SQLITE_DEBUG
pOp->zComment = 0;
if( sqlite3VdbeAddopTrace ) sqlite3VdbePrintOp(0, i, &p->aOp[i]);
@@ -202,6 +195,20 @@ int sqlite3VdbeAddOp4(
}
/*
+** Add an OP_ParseSchema opcode. This routine is broken out from
+** sqlite3VdbeAddOp4() since it needs to also local all btrees.
+**
+** The zWhere string must have been obtained from sqlite3_malloc().
+** This routine will take ownership of the allocated memory.
+*/
+void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){
+ int j;
+ int addr = sqlite3VdbeAddOp3(p, OP_ParseSchema, iDb, 0, 0);
+ sqlite3VdbeChangeP4(p, addr, zWhere, P4_DYNAMIC);
+ for(j=0; j<p->db->nDb; j++) sqlite3VdbeUsesBtree(p, j);
+}
+
+/*
** Add an opcode that includes the p4 value as an integer.
*/
int sqlite3VdbeAddOp4Int(
diff --git a/src/vtab.c b/src/vtab.c
index dffd6a266..223ef4e7b 100644
--- a/src/vtab.c
+++ b/src/vtab.c
@@ -383,7 +383,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
- sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC);
+ sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0,
pTab->zName, sqlite3Strlen30(pTab->zName) + 1);
}