diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 3 | ||||
-rw-r--r-- | src/insert.c | 39 | ||||
-rw-r--r-- | src/pragma.c | 5 | ||||
-rw-r--r-- | src/prepare.c | 3 | ||||
-rw-r--r-- | src/select.c | 49 | ||||
-rw-r--r-- | src/vdbeaux.c | 8 | ||||
-rw-r--r-- | src/vtab.c | 6 |
7 files changed, 53 insertions, 60 deletions
diff --git a/src/build.c b/src/build.c index bc242de61..464dc39da 100644 --- a/src/build.c +++ b/src/build.c @@ -22,7 +22,7 @@ ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.504 2008/12/05 15:24:16 drh Exp $ +** $Id: build.c,v 1.505 2008/12/10 17:20:00 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -2046,7 +2046,6 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){ #ifndef SQLITE_OMIT_VIRTUALTABLE if( IsVirtual(pTab) ){ - Vdbe *v = sqlite3GetVdbe(pParse); if( v ){ sqlite3VdbeAddOp0(v, OP_VBegin); } diff --git a/src/insert.c b/src/insert.c index f7492ebc9..560394312 100644 --- a/src/insert.c +++ b/src/insert.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** -** $Id: insert.c,v 1.253 2008/11/19 09:05:27 danielk1977 Exp $ +** $Id: insert.c,v 1.254 2008/12/10 17:20:00 drh Exp $ */ #include "sqliteInt.h" @@ -572,24 +572,24 @@ void sqlite3Insert( ** goto L ** M: ... */ - int regRec; /* Register to hold packed record */ - int regRowid; /* Register to hold temp table ROWID */ - int addrTop; /* Label "L" */ - int addrIf; /* Address of jump to M */ + int regRec; /* Register to hold packed record */ + int regTempRowid; /* Register to hold temp table ROWID */ + int addrTop; /* Label "L" */ + int addrIf; /* Address of jump to M */ srcTab = pParse->nTab++; regRec = sqlite3GetTempReg(pParse); - regRowid = sqlite3GetTempReg(pParse); + regTempRowid = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp2(v, OP_OpenEphemeral, srcTab, nColumn); addrTop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); addrIf = sqlite3VdbeAddOp1(v, OP_If, regEof); sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec); - sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regRowid); - sqlite3VdbeAddOp3(v, OP_Insert, srcTab, regRec, regRowid); + sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid); + sqlite3VdbeAddOp3(v, OP_Insert, srcTab, regRec, regTempRowid); sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop); sqlite3VdbeJumpHere(v, addrIf); sqlite3ReleaseTempReg(pParse, regRec); - sqlite3ReleaseTempReg(pParse, regRowid); + sqlite3ReleaseTempReg(pParse, regTempRowid); } }else{ /* This is the case if the data for the INSERT is coming from a VALUES @@ -690,7 +690,6 @@ void sqlite3Insert( /* If this is not a view, open the table and and all indices */ if( !isView ){ int nIdx; - int i; baseCur = pParse->nTab; nIdx = sqlite3OpenTableAndIndices(pParse, pTab, baseCur, OP_OpenWrite); @@ -746,7 +745,7 @@ void sqlite3Insert( */ endOfLoop = sqlite3VdbeMakeLabel(v); if( triggers_exist & TRIGGER_BEFORE ){ - int regRowid; + int regTrigRowid; int regCols; int regRec; @@ -756,19 +755,19 @@ void sqlite3Insert( ** we do not know what the unique ID will be (because the insert has ** not happened yet) so we substitute a rowid of -1 */ - regRowid = sqlite3GetTempReg(pParse); + regTrigRowid = sqlite3GetTempReg(pParse); if( keyColumn<0 ){ - sqlite3VdbeAddOp2(v, OP_Integer, -1, regRowid); + sqlite3VdbeAddOp2(v, OP_Integer, -1, regTrigRowid); }else if( useTempTable ){ - sqlite3VdbeAddOp3(v, OP_Column, srcTab, keyColumn, regRowid); + sqlite3VdbeAddOp3(v, OP_Column, srcTab, keyColumn, regTrigRowid); }else{ int j1; assert( pSelect==0 ); /* Otherwise useTempTable is true */ - sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr, regRowid); - j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid); - sqlite3VdbeAddOp2(v, OP_Integer, -1, regRowid); + sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr, regTrigRowid); + j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regTrigRowid); + sqlite3VdbeAddOp2(v, OP_Integer, -1, regTrigRowid); sqlite3VdbeJumpHere(v, j1); - sqlite3VdbeAddOp1(v, OP_MustBeInt, regRowid); + sqlite3VdbeAddOp1(v, OP_MustBeInt, regTrigRowid); } /* Cannot have triggers on a virtual table. If it were possible, @@ -807,9 +806,9 @@ void sqlite3Insert( if( !isView ){ sqlite3TableAffinityStr(v, pTab); } - sqlite3VdbeAddOp3(v, OP_Insert, newIdx, regRec, regRowid); + sqlite3VdbeAddOp3(v, OP_Insert, newIdx, regRec, regTrigRowid); sqlite3ReleaseTempReg(pParse, regRec); - sqlite3ReleaseTempReg(pParse, regRowid); + sqlite3ReleaseTempReg(pParse, regTrigRowid); sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol); /* Fire BEFORE or INSTEAD OF triggers */ diff --git a/src/pragma.c b/src/pragma.c index a467b6289..1fb07736f 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.195 2008/11/21 00:10:35 aswift Exp $ +** $Id: pragma.c,v 1.196 2008/12/10 17:20:01 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -394,9 +394,7 @@ void sqlite3Pragma( ** Return the number of pages in the specified database. */ if( sqlite3StrICmp(zLeft,"page_count")==0 ){ - Vdbe *v; int iReg; - v = sqlite3GetVdbe(pParse); if( !v || sqlite3ReadSchema(pParse) ) goto pragma_out; sqlite3CodeVerifySchema(pParse, iDb); iReg = ++pParse->nMem; @@ -1309,7 +1307,6 @@ void sqlite3Pragma( "unlocked", "shared", "reserved", "pending", "exclusive" }; int i; - Vdbe *v = sqlite3GetVdbe(pParse); sqlite3VdbeSetNumCols(v, 2); pParse->nMem = 2; sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", SQLITE_STATIC); diff --git a/src/prepare.c b/src/prepare.c index cfbd5e0fe..d141cb6fe 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -13,7 +13,7 @@ ** interface, and routines that contribute to loading the database schema ** from disk. ** -** $Id: prepare.c,v 1.101 2008/11/19 16:52:44 danielk1977 Exp $ +** $Id: prepare.c,v 1.102 2008/12/10 17:20:01 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -547,7 +547,6 @@ static int sqlite3Prepare( for(i=0; i<db->nDb; i++) { Btree *pBt = db->aDb[i].pBt; if( pBt ){ - int rc; rc = sqlite3BtreeSchemaLocked(pBt); if( rc ){ const char *zDb = db->aDb[i].zName; diff --git a/src/select.c b/src/select.c index f1cf0dc35..a2b532c77 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.490 2008/12/06 16:10:42 drh Exp $ +** $Id: select.c,v 1.491 2008/12/10 17:20:01 drh Exp $ */ #include "sqliteInt.h" @@ -786,8 +786,8 @@ static void generateSortTail( int nColumn, /* Number of columns of data */ SelectDest *pDest /* Write the sorted results here */ ){ - int brk = sqlite3VdbeMakeLabel(v); - int cont = sqlite3VdbeMakeLabel(v); + int addrBreak = sqlite3VdbeMakeLabel(v); /* Jump here to exit loop */ + int addrContinue = sqlite3VdbeMakeLabel(v); /* Jump here for next cycle */ int addr; int iTab; int pseudoTab = 0; @@ -805,8 +805,8 @@ static void generateSortTail( sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, nColumn); sqlite3VdbeAddOp2(v, OP_OpenPseudo, pseudoTab, eDest==SRT_Output); } - addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, brk); - codeOffset(v, p, cont); + addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); + codeOffset(v, p, addrContinue); regRow = sqlite3GetTempReg(pParse); regRowid = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp3(v, OP_Column, iTab, pOrderBy->nExpr + 1, regRow); @@ -864,13 +864,12 @@ static void generateSortTail( /* The bottom of the loop */ - sqlite3VdbeResolveLabel(v, cont); + sqlite3VdbeResolveLabel(v, addrContinue); sqlite3VdbeAddOp2(v, OP_Next, iTab, addr); - sqlite3VdbeResolveLabel(v, brk); + sqlite3VdbeResolveLabel(v, addrBreak); if( eDest==SRT_Output || eDest==SRT_Coroutine ){ sqlite3VdbeAddOp2(v, OP_Close, pseudoTab, 0); } - } /* @@ -1151,13 +1150,14 @@ static int selectColumnsFromExprList( int *pnCol, /* Write the number of columns here */ Column **paCol /* Write the new column list here */ ){ - sqlite3 *db = pParse->db; - int i, j, cnt; - Column *aCol, *pCol; - int nCol; - Expr *p; - char *zName; - int nName; + sqlite3 *db = pParse->db; /* Database connection */ + int i, j; /* Loop counters */ + int cnt; /* Index added to make the name unique */ + Column *aCol, *pCol; /* For looping over result columns */ + int nCol; /* Number of columns in the result set */ + Expr *p; /* Expression for a single result column */ + char *zName; /* Column name */ + int nName; /* Size of name in zName[] */ *pnCol = nCol = pEList->nExpr; aCol = *paCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol); @@ -1171,18 +1171,18 @@ static int selectColumnsFromExprList( /* If the column contains an "AS <name>" phrase, use <name> as the name */ zName = sqlite3DbStrDup(db, zName); }else{ - Expr *pCol = p; - Table *pTab; - while( pCol->op==TK_DOT ) pCol = pCol->pRight; - if( pCol->op==TK_COLUMN && (pTab = pCol->pTab)!=0 ){ + Expr *pColExpr = p; /* The expression that is the result column name */ + Table *pTab; /* Table associated with this expression */ + while( pColExpr->op==TK_DOT ) pColExpr = pColExpr->pRight; + if( pColExpr->op==TK_COLUMN && (pTab = pColExpr->pTab)!=0 ){ /* For columns use the column name name */ - int iCol = pCol->iColumn; + int iCol = pColExpr->iColumn; if( iCol<0 ) iCol = pTab->iPKey; zName = sqlite3MPrintf(db, "%s", iCol>=0 ? pTab->aCol[iCol].zName : "rowid"); }else{ /* Use the original text of the column expression as its name */ - Token *pToken = (pCol->span.z?&pCol->span:&pCol->token); + Token *pToken = (pColExpr->span.z?&pColExpr->span:&pColExpr->token); zName = sqlite3MPrintf(db, "%T", pToken); } } @@ -1210,7 +1210,6 @@ static int selectColumnsFromExprList( pCol->zName = zName; } if( db->mallocFailed ){ - int j; for(j=0; j<i; j++){ sqlite3DbFree(db, aCol[j].zName); } @@ -3747,13 +3746,13 @@ int sqlite3Select( ** GROUP BY clause. */ if( pGroupBy ){ - int i; /* Loop counter */ + int k; /* Loop counter */ struct ExprList_item *pItem; /* For looping over expression in a list */ - for(i=p->pEList->nExpr, pItem=p->pEList->a; i>0; i--, pItem++){ + for(k=p->pEList->nExpr, pItem=p->pEList->a; k>0; k--, pItem++){ pItem->iAlias = 0; } - for(i=pGroupBy->nExpr, pItem=pGroupBy->a; i>0; i--, pItem++){ + for(k=pGroupBy->nExpr, pItem=pGroupBy->a; k>0; k--, pItem++){ pItem->iAlias = 0; } } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index c7cd883d8..aba2ef898 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -14,7 +14,7 @@ ** to version 2.8.7, all this code was combined into the vdbe.c source file. ** But that file was getting too big so this subroutines were split out. ** -** $Id: vdbeaux.c,v 1.424 2008/12/09 02:51:24 drh Exp $ +** $Id: vdbeaux.c,v 1.425 2008/12/10 17:20:01 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -1333,10 +1333,10 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){ /* Select a master journal file name */ do { - u32 random; + u32 iRandom; sqlite3DbFree(db, zMaster); - sqlite3_randomness(sizeof(random), &random); - zMaster = sqlite3MPrintf(db, "%s-mj%08X", zMainFile, random&0x7fffffff); + sqlite3_randomness(sizeof(iRandom), &iRandom); + zMaster = sqlite3MPrintf(db, "%s-mj%08X", zMainFile, iRandom&0x7fffffff); if( !zMaster ){ return SQLITE_NOMEM; } diff --git a/src/vtab.c b/src/vtab.c index d18f6b3c2..9dbd0dd2c 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to help implement virtual tables. ** -** $Id: vtab.c,v 1.78 2008/11/13 19:12:36 danielk1977 Exp $ +** $Id: vtab.c,v 1.79 2008/12/10 17:20:01 drh Exp $ */ #ifndef SQLITE_OMIT_VIRTUALTABLE #include "sqliteInt.h" @@ -762,8 +762,8 @@ FuncDef *sqlite3VtabOverloadFunction( Table *pTab; sqlite3_vtab *pVtab; sqlite3_module *pMod; - void (*xFunc)(sqlite3_context*,int,sqlite3_value**); - void *pArg; + void (*xFunc)(sqlite3_context*,int,sqlite3_value**) = 0; + void *pArg = 0; FuncDef *pNew; int rc = 0; char *zLowerName; |