Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Tweaks to the IN expression code generator. Fix an an unrelated bug in the compound SELECT code generator. (CVS 5318) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a4005782690f022e982df4873779a029 |
User & Date: | drh 2008-06-27 00:47:29.000 |
Context
2008-06-27
| ||
00:52 | Remove unused variable. Fix a compiler warning. (CVS 5319) (check-in: 0b01ec5cf7 user: drh tags: trunk) | |
00:47 | Tweaks to the IN expression code generator. Fix an an unrelated bug in the compound SELECT code generator. (CVS 5318) (check-in: a400578269 user: drh tags: trunk) | |
2008-06-26
| ||
21:45 | Fix a bug introduced by check-in (5316). Add some VDBE comments to the IN expression code generator. (CVS 5317) (check-in: 1043a605e2 user: drh tags: trunk) | |
Changes
Changes to src/expr.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** ** $Id: expr.c,v 1.380 2008/06/27 00:47:29 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** Return the 'affinity' of the expression pExpr if any. ** |
︙ | ︙ | |||
2590 2591 2592 2593 2594 2595 2596 | /* Figure out the affinity to use to create a key from the results ** of the expression. affinityStr stores a static string suitable for ** P4 of OP_MakeRecord. */ affinity = comparisonAffinity(pExpr); | < > | < > | < < < | | > | | | 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 | /* Figure out the affinity to use to create a key from the results ** of the expression. affinityStr stores a static string suitable for ** P4 of OP_MakeRecord. */ affinity = comparisonAffinity(pExpr); /* Code the <expr> from "<expr> IN (...)". The temporary table ** pExpr->iTable contains the values that make up the (...) set. */ pParse->disableColCache++; sqlite3ExprCode(pParse, pExpr->pLeft, target); pParse->disableColCache--; j2 = sqlite3VdbeAddOp1(v, OP_IsNull, target); if( eType==IN_INDEX_ROWID ){ j3 = sqlite3VdbeAddOp1(v, OP_MustBeInt, target); j4 = sqlite3VdbeAddOp3(v, OP_NotExists, pExpr->iTable, 0, target); sqlite3VdbeAddOp2(v, OP_Integer, 1, target); j5 = sqlite3VdbeAddOp0(v, OP_Goto); sqlite3VdbeJumpHere(v, j3); sqlite3VdbeJumpHere(v, j4); sqlite3VdbeAddOp2(v, OP_Integer, 0, target); }else{ r2 = regFree2 = sqlite3GetTempReg(pParse); /* Create a record and test for set membership. If the set contains ** the value, then jump to the end of the test code. The target ** register still contains the true (1) value written to it earlier. */ sqlite3VdbeAddOp4(v, OP_MakeRecord, target, 1, r2, &affinity, 1); sqlite3VdbeAddOp2(v, OP_Integer, 1, target); j5 = sqlite3VdbeAddOp3(v, OP_Found, pExpr->iTable, 0, r2); /* If the set membership test fails, then the result of the ** "x IN (...)" expression must be either 0 or NULL. If the set ** contains no NULL values, then the result is 0. If the set ** contains one or more NULL values, then the result of the ** expression is also NULL. |
︙ | ︙ | |||
2640 2641 2642 2643 2644 2645 2646 2647 2648 | /* This block populates the rNotFound register with either NULL ** or 0 (an integer value). If the data structure contains one ** or more NULLs, then set rNotFound to NULL. Otherwise, set it ** to 0. If register rMayHaveNull is already set to some value ** other than NULL, then the test has already been run and ** rNotFound is already populated. */ j3 = sqlite3VdbeAddOp1(v, OP_NotNull, rMayHaveNull); sqlite3VdbeAddOp2(v, OP_Null, 0, rNotFound); | > | | | | 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 | /* This block populates the rNotFound register with either NULL ** or 0 (an integer value). If the data structure contains one ** or more NULLs, then set rNotFound to NULL. Otherwise, set it ** to 0. If register rMayHaveNull is already set to some value ** other than NULL, then the test has already been run and ** rNotFound is already populated. */ static const char nullRecord[] = { 0x02, 0x00 }; j3 = sqlite3VdbeAddOp1(v, OP_NotNull, rMayHaveNull); sqlite3VdbeAddOp2(v, OP_Null, 0, rNotFound); sqlite3VdbeAddOp4(v, OP_Blob, 2, rMayHaveNull, 0, nullRecord, P4_STATIC); j4 = sqlite3VdbeAddOp3(v, OP_Found, pExpr->iTable, 0, rMayHaveNull); sqlite3VdbeAddOp2(v, OP_Integer, 0, rNotFound); sqlite3VdbeJumpHere(v, j4); sqlite3VdbeJumpHere(v, j3); /* Copy the value of register rNotFound (which is either NULL or 0) ** into the target register. This will be the result of the ** expression. |
︙ | ︙ |
Changes to src/select.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** ** $Id: select.c,v 1.438 2008/06/27 00:47:29 drh Exp $ */ #include "sqliteInt.h" /* ** Delete all the content of a Select structure but do not deallocate ** the select structure itself. |
︙ | ︙ | |||
2336 2337 2338 2339 2340 2341 2342 | KeyInfo *pKeyInfo, /* For comparing with previous entry */ int p4type, /* The p4 type for pKeyInfo */ int iBreak /* Jump here if we hit the LIMIT */ ){ Vdbe *v = pParse->pVdbe; int iContinue; int addr; | | | 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 | KeyInfo *pKeyInfo, /* For comparing with previous entry */ int p4type, /* The p4 type for pKeyInfo */ int iBreak /* Jump here if we hit the LIMIT */ ){ Vdbe *v = pParse->pVdbe; int iContinue; int addr; if( pParse->db->mallocFailed ) return 0; addr = sqlite3VdbeCurrentAddr(v); iContinue = sqlite3VdbeMakeLabel(v); /* Suppress duplicates for UNION, EXCEPT, and INTERSECT */ if( regPrev ){ |
︙ | ︙ |