]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a bug in DELETE that might cause a segfault when deleting more
authordrh <drh@noemail.net>
Wed, 24 Aug 2005 16:13:51 +0000 (16:13 +0000)
committerdrh <drh@noemail.net>
Wed, 24 Aug 2005 16:13:51 +0000 (16:13 +0000)
than 40940 rows of data all at once. (CVS 2620)

FossilOrigin-Name: 7c599bae33ba4eb10fc486ae3dab76330ce69936

manifest
manifest.uuid
src/vdbefifo.c
test/delete3.test [new file with mode: 0644]

index 16fd760460275cabc2f053092bdef38b937c6ef1..29a151d7fc80520241b7267b61e6334782d5b987 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Version\s3.2.4\s(CVS\s2619)
-D 2005-08-24T11:14:47
+C Fix\sa\sbug\sin\sDELETE\sthat\smight\scause\sa\ssegfault\swhen\sdeleting\smore\nthan\s40940\srows\sof\sdata\sall\sat\sonce.\s(CVS\s2620)
+D 2005-08-24T16:13:52
 F Makefile.in b109ddb46a5550d0732dcd6caca01c123f6d5cdd
 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -85,7 +85,7 @@ F src/vdbe.h 3b29a9af6c7a64ed692bef1fc5f61338f40d2f67
 F src/vdbeInt.h 9be9a6c43d38124bd03cc5cf05715605b1789fd9
 F src/vdbeapi.c 7790e9f8da2dde29510a196d1e41ff53da7eb8a8
 F src/vdbeaux.c 874624698fad54a59c6a0bcccea9d5aaa8655ab6
-F src/vdbefifo.c b8805850afe13b43f1de78d58088cb5d66f88e1e
+F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
 F src/vdbemem.c 4732fd4d1a75dc38549493d7f9a81d02bf7c59b5
 F src/where.c 485041aa51fb33f43b346e018f7c01422847f364
 F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
@@ -138,6 +138,7 @@ F test/date.test 30ca15e608a45d868fd419c901795382efe27020
 F test/default.test 252298e42a680146b1dd64f563b95bdf088d94fb
 F test/delete.test 33e1670049364fc3604217a6c2eda042a47115ab
 F test/delete2.test e382b6a97787197eb8b93dd4ccd37797c3725ea3
+F test/delete3.test 555e84a00a99230b7d049d477a324a631126a6ab
 F test/diskfull.test ba27afd587af1216f92d2bb00132cbc0e39354fc
 F test/enc.test 7a03417a1051fe8bc6c7641cf4c8c3f7e0066d52
 F test/enc2.test d1ab077b84f4d3099246915422b1ab6b81481e0a
@@ -297,7 +298,7 @@ F www/tclsqlite.tcl 3df553505b6efcad08f91e9b975deb2e6c9bb955
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 139a28d231875e72538fd6842168c458441ad1d0
-R 2f6c9b894551e0a3c64b6097033bd8f9
+P 8cef2c1ae728970a38d794f9903115da5d0fcd55
+R a70653770f548ef58ecb2d4303ec79dd
 U drh
-Z fbfbdff77016e0ef0591035e80b41a64
+Z 4fc4e011eef56b244e6411516a20c5a0
index f6979459da7913d3f53aa12a66e2107c752e9225..13623ac161956688b7a25684999db2f5f38d9fee 100644 (file)
@@ -1 +1 @@
-8cef2c1ae728970a38d794f9903115da5d0fcd55
\ No newline at end of file
+7c599bae33ba4eb10fc486ae3dab76330ce69936
\ No newline at end of file
index e752e16698d1530b67968cd625f7615ce83b5093..7ea6c050f9bbdf94756d1fb834335735f42b769a 100644 (file)
@@ -21,6 +21,9 @@
 */
 static FifoPage *allocatePage(int nEntry){
   FifoPage *pPage;
+  if( nEntry>32767 ){
+    nEntry = 32767;
+  }
   pPage = sqliteMallocRaw( sizeof(FifoPage) + sizeof(i64)*(nEntry-1) );
   if( pPage ){
     pPage->nSlot = nEntry;
@@ -77,7 +80,9 @@ int sqlite3VdbeFifoPop(Fifo *pFifo, i64 *pVal){
   pPage = pFifo->pFirst;
   assert( pPage!=0 );
   assert( pPage->iWrite>pPage->iRead );
+  assert( pPage->iWrite<=pPage->nSlot );
   assert( pPage->iRead<pPage->nSlot );
+  assert( pPage->iRead>=0 );
   *pVal = pPage->aSlot[pPage->iRead++];
   pFifo->nEntry--;
   if( pPage->iRead>=pPage->iWrite ){
diff --git a/test/delete3.test b/test/delete3.test
new file mode 100644 (file)
index 0000000..a31f6ec
--- /dev/null
@@ -0,0 +1,57 @@
+# 2005 August 24
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.  The
+# focus of this script is a test of the DELETE command where a
+# large number of rows are deleted.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# Create a table that contains a large number of rows.
+#
+do_test delete3-1.1 {
+  execsql {
+    CREATE TABLE t1(x integer primary key);
+    BEGIN;
+    INSERT INTO t1 VALUES(1);
+    INSERT INTO t1 VALUES(2);
+    INSERT INTO t1 SELECT x+2 FROM t1;
+    INSERT INTO t1 SELECT x+4 FROM t1;
+    INSERT INTO t1 SELECT x+8 FROM t1;
+    INSERT INTO t1 SELECT x+16 FROM t1;
+    INSERT INTO t1 SELECT x+32 FROM t1;
+    INSERT INTO t1 SELECT x+64 FROM t1;
+    INSERT INTO t1 SELECT x+128 FROM t1;
+    INSERT INTO t1 SELECT x+256 FROM t1;
+    INSERT INTO t1 SELECT x+512 FROM t1;
+    INSERT INTO t1 SELECT x+1024 FROM t1;
+    INSERT INTO t1 SELECT x+2048 FROM t1;
+    INSERT INTO t1 SELECT x+4096 FROM t1;
+    INSERT INTO t1 SELECT x+8192 FROM t1;
+    INSERT INTO t1 SELECT x+16384 FROM t1;
+    INSERT INTO t1 SELECT x+32768 FROM t1;
+    INSERT INTO t1 SELECT x+65536 FROM t1;
+    INSERT INTO t1 SELECT x+131072 FROM t1;
+    INSERT INTO t1 SELECT x+262144 FROM t1;
+    COMMIT;
+    SELECT count(*) FROM t1;   
+  }
+} {524288}
+do_test delete3-1.2 {
+  execsql {
+    DELETE FROM t1 WHERE x%2==0;
+    SELECT count(*) FROM t1;
+  }
+} {262144}
+integrity_check delete3-1.3
+
+finish_test