From: D. Richard Hipp Date: Sat, 3 Nov 2018 13:11:24 +0000 (+0000) Subject: Fix a assert() in the query planner that can arise when doing row-value X-Git-Url: https://repo.or.cz/sqlite.git/commitdiff_plain/24298027a30cf7941f16a8cc878d0c1f9f14308f Fix a assert() in the query planner that can arise when doing row-value operations on a PRIMARY KEY that contains duplicate columns. Ticket [1a84668dcfdebaf12415d]. --- diff --git a/src/wherecode.c b/src/wherecode.c index f337006b97..e371cb853d 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -425,7 +425,7 @@ static Expr *removeUnindexableInClauseTerms( for(i=iEq; inLTerm; i++){ if( pLoop->aLTerm[i]->pExpr==pX ){ int iField = pLoop->aLTerm[i]->iField - 1; - assert( pOrigRhs->a[iField].pExpr!=0 ); + if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */ pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr); pOrigRhs->a[iField].pExpr = 0; assert( pOrigLhs->a[iField].pExpr!=0 ); diff --git a/test/rowvalue.test b/test/rowvalue.test index b8ba2e0447..2a2f8a9d13 100644 --- a/test/rowvalue.test +++ b/test/rowvalue.test @@ -546,4 +546,15 @@ do_catchsql_test 20.1 { SELECT 1 WHERE (2,(2,0)) IS (2,(2,0)); } {0 1} +# 2018-11-03: Ticket https://www.sqlite.org/src/info/1a84668dcfdebaf1 +# Assertion fault when doing row-value operations on a primary key +# containing duplicate columns. +# +do_execsql_test 21.0 { + DROP TABLE IF EXISTS t1; + CREATE TABLE t1(a,b,PRIMARY KEY(b,b)); + INSERT INTO t1 VALUES(1,2),(3,4),(5,6); + SELECT * FROM t1 WHERE (a,b) IN (VALUES(1,2)); +} {1 2} + finish_test