Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix comment typos. no code changes. (CVS 2173) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
4165217e5114f5377f0823c63ff2aba8 |
User & Date: | drh 2005-01-03 01:27:19.000 |
Context
2005-01-03
| ||
01:28 | Fix a typo in a comment. No code changes. Ticket #1052. (CVS 2174) (check-in: 9fb1402f08 user: drh tags: trunk) | |
01:27 | Fix comment typos. no code changes. (CVS 2173) (check-in: 4165217e51 user: drh tags: trunk) | |
2004-12-25
| ||
01:03 | Fix ticket #1046 by removing code and simplifying the query optimizer. Remarkably, this simplification also makes the optimizer do a better job. Ticket #1051 was fixed as a side-effect. (CVS 2172) (check-in: 5fd1f47118 user: drh tags: trunk) | |
Changes
Changes to src/sqliteInt.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.350 2005/01/03 01:27:19 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** These #defines should enable >2GB file support on Posix if the ** underlying operating system supports it. If the OS lacks |
︙ | ︙ | |||
910 911 912 913 914 915 916 | ** access or modified by other modules. */ struct WhereLevel { int iMem; /* Memory cell used by this level */ 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 */ | | | 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | ** access or modified by other modules. */ struct WhereLevel { int iMem; /* Memory cell used by this level */ 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 */ |
︙ | ︙ |
Changes to src/where.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is reponsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is reponsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** ** $Id: where.c,v 1.125 2005/01/03 01:27:19 drh Exp $ */ #include "sqliteInt.h" /* ** The query generator uses an array of instances of this structure to ** help it analyze the subexpressions of the WHERE clause. Each WHERE ** clause subexpression is separated from the others by an AND operator. |
︙ | ︙ | |||
492 493 494 495 496 497 498 | ** The number of bits in a Bitmask */ #define BMS (sizeof(Bitmask)*8-1) /* ** Generate the beginning of the loop used for WHERE clause processing. | | | 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | ** The number of bits in a Bitmask */ #define BMS (sizeof(Bitmask)*8-1) /* ** Generate the beginning of the loop used for WHERE clause processing. ** The return value is a pointer to an opaque structure that contains ** information needed to terminate the loop. Later, the calling routine ** should invoke sqlite3WhereEnd() with the return value of this function ** in order to complete the WHERE clause processing. ** ** If an error occurs, this routine returns NULL. ** ** The basic idea is to do a nested loop, one loop for each table in |
︙ | ︙ | |||
725 726 727 728 729 730 731 | continue; } /* Do a search for usable indices. Leave pBestIdx pointing to ** the "best" index. pBestIdx is left set to NULL if no indices ** are usable. ** | > | | 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 | continue; } /* Do a search for usable indices. Leave pBestIdx pointing to ** the "best" index. pBestIdx is left set to NULL if no indices ** are usable. ** ** The best index is the one with the highest score. The score ** for the index is determined as follows. For each of the ** left-most terms that is fixed by an equality operator, add ** 32 to the score. The right-most term of the index may be ** constrained by an inequality. Add 4 if for an "x<..." constraint ** and add 8 for an "x>..." constraint. If both constraints ** are present, add 12. ** ** If the left-most term of the index uses an IN operator |
︙ | ︙ | |||
1364 1365 1366 1367 1368 1369 1370 | } /* The "break" point is here, just past the end of the outer loop. ** Set it. */ sqlite3VdbeResolveLabel(v, pWInfo->iBreak); | | | | 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 | } /* The "break" point is here, just past the end of the outer loop. ** Set it. */ sqlite3VdbeResolveLabel(v, pWInfo->iBreak); /* Close all of the cursors that were opend by sqlite3WhereBegin. */ pLevel = pWInfo->a; pTabItem = pTabList->a; for(i=0; i<pTabList->nSrc; i++, pTabItem++, pLevel++){ Table *pTab = pTabItem->pTab; assert( pTab!=0 ); if( pTab->isTransient || pTab->pSelect ) continue; if( (pLevel->score & 1)==0 ){ sqlite3VdbeAddOp(v, OP_Close, pTabItem->iCursor, 0); } if( pLevel->pIdx!=0 ){ sqlite3VdbeAddOp(v, OP_Close, pLevel->iIdxCur, 0); } /* Make cursor substitutions for cases where we want to use ** just the index and never reference the table. ** ** Calls to the code generator in between sqlite3WhereBegin and ** sqlite3WhereEnd will have created code that references the table ** directly. This loop scans all that code looking for opcodes ** that reference the table and converts them into opcodes that ** reference the index. |
︙ | ︙ |