diff options
| author | Hans-Christoph Steiner <hans@eds.org> | 2014-10-16 22:51:43 -0400 | 
|---|---|---|
| committer | Hans-Christoph Steiner <hans@eds.org> | 2014-10-16 22:51:43 -0400 | 
| commit | 9f67c0520ea0d5f11a190197cdf746c512db4ce4 (patch) | |
| tree | c88a33f01f20a3d13a09594f114fffacebd0d1a4 /ext/misc/closure.c | |
| parent | ee20336e9c78d2e3782c8d096b9ab4f6ca8ce95f (diff) | |
| parent | 569c6676a6ddb0ff73821d7693b5e18ddef809b9 (diff) | |
Merge tag 'upstream/3.2.0'
Upstream version 3.2.0
# gpg: Signature made Thu 16 Oct 2014 10:51:39 PM EDT using RSA key ID 374BBE81
# gpg: Good signature from "Hans-Christoph Steiner <hans@guardianproject.info>"
# gpg:                 aka "Hans-Christoph Steiner <hans@eds.org>"
# gpg:                 aka "Hans-Christoph Steiner <hans@at.or.at>"
# gpg:                 aka "[jpeg image of size 5408]"
Diffstat (limited to 'ext/misc/closure.c')
| -rw-r--r-- | ext/misc/closure.c | 16 | 
1 files changed, 13 insertions, 3 deletions
| diff --git a/ext/misc/closure.c b/ext/misc/closure.c index 213b763..30c812d 100644 --- a/ext/misc/closure.c +++ b/ext/misc/closure.c @@ -496,7 +496,7 @@ static const char *closureValueOfKey(const char *zKey, const char *zStr){  /*  ** xConnect/xCreate method for the closure module. Arguments are:  ** -**   argv[0]    -> module name  ("approximate_match") +**   argv[0]    -> module name  ("transitive_closure")  **   argv[1]    -> database name  **   argv[2]    -> table name  **   argv[3...] -> arguments @@ -826,11 +826,17 @@ static int closureBestIndex(    int iPlan = 0;    int i;    int idx = 1; +  int seenMatch = 0;    const struct sqlite3_index_constraint *pConstraint;    closure_vtab *pVtab = (closure_vtab*)pTab; +  double rCost = 10000000.0;    pConstraint = pIdxInfo->aConstraint;    for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){ +    if( pConstraint->iColumn==CLOSURE_COL_ROOT +     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){ +      seenMatch = 1; +    }      if( pConstraint->usable==0 ) continue;      if( (iPlan & 1)==0        && pConstraint->iColumn==CLOSURE_COL_ROOT @@ -839,6 +845,7 @@ static int closureBestIndex(        iPlan |= 1;        pIdxInfo->aConstraintUsage[i].argvIndex = 1;        pIdxInfo->aConstraintUsage[i].omit = 1; +      rCost /= 100.0;      }      if( (iPlan & 0x0000f0)==0       && pConstraint->iColumn==CLOSURE_COL_DEPTH @@ -849,6 +856,7 @@ static int closureBestIndex(        iPlan |= idx<<4;        pIdxInfo->aConstraintUsage[i].argvIndex = ++idx;        if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_LT ) iPlan |= 0x000002; +      rCost /= 5.0;      }      if( (iPlan & 0x000f00)==0       && pConstraint->iColumn==CLOSURE_COL_TABLENAME @@ -857,6 +865,7 @@ static int closureBestIndex(        iPlan |= idx<<8;        pIdxInfo->aConstraintUsage[i].argvIndex = ++idx;        pIdxInfo->aConstraintUsage[i].omit = 1; +      rCost /= 5.0;      }      if( (iPlan & 0x00f000)==0       && pConstraint->iColumn==CLOSURE_COL_IDCOLUMN @@ -891,13 +900,14 @@ static int closureBestIndex(    ){      pIdxInfo->orderByConsumed = 1;    } -  pIdxInfo->estimatedCost = (double)10000; +  if( seenMatch && (iPlan&1)==0 ) rCost *= 1e30; +  pIdxInfo->estimatedCost = rCost;    return SQLITE_OK;  }  /* -** A virtual table module that implements the "approximate_match". +** A virtual table module that implements the "transitive_closure".  */  static sqlite3_module closureModule = {    0,                      /* iVersion */ | 
