From 8bc9e8b38de805a0c02db12c6afe796a47b22747 Mon Sep 17 00:00:00 2001 From: Dan Kennedy Date: Tue, 11 Sep 2018 13:38:35 +0000 Subject: [PATCH 0363/1009] Fix a problem causing ENABLE_CURSOR_HINTS builds to segfault. https://github.com/mackyle/sqlite/commit/8bc9e8b38de805a0c02db12c6afe796a47b22747 --- src/wherecode.c | 4 +--- test/cursorhint2.test | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/wherecode.c b/src/wherecode.c index 8251923..07de2c6 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -886,9 +886,7 @@ static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){ if( pExpr->iTable!=pHint->iTabCur ){ Vdbe *v = pWalker->pParse->pVdbe; int reg = ++pWalker->pParse->nMem; /* Register for column value */ - sqlite3ExprCodeGetColumnOfTable( - v, pExpr->pTab, pExpr->iTable, pExpr->iColumn, reg - ); + sqlite3ExprCode(pWalker->pParse, pExpr, reg); pExpr->op = TK_REGISTER; pExpr->iTable = reg; }else if( pHint->pIdx!=0 ){ diff --git a/test/cursorhint2.test b/test/cursorhint2.test index 0175568..a78d151 100644 --- a/test/cursorhint2.test +++ b/test/cursorhint2.test @@ -186,4 +186,19 @@ do_extract_hints_test 2.12 { x2 {EQ(c0,r[2])} } +reset_db +do_execsql_test 3.0 { + CREATE TABLE t1 (i1 TEXT); + CREATE TABLE t2 (i2 TEXT UNIQUE); + INSERT INTO t1 VALUES('0'); + INSERT INTO t2 VALUES('0'); +} + +do_extract_hints_test 3.1 { + SELECT * FROM t1 CROSS JOIN t2 WHERE (t1.i1 = t2.i2) AND t2.i2 = 1; +} { + t1 {EQ(c0,r[1])} t2 EQ(c0,1) +} + + finish_test -- 1.8.3.1