]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Take care to free the memory for the ORDER BY clause on SELECT statements
authordrh <drh@noemail.net>
Sun, 17 May 2009 15:26:20 +0000 (15:26 +0000)
committerdrh <drh@noemail.net>
Sun, 17 May 2009 15:26:20 +0000 (15:26 +0000)
containing errors and contained within triggers.  Ticket #3863. (CVS 6644)

FossilOrigin-Name: dd665eac8c04259e44a95827ebd1f037460fe1b2

manifest
manifest.uuid
src/select.c
test/selectC.test

index 84b4e9e28d32a046e5fd2e3e8868723ab5a3b2c2..9e7eb3455735086c86d09cefe83fdc5779839c6a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\stypo\sin\sthe\ssqlite3_blob_open()\sdocumentation.\s(CVS\s6643)
-D 2009-05-17T12:07:48
+C Take\scare\sto\sfree\sthe\smemory\sfor\sthe\sORDER\sBY\sclause\son\sSELECT\sstatements\ncontaining\serrors\sand\scontained\swithin\striggers.\s\sTicket\s#3863.\s(CVS\s6644)
+D 2009-05-17T15:26:21
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -158,7 +158,7 @@ F src/printf.c 3f4dca207a88258d37af5a7a03e800a825fe6456
 F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628
 F src/resolve.c 2ce8f8bc8a0c913cbaec3fb3da2be113ea1fa5af
 F src/rowset.c 14d12b5e81b5907b87d511f6f4219805f96a4b55
-F src/select.c 3adc1da3ba3ee024c9416fa61d5deae0ad833360
+F src/select.c 1f95ac86aca8cf5490c89f563aea98b41f158300
 F src/shell.c 0a11f831603f17fea20ca97133c0f64e716af4a7
 F src/sqlite.h.in 0c459a45c1047be24c6a58646e8be4d001a3a28a
 F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
@@ -532,7 +532,7 @@ F test/select8.test 391de11bdd52339c30580dabbbbe97e3e9a3c79d
 F test/select9.test b4007b15396cb7ba2615cab31e1973b572e43210
 F test/selectA.test 06d1032fa9009314c95394f2ca2e60d9f7ae8532
 F test/selectB.test f305cc6660804cb239aab4e2f26b0e288b59958b
-F test/selectC.test ae49d258c875bc1712898f1632062bc5c01a7470
+F test/selectC.test 035597b7a58917dbf63eed7c393cfe6ce729d7bf
 F test/server1.test f5b790d4c0498179151ca8a7715a65a7802c859c
 F test/shared.test 3b448dc0f7a9356e641894ed81c27599f39d809d
 F test/shared2.test 8973e41e008acbbd8d1b191b91a23cd472f058e8
@@ -729,7 +729,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P e3ccbc69babd05d45db8065f6612751eda1aa645
-R 4c50604c2b46c8a295a297827d1007aa
+P 92866482ef7cc91b5ac7bebec7e6edf900aa64c6
+R cb455d7944af8d54cd2c606fc118f81d
 U drh
-Z 24364081c0a342b84ec9ac3838ce6a93
+Z 53d20478e7a87c54ccd99a9df25932c8
index 0795e43fec3aa109c01401fc645f039e5891c740..be9a99b6729daf4fc157573905cd1b356b4602a9 100644 (file)
@@ -1 +1 @@
-92866482ef7cc91b5ac7bebec7e6edf900aa64c6
\ No newline at end of file
+dd665eac8c04259e44a95827ebd1f037460fe1b2
\ No newline at end of file
index 9ac9cde3608689d06ec09e0c6e37d2d0b2693291..6111e2ef89f7b6dd9443db14da4de7adbc73ac61 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements in SQLite.
 **
-** $Id: select.c,v 1.514 2009/05/17 02:06:15 drh Exp $
+** $Id: select.c,v 1.515 2009/05/17 15:26:21 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -3575,12 +3575,12 @@ int sqlite3Select(
     p->selFlags &= ~SF_Distinct;
   }
   sqlite3SelectPrep(pParse, p, 0);
+  p->pOrderBy = pOrderBy;
   pTabList = p->pSrc;
   pEList = p->pEList;
   if( pParse->nErr || db->mallocFailed ){
     goto select_end;
   }
-  p->pOrderBy = pOrderBy;
   isAgg = (p->selFlags & SF_Aggregate)!=0;
   if( pEList==0 ) goto select_end;
 
index e92b83bbd468ca66c4a1ae48e7fdda6246daf481..10804a9b920e1fbe269aaf8a2ba43681c35f2098 100644 (file)
@@ -10,7 +10,7 @@
 #***********************************************************************
 # This file implements regression tests for SQLite library. 
 #
-# $Id: selectC.test,v 1.4 2009/03/02 01:22:40 drh Exp $
+# $Id: selectC.test,v 1.5 2009/05/17 15:26:21 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -149,4 +149,19 @@ do_test selectC-1.14.2 {
   }
 } {CCC AAA AAA}
 
+# The following query used to leak memory.  Verify that has been fixed.
+#
+do_test selectC-2.1 {
+  catchsql {
+    CREATE TABLE t21a(a,b);
+    INSERT INTO t21a VALUES(1,2);
+    CREATE TABLE t21b(n);
+    CREATE TRIGGER r21 AFTER INSERT ON t21b BEGIN
+      SELECT a FROM t21a WHERE a>new.x UNION ALL
+      SELECT b FROM t21a WHERE b>new.x ORDER BY 1 LIMIT 2;
+    END;
+    INSERT INTO t21b VALUES(6);
+  }
+} {1 {no such column: new.x}}
+
 finish_test