From 84e30ca0ed0953a6b838d5c86e1105dd497f3ac8 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 10 Feb 2011 17:46:14 +0000 Subject: [PATCH] Prevent a segfault when automatic indices try to use a column with an unknown collating function. Ticket [77aa3b1e6592582e38605d36]. This check-in also removes some stray \r characters unrelated to the problem. FossilOrigin-Name: f01030a0df4f94f886ab209ee8766b095da28c1e --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/expr.c | 6 +++--- src/where.c | 3 ++- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 410f03eb5d..962d259cbb 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Refactor\sthe\scost\sfunction\sin\sthe\squery\splanner.\s\sGive\sextra\scost\s(thus\nreduce\slikelihood\sof\sselection)\sto\sfull\stable\sscans. -D 2011-02-10T00:08:47.701 +C Prevent\sa\ssegfault\swhen\sautomatic\sindices\stry\sto\suse\sa\scolumn\swith\san\nunknown\scollating\sfunction.\s\sTicket\s[77aa3b1e6592582e38605d36].\s\sThis\ncheck-in\salso\sremoves\ssome\sstray\s\\r\scharacters\sunrelated\sto\sthe\sproblem. +D 2011-02-10T17:46:14.555 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -132,7 +132,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 F src/date.c 1548fdac51377e4e7833251de878b4058c148e1b F src/delete.c 7ed8a8c8b5f748ece92df173d7e0f7810c899ebd -F src/expr.c 9b02a6dc3c7b97be01619674abebb59ed8830f1d +F src/expr.c 400e27db545e0d8b3b18043363294b525596f507 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 17950a28f28b23e8ad3feaac5fc88c324d2f600a F src/func.c cb41f614edc43b00bfeb030f9768e80eaff47edd @@ -244,7 +244,7 @@ F src/vtab.c b297e8fa656ab5e66244ab15680d68db0adbec30 F src/wal.c aca10a60655e103fc8630a75345000f43c6d47ca F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c 83a89fe4822caf45391459224891b66d3e2ba237 +F src/where.c ebecb7b9e08cf1c0bf84bbc26756ff09e9479f08 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 51756962d522e474338e9b2ebb26e7364d4aa125 @@ -909,14 +909,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 7cc515edc9cade2bc6c74699b3e4153bf2b74ebb -R 08fe91f055ce4403c87684038df163cb +P 878da276ebf643b716ddd650d4d0ca3595fe5bf2 +R 7115e9b9167d54b1bd5babaa217ab874 U drh -Z 1ef92ed18aa7502ebbef18dbb05b7e9d +Z a8209f45d500942f895f6428366345d2 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNUyyToxKgR168RlERAiF4AKCIVGuKzORossDsmQaAQbZKU4Xd/gCfWOhI -4aKFZ+7oNbX7dj0deyXznl8= -=Ts3F +iD8DBQFNVCRpoxKgR168RlERAt6wAJoDNGsC+YrJposBo+/cLnxCnBAN3gCfbqz3 +zSgAQldrrpVNMc5IxEfC5AM= +=muXT -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 9097819203..96301c157d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -878da276ebf643b716ddd650d4d0ca3595fe5bf2 \ No newline at end of file +f01030a0df4f94f886ab209ee8766b095da28c1e \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 8c68d9d658..f624133428 100644 --- a/src/expr.c +++ b/src/expr.c @@ -92,7 +92,7 @@ Expr *sqlite3ExprSetCollByToken(Parse *pParse, Expr *pExpr, Token *pCollName){ CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){ CollSeq *pColl = 0; Expr *p = pExpr; - while( ALWAYS(p) ){ + while( p ){ int op; pColl = p->pColl; if( pColl ) break; @@ -3251,7 +3251,7 @@ void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){ exprCodeBetween(pParse, pExpr, dest, 1, jumpIfNull); break; } -#ifndef SQLITE_OMIT_SUBQUERY +#ifndef SQLITE_OMIT_SUBQUERY case TK_IN: { int destIfFalse = sqlite3VdbeMakeLabel(v); int destIfNull = jumpIfNull ? dest : destIfFalse; @@ -3394,7 +3394,7 @@ void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){ exprCodeBetween(pParse, pExpr, dest, 0, jumpIfNull); break; } -#ifndef SQLITE_OMIT_SUBQUERY +#ifndef SQLITE_OMIT_SUBQUERY case TK_IN: { if( jumpIfNull ){ sqlite3ExprCodeIN(pParse, pExpr, dest, dest); diff --git a/src/where.c b/src/where.c index d3356cee78..2fc0a80feb 100644 --- a/src/where.c +++ b/src/where.c @@ -1882,7 +1882,8 @@ static void constructAutomaticIndex( idxCols |= cMask; pIdx->aiColumn[n] = pTerm->u.leftColumn; pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); - pIdx->azColl[n] = pColl->zName; + assert( pColl!=0 || pParse->nErr>0 ); + pIdx->azColl[n] = pColl ? pColl->zName : "BINARY"; n++; } }