/ Check-in [00c32831]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:New assert() statements in the rowvalue IN expression processing.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 00c328317473cee8fd7bd92c58409a356337b727cfa562bd8de59350d978769c
User & Date: drh 2017-11-17 17:32:40
Context
2017-11-17
20:07
Add some missing "finish_test" lines to the end of test scripts. check-in: c21406ab user: dan tags: trunk
17:32
New assert() statements in the rowvalue IN expression processing. check-in: 00c32831 user: drh tags: trunk
15:02
Clarification of comments on sqlite3FindInIndex(). No changes to code. check-in: 071cabd2 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/wherecode.c.

372
373
374
375
376
377
378





















379
380
381
382
383
384
385
...
459
460
461
462
463
464
465








466
467
468
469
470
471
472
    if( sqlite3CompareAffinity(p, zAff[i])==SQLITE_AFF_BLOB
     || sqlite3ExprNeedsNoAffinityChange(p, zAff[i])
    ){
      zAff[i] = SQLITE_AFF_BLOB;
    }
  }
}






















/*
** Generate code for a single equality term of the WHERE clause.  An equality
** term can be either X=expr or X IN (...).   pTerm is the term to be 
** coded.
**
** The current value for the constraint is left in a register, the index
................................................................................
          Expr *pNewRhs = sqlite3ExprDup(db, pOrigRhs->a[iField].pExpr, 0);
          Expr *pNewLhs = sqlite3ExprDup(db, pOrigLhs->a[iField].pExpr, 0);

          pRhs = sqlite3ExprListAppend(pParse, pRhs, pNewRhs);
          pLhs = sqlite3ExprListAppend(pParse, pLhs, pNewLhs);
        }
      }








      if( !db->mallocFailed ){
        Expr *pLeft = pX->pLeft;

        if( pSelect->pOrderBy ){
          /* If the SELECT statement has an ORDER BY clause, zero the 
          ** iOrderByCol variables. These are set to non-zero when an 
          ** ORDER BY term exactly matches one of the terms of the 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
...
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
    if( sqlite3CompareAffinity(p, zAff[i])==SQLITE_AFF_BLOB
     || sqlite3ExprNeedsNoAffinityChange(p, zAff[i])
    ){
      zAff[i] = SQLITE_AFF_BLOB;
    }
  }
}

#ifdef SQLITE_DEBUG
/* Return true if the pSub ExprList is a subset of pMain.  The terms
** of pSub can be in a different order from pMain.  The only requirement
** is that every term in pSub must exist somewhere in pMain.
**
** Return false if pSub contains any term that is not found in pMain.
*/
static int exprListSubset(ExprList *pSub, ExprList *pMain){
  int i, j;
  for(i=0; i<pSub->nExpr; i++){
    Expr *p = pSub->a[i].pExpr;
    for(j=0; j<pMain->nExpr; j++){
      if( sqlite3ExprCompare(0, p, pMain->a[j].pExpr, 0)==0 ) break;
    }
    if( j>=pMain->nExpr ) return 0;
  }
  return 1;
}
#endif /* SQLITE_DEBUG */


/*
** Generate code for a single equality term of the WHERE clause.  An equality
** term can be either X=expr or X IN (...).   pTerm is the term to be 
** coded.
**
** The current value for the constraint is left in a register, the index
................................................................................
          Expr *pNewRhs = sqlite3ExprDup(db, pOrigRhs->a[iField].pExpr, 0);
          Expr *pNewLhs = sqlite3ExprDup(db, pOrigLhs->a[iField].pExpr, 0);

          pRhs = sqlite3ExprListAppend(pParse, pRhs, pNewRhs);
          pLhs = sqlite3ExprListAppend(pParse, pLhs, pNewLhs);
        }
      }
 
      /* pRhs should be a subset of pOrigRhs (though possibly in a different
      ** order).  And pLhs should be a subset of pOrigLhs.  To put it 
      ** another way:  Every term of pRhs should exist in pOrigRhs and
      ** every term of pLhs should exist in pOrigLhs. */
      assert( db->mallocFailed || exprListSubset(pRhs, pOrigRhs) );
      assert( db->mallocFailed || exprListSubset(pLhs, pOrigLhs) );

      if( !db->mallocFailed ){
        Expr *pLeft = pX->pLeft;

        if( pSelect->pOrderBy ){
          /* If the SELECT statement has an ORDER BY clause, zero the 
          ** iOrderByCol variables. These are set to non-zero when an 
          ** ORDER BY term exactly matches one of the terms of the