summaryrefslogtreecommitdiffstats
path: root/lib/libsqlite3/src/parse.y
diff options
context:
space:
mode:
authorjturner <jturner@openbsd.org>2014-09-29 22:57:54 +0000
committerjturner <jturner@openbsd.org>2014-09-29 22:57:54 +0000
commitfa0a49b86872bba004e240b6df8c3d650500f032 (patch)
tree5af7f2bfcf89ea797e40928a846edf857845dee7 /lib/libsqlite3/src/parse.y
parentUpdate sqlite3 to 3.8.6. A list of changes are available here: (diff)
downloadwireguard-openbsd-fa0a49b86872bba004e240b6df8c3d650500f032.tar.xz
wireguard-openbsd-fa0a49b86872bba004e240b6df8c3d650500f032.zip
Merge conflicts.
Diffstat (limited to 'lib/libsqlite3/src/parse.y')
-rw-r--r--lib/libsqlite3/src/parse.y27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/libsqlite3/src/parse.y b/lib/libsqlite3/src/parse.y
index ad9bedf0b47..dbc129ce638 100644
--- a/lib/libsqlite3/src/parse.y
+++ b/lib/libsqlite3/src/parse.y
@@ -1020,6 +1020,33 @@ expr(A) ::= expr(W) between_op(N) expr(X) AND expr(Y). [BETWEEN] {
*/
A.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[N]);
sqlite3ExprDelete(pParse->db, X.pExpr);
+ }else if( Y->nExpr==1 ){
+ /* Expressions of the form:
+ **
+ ** expr1 IN (?1)
+ ** expr1 NOT IN (?2)
+ **
+ ** with exactly one value on the RHS can be simplified to something
+ ** like this:
+ **
+ ** expr1 == ?1
+ ** expr1 <> ?2
+ **
+ ** But, the RHS of the == or <> is marked with the EP_Generic flag
+ ** so that it may not contribute to the computation of comparison
+ ** affinity or the collating sequence to use for comparison. Otherwise,
+ ** the semantics would be subtly different from IN or NOT IN.
+ */
+ Expr *pRHS = Y->a[0].pExpr;
+ Y->a[0].pExpr = 0;
+ sqlite3ExprListDelete(pParse->db, Y);
+ /* pRHS cannot be NULL because a malloc error would have been detected
+ ** before now and control would have never reached this point */
+ if( ALWAYS(pRHS) ){
+ pRHS->flags &= ~EP_Collate;
+ pRHS->flags |= EP_Generic;
+ }
+ A.pExpr = sqlite3PExpr(pParse, N ? TK_NE : TK_EQ, X.pExpr, pRHS, 0);
}else{
A.pExpr = sqlite3PExpr(pParse, TK_IN, X.pExpr, 0, 0);
if( A.pExpr ){