aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2014-10-25 13:42:16 +0000
committerdrh <drh@noemail.net>2014-10-25 13:42:16 +0000
commitd05ab6aacf08a1fd7af581cae4b28390ecd5c44c (patch)
treea0d6853758bf5745ff18c58bd46a650c12c0cf1c /src
parent051575cbf4c47fc472f53146e30d6ddddc9054b3 (diff)
downloadsqlite-d05ab6aacf08a1fd7af581cae4b28390ecd5c44c.tar.gz
sqlite-d05ab6aacf08a1fd7af581cae4b28390ecd5c44c.zip
Increase the resolution of the second parameter to the likelihood() SQL
function (the probability value) so that it can handle probabilities as small as 0.00000001. Formerly, it ran out of precision at 0.001. FossilOrigin-Name: 0f08924fe0c52a85a103f67bee9809e0f8f884b0
Diffstat (limited to 'src')
-rw-r--r--src/resolve.c4
-rw-r--r--src/sqliteInt.h2
-rw-r--r--src/where.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/resolve.c b/src/resolve.c
index e507ccb81..8fb580b3a 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -584,7 +584,7 @@ static int exprProbability(Expr *p){
sqlite3AtoF(p->u.zToken, &r, sqlite3Strlen30(p->u.zToken), SQLITE_UTF8);
assert( r>=0.0 );
if( r>1.0 ) return -1;
- return (int)(r*1000.0);
+ return (int)(r*134217728.0);
}
/*
@@ -716,7 +716,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent to
** likelihood(X,0.9375). */
/* TUNING: unlikely() probability is 0.0625. likely() is 0.9375 */
- pExpr->iTable = pDef->zName[0]=='u' ? 62 : 938;
+ pExpr->iTable = pDef->zName[0]=='u' ? 8388608 : 125829120;
}
}
#ifndef SQLITE_OMIT_AUTHORIZATION
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index b7f992c34..5114ccccf 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -2000,7 +2000,7 @@ struct Expr {
int iTable; /* TK_COLUMN: cursor number of table holding column
** TK_REGISTER: register number
** TK_TRIGGER: 1 -> new, 0 -> old
- ** EP_Unlikely: 1000 times likelihood */
+ ** EP_Unlikely: 134217728 times likelihood */
ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
** TK_VARIABLE: variable number (always >= 1). */
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
diff --git a/src/where.c b/src/where.c
index 2e42b8fc3..358d50826 100644
--- a/src/where.c
+++ b/src/where.c
@@ -225,7 +225,7 @@ static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
}
pTerm = &pWC->a[idx = pWC->nTerm++];
if( p && ExprHasProperty(p, EP_Unlikely) ){
- pTerm->truthProb = sqlite3LogEst(p->iTable) - 99;
+ pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;
}else{
pTerm->truthProb = 1;
}