Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch branch-3.6.21 Excluding Merge-Ins
This is equivalent to a diff from 1ed88e9d01 to 867347323b
2009-12-16
| ||
23:28 | Fix for the "(x AND y) OR z" bug backported to version 3.6.21. (Leaf check-in: 867347323b user: drh tags: branch-3.6.21) | |
2009-12-08
| ||
02:06 | Add evidence marks for the abs() and soundex() SQL functions. (check-in: 003f3ed10c user: drh tags: trunk) | |
2009-12-07
| ||
23:53 | Merge all changes associated with the version 3.6.21 release into the OS-X branch. (check-in: ad08794d72 user: drh tags: apple-osx) | |
16:39 | Version 3.6.21 (check-in: 1ed88e9d01 user: drh tags: trunk, release) | |
16:26 | Remove a redundant line from fts3. (check-in: cd50acf37f user: dan tags: trunk) | |
Changes to VERSION.
| 1 | - + |
|
Changes to src/sqliteInt.h.
︙ | |||
1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 | 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 | + + | #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ #define WHERE_OMIT_OPEN 0x0010 /* Table cursor are already open */ #define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */ #define WHERE_FORCE_TABLE 0x0040 /* Do not use an index-only search */ #define WHERE_ONETABLE_ONLY 0x0080 /* Only code the 1st table in pTabList */ /* ** The WHERE clause processing routine has two halves. The ** first part does the start of the WHERE loop and the second ** half does the tail of the WHERE loop. An instance of ** this structure is returned by the first half and passed ** into the second half to give some continuity. */ struct WhereInfo { Parse *pParse; /* Parsing and code generating context */ u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */ u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ 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 */ WhereLevel a[1]; /* Information about each nest loop in WHERE */ |
︙ |
Changes to src/where.c.
︙ | |||
3261 3262 3263 3264 3265 3266 3267 | 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 | - + + + + - - - - + + + + + + + + + + + + + + + + + + + + | ** Return 2 # Jump back to the Gosub ** ** B: <after the loop> ** */ WhereClause *pOrWc; /* The OR-clause broken out into subterms */ WhereTerm *pFinal; /* Final subterm within the OR-clause. */ |
︙ | |||
3305 3306 3307 3308 3309 3310 3311 | 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 | - - + + + + + + + + + + - - + - - + | iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn); for(ii=0; ii<pOrWc->nTerm; ii++){ WhereTerm *pOrTerm = &pOrWc->a[ii]; if( pOrTerm->leftCursor==iCur || pOrTerm->eOperator==WO_AND ){ WhereInfo *pSubWInfo; /* Info for single OR-term scan */ /* Loop through table entries that match term pOrTerm. */ |
︙ | |||
3358 3359 3360 3361 3362 3363 3364 | 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 | - + + + + + + | */ k = 0; for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ Expr *pE; testcase( pTerm->wtFlags & TERM_VIRTUAL ); testcase( pTerm->wtFlags & TERM_CODED ); if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
︙ | |||
3381 3382 3383 3384 3385 3386 3387 | 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 | - + + + + | sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin); VdbeComment((v, "record LEFT JOIN hit")); sqlite3ExprCacheClear(pParse); for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){ testcase( pTerm->wtFlags & TERM_VIRTUAL ); testcase( pTerm->wtFlags & TERM_CODED ); if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
︙ | |||
3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 | 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 | + + + + + + + + - + - + - + + + + + + | SrcList *pTabList, /* A list of all tables to be scanned */ Expr *pWhere, /* The WHERE clause */ ExprList **ppOrderBy, /* An ORDER BY clause, or NULL */ u16 wctrlFlags /* One of the WHERE_* flags defined in sqliteInt.h */ ){ int i; /* Loop counter */ int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */ int nTabList; /* Number of elements in pTabList */ WhereInfo *pWInfo; /* Will become the return value of this function */ Vdbe *v = pParse->pVdbe; /* The virtual database engine */ Bitmask notReady; /* Cursors that are not yet positioned */ WhereMaskSet *pMaskSet; /* The expression mask set */ WhereClause *pWC; /* Decomposition of the WHERE clause */ struct SrcList_item *pTabItem; /* A single entry from pTabList */ WhereLevel *pLevel; /* A single level in the pWInfo list */ int iFrom; /* First unused FROM clause element */ int andFlags; /* AND-ed combination of all pWC->a[].wtFlags */ sqlite3 *db; /* Database connection */ /* The number of tables in the FROM clause is limited by the number of ** bits in a Bitmask */ if( pTabList->nSrc>BMS ){ sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS); return 0; } /* This function normally generates a nested loop for all tables in ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should ** only generate code for the first table in pTabList and assume that ** any cursors associated with subsequent tables are uninitialized. */ nTabList = (wctrlFlags & WHERE_ONETABLE_ONLY) ? 1 : pTabList->nSrc; /* Allocate and initialize the WhereInfo structure that will become the ** return value. A single allocation is used to store the WhereInfo ** struct, the contents of WhereInfo.a[], the WhereClause structure ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte ** field (type Bitmask) it must be aligned on an 8-byte boundary on ** some architectures. Hence the ROUND8() below. */ db = pParse->db; |
︙ | |||
3650 3651 3652 3653 3654 3655 3656 | 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 | - + | ** clause. */ notReady = ~(Bitmask)0; pTabItem = pTabList->a; pLevel = pWInfo->a; andFlags = ~0; WHERETRACE(("*** Optimizer Start ***\n")); |
︙ | |||
3695 3696 3697 3698 3699 3700 3701 | 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 | - - + + | ** However, since the cost of a linear scan through table t2 is the same ** as the cost of a linear scan through table t1, a simple greedy ** algorithm may choose to use t2 for the outer loop, which is a much ** costlier approach. */ for(isOptimal=1; isOptimal>=0 && bestJ<0; isOptimal--){ Bitmask mask = (isOptimal ? 0 : notReady); |
︙ | |||
3793 3794 3795 3796 3797 3798 3799 | 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 | - + | pWInfo->a[0].plan.wsFlags &= ~WHERE_IDX_ONLY; } /* Open all tables in the pTabList and any indices selected for ** searching those tables. */ sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */ |
︙ | |||
3872 3873 3874 3875 3876 3877 3878 | 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 | - + - + | pWInfo->iTop = sqlite3VdbeCurrentAddr(v); /* Generate the code to do the search. Each iteration of the for ** loop below generates code for a single nested loop of the VM ** program. */ notReady = ~(Bitmask)0; |
︙ | |||
3952 3953 3954 3955 3956 3957 3958 | 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 | - + | WhereLevel *pLevel; SrcList *pTabList = pWInfo->pTabList; sqlite3 *db = pParse->db; /* Generate loop termination code. */ sqlite3ExprCacheClear(pParse); |
︙ | |||
3998 3999 4000 4001 4002 4003 4004 | 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 | + - + | /* 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 opened by sqlite3WhereBegin. */ assert( pWInfo->nLevel==1 || pWInfo->nLevel==pTabList->nSrc ); |
︙ |
Added test/tkt-31338dca7e.test.
|
Changes to test/where8.test.
︙ | |||
394 395 396 397 398 399 400 401 402 403 404 405 406 407 | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | + + + + | INSERT INTO t4 VALUES(378678316.5, 'his', 'Alpine'); INSERT INTO t4 VALUES('from', 'of', 'all'); INSERT INTO t4 VALUES(0938446095, 'same', NULL); INSERT INTO t4 VALUES(0938446095, 'Alpine', NULL); INSERT INTO t4 VALUES('his', 'of', 378678316.5); INSERT INTO t4 VALUES(271.2019091, 'viewed', 3282306647); INSERT INTO t4 VALUES('hills', 'all', 'peak'); CREATE TABLE t5(s); INSERT INTO t5 VALUES('tab-t5'); CREATE TABLE t6(t); INSERT INTO t6 VALUES(123456); COMMIT; } } {} catch {unset results} catch {unset A} catch {unset B} |
︙ | |||
635 636 637 638 639 640 641 642 643 644 645 646 647 648 | 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | + + + + + + + + | 193 { SELECT * FROM t3, t4 WHERE c >= g OR 'writings' >= c AND b = 'all' } 194 { SELECT * FROM t3, t4 WHERE 'remarkably' < g } 195 { SELECT * FROM t3, t4 WHERE a BETWEEN 'or' AND 'paintings' AND g <= f } 196 { SELECT * FROM t3, t4 WHERE 0938446095 > b OR g <= a OR h > b } 197 { SELECT * FROM t3, t4 WHERE g = 2643383279 AND f = g } 198 { SELECT * FROM t3, t4 WHERE g < 8979323846 } 199 { SELECT * FROM t3, t4 WHERE 'are' <= b } 200 { SELECT * FROM t3, t4 WHERE (a=1415926535 AND f=8628034825) OR (a=6939937510 AND f=2643383279) } 201 { SELECT * FROM t3, t4, t5, t6 WHERE (a=1415926535 AND f=8628034825 AND s!='hello' AND t!=5) OR (a=6939937510 AND f=2643383279 AND s='tab-t5' AND t=123456) } 202 { SELECT * FROM t3, t4, t5, t6 WHERE (a=1415926535 AND f=8628034825 AND s!='hello' AND t==5) OR (a=6939937510 AND f=2643383279 AND s='tab-t5' AND t!=123456) } } { do_test where8-4.$A.$B.1 { unset -nocomplain R set R [execsql $sql] if {![info exists results($B)]} { set results($B) $R |
︙ |