/ Check-in [b5ca80d9]

Overview
Comment: Fix an off-by-one error in the WhereCost to integer conversion. Tarball | ZIP archive | SQL archive family | ancestors | descendants | both | files | file ages | folders b5ca80d924f8c6d31f036247ba6e20d234f4482e drh 2013-06-13 14:51:53
Context
 2013-06-13 15:16 Make the MIN() and MAX() macros available in sqliteInt.h. Add TUNING comments to the NGQP and adjust costs slightly. check-in: 3a72af2a user: drh tags: nextgen-query-plan-exp 14:51 Fix an off-by-one error in the WhereCost to integer conversion. check-in: b5ca80d9 user: drh tags: nextgen-query-plan-exp 2013-06-12 20:18 Activate the one-pass optimization. Update comments, especially the descriptions of the various objects. check-in: e120c558 user: drh tags: nextgen-query-plan-exp
Changes

Changes to src/where.c.

```   445    445
446    446
447    447   /* Convert a WhereCost value (10 times log2(X)) into its integer value X.
448    448   ** A rough approximation is used.  The value returned is not exact.
449    449   */
450    450   static u64 whereCostToInt(WhereCost x){
451    451     u64 n;
452         -  if( x<=10 ) return 1;
452  +  if( x<10 ) return 1;
453    453     n = x%10;
454    454     x /= 10;
455    455     if( n>=5 ) n -= 2;
456    456     else if( n>=1 ) n -= 1;
457    457     if( x>=3 ) return (n+8)<<(x-3);
458    458     return (n+8)>>(3-x);
459    459   }

```

Changes to tool/wherecosttest.c.

```    69     69       while( x>255 ){ y += 40; x >>= 4; }
70     70       while( x>15 ){  y += 10; x >>= 1; }
71     71     }
72     72     return a[x&7] + y - 10;
73     73   }
74     74   static unsigned long int whereCostToInt(WhereCost x){
75     75     unsigned long int n;
76         -  if( x<=10 ) return 1;
76  +  if( x<10 ) return 1;
77     77     n = x%10;
78     78     x /= 10;
79     79     if( n>=5 ) n -= 2;
80     80     else if( n>=1 ) n -= 1;
81     81     if( x>=3 ) return (n+8)<<(x-3);
82     82     return (n+8)>>(3-x);
83     83   }

```