From a46417151af7f8b7d36fa17225b61ea5643c68ba Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 2 Nov 2013 11:34:58 +0000 Subject: [PATCH] A pair of sqlite3_analyzer bug fixes: (1) quote strings in the SQL at the end of the output. (2) Fix test_stat.c so that it no longer misses some overflow pages on internal index pages. FossilOrigin-Name: 42a11e7464ab1d97d603c7409f10710ad4f1f542 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/test_stat.c | 5 +++-- test/stat.test | 46 ++++++++++++++++++++++++++++------------------ tool/spaceanal.tcl | 2 +- 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index 67d073cdb6..e768e808a9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sos_unix.c\scausing\scompilation\sfailure\sif\sSQLITE_DEBUG\sand\sSQLITE_MAX_MMAP_SIZE=0\sare\sboth\sdefined. -D 2013-10-31T18:49:58.493 +C A\spair\sof\ssqlite3_analyzer\sbug\sfixes:\s(1)\squote\sstrings\sin\sthe\sSQL\sat\sthe\send\nof\sthe\soutput.\s(2)\sFix\stest_stat.c\sso\sthat\sit\sno\slonger\smisses\ssome\soverflow\npages\son\sinternal\sindex\spages. +D 2013-11-02T11:34:58.851 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -265,7 +265,7 @@ F src/test_rtree.c f3d1d12538dccb75fd916e3fa58f250edbdd3b47 F src/test_schema.c cd12a2223c3a394f4d07bb93bdf6d344c5c121b6 F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe F src/test_sqllog.c c1c1bbedbcaf82b93d83e4f9dd990e62476a680e -F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935 +F src/test_stat.c 9898687a6c2beca733b0dd6fe19163d987826d31 F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c 16dbe79fb320fadb5acd7a0a59f49e52ab2d2091 F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa @@ -812,7 +812,7 @@ F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b F test/spellfix.test 8c40b169b104086d8795781f670ba3c786d6d8be F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298 -F test/stat.test be8d477306006ec696bc86757cfb34bec79447ce +F test/stat.test c8eccfe8fcd3f3cfc864ce22d5b9e803a3c69940 F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9 F test/subquery.test 666fdecceac258f5fd84bed09a64e49d9f37edd9 F test/subquery2.test 91e1e364072aeff431d1f9689b15147e421d88c7 @@ -1111,7 +1111,7 @@ F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b -F tool/spaceanal.tcl d8c11da184b1a13d0456d786e70b3867e141b74a +F tool/spaceanal.tcl 81fad69052145daa3a0a89d47ba69adf52b7aa01 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff @@ -1126,7 +1126,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 0414bb73ef83332bec3d06471d431690356dbe13 -R 10dc38d378b39c081f52d9ea4434ffc9 -U dan -Z f097b706b4798a5e46296317a11afe2d +P 090db8c81d8ca216277d11c8c4751c0a37801524 +R 3b67c293eec6cc448a29f4c028337c5f +U drh +Z 034fbe99525e12c2d1270c2b13585d64 diff --git a/manifest.uuid b/manifest.uuid index fdc44fddfb..095deb42d6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -090db8c81d8ca216277d11c8c4751c0a37801524 \ No newline at end of file +42a11e7464ab1d97d603c7409f10710ad4f1f542 \ No newline at end of file diff --git a/src/test_stat.c b/src/test_stat.c index d4c902b5ea..615df3d80f 100644 --- a/src/test_stat.c +++ b/src/test_stat.c @@ -397,6 +397,7 @@ static int statNext(sqlite3_vtab_cursor *pCursor){ sqlite3_free(pCsr->zPath); pCsr->zPath = 0; +statNextRestart: if( pCsr->aPage[0].pPg==0 ){ rc = sqlite3_step(pCsr->pStmt); if( rc==SQLITE_ROW ){ @@ -448,11 +449,11 @@ static int statNext(sqlite3_vtab_cursor *pCursor){ p->iCell++; } - while( !p->iRightChildPg || p->iCell>p->nCell ){ + if( !p->iRightChildPg || p->iCell>p->nCell ){ statClearPage(p); if( pCsr->iPage==0 ) return statNext(pCursor); pCsr->iPage--; - p = &pCsr->aPage[pCsr->iPage]; + goto statNextRestart; /* Tail recursion */ } pCsr->iPage++; assert( p==&pCsr->aPage[pCsr->iPage-1] ); diff --git a/test/stat.test b/test/stat.test index ac88f7acb3..f8d3877e36 100644 --- a/test/stat.test +++ b/test/stat.test @@ -112,7 +112,17 @@ do_execsql_test stat-2.1 { t3 /00e/ 22 leaf 2 730 276 366 \ t3 /00f/ 23 leaf 2 738 268 370 \ ] -do_execsql_test stat-2.2 { DROP TABLE t3 } {} + +# With every index entry overflowing, make sure no pages are missed +# (other than the locking page which is 64 in this test build.) +# +do_execsql_test stat-2.2 { + UPDATE t3 SET a=a||hex(randomblob(700)); + VACUUM; + SELECT pageno FROM stat EXCEPT SELECT pageno-1 FROM stat; +} {64 136} + +do_execsql_test stat-2.3 { DROP TABLE t3; VACUUM; } {} do_execsql_test stat-3.1 { CREATE TABLE t4(x); @@ -122,22 +132,22 @@ do_execsql_test stat-3.1 { FROM stat WHERE name != 'sqlite_master'; } [list \ i4 / 3 leaf 1 103 905 7782 \ - i4 /000+000000 9 overflow 0 1020 0 0 \ - i4 /000+000001 10 overflow 0 1020 0 0 \ - i4 /000+000002 11 overflow 0 1020 0 0 \ - i4 /000+000003 12 overflow 0 1020 0 0 \ - i4 /000+000004 13 overflow 0 1020 0 0 \ - i4 /000+000005 14 overflow 0 1020 0 0 \ - i4 /000+000006 15 overflow 0 1020 0 0 \ - i4 /000+000007 16 overflow 0 539 481 0 \ + i4 /000+000000 4 overflow 0 1020 0 0 \ + i4 /000+000001 5 overflow 0 1020 0 0 \ + i4 /000+000002 6 overflow 0 1020 0 0 \ + i4 /000+000003 7 overflow 0 1020 0 0 \ + i4 /000+000004 8 overflow 0 1020 0 0 \ + i4 /000+000005 9 overflow 0 1020 0 0 \ + i4 /000+000006 10 overflow 0 1020 0 0 \ + i4 /000+000007 11 overflow 0 539 481 0 \ t4 / 2 leaf 1 640 367 7780 \ - t4 /000+000000 22 overflow 0 1020 0 0 \ - t4 /000+000001 23 overflow 0 1020 0 0 \ - t4 /000+000002 21 overflow 0 1020 0 0 \ - t4 /000+000003 20 overflow 0 1020 0 0 \ - t4 /000+000004 19 overflow 0 1020 0 0 \ - t4 /000+000005 18 overflow 0 1020 0 0 \ - t4 /000+000006 17 overflow 0 1020 0 0 \ + t4 /000+000000 12 overflow 0 1020 0 0 \ + t4 /000+000001 13 overflow 0 1020 0 0 \ + t4 /000+000002 14 overflow 0 1020 0 0 \ + t4 /000+000003 15 overflow 0 1020 0 0 \ + t4 /000+000004 16 overflow 0 1020 0 0 \ + t4 /000+000005 17 overflow 0 1020 0 0 \ + t4 /000+000006 18 overflow 0 1020 0 0 \ ] do_execsql_test stat-4.1 { @@ -146,8 +156,8 @@ do_execsql_test stat-4.1 { SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload FROM stat WHERE name = 't5' OR name = 'i5'; } [list \ - i5 / 5 leaf 0 0 1016 0 \ - t5 / 4 leaf 0 0 1016 0 \ + i5 / 20 leaf 0 0 1016 0 \ + t5 / 19 leaf 0 0 1016 0 \ ] db close diff --git a/tool/spaceanal.tcl b/tool/spaceanal.tcl index 9cb62983ef..7079e92fe5 100644 --- a/tool/spaceanal.tcl +++ b/tool/spaceanal.tcl @@ -766,7 +766,7 @@ mem eval {SELECT * FROM space_used} x { set sep ( foreach col $x(*) { set v $x($col) - if {$v=="" || ![string is double $v]} {set v [quote $v]} + if {$v=="" || ![string is double $v]} {set v '[quote $v]'} puts -nonewline $sep$v set sep , }