Continue refactoring where.c in preparation for installing OR-clause

optimizations. (CVS 6050)

FossilOrigin-Name: 778e91ddb834f6084ecdf3909692b54bb7da8f6d
This commit is contained in:
drh 2008-12-21 03:51:16 +00:00
parent a0fc72967e
commit 111a6a7d47
4 changed files with 769 additions and 666 deletions

View File

@ -1,5 +1,5 @@
C Add\sa\svfs\sbackend\sthat\sdetects\sproblems\slike\sthe\sone\saddressed\sby\s(6043)\sand\s(6047).\s(CVS\s6049)
D 2008-12-20T18:33:59
C Continue\srefactoring\swhere.c\sin\spreparation\sfor\sinstalling\sOR-clause\noptimizations.\s(CVS\s6050)
D 2008-12-21T03:51:16
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in f7e4c81c347b04f7b0f1c1b081a168645d7b8af7
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -158,7 +158,7 @@ F src/select.c a4316c5e8a417687e159b3d3ae689363d1dec5df
F src/shell.c 65d19f8996a160f288087e31810f24025439c62a
F src/sqlite.h.in 065a828e299960316aa34f05b9f0f10f33afe4c8
F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
F src/sqliteInt.h dfe2dd15e55abbcd028d1582e01b599930bde631
F src/sqliteInt.h 24f71f7e2758516aa6b64e1f0ca02ee6e29344d3
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
F src/table.c 23db1e5f27c03160987c122a078b4bb51ef0b2f8
@ -207,7 +207,7 @@ F src/vdbeblob.c b0dcebfafedcf9c0addc7901ad98f6f986c08935
F src/vdbemem.c f9c859ac17e2e05a0f249868ce4f191f69edd31d
F src/vtab.c e39e011d7443a8d574b1b9cde207a35522e6df43
F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
F src/where.c d373103ee8a7f2c69d42d585e83adef0b50ad3a0
F src/where.c 6e5de2421da8d9ed62a2fcf7df70df8301282936
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
@ -684,7 +684,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 51b3bfc3b9628ca4ec754fa7f23aef7302f890ff
R 1cd5d078a6ea4c15c2f815a2234d69ba
U danielk1977
Z 18495ec6b55a95f7beb0c7b663238125
P 49172e487610268662c39fc4038032779a41c47f
R 019fd4ad031eb96e8df6ba9c36e53615
U drh
Z 8c8a7b38e53711dc931521d447fa489c

View File

@ -1 +1 @@
49172e487610268662c39fc4038032779a41c47f
778e91ddb834f6084ecdf3909692b54bb7da8f6d

View File

