In where.c, split out the code that selects an index into a separate

subroutine. (CVS 2554)

FossilOrigin-Name: c30cbba9ead1b4d07f225b1e8a65d5d5230ea45d
This commit is contained in:
drh
2005-07-21 03:14:59 +00:00
parent 013972052e
commit fe05af87f8
9 changed files with 496 additions and 442 deletions
+28 -27
View File
@@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
** $Id: build.c,v 1.330 2005/06/30 17:04:21 drh Exp $
** $Id: build.c,v 1.331 2005/07/21 03:15:00 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -2476,6 +2476,32 @@ IdList *sqlite3IdListAppend(IdList *pList, Token *pToken){
return pList;
}
/*
** Delete an IdList.
*/
void sqlite3IdListDelete(IdList *pList){
int i;
if( pList==0 ) return;
for(i=0; i<pList->nId; i++){
sqliteFree(pList->a[i].zName);
}
sqliteFree(pList->a);
sqliteFree(pList);
}
/*
** Return the index in pList of the identifier named zId. Return -1
** if not found.
*/
int sqlite3IdListIndex(IdList *pList, const char *zName){
int i;
if( pList==0 ) return -1;
for(i=0; i<pList->nId; i++){
if( sqlite3StrICmp(pList->a[i].zName, zName)==0 ) return i;
}
return -1;
}
/*
** Append a new table name to the given SrcList. Create a new SrcList if
** need be. A new entry is created in the SrcList even if pToken is NULL.
@@ -2560,32 +2586,6 @@ void sqlite3SrcListAddAlias(SrcList *pList, Token *pToken){
}
}
/*
** Delete an IdList.
*/
void sqlite3IdListDelete(IdList *pList){
int i;
if( pList==0 ) return;
for(i=0; i<pList->nId; i++){
sqliteFree(pList->a[i].zName);
}
sqliteFree(pList->a);
sqliteFree(pList);
}
/*
** Return the index in pList of the identifier named zId. Return -1
** if not found.
*/
int sqlite3IdListIndex(IdList *pList, const char *zName){
int i;
if( pList==0 ) return -1;
for(i=0; i<pList->nId; i++){
if( sqlite3StrICmp(pList->a[i].zName, zName)==0 ) return i;
}
return -1;
}
/*
** Delete an entire SrcList including all its substructure.
*/
@@ -2601,6 +2601,7 @@ void sqlite3SrcListDelete(SrcList *pList){
sqlite3SelectDelete(pItem->pSelect);
sqlite3ExprDelete(pItem->pOn);
sqlite3IdListDelete(pItem->pUsing);
sqlite3WhereIdxListDelete(pItem->pWIdx);
}
sqliteFree(pList);
}
+3 -1
View File
@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.211 2005/07/08 18:25:26 drh Exp $
** $Id: expr.c,v 1.212 2005/07/21 03:15:00 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -93,6 +93,7 @@ char sqlite3CompareAffinity(Expr *pExpr, char aff2){
return SQLITE_AFF_NONE;
}else{
/* One side is a column, the other is not. Use the columns affinity. */
assert( aff1==0 || aff2==0 );
return (aff1 + aff2);
}
}
@@ -488,6 +489,7 @@ SrcList *sqlite3SrcListDup(SrcList *p){
pNewItem->pSelect = sqlite3SelectDup(pOldItem->pSelect);
pNewItem->pOn = sqlite3ExprDup(pOldItem->pOn);
pNewItem->pUsing = sqlite3IdListDup(pOldItem->pUsing);
pNewItem->pWIdx = 0;
pNewItem->colUsed = pOldItem->colUsed;
}
return pNew;
+24 -22
View File
@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.394 2005/07/19 17:38:23 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.395 2005/07/21 03:15:00 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@@ -298,30 +298,31 @@ extern int sqlite3_iMallocReset; /* Set iMallocFail to this when it reaches 0 */
/*
** Forward references to structures
*/
typedef struct AggExpr AggExpr;
typedef struct AuthContext AuthContext;
typedef struct CollSeq CollSeq;
typedef struct Column Column;
typedef struct Table Table;
typedef struct Index Index;
typedef struct Db Db;
typedef struct Expr Expr;
typedef struct ExprList ExprList;
typedef struct Parse Parse;
typedef struct Token Token;
typedef struct IdList IdList;
typedef struct SrcList SrcList;
typedef struct WhereInfo WhereInfo;
typedef struct WhereLevel WhereLevel;
typedef struct Select Select;
typedef struct AggExpr AggExpr;
typedef struct FuncDef FuncDef;
typedef struct Trigger Trigger;
typedef struct TriggerStep TriggerStep;
typedef struct TriggerStack TriggerStack;
typedef struct FKey FKey;
typedef struct Db Db;
typedef struct AuthContext AuthContext;
typedef struct FuncDef FuncDef;
typedef struct IdList IdList;
typedef struct Index Index;
typedef struct KeyClass KeyClass;
typedef struct CollSeq CollSeq;
typedef struct KeyInfo KeyInfo;
typedef struct NameContext NameContext;
typedef struct Parse Parse;
typedef struct Select Select;
typedef struct SrcList SrcList;
typedef struct Table Table;
typedef struct Token Token;
typedef struct TriggerStack TriggerStack;
typedef struct TriggerStep TriggerStep;
typedef struct Trigger Trigger;
typedef struct WhereIdx WhereIdx;
typedef struct WhereInfo WhereInfo;
typedef struct WhereLevel WhereLevel;
/*
** Each database file to be accessed by the system is an instance
@@ -924,10 +925,11 @@ struct SrcList {
char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */
Table *pTab; /* An SQL table corresponding to zName */
Select *pSelect; /* A SELECT statement used in place of a table name */
int jointype; /* Type of join between this table and the next */
int iCursor; /* The VDBE cursor number used to access this table */
u8 jointype; /* Type of join between this table and the next */
i16 iCursor; /* The VDBE cursor number used to access this table */
Expr *pOn; /* The ON clause of a join */
IdList *pUsing; /* The USING clause of a join */
WhereIdx *pWIdx; /* List of structures used by the optimizer */
Bitmask colUsed; /* Bit N (1<<N) set if column N or pTab is used */
} a[1]; /* One entry for each identifier on the list */
};
@@ -953,14 +955,13 @@ struct WhereLevel {
Index *pIdx; /* Index used. NULL if no index */
int iTabCur; /* The VDBE cursor used to access the table */
int iIdxCur; /* The VDBE cursor used to acesss pIdx */
int score; /* How well this index scored */
int brk; /* Jump here to break out of the loop */
int cont; /* Jump here to continue with the next loop cycle */
int op, p1, p2; /* Opcode used to terminate the loop */
int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */
int top; /* First instruction of interior of the loop */
int inOp, inP1, inP2;/* Opcode used to implement an IN operator */
int bRev; /* Do the scan in the reverse direction */
int flags; /* Flags associated with this level */
};
/*
@@ -1568,6 +1569,7 @@ CollSeq *sqlite3GetCollSeq(sqlite3*, CollSeq *, const char *, int);
char sqlite3AffinityType(const Token*);
void sqlite3Analyze(Parse*, Token*, Token*);
int sqlite3InvokeBusyHandler(BusyHandler*);
void sqlite3WhereIdxListDelete(WhereIdx*);
#ifdef SQLITE_SSE
#include "sseInt.h"
+422 -375
View File
File diff suppressed because it is too large Load Diff