diff options
author | drh <drh@noemail.net> | 2013-06-03 21:25:28 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-06-03 21:25:28 +0000 |
commit | a3855653ed06222b8c0f0329a4ab23ea8a8adbbb (patch) | |
tree | e1f96b0c32b5e76d33f57dc9c30bc446252786ef /ext/misc/fuzzer.c | |
parent | 45c154ac90fa300d509e8844b345c3e7645e6f17 (diff) | |
download | sqlite-a3855653ed06222b8c0f0329a4ab23ea8a8adbbb.tar.gz sqlite-a3855653ed06222b8c0f0329a4ab23ea8a8adbbb.zip |
Adjust the xBestIndex methods on both the fuzzer and transitive_closure
virtual tables so that an unused MATCH operator gets a really large cost.
Remove ambiguities from the fuzzer test cases.
FossilOrigin-Name: e2c1af78b65a8ace976fa6c035db212e1ffc79b8
Diffstat (limited to 'ext/misc/fuzzer.c')
-rw-r--r-- | ext/misc/fuzzer.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ext/misc/fuzzer.c b/ext/misc/fuzzer.c index 642b8f9e9..023bdb1d0 100644 --- a/ext/misc/fuzzer.c +++ b/ext/misc/fuzzer.c @@ -1077,9 +1077,16 @@ static int fuzzerBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ int iDistTerm = -1; int iRulesetTerm = -1; int i; + int seenMatch = 0; const struct sqlite3_index_constraint *pConstraint; + double rCost = 100000; + pConstraint = pIdxInfo->aConstraint; for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){ + if( pConstraint->iColumn==0 + && pConstraint->op==SQLITE_INDEX_CONSTRAINT_MATCH ){ + seenMatch = 1; + } if( pConstraint->usable==0 ) continue; if( (iPlan & 1)==0 && pConstraint->iColumn==0 @@ -1088,6 +1095,7 @@ static int fuzzerBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ iPlan |= 1; pIdxInfo->aConstraintUsage[i].argvIndex = 1; pIdxInfo->aConstraintUsage[i].omit = 1; + rCost /= 1000000.0; } if( (iPlan & 2)==0 && pConstraint->iColumn==1 @@ -1096,6 +1104,7 @@ static int fuzzerBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ ){ iPlan |= 2; iDistTerm = i; + rCost /= 10.0; } if( (iPlan & 4)==0 && pConstraint->iColumn==2 @@ -1104,6 +1113,7 @@ static int fuzzerBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ iPlan |= 4; pIdxInfo->aConstraintUsage[i].omit = 1; iRulesetTerm = i; + rCost /= 10.0; } } if( iPlan & 2 ){ @@ -1122,7 +1132,8 @@ static int fuzzerBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ ){ pIdxInfo->orderByConsumed = 1; } - pIdxInfo->estimatedCost = (double)10000; + if( seenMatch && (iPlan&1)==0 ) rCost *= 1e30; + pIdxInfo->estimatedCost = rCost; return SQLITE_OK; } |