Fix a problems that arise if malloc() fails while compiling SELECT

statements within a TRIGGER. (CVS 3478)

FossilOrigin-Name: ee4894b49995e4904db1991281563cfbb7b1c16d
This commit is contained in:
drh 2006-10-18 23:26:38 +00:00
parent f6bbe022c7
commit 28f4591466
5 changed files with 25 additions and 18 deletions

View File

@ -1,5 +1,5 @@
C Make\ssure\sthe\snames\sof\sall\sexpressions\sin\scompound\sSELECT\sstatements\sused\nas\ssubqueries\sare\scorrectly\sresolved.\s\sTicket\s#2018.\s(CVS\s3477)
D 2006-10-13T15:34:17
C Fix\sa\sproblems\sthat\sarise\sif\smalloc()\sfails\swhile\scompiling\sSELECT\nstatements\swithin\sa\sTRIGGER.\s(CVS\s3478)
D 2006-10-18T23:26:39
F Makefile.in 4379c909d46b38b8c5db3533084601621d4f14b2
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -116,7 +116,7 @@ F src/test_schema.c ced72140a3a25c148975428e170ec1850d3c3a7d
F src/test_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c
F src/test_tclvar.c 315e77c17f128ff8c06b38c08617fd07c825a95b
F src/tokenize.c dfdff21768fbedd40e8d3ca84fc5d0d7af2b46dd
F src/trigger.c 74ccec784683232f89f3b4db34a089d8cace2058
F src/trigger.c 8c55d31876013ed4e97ee7ce24478fbe00db49bb
F src/update.c 951f95ef044cf6d28557c48dc35cb0711a0b9129
F src/utf.c f467b4892a75f60d36ee933be83f5d7562c5290e
F src/util.c 91d4cb189476906639ae611927d939691d1365f6
@ -129,7 +129,7 @@ F src/vdbeaux.c 6fcc47988bdd563755193c922695032f9d5e5e2b
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
F src/vdbemem.c 26623176bf1c616aa478da958fac49502491a921
F src/vtab.c aa30e940058ea56a1b7a9a7019ec21d307316fb4
F src/where.c 75a89957fcb8c068bec55caa4e9d2ed5fa0b0724
F src/where.c 49a0e7cc1cd4b80b7070a86bbee78db8409e762d
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/all.test 5df90d015ca63fcef2a4b62c24f7316b66c4bfd4
@ -232,7 +232,7 @@ F test/lock.test 6825aea0b5885578b1b63a3b178803842c4ee9f1
F test/lock2.test d83ba79d3c4fffdb5b926c7d8ca7a36c34288a55
F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
F test/main.test e7212ce1023957c7209778cc87fa932bd79ba89a
F test/malloc.test 7831ab6ceb7ff53407dbab4b1c07e608f4142533
F test/malloc.test 0eb9fcffa8693bcbc47fd28f26616474da44f18b
F test/malloc2.test 4ed7d719542c4570dec9c2ebe2bbdf3a9f3b0d05
F test/malloc3.test fd4186bee73c2a2638f4e2a05a684c06836f725b
F test/malloc4.test 59cd02f71b363302a04c4e77b97c0a1572eaa210
@ -410,7 +410,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P 81daedcf48372949b9df009ce6121a514ecf6f2e
R 51a343f1ad7e509354c3abfdf659cea7
P b886eaa334150262ce4d1a1d0470ca4cf623a396
R 9bb26a66074bed22316d4b359f75108a
U drh
Z 333f96e3dffc96d0cf5e4ba951325035
Z 42173c26897f66009294e3d680c52f79

View File

@ -1 +1 @@
b886eaa334150262ce4d1a1d0470ca4cf623a396
ee4894b49995e4904db1991281563cfbb7b1c16d

View File

@ -668,12 +668,12 @@ static int codeTriggerProgram(
pParse->trigStack->orconf = orconf;
switch( pTriggerStep->op ){
case TK_SELECT: {
Select * ss = sqlite3SelectDup(pTriggerStep->pSelect);
assert(ss);
assert(ss->pSrc);
sqlite3SelectResolve(pParse, ss, 0);
sqlite3Select(pParse, ss, SRT_Discard, 0, 0, 0, 0, 0);
sqlite3SelectDelete(ss);
Select *ss = sqlite3SelectDup(pTriggerStep->pSelect);
if( ss ){
sqlite3SelectResolve(pParse, ss, 0);
sqlite3Select(pParse, ss, SRT_Discard, 0, 0, 0, 0, 0);
sqlite3SelectDelete(ss);
}
break;
}
case TK_UPDATE: {

View File

@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.228 2006/06/27 13:20:22 drh Exp $
** $Id: where.c,v 1.229 2006/10/18 23:26:39 drh Exp $
*/
#include "sqliteInt.h"
@ -622,6 +622,10 @@ static void exprAnalyze(
if( pTerm->leftCursor>=0 ){
int idxNew;
pDup = sqlite3ExprDup(pExpr);
if( sqlite3MallocFailed() ){
sqliteFree(pDup);
return;
}
idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC);
if( idxNew==0 ) return;
pNew = &pWC->a[idxNew];

View File

@ -14,7 +14,7 @@
# special feature is used to see what happens in the library if a malloc
# were to really fail due to an out-of-memory situation.
#
# $Id: malloc.test,v 1.35 2006/10/04 11:55:50 drh Exp $
# $Id: malloc.test,v 1.36 2006/10/18 23:26:39 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -229,7 +229,10 @@ do_malloc_test 5 -sqlbody {
CREATE TABLE t1(a,b);
CREATE TABLE t2(x,y);
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
INSERT INTO t2(x,y) VALUES(new.rowid,1);
INSERT INTO t2(x,y) VALUES(new.rowid,1);
UPDATE t2 SET y=y+1 WHERE x=new.rowid;
SELECT 123;
DELETE FROM t2 WHERE x=new.rowid;
END;
INSERT INTO t1(a,b) VALUES(2,3);
COMMIT;