@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.812 2008/12/20 02:14:40 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.813 2008/12/21 03:51:16 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@ -534,6 +534,7 @@ typedef struct TriggerStep TriggerStep;
typedef struct Trigger Trigger;
typedef struct UnpackedRecord UnpackedRecord;
typedef struct Walker Walker;
typedef struct WherePlan WherePlan;
typedef struct WhereInfo WhereInfo;
typedef struct WhereLevel WhereLevel;
@ -1519,50 +1520,74 @@ struct SrcList {
#define JT_OUTER 0x0020 /* The "OUTER" keyword is present */
#define JT_ERROR 0x0040 /* unknown or unsupported join type */
/*
** A WherePlan object holds information that describes a lookup
** strategy.
**
** This object is intended to be opaque outside of the where.c module.
** It is included here only so that that compiler will know how big it
** is. None of the fields in this object should be used outside of
** the where.c module.
**
** Within the union, pIdx is only used when wsFlags&WHERE_INDEXED is true.
** pTerm is only used when wsFlags&WHERE_MULTI_OR is true. And pVtabIdx
** is only used when wsFlags&WHERE_VIRTUALTABLE is true. It is never the
** case that more than one of these conditions is true.
*/
struct WherePlan {
u32 wsFlags; /* WHERE_* flags that describe the strategy */
u32 nEq; /* Number of == constraints */
union {
Index *pIdx; /* Index when WHERE_INDEXED is true */
struct WhereTerm *pTerm; /* WHERE clause term for OR-search */
sqlite3_index_info *pVtabIdx; /* Virtual table index to use */
} u;
};
/*
** For each nested loop in a WHERE clause implementation, the WhereInfo
** structure contains a single instance of this structure. This structure
** is intended to be private the the where.c module and should not be
** access or modified by other modules.
**
** The pIdxInfo and pBestIdx fields are used to help pick the best
** index on a virtual table. The pIdxInfo pointer contains indexing
** The pIdxInfo field is used to help pick the best index on a
** virtual table. The pIdxInfo pointer contains indexing
** information for the i-th table in the FROM clause before reordering.
** All the pIdxInfo pointers are freed by whereInfoFree() in where.c.
** The pBestIdx pointer is a copy of pIdxInfo for the i-th table after
** FROM clause ordering. This is a little confusing so I will repeat
** it in different words. WhereInfo.a[i].pIdxInfo is index information
** for WhereInfo.pTabList.a[i]. WhereInfo.a[i].pBestInfo is the
** index information for the i-th loop of the join. pBestInfo is always
** either NULL or a copy of some pIdxInfo. So for cleanup it is
** sufficient to free all of the pIdxInfo pointers.
**
** All other information in the i-th WhereLevel object for the i-th table
** after FROM clause ordering.
*/
struct WhereLevel {
u32 wsFlags; /* "Where-Scan" flags show the choosen scan strategy */
WherePlan plan; /* query plan for this element of the FROM clause */
int iLeftJoin; /* Memory cell used to implement LEFT OUTER JOIN */
Index *pIdx; /* Index used. NULL if no index */
struct WhereTerm *pTerm; /* Where term containing OR clause */
int iTabCur; /* The VDBE cursor used to access the table */
int iIdxCur; /* The VDBE cursor used to access pIdx */
int addrBrk; /* Jump here to break out of the loop */
int addrNxt; /* Jump here to start the next IN combination */
int addrCont; /* Jump here to continue with the next loop cycle */
int addrFirst; /* First instruction of interior of the loop */
int op, p1, p2; /* Opcode used to terminate the loop */
u8 p5; /* P5 operand of the opcode that terminates the loop */
u8 iFrom; /* Which entry in the FROM clause */
u16 nEq; /* Number of == or IN constraints on this loop */
u16 nIn; /* Number of IN operators constraining this loop */
struct InLoop {
int iCur; /* The VDBE cursor used by this IN operator */
int addrInTop; /* Top of the IN loop */
} *aInLoop; /* Information about each nested IN operator */
sqlite3_index_info *pBestIdx; /* Index information for this level */
u8 op, p5; /* Opcode and P5 of the opcode that ends the loop */
int p1, p2; /* Operands of the opcode used to ends the loop */
union { /* Information that depends on plan.wsFlags */
struct {
int nIn; /* Number of entries in aInLoop[] */
struct InLoop {
int iCur; /* The VDBE cursor used by this IN operator */
int addrInTop; /* Top of the IN loop */
} *aInLoop; /* Information about each nested IN operator */
} in; /* Used when plan.wsFlags&WHERE_IN_ABLE */
struct {
WherePlan *aPlan; /* Plans for each term of the WHERE clause */
} or; /* Used when plan.wsFlags&WHERE_MULTI_OR */
} u;
/* The following field is really not part of the current level. But
** we need a place to cache index information for each table in the
** FROM clause and the WhereLevel structure is a convenient place.
** we need a place to cache virtual table index information for each
** virtual table in the FROM clause and the WhereLevel structure is
** a convenient place since there is one WhereLevel for each FROM clause
** element.
*/
sqlite3_index_info *pIdxInfo; /* Index info for n-th source table */
};
@ -1585,13 +1610,14 @@ struct WhereLevel {
struct WhereInfo {
Parse *pParse; /* Parsing and code generating context */
u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */
SrcList *pTabList; /* List of tables in the join */
int iTop; /* The very beginning of the WHERE loop */
int iContinue; /* Jump here to continue with next record */
int iBreak; /* Jump here to break out of the loop */
int nLevel; /* Number of nested loop */
sqlite3_index_info **apInfo; /* Array of pointers to index info structures */
WhereLevel a[1]; /* Information about each nest loop in the WHERE */
SrcList *pTabList; /* List of tables in the join */
int iTop; /* The very beginning of the WHERE loop */
int iContinue; /* Jump here to continue with next record */
int iBreak; /* Jump here to break out of the loop */
int nLevel; /* Number of nested loop */
struct WhereClause *pWC; /* Decomposition of the WHERE clause */
sqlite3_index_info **apInfo; /* Array of pointers to index info objects */
WhereLevel a[1]; /* Information about each nest loop in WHERE */
};
/*

File diff suppressed because it is too large Load Diff