diff options
author | drh <drh@noemail.net> | 2017-11-17 17:32:40 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2017-11-17 17:32:40 +0000 |
commit | 9b1ecb67c3a5bd5a049b4e2c0d027405e991febd (patch) | |
tree | e9f68d75dfd4b8a34ec36accbe1208aba74c4973 | |
parent | 7fc0ba0f4cb864cfb518aae35b6fb4adbe7a12f4 (diff) | |
download | sqlite-9b1ecb67c3a5bd5a049b4e2c0d027405e991febd.tar.gz sqlite-9b1ecb67c3a5bd5a049b4e2c0d027405e991febd.zip |
New assert() statements in the rowvalue IN expression processing.
FossilOrigin-Name: 00c328317473cee8fd7bd92c58409a356337b727cfa562bd8de59350d978769c
-rw-r--r-- | manifest | 12 | ||||
-rw-r--r-- | manifest.uuid | 2 | ||||
-rw-r--r-- | src/wherecode.c | 29 |
3 files changed, 36 insertions, 7 deletions
@@ -1,5 +1,5 @@ -C Clarification\sof\scomments\son\ssqlite3FindInIndex().\s\sNo\schanges\sto\scode. -D 2017-11-17T15:02:00.058 +C New\sassert()\sstatements\sin\sthe\srowvalue\sIN\sexpression\sprocessing. +D 2017-11-17T17:32:40.141 F Makefile.in b142eb20482922153ebc77b261cdfd0a560ed05a81e9f6d9a2b0e8192922a1d2 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc a55372a22454e742ba7c8f6edf05b83213ec01125166ad7dcee0567e2f7fc81b @@ -555,7 +555,7 @@ F src/wal.h 8de5d2d3de0956d6f6cb48c83a4012d5f227b8fe940f3a349a4b7e85ebcb492a F src/walker.c da987a20d40145c0a03c07d8fefcb2ed363becc7680d0500d9c79915591f5b1f F src/where.c 031a80bcafe93934fd7052f3031c9e7eb36b61754c6c84d6bf0833184abad3db F src/whereInt.h 82c04c5075308abbac59180c8bad5ecb45b07453981f60a53f3c7dee21e1e971 -F src/wherecode.c 4a117dd5886616d074f7b6589c23bf742f5a9858d6ffdaf8b9d1f76ab06245d2 +F src/wherecode.c 8605c0ca0c34d4692011cf68a5f4cfc85352c1df917dc6eada320cecc4f5ea73 F src/whereexpr.c 427ea8e96ec24f2a7814c67b8024ad664a9c7656264c4566c34743cb23186e46 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1677,7 +1677,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 93e012a317c8a4bfb84327616a597acabfcb24417197eefdccb8031bcf64e0c0 -R 9e3518c1c08ebf61892be3d9ca3ce745 +P 071cabd23cd010180711a138f891a0e358031dd128532def4f62c5764651bace +R e07fbdd249f84df3df0af0935ae0894c U drh -Z 183368b52c0a93e109b0b85758c70894 +Z dfffcc7482c8c9b6b4a114214fd236e3 diff --git a/manifest.uuid b/manifest.uuid index cea62a5a5..e60558e45 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -071cabd23cd010180711a138f891a0e358031dd128532def4f62c5764651bace
\ No newline at end of file +00c328317473cee8fd7bd92c58409a356337b727cfa562bd8de59350d978769c
\ No newline at end of file diff --git a/src/wherecode.c b/src/wherecode.c index da5c686a9..cc2759eea 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -377,6 +377,27 @@ static void updateRangeAffinityStr( } } +#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 @@ -463,6 +484,14 @@ static int codeEqualityTerm( 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; |