From 6c34e58e8fb73d9c526c33b3006801b249da8c07 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 18 Jun 2014 15:24:40 +0000 Subject: [PATCH 01/27] Fix a comment on the sqlite3Utf8Read() routine. No changes to code. FossilOrigin-Name: 5e514f6acebcfad4f18300d1a34f4917f1a746d9 --- manifest | 13 ++++++------- manifest.uuid | 2 +- src/utf.c | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index e6ed1d11b8..970aaa677e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prevent\san\sautomatic\sindex\sfrom\staking\sthe\splace\sof\sa\sdeclared\sindex. -D 2014-06-18T15:11:54.897 +C Fix\sa\scomment\son\sthe\ssqlite3Utf8Read()\sroutine.\s\sNo\schanges\sto\scode. +D 2014-06-18T15:24:40.324 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in ed5e4aae4799f724699d5509fac2977786414dbb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -280,7 +280,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c 6da2de6e12218ccb0aea5184b56727d011f4bee7 F src/trigger.c 66f3470b03b52b395e839155786966e3e037fddb F src/update.c 01564b3c430f6c7b0a35afaf7aba7987206fa3a5 -F src/utf.c 6dc9ec9f1b3db43ae8ba0365377f11df1ee4c01c +F src/utf.c a0314e637768a030e6e84a957d0c4f6ba910cc05 F src/util.c 049fe1d3c0e2209c1bee107aec2fcff6285f909f F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 F src/vdbe.c 9bfe6becfc094382ae213656fbe511055ad83a54 @@ -1179,8 +1179,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b500f2a09721b49c95a69c47a0205bc2375af2cd 4ece839d445ff578a449a339ab579a32e64c9d28 -R 1a9a8498bcd344a9075e008919374ef9 -T +closed 4ece839d445ff578a449a339ab579a32e64c9d28 +P 0a52bddd9db49b2b79fc24888b50023d0fe74f7b +R 1483fc05b60a54244db236c2feca8e58 U drh -Z c3c3ed7d30575f073ff51d887a334d78 +Z 0243b0be22165644a3d48f8093dd6d50 diff --git a/manifest.uuid b/manifest.uuid index 585f159241..0488c4af6b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a52bddd9db49b2b79fc24888b50023d0fe74f7b \ No newline at end of file +5e514f6acebcfad4f18300d1a34f4917f1a746d9 \ No newline at end of file diff --git a/src/utf.c b/src/utf.c index 96b679fff4..97898746a2 100644 --- a/src/utf.c +++ b/src/utf.c @@ -148,8 +148,8 @@ static const unsigned char sqlite3Utf8Trans1[] = { ** and rendered as themselves even though they are technically ** invalid characters. ** -** * This routine accepts an infinite number of different UTF8 encodings -** for unicode values 0x80 and greater. It do not change over-length +** * This routine accepts over-length UTF8 encodings +** for unicode values 0x80 and greater. It does not change over-length ** encodings to 0xfffd as some systems recommend. */ #define READ_UTF8(zIn, zTerm, c) \ From 267a13fd47741e88b5559526ef6680a6b9c44550 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 18 Jun 2014 18:10:12 +0000 Subject: [PATCH 02/27] Add the "LogEst" and "LogEst.exe" target to the makefiles. FossilOrigin-Name: 7b91b0581d169a353462d96120a2e0d4dcc8e8ae --- Makefile.in | 3 +++ Makefile.msc | 3 +++ main.mk | 3 +++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index 920f3d893d..72f7cfc007 100644 --- a/Makefile.in +++ b/Makefile.in @@ -942,6 +942,9 @@ sqlite3_analyzer$(TEXE): sqlite3_analyzer.c showdb$(TEXE): $(TOP)/tool/showdb.c sqlite3.c $(LTLINK) -o $@ $(TOP)/tool/showdb.c sqlite3.c $(TLIBS) +LogEst$(TEXE): $(TOP)/tool/logest.c sqlite3.h + $(LTLINK) -I. -o $@ $(TOP)/tool/logest.c + wordcount$(TEXE): $(TOP)/test/wordcount.c sqlite3.c $(LTLINK) -o $@ $(TOP)/test/wordcount.c sqlite3.c $(TLIBS) diff --git a/Makefile.msc b/Makefile.msc index fce958b947..409f7b3d28 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1435,6 +1435,9 @@ showdb.exe: $(TOP)\tool\showdb.c $(SQLITE3C) $(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\tool\showdb.c $(SQLITE3C) +LogEst.exe: $(TOP)\tool\logest.c sqlite3.h + $(LTLINK) -Fe$@ $(TOP)\tool\LogEst.c + wordcount.exe: $(TOP)\test\wordcount.c $(SQLITE3C) $(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\test\wordcount.c $(SQLITE3C) diff --git a/main.mk b/main.mk index 3076229d5e..30149eccab 100644 --- a/main.mk +++ b/main.mk @@ -632,6 +632,9 @@ showdb$(EXE): $(TOP)/tool/showdb.c sqlite3.c $(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o showdb$(EXE) \ $(TOP)/tool/showdb.c sqlite3.c +LogEst$(EXE): $(TOP)/tool/logest.c sqlite3.h + $(TCC) -o LogEst$(EXE) $(TOP)/tool/logest.c + wordcount$(EXE): $(TOP)/test/wordcount.c sqlite3.c $(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o wordcount$(EXE) \ $(TOP)/test/wordcount.c sqlite3.c diff --git a/manifest b/manifest index 970aaa677e..e4246ebcc8 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Fix\sa\scomment\son\sthe\ssqlite3Utf8Read()\sroutine.\s\sNo\schanges\sto\scode. -D 2014-06-18T15:24:40.324 +C Add\sthe\s"LogEst"\sand\s"LogEst.exe"\starget\sto\sthe\smakefiles. +D 2014-06-18T18:10:12.200 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in ed5e4aae4799f724699d5509fac2977786414dbb +F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc b5ff082a24cd1e0694a0001891e13e3b56c8ef31 +F Makefile.msc b2d3ac211b479fa5a6c9aaf3b9c49fdea900d228 F Makefile.vxworks 034289efa9d591b04b1a73598623119c306cbba0 F README.md 64f270c43c38c46de749e419c22f0ae2f4499fe8 F VERSION 9f823c026c6a32fc5f84d212a8aae0a221dba45c @@ -146,7 +146,7 @@ F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 0cb97ec3285474651736053ee741145ef8c5185f +F main.mk 7b1d0be0840f213405c977c87917241158126a33 F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea F mkopcodeh.awk c6b3fa301db6ef7ac916b14c60868aeaec1337b5 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 @@ -1179,7 +1179,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 0a52bddd9db49b2b79fc24888b50023d0fe74f7b -R 1483fc05b60a54244db236c2feca8e58 +P 5e514f6acebcfad4f18300d1a34f4917f1a746d9 +R 608fed792452245bc29949099b24055c U drh -Z 0243b0be22165644a3d48f8093dd6d50 +Z 8ecf2902c498abf367d738a353cfaa20 diff --git a/manifest.uuid b/manifest.uuid index 0488c4af6b..858eff2d28 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5e514f6acebcfad4f18300d1a34f4917f1a746d9 \ No newline at end of file +7b91b0581d169a353462d96120a2e0d4dcc8e8ae \ No newline at end of file From 6a30cd5a446405d19b047de984d78c048da4ae08 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 19 Jun 2014 23:38:53 +0000 Subject: [PATCH 03/27] Add the ability to decode the headers of individual cells, byte-by-byte, in the "showdb.exe" utility. FossilOrigin-Name: 306b461d7c0643b6ac4df944759ecc9ce8581634 --- manifest | 12 ++-- manifest.uuid | 2 +- tool/showdb.c | 168 +++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 159 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index e4246ebcc8..d6ee27e4ac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"LogEst"\sand\s"LogEst.exe"\starget\sto\sthe\smakefiles. -D 2014-06-18T18:10:12.200 +C Add\sthe\sability\sto\sdecode\sthe\sheaders\sof\sindividual\scells,\sbyte-by-byte,\nin\sthe\s"showdb.exe"\sutility. +D 2014-06-19T23:38:53.722 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1158,7 +1158,7 @@ F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c 1f3fe634d6f690b8d39ab1b9fd34583d468921e1 +F tool/showdb.c c080dea3addc8440191aef2c7cf222ee7959529c F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -1179,7 +1179,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 5e514f6acebcfad4f18300d1a34f4917f1a746d9 -R 608fed792452245bc29949099b24055c +P 7b91b0581d169a353462d96120a2e0d4dcc8e8ae +R 80dc9f5b1256cb0818cbd9270f47db96 U drh -Z 8ecf2902c498abf367d738a353cfaa20 +Z ec7d321d3c2511a642cbe0539a129858 diff --git a/manifest.uuid b/manifest.uuid index 858eff2d28..204ffc59ee 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7b91b0581d169a353462d96120a2e0d4dcc8e8ae \ No newline at end of file +306b461d7c0643b6ac4df944759ecc9ce8581634 \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index 4d274a7aac..d4e26f45c1 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -129,6 +129,7 @@ static void print_page(int iPg){ free(aData); } + /* Print a line of decode output showing a 4-byte integer. */ static void print_decode_line( @@ -341,6 +342,120 @@ static int describeCell( return nLocal+n; } +/* Print an offset followed by nByte bytes. Add extra white-space +** at the end so that subsequent text is aligned. +*/ +static void printBytes( + unsigned char *aData, /* Content being decoded */ + unsigned char *aStart, /* Start of content to be printed */ + int nByte /* Number of bytes to print */ +){ + int j; + printf(" %03x: ", (int)(aStart-aData)); + for(j=0; j<9; j++){ + if( j>=nByte ){ + printf(" "); + }else{ + printf("%02x ", aStart[j]); + } + } +} + + +/* +** Write a full decode on stdout for the cell at a[ofst]. +** Assume the page contains a header of size szPgHdr bytes. +*/ +static void decodeCell( + unsigned char *a, /* Page content (without the page-1 header) */ + unsigned pgno, /* Page number */ + int iCell, /* Cell index */ + int szPgHdr, /* Size of the page header. 0 or 100 */ + int ofst /* Cell begins at a[ofst] */ +){ + int i, j, k; + int leftChild; + i64 nPayload; + i64 rowid; + i64 nHdr; + i64 iType; + int nLocal; + unsigned char *x = a + ofst; + unsigned char *end; + unsigned char cType = a[0]; + + printf("Decode cell[%d] on page %d offset %04x....\n", + iCell, pgno, szPgHdr+ofst); + if( cType<=5 ){ + leftChild = ((x[0]*256 + x[1])*256 + x[2])*256 + x[3]; + printBytes(a, x, 4); + printf("left child page:: %d\n", leftChild); + x += 4; + } + if( cType!=5 ){ + i = decodeVarint(x, &nPayload); + printBytes(a, x, i); + nLocal = localPayload(nPayload, cType); + printf("bytes of payload: %d (local: %d)\n", (int)nPayload, nLocal); + x += i; + }else{ + nPayload = nLocal = 0; + } + end = x + nLocal; + if( cType==5 || cType==13 ){ + i = decodeVarint(x, &rowid); + printBytes(a, x, i); + printf("rowid: %lld\n", rowid); + x += i; + } + if( nLocal>0 ){ + i = decodeVarint(x, &nHdr); + printBytes(a, x, i); + printf("record header size: %d\n", (int)nHdr); + j = i; + k = 0; + while( x+j0 ){ - printf(" key: lx=left-child n=payload-size r=rowid\n"); + iCellPtr = (a[0]==2 || a[0]==5) ? 12 : 8; + if( cellToDecode==(-2) ){ + printf("Decode of btree page %d:\n", pgno); + print_decode_line(a, 0, 1, zType); + print_decode_line(a, 1, 2, "Offset to first freeblock"); + print_decode_line(a, 3, 2, "Number of cells on this page"); + print_decode_line(a, 5, 2, "Offset to cell content area"); + print_decode_line(a, 7, 1, "Fragmented byte count"); + if( a[0]==2 || a[0]==5 ){ + print_decode_line(a, 8, 4, "Right child"); + } + if( nCell>0 ){ + printf(" key: lx=left-child n=payload-size r=rowid\n"); + } + }else if( cellToDecode>=nCell ){ + printf("Page %d has only %d cells\n", pgno, nCell); + return; } if( showMap ){ zMap = malloc(pagesize); @@ -409,14 +540,18 @@ static void decode_btree_page( j = strlen(zBuf); if( j<=n-2 ) memcpy(&zMap[cofst+1], zBuf, j); } - printf(" %03x: cell[%d] %s\n", cofst, i, zDesc); + if( cellToDecode==(-2) ){ + printf(" %03x: cell[%d] %s\n", cofst, i, zDesc); + }else if( cellToDecode==(-1) || cellToDecode==i ){ + decodeCell(a, pgno, i, hdrSize, cofst-hdrSize); + } } if( showMap ){ for(i=0; i Date: Fri, 20 Jun 2014 01:32:42 +0000 Subject: [PATCH 04/27] In the showdb.exe utility, for the "NNNbd" command, also show data fields in addition to header fields on each record decoded. Improvements to formatting. FossilOrigin-Name: b451fe0cb92278deb7724e7995c1bd46ae83c119 --- manifest | 12 ++++---- manifest.uuid | 2 +- tool/showdb.c | 84 +++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 69 insertions(+), 29 deletions(-) diff --git a/manifest b/manifest index d6ee27e4ac..d8af3f1d0f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sability\sto\sdecode\sthe\sheaders\sof\sindividual\scells,\sbyte-by-byte,\nin\sthe\s"showdb.exe"\sutility. -D 2014-06-19T23:38:53.722 +C In\sthe\sshowdb.exe\sutility,\sfor\sthe\s"NNNbd"\scommand,\salso\sshow\sdata\sfields\nin\saddition\sto\sheader\sfields\son\seach\srecord\sdecoded.\s\sImprovements\sto\s\nformatting. +D 2014-06-20T01:32:42.411 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1158,7 +1158,7 @@ F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c c080dea3addc8440191aef2c7cf222ee7959529c +F tool/showdb.c eef4bd98ba995c6a9373cbc0e7b8a3201a658585 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -1179,7 +1179,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 7b91b0581d169a353462d96120a2e0d4dcc8e8ae -R 80dc9f5b1256cb0818cbd9270f47db96 +P 306b461d7c0643b6ac4df944759ecc9ce8581634 +R 1d1b4729d93a91658ee348794dbfb980 U drh -Z ec7d321d3c2511a642cbe0539a129858 +Z 8ea506b1401ff81840cba469aab2c6cc diff --git a/manifest.uuid b/manifest.uuid index 204ffc59ee..e90ca871c2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -306b461d7c0643b6ac4df944759ecc9ce8581634 \ No newline at end of file +b451fe0cb92278deb7724e7995c1bd46ae83c119 \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index d4e26f45c1..d97838220a 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -383,9 +383,12 @@ static void decodeCell( unsigned char *x = a + ofst; unsigned char *end; unsigned char cType = a[0]; + int nCol = 0; + int szCol[2000]; + int ofstCol[2000]; + int typeCol[2000]; - printf("Decode cell[%d] on page %d offset %04x....\n", - iCell, pgno, szPgHdr+ofst); + printf("Cell[%d]:\n", iCell); if( cType<=5 ){ leftChild = ((x[0]*256 + x[1])*256 + x[2])*256 + x[3]; printBytes(a, x, 4); @@ -396,7 +399,12 @@ static void decodeCell( i = decodeVarint(x, &nPayload); printBytes(a, x, i); nLocal = localPayload(nPayload, cType); - printf("bytes of payload: %d (local: %d)\n", (int)nPayload, nLocal); + if( nLocal==nPayload ){ + printf("payload-size: %d\n", (int)nPayload); + }else{ + printf("payload-size: %d (%d local, %d overflow)\n", + (int)nPayload, nLocal, (int)(nPayload-nLocal)); + } x += i; }else{ nPayload = nLocal = 0; @@ -411,16 +419,17 @@ static void decodeCell( if( nLocal>0 ){ i = decodeVarint(x, &nHdr); printBytes(a, x, i); - printf("record header size: %d\n", (int)nHdr); + printf("record-header-size: %d\n", (int)nHdr); j = i; - k = 0; + nCol = 0; + k = nHdr; while( x+j0 ){ - printf(" key: lx=left-child n=payload-size r=rowid\n"); - } - }else if( cellToDecode>=nCell ){ + if( cellToDecode>=nCell ){ printf("Page %d has only %d cells\n", pgno, nCell); return; } + printf("Header on btree page %d:\n", pgno); + print_decode_line(a, 0, 1, zType); + print_decode_line(a, 1, 2, "Offset to first freeblock"); + print_decode_line(a, 3, 2, "Number of cells on this page"); + print_decode_line(a, 5, 2, "Offset to cell content area"); + print_decode_line(a, 7, 1, "Fragmented byte count"); + if( a[0]==2 || a[0]==5 ){ + print_decode_line(a, 8, 4, "Right child"); + } + if( cellToDecode==(-2) && nCell>0 ){ + printf(" key: lx=left-child n=payload-size r=rowid\n"); + } if( showMap ){ zMap = malloc(pagesize); memset(zMap, '.', pagesize); @@ -547,6 +586,7 @@ static void decode_btree_page( } } if( showMap ){ + printf("Page map: (H=header P=cell-index 1=page-1-header .=free-space)\n"); for(i=0; i Date: Fri, 20 Jun 2014 13:55:06 +0000 Subject: [PATCH 05/27] Improved display of record data in the "NNNbd" output of the showdb.exe utility program. FossilOrigin-Name: f735c2497eaad15216c90c6b92fd5ceff460220a --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/showdb.c | 23 +++++++++++++++++++++-- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index d8af3f1d0f..1d0fee3b9d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sshowdb.exe\sutility,\sfor\sthe\s"NNNbd"\scommand,\salso\sshow\sdata\sfields\nin\saddition\sto\sheader\sfields\son\seach\srecord\sdecoded.\s\sImprovements\sto\s\nformatting. -D 2014-06-20T01:32:42.411 +C Improved\sdisplay\sof\srecord\sdata\sin\sthe\s"NNNbd"\soutput\sof\sthe\sshowdb.exe\nutility\sprogram. +D 2014-06-20T13:55:06.139 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1158,7 +1158,7 @@ F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c eef4bd98ba995c6a9373cbc0e7b8a3201a658585 +F tool/showdb.c b018a8a69d07050fc0fe9afcf17313cdef0cc599 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -1179,7 +1179,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 306b461d7c0643b6ac4df944759ecc9ce8581634 -R 1d1b4729d93a91658ee348794dbfb980 +P b451fe0cb92278deb7724e7995c1bd46ae83c119 +R ed297bdcc3956dc354f00523f5ca1d92 U drh -Z 8ea506b1401ff81840cba469aab2c6cc +Z 0815d87a0909198bac782c1612f71277 diff --git a/manifest.uuid b/manifest.uuid index e90ca871c2..d85d37c37c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b451fe0cb92278deb7724e7995c1bd46ae83c119 \ No newline at end of file +f735c2497eaad15216c90c6b92fd5ceff460220a \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index d97838220a..bf4af444b2 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -479,8 +479,27 @@ static void decodeCell( printf("%lld\n", v); } }else{ - printf("%d bytes of %s\n", szCol[i], - (typeCol[i]&1)==0 ? "BLOB" : "TEXT"); + int ii, jj; + char zConst[32]; + if( (typeCol[i]&1)==0 ){ + zConst[0] = 'x'; + zConst[1] = '\''; + for(ii=2, jj=0; jj Date: Mon, 23 Jun 2014 10:04:58 +0000 Subject: [PATCH 06/27] Fix a problem with SQLITE_OMIT_WAL builds. FossilOrigin-Name: 612b6d1b1f74eaf618520b90811eca10f978fc71 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 37 ++++++++++++++++++++----------------- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 1d0fee3b9d..9d6dafaed6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\sdisplay\sof\srecord\sdata\sin\sthe\s"NNNbd"\soutput\sof\sthe\sshowdb.exe\nutility\sprogram. -D 2014-06-20T13:55:06.139 +C Fix\sa\sproblem\swith\sSQLITE_OMIT_WAL\sbuilds. +D 2014-06-23T10:04:58.236 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -207,7 +207,7 @@ F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa -F src/os_unix.c 9a97268f1ea97ddea17f1c392f7c76197ac4cea9 +F src/os_unix.c a7baf1b30f3c58ba20b813e01aab23b18ae44f85 F src/os_win.c 8dbf6c11780fe2eb96c1f289e664d0c7b2911d37 F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8 @@ -1179,7 +1179,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b451fe0cb92278deb7724e7995c1bd46ae83c119 -R ed297bdcc3956dc354f00523f5ca1d92 -U drh -Z 0815d87a0909198bac782c1612f71277 +P f735c2497eaad15216c90c6b92fd5ceff460220a +R d7976d2787b6fe6354165e317bb92fd4 +U dan +Z fd6ff630a9de62a9d7a43a3d2f98ba30 diff --git a/manifest.uuid b/manifest.uuid index d85d37c37c..4ccc4a184b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f735c2497eaad15216c90c6b92fd5ceff460220a \ No newline at end of file +612b6d1b1f74eaf618520b90811eca10f978fc71 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 7eb25c85f3..347e82220c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -445,11 +445,11 @@ static struct unix_syscall { { "mremap", (sqlite3_syscall_ptr)0, 0 }, #endif #define osMremap ((void*(*)(void*,size_t,size_t,int,...))aSyscall[23].pCurrent) -#endif - { "getpagesize", (sqlite3_syscall_ptr)unixGetpagesize, 0 }, #define osGetpagesize ((int(*)(void))aSyscall[24].pCurrent) +#endif + }; /* End of the overrideable system calls */ /* @@ -3964,8 +3964,25 @@ static int unixDeviceCharacteristics(sqlite3_file *id){ return rc; } -#ifndef SQLITE_OMIT_WAL +#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 +/* +** Return the system page size. +** +** This function should not be called directly by other code in this file. +** Instead, it should be called via macro osGetpagesize(). +*/ +static int unixGetpagesize(void){ +#if defined(_BSD_SOURCE) + return getpagesize(); +#else + return (int)sysconf(_SC_PAGESIZE); +#endif +} + +#endif /* !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 */ + +#ifndef SQLITE_OMIT_WAL /* ** Object used to represent an shared memory buffer. @@ -4116,20 +4133,6 @@ static int unixShmSystemLock( return rc; } -/* -** Return the system page size. -** -** This function should not be called directly by other code in this file. -** Instead, it should be called via macro osGetpagesize(). -*/ -static int unixGetpagesize(void){ -#if defined(_BSD_SOURCE) - return getpagesize(); -#else - return (int)sysconf(_SC_PAGESIZE); -#endif -} - /* ** Return the minimum number of 32KB shm regions that should be mapped at ** a time, assuming that each mapping must be an integer multiple of the From 685ffb134af3f794e5a15ac8f4092a4ad9f37a68 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 23 Jun 2014 10:18:50 +0000 Subject: [PATCH 07/27] Fix a problem with SQLITE_OMIT_WSD builds. FossilOrigin-Name: 07dda49c1bf8997a18c3368acb81b6d863ea38d6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 9d6dafaed6..fe8a9edf8e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sSQLITE_OMIT_WAL\sbuilds. -D 2014-06-23T10:04:58.236 +C Fix\sa\sproblem\swith\sSQLITE_OMIT_WSD\sbuilds. +D 2014-06-23T10:18:50.447 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -189,7 +189,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303 -F src/main.c 40d0837e5d0597eadc47c3acc2fc95bdbd9250b8 +F src/main.c 7c2c3cafdd6313c8f9319ebec1565782e624372e F src/malloc.c 0203ebce9152c6a0e5de520140b8ba65187350be F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b @@ -1179,7 +1179,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P f735c2497eaad15216c90c6b92fd5ceff460220a -R d7976d2787b6fe6354165e317bb92fd4 +P 612b6d1b1f74eaf618520b90811eca10f978fc71 +R 283ec0802d51fd4e82222d529f6a8475 U dan -Z fd6ff630a9de62a9d7a43a3d2f98ba30 +Z de359222916ca6f6bd684ca986937509 diff --git a/manifest.uuid b/manifest.uuid index 4ccc4a184b..1a8777f6b6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -612b6d1b1f74eaf618520b90811eca10f978fc71 \ No newline at end of file +07dda49c1bf8997a18c3368acb81b6d863ea38d6 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 6b54ca6da5..564c012472 100644 --- a/src/main.c +++ b/src/main.c @@ -3128,10 +3128,10 @@ int sqlite3_test_control(int op, ...){ case SQLITE_TESTCTRL_FAULT_INSTALL: { /* MSVC is picky about pulling func ptrs from va lists. ** http://support.microsoft.com/kb/47961 - ** sqlite3Config.xTestCallback = va_arg(ap, int(*)(int)); + ** sqlite3GlobalConfig.xTestCallback = va_arg(ap, int(*)(int)); */ typedef int(*TESTCALLBACKFUNC_t)(int); - sqlite3Config.xTestCallback = va_arg(ap, TESTCALLBACKFUNC_t); + sqlite3GlobalConfig.xTestCallback = va_arg(ap, TESTCALLBACKFUNC_t); rc = sqlite3FaultSim(0); break; } From c1971541e4e98434e36d82f4c2a7b18ea17078be Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 23 Jun 2014 23:28:13 +0000 Subject: [PATCH 08/27] Add the .fullschema command to the sqlite3.exe utility. This command shows the schema and the content of the sqlite_stat tables, all in one go. Useful when reporting problems with the query planner. FossilOrigin-Name: ebec48921c092e20c9d7608242b63db40b40be5e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/shell.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index fe8a9edf8e..9a02b2a068 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sSQLITE_OMIT_WSD\sbuilds. -D 2014-06-23T10:18:50.447 +C Add\sthe\s.fullschema\scommand\sto\sthe\ssqlite3.exe\sutility.\s\sThis\scommand\sshows\nthe\sschema\sand\sthe\scontent\sof\sthe\ssqlite_stat\stables,\sall\sin\sone\sgo.\s\sUseful\nwhen\sreporting\sproblems\swith\sthe\squery\splanner. +D 2014-06-23T23:28:13.644 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -223,7 +223,7 @@ F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece F src/resolve.c 5fc110baeacf120a73fe34e103f052632ff11a02 F src/rowset.c a9c9aae3234b44a6d7c6f5a3cadf90dce1e627be F src/select.c 6762c62e11b504aa014edceab8886495165e3a77 -F src/shell.c 058940e8a7198ea15ae90f60ffb0e2d67287b46c +F src/shell.c 56de2dfa3f25def4bf03098f7e2256fbb42f6e3c F src/sqlite.h.in a98eb3e8c86c934ea6f5bcfc6b69653dde2f4ed4 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc @@ -1179,7 +1179,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 612b6d1b1f74eaf618520b90811eca10f978fc71 -R 283ec0802d51fd4e82222d529f6a8475 -U dan -Z de359222916ca6f6bd684ca986937509 +P 07dda49c1bf8997a18c3368acb81b6d863ea38d6 +R 4c1bf033e13f45ce881081fa1f198f33 +U drh +Z 8c91ced329194a39e8cdf52b6d2ec4dd diff --git a/manifest.uuid b/manifest.uuid index 1a8777f6b6..bc939b8328 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -07dda49c1bf8997a18c3368acb81b6d863ea38d6 \ No newline at end of file +ebec48921c092e20c9d7608242b63db40b40be5e \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 00d4597545..ff87d817b9 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1583,6 +1583,7 @@ static char zHelp[] = ".exit Exit this program\n" ".explain ?on|off? Turn output mode suitable for EXPLAIN on or off.\n" " With no args, it turns EXPLAIN on.\n" + ".fullschema Show schema and the content of sqlite_stat tables\n" ".headers on|off Turn display of headers on or off\n" ".help Show this message\n" ".import FILE TABLE Import data from FILE into TABLE\n" @@ -2412,6 +2413,44 @@ static int do_meta_command(char *zLine, struct callback_data *p){ } }else + if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){ + struct callback_data data; + char *zErrMsg = 0; + if( nArg!=1 ){ + fprintf(stderr, "Usage: .fullschema\n"); + rc = 1; + goto meta_command_exit; + } + open_db(p, 0); + memcpy(&data, p, sizeof(data)); + data.showHeader = 0; + data.mode = MODE_Semi; + rc = sqlite3_exec(p->db, + "SELECT sql FROM" + " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x" + " FROM sqlite_master UNION ALL" + " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) " + "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%'" + "ORDER BY rowid", + callback, &data, &zErrMsg + ); + sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_master;'", + callback, &data, &zErrMsg); + data.mode = MODE_Insert; + data.zDestTable = "sqlite_stat1"; + shell_exec(p->db, "SELECT * FROM sqlite_stat1", + shell_callback, &data,&zErrMsg); + data.zDestTable = "sqlite_stat3"; + shell_exec(p->db, "SELECT * FROM sqlite_stat3", + shell_callback, &data,&zErrMsg); + data.zDestTable = "sqlite_stat4"; + shell_exec(p->db, "SELECT * FROM sqlite_stat4", + shell_callback, &data, &zErrMsg); + data.mode = MODE_Semi; + shell_exec(p->db, "SELECT 'ANALYZE sqlite_master;'", + shell_callback, &data, &zErrMsg); + }else + if( c=='h' && strncmp(azArg[0], "headers", n)==0 ){ if( nArg==2 ){ p->showHeader = booleanValue(azArg[1]); From f127814eaea2b71c63f620dab60be4ba7a37a72f Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 Jun 2014 00:59:15 +0000 Subject: [PATCH 09/27] Add the showstat4.exe utility program for decoding and displaying the content of the sqlite_stat4 table in a database. FossilOrigin-Name: b4d9f6053d1d95fdc1eab8ce610b51e7df8d896d --- manifest | 11 ++-- manifest.uuid | 2 +- tool/showstat4.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 tool/showstat4.c diff --git a/manifest b/manifest index 9a02b2a068..14bc9eca79 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s.fullschema\scommand\sto\sthe\ssqlite3.exe\sutility.\s\sThis\scommand\sshows\nthe\sschema\sand\sthe\scontent\sof\sthe\ssqlite_stat\stables,\sall\sin\sone\sgo.\s\sUseful\nwhen\sreporting\sproblems\swith\sthe\squery\splanner. -D 2014-06-23T23:28:13.644 +C Add\sthe\sshowstat4.exe\sutility\sprogram\sfor\sdecoding\sand\sdisplaying\sthe\s\ncontent\sof\sthe\ssqlite_stat4\stable\sin\sa\sdatabase. +D 2014-06-24T00:59:15.223 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1160,6 +1160,7 @@ F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 F tool/showdb.c b018a8a69d07050fc0fe9afcf17313cdef0cc599 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 +F tool/showstat4.c 47662af1e2c9567fd821da910b3a247c5c138021 F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b @@ -1179,7 +1180,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 07dda49c1bf8997a18c3368acb81b6d863ea38d6 -R 4c1bf033e13f45ce881081fa1f198f33 +P ebec48921c092e20c9d7608242b63db40b40be5e +R 0ce5547c26474f508ca16bdace146cd3 U drh -Z 8c91ced329194a39e8cdf52b6d2ec4dd +Z 0e7559d34a6f25f8be2f321b29251255 diff --git a/manifest.uuid b/manifest.uuid index bc939b8328..142fcbe956 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ebec48921c092e20c9d7608242b63db40b40be5e \ No newline at end of file +b4d9f6053d1d95fdc1eab8ce610b51e7df8d896d \ No newline at end of file diff --git a/tool/showstat4.c b/tool/showstat4.c new file mode 100644 index 0000000000..c85ab1c770 --- /dev/null +++ b/tool/showstat4.c @@ -0,0 +1,155 @@ +/* +** This utility program decodes and displays the content of the +** sqlite_stat4 table in the database file named on the command +** line. +*/ +#include +#include +#include +#include +#include "sqlite3.h" + +typedef sqlite3_int64 i64; /* 64-bit signed integer type */ + + +/* +** Convert the var-int format into i64. Return the number of bytes +** in the var-int. Write the var-int value into *pVal. +*/ +static int decodeVarint(const unsigned char *z, i64 *pVal){ + i64 v = 0; + int i; + for(i=0; i<8; i++){ + v = (v<<7) + (z[i]&0x7f); + if( (z[i]&0x80)==0 ){ *pVal = v; return i+1; } + } + v = (v<<8) + (z[i]&0xff); + *pVal = v; + return 9; +} + + + +int main(int argc, char **argv){ + sqlite3 *db; + sqlite3_stmt *pStmt; + char *zIdx = 0; + int rc, j, x, y, mxHdr; + const unsigned char *aSample; + int nSample; + i64 iVal; + const char *zSep; + + if( argc!=2 ){ + fprintf(stderr, "Usage: %s DATABASE-FILE\n", argv[0]); + exit(1); + } + rc = sqlite3_open(argv[1], &db); + if( rc!=SQLITE_OK || db==0 ){ + fprintf(stderr, "Cannot open database file [%s]\n", argv[1]); + exit(1); + } + rc = sqlite3_prepare_v2(db, + "SELECT tbl||'.'||idx, nEq, nLT, nDLt, sample " + "FROM sqlite_stat4 ORDER BY 1", -1, + &pStmt, 0); + if( rc!=SQLITE_OK || pStmt==0 ){ + fprintf(stderr, "%s\n", sqlite3_errmsg(db)); + sqlite3_close(db); + exit(1); + } + while( SQLITE_ROW==sqlite3_step(pStmt) ){ + if( zIdx==0 || strcmp(zIdx, (const char*)sqlite3_column_text(pStmt,0))!=0 ){ + if( zIdx ) printf("\n"); + sqlite3_free(zIdx); + zIdx = sqlite3_mprintf("%s", sqlite3_column_text(pStmt,0)); + printf("%s:\n", zIdx); + }else{ + printf(" -----------------------------------------------------------\n"); + } + printf(" nEq = %s\n", sqlite3_column_text(pStmt,1)); + printf(" nLt = %s\n", sqlite3_column_text(pStmt,2)); + printf(" nDLt = %s\n", sqlite3_column_text(pStmt,3)); + printf(" sample = x'"); + aSample = sqlite3_column_blob(pStmt,4); + nSample = sqlite3_column_bytes(pStmt,4); + for(j=0; jnSample ){ + printf(" \n"); + continue; + } + y = mxHdr = (int)iVal; + while( xmxHdr ) break; + if( iVal<0 ) break; + switch( iVal ){ + case 0: sz = 0; break; + case 1: sz = 1; break; + case 2: sz = 2; break; + case 3: sz = 3; break; + case 4: sz = 4; break; + case 5: sz = 6; break; + case 6: sz = 8; break; + case 7: sz = 8; break; + case 8: sz = 0; break; + case 9: sz = 0; break; + case 10: + case 11: sz = 0; break; + default: sz = (int)(iVal-12)/2; break; + } + if( y+sz>nSample ) break; + if( iVal==0 ){ + printf("%sNULL", zSep); + }else if( iVal<=7 ){ + v = (signed char)aSample[y]; + for(j=1; j Date: Tue, 24 Jun 2014 20:19:21 +0000 Subject: [PATCH 10/27] Fix showstat4.c so that it decodes typecodes 8 and 9 correctly. FossilOrigin-Name: 9ca737c0b41f87998d842e7772c3e483bb291c50 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/showstat4.c | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 14bc9eca79..fea0a6e2cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sshowstat4.exe\sutility\sprogram\sfor\sdecoding\sand\sdisplaying\sthe\s\ncontent\sof\sthe\ssqlite_stat4\stable\sin\sa\sdatabase. -D 2014-06-24T00:59:15.223 +C Fix\sshowstat4.c\sso\sthat\sit\sdecodes\stypecodes\s8\sand\s9\scorrectly. +D 2014-06-24T20:19:21.030 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1160,7 +1160,7 @@ F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 F tool/showdb.c b018a8a69d07050fc0fe9afcf17313cdef0cc599 F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 -F tool/showstat4.c 47662af1e2c9567fd821da910b3a247c5c138021 +F tool/showstat4.c c39279d6bd37cb999b634f0064f6f86ad7af008f F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b @@ -1180,7 +1180,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ebec48921c092e20c9d7608242b63db40b40be5e -R 0ce5547c26474f508ca16bdace146cd3 +P b4d9f6053d1d95fdc1eab8ce610b51e7df8d896d +R 508dd98757238bd14305734cabeeae37 U drh -Z 0e7559d34a6f25f8be2f321b29251255 +Z 96b01d8567714808bc64d5917b4d4853 diff --git a/manifest.uuid b/manifest.uuid index 142fcbe956..5313f68aef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b4d9f6053d1d95fdc1eab8ce610b51e7df8d896d \ No newline at end of file +9ca737c0b41f87998d842e7772c3e483bb291c50 \ No newline at end of file diff --git a/tool/showstat4.c b/tool/showstat4.c index c85ab1c770..668d2106af 100644 --- a/tool/showstat4.c +++ b/tool/showstat4.c @@ -106,6 +106,8 @@ int main(int argc, char **argv){ if( y+sz>nSample ) break; if( iVal==0 ){ printf("%sNULL", zSep); + }else if( iVal==8 || iVal==9 ){ + printf("%s%d", zSep, ((int)iVal)-8); }else if( iVal<=7 ){ v = (signed char)aSample[y]; for(j=1; j Date: Thu, 26 Jun 2014 20:21:46 +0000 Subject: [PATCH 11/27] Attempt to use sqlite_stat4 data to estimate the number of rows visited by a range query that uses a skip-scan. This code is largely untested. FossilOrigin-Name: 01dc8102592427b71a18c2cb82301d2266dd59c2 --- manifest | 21 ++-- manifest.uuid | 2 +- src/sqliteInt.h | 2 + src/vdbemem.c | 137 +++++++++++++++++++------ src/where.c | 261 +++++++++++++++++++++++++++++++++--------------- 5 files changed, 300 insertions(+), 123 deletions(-) diff --git a/manifest b/manifest index fea0a6e2cc..5a780681cb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sshowstat4.c\sso\sthat\sit\sdecodes\stypecodes\s8\sand\s9\scorrectly. -D 2014-06-24T20:19:21.030 +C Attempt\sto\suse\ssqlite_stat4\sdata\sto\sestimate\sthe\snumber\sof\srows\svisited\sby\sa\srange\squery\sthat\suses\sa\sskip-scan.\sThis\scode\sis\slargely\suntested. +D 2014-06-26T20:21:46.005 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -227,7 +227,7 @@ F src/shell.c 56de2dfa3f25def4bf03098f7e2256fbb42f6e3c F src/sqlite.h.in a98eb3e8c86c934ea6f5bcfc6b69653dde2f4ed4 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h fccdc735c27b3dc12322fec7cdad8bc76be8d00b +F src/sqliteInt.h e88614d7371b80ff69dbbb5e4b9813ee93dfd890 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -289,14 +289,14 @@ F src/vdbeInt.h e6d83e5bfd62fc6685ba1ed6153f7099f82de9f7 F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 F src/vdbeaux.c e493f38758c4b8f4ca2007cf6a700bd405d192f3 F src/vdbeblob.c 9205ce9d3b064d9600f8418a897fc88b5687d9ac -F src/vdbemem.c 6fc77594c60f6155404f3f8d71bf36d1fdeb4447 +F src/vdbemem.c 8f28cb5bdd5b8748dba67aab5a07a47386fe40dc F src/vdbesort.c 44441d73b08b3a638dcdb725afffb87c6574ad27 F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767 F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 7b9e13cff91a2f14ac61e6a1bc3a83b5113e6298 +F src/where.c 643abd2dce6650d537c240c1ecdfc4090271091f F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1180,7 +1180,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b4d9f6053d1d95fdc1eab8ce610b51e7df8d896d -R 508dd98757238bd14305734cabeeae37 -U drh -Z 96b01d8567714808bc64d5917b4d4853 +P 9ca737c0b41f87998d842e7772c3e483bb291c50 +R 48ab9caf5628261ea5cdb35094645ef7 +T *branch * stat4-skipscan +T *sym-stat4-skipscan * +T -sym-trunk * +U dan +Z a77d7df51663ffd17fb07ab0f5d5231a diff --git a/manifest.uuid b/manifest.uuid index 5313f68aef..4422476212 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9ca737c0b41f87998d842e7772c3e483bb291c50 \ No newline at end of file +01dc8102592427b71a18c2cb82301d2266dd59c2 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index cc3a030510..7e347c4ee2 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3431,7 +3431,9 @@ void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *); #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 void sqlite3AnalyzeFunctions(void); int sqlite3Stat4ProbeSetValue(Parse*,Index*,UnpackedRecord**,Expr*,u8,int,int*); +int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**); void sqlite3Stat4ProbeFree(UnpackedRecord*); +int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**); #endif /* diff --git a/src/vdbemem.c b/src/vdbemem.c index 2c4aa4ad7f..67dea9c282 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1152,6 +1152,50 @@ void sqlite3AnalyzeFunctions(void){ } } +static int stat4ValueFromExpr( + Parse *pParse, /* Parse context */ + Expr *pExpr, /* The expression to extract a value from */ + u8 affinity, /* Affinity to use */ + struct ValueNewStat4Ctx *pAlloc,/* How to allocate space */ + sqlite3_value **ppVal /* OUT: New value object (or NULL) */ +){ + int rc = SQLITE_OK; + sqlite3_value *pVal = 0; + sqlite3 *db = pParse->db; + + /* Skip over any TK_COLLATE nodes */ + pExpr = sqlite3ExprSkipCollate(pExpr); + + if( !pExpr ){ + pVal = valueNew(db, pAlloc); + if( pVal ){ + sqlite3VdbeMemSetNull((Mem*)pVal); + } + }else if( pExpr->op==TK_VARIABLE + || NEVER(pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) + ){ + Vdbe *v; + int iBindVar = pExpr->iColumn; + sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar); + if( (v = pParse->pReprepare)!=0 ){ + pVal = valueNew(db, pAlloc); + if( pVal ){ + rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]); + if( rc==SQLITE_OK ){ + sqlite3ValueApplyAffinity(pVal, affinity, ENC(db)); + } + pVal->db = pParse->db; + } + } + }else{ + rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc); + } + + assert( pVal==0 || pVal->db==db ); + *ppVal = pVal; + return rc; +} + /* ** This function is used to allocate and populate UnpackedRecord ** structures intended to be compared against sample index keys stored @@ -1191,47 +1235,76 @@ int sqlite3Stat4ProbeSetValue( int iVal, /* Array element to populate */ int *pbOk /* OUT: True if value was extracted */ ){ - int rc = SQLITE_OK; + int rc; sqlite3_value *pVal = 0; - sqlite3 *db = pParse->db; - - struct ValueNewStat4Ctx alloc; + alloc.pParse = pParse; alloc.pIdx = pIdx; alloc.ppRec = ppRec; alloc.iVal = iVal; - /* Skip over any TK_COLLATE nodes */ - pExpr = sqlite3ExprSkipCollate(pExpr); - - if( !pExpr ){ - pVal = valueNew(db, &alloc); - if( pVal ){ - sqlite3VdbeMemSetNull((Mem*)pVal); - } - }else if( pExpr->op==TK_VARIABLE - || NEVER(pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) - ){ - Vdbe *v; - int iBindVar = pExpr->iColumn; - sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar); - if( (v = pParse->pReprepare)!=0 ){ - pVal = valueNew(db, &alloc); - if( pVal ){ - rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]); - if( rc==SQLITE_OK ){ - sqlite3ValueApplyAffinity(pVal, affinity, ENC(db)); - } - pVal->db = pParse->db; - } - } - }else{ - rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, &alloc); - } + rc = stat4ValueFromExpr(pParse, pExpr, affinity, &alloc, &pVal); + assert( pVal==0 || pVal->db==pParse->db ); *pbOk = (pVal!=0); + return rc; +} - assert( pVal==0 || pVal->db==db ); +/* +** Attempt to extract a value from expression pExpr using the methods +** as described for sqlite3Stat4ProbeSetValue() above. +** +** If successful, set *ppVal to point to a new value object and return +** SQLITE_OK. If no value can be extracted, but no other error occurs +** (e.g. OOM), return SQLITE_OK and set *ppVal to NULL. Or, if an error +** does occur, return an SQLite error code. The final value of *ppVal +** is undefined in this case. +*/ +int sqlite3Stat4ValueFromExpr( + Parse *pParse, /* Parse context */ + Expr *pExpr, /* The expression to extract a value from */ + u8 affinity, /* Affinity to use */ + sqlite3_value **ppVal /* OUT: New value object (or NULL) */ +){ + return stat4ValueFromExpr(pParse, pExpr, affinity, 0, ppVal); +} + +int sqlite3Stat4Column( + sqlite3 *db, /* Database handle */ + const void *pRec, /* Pointer to buffer containing record */ + int nRec, /* Size of buffer pRec in bytes */ + int iCol, /* Column to extract */ + sqlite3_value **ppVal /* OUT: Extracted value */ +){ + int rc = SQLITE_OK; + Mem *pMem = *ppVal; + if( pMem==0 ){ + pMem = (Mem*)sqlite3ValueNew(db); + if( pMem==0 ){ + rc = SQLITE_NOMEM; + } + } + + if( rc==SQLITE_OK ){ + u32 t; + int nHdr; + int iHdr; + int iField; + int i; + u8 *a = (u8*)pRec; + + iHdr = getVarint32(a, nHdr); + iField = nHdr; + for(i=0; inOut is currently set to the estimated number of rows +** visited for scanning (a=? AND b=?). This function reduces that estimate +** by some factor to account for the (c BETWEEN ? AND ?) expression based +** on the stat4 data for the index. this scan will be peformed multiple +** times (once for each (a,b) combination that matches a=?) is dealt with +** by the caller. +** +** It does this by scanning through all stat4 samples, comparing values +** extracted from pLower and pUpper with the corresponding column in each +** sample. If L and U are the number of samples found to be less than or +** equal to the values extracted from pLower and pUpper respectively, and +** N is the total number of samples, the pLoop->nOut value is adjusted +** as follows: +** +** nOut = nOut * ( min(U - L, 1) / N ) +** +** If pLower is NULL, or a value cannot be extracted from the term, L is +** set to zero. If pUpper is NULL, or a value cannot be extracted from it, +** U is set to N. +** +** Normally, this function sets *pbDone to 1 before returning. However, +** if no value can be extracted from either pLower or pUpper (and so the +** estimate of the number of rows delivered remains unchanged), *pbDone +** is left as is. +** +** If an error occurs, an SQLite error code is returned. Otherwise, +** SQLITE_OK. +*/ +static int whereRangeSkipScanEst( + Parse *pParse, /* Parsing & code generating context */ + WhereTerm *pLower, /* Lower bound on the range. ex: "x>123" Might be NULL */ + WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */ + WhereLoop *pLoop, /* Update the .nOut value of this loop */ + int *pbDone /* Set to true if at least one expr. value extracted */ +){ + Index *p = pLoop->u.btree.pIndex; + int nEq = pLoop->u.btree.nEq; + sqlite3 *db = pParse->db; + int nLower = 0; + int nUpper = 0; + int rc = SQLITE_OK; + u8 aff = p->pTable->aCol[ p->aiColumn[nEq] ].affinity; + CollSeq *pColl; + + sqlite3_value *p1 = 0; /* Value extracted from pLower */ + sqlite3_value *p2 = 0; /* Value extracted from pUpper */ + sqlite3_value *pVal = 0; /* Value extracted from record */ + + pColl = sqlite3LocateCollSeq(pParse, p->azColl[nEq]); + if( pLower ){ + rc = sqlite3Stat4ValueFromExpr(pParse, pLower->pExpr->pRight, aff, &p1); + } + if( pUpper && rc==SQLITE_OK ){ + rc = sqlite3Stat4ValueFromExpr(pParse, pUpper->pExpr->pRight, aff, &p2); + } + + if( p1 || p2 ){ + int i; + int nDiff; + for(i=0; rc==SQLITE_OK && inSample; i++){ + rc = sqlite3Stat4Column(db, p->aSample[i].p, p->aSample[i].n, nEq, &pVal); + if( rc==SQLITE_OK && p1 ){ + int res = sqlite3MemCompare(p1, pVal, pColl); + if( res<=0 ) nLower++; + } + if( rc==SQLITE_OK && p2 ){ + int res = sqlite3MemCompare(p2, pVal, pColl); + if( res<=0 ) nUpper++; + } + } + if( p2==0 ) nUpper = p->nSample; + nDiff = (nUpper - nLower); + if( nDiff<=0 ) nDiff = 1; + pLoop->nOut -= (sqlite3LogEst(p->nSample) - sqlite3LogEst(nDiff)); + *pbDone = 1; + }else{ + assert( *pbDone==0 ); + } + + sqlite3ValueFree(p1); + sqlite3ValueFree(p2); + sqlite3ValueFree(pVal); + + return rc; +} + /* ** This function is used to estimate the number of rows that will be visited ** by scanning an index for a range of values. The range may have an upper @@ -2054,95 +2148,100 @@ static int whereRangeScanEst( int nEq = pLoop->u.btree.nEq; if( p->nSample>0 - && nEq==pBuilder->nRecValid && nEqnSampleCol && OptimizationEnabled(pParse->db, SQLITE_Stat3) ){ - UnpackedRecord *pRec = pBuilder->pRec; - tRowcnt a[2]; - u8 aff; + if( nEq==pBuilder->nRecValid ){ + UnpackedRecord *pRec = pBuilder->pRec; + tRowcnt a[2]; + u8 aff; - /* Variable iLower will be set to the estimate of the number of rows in - ** the index that are less than the lower bound of the range query. The - ** lower bound being the concatenation of $P and $L, where $P is the - ** key-prefix formed by the nEq values matched against the nEq left-most - ** columns of the index, and $L is the value in pLower. - ** - ** Or, if pLower is NULL or $L cannot be extracted from it (because it - ** is not a simple variable or literal value), the lower bound of the - ** range is $P. Due to a quirk in the way whereKeyStats() works, even - ** if $L is available, whereKeyStats() is called for both ($P) and - ** ($P:$L) and the larger of the two returned values used. - ** - ** Similarly, iUpper is to be set to the estimate of the number of rows - ** less than the upper bound of the range query. Where the upper bound - ** is either ($P) or ($P:$U). Again, even if $U is available, both values - ** of iUpper are requested of whereKeyStats() and the smaller used. - */ - tRowcnt iLower; - tRowcnt iUpper; + /* Variable iLower will be set to the estimate of the number of rows in + ** the index that are less than the lower bound of the range query. The + ** lower bound being the concatenation of $P and $L, where $P is the + ** key-prefix formed by the nEq values matched against the nEq left-most + ** columns of the index, and $L is the value in pLower. + ** + ** Or, if pLower is NULL or $L cannot be extracted from it (because it + ** is not a simple variable or literal value), the lower bound of the + ** range is $P. Due to a quirk in the way whereKeyStats() works, even + ** if $L is available, whereKeyStats() is called for both ($P) and + ** ($P:$L) and the larger of the two returned values used. + ** + ** Similarly, iUpper is to be set to the estimate of the number of rows + ** less than the upper bound of the range query. Where the upper bound + ** is either ($P) or ($P:$U). Again, even if $U is available, both values + ** of iUpper are requested of whereKeyStats() and the smaller used. + */ + tRowcnt iLower; + tRowcnt iUpper; - if( nEq==p->nKeyCol ){ - aff = SQLITE_AFF_INTEGER; - }else{ - aff = p->pTable->aCol[p->aiColumn[nEq]].affinity; - } - /* Determine iLower and iUpper using ($P) only. */ - if( nEq==0 ){ - iLower = 0; - iUpper = sqlite3LogEstToInt(p->aiRowLogEst[0]); - }else{ - /* Note: this call could be optimized away - since the same values must - ** have been requested when testing key $P in whereEqualScanEst(). */ - whereKeyStats(pParse, p, pRec, 0, a); - iLower = a[0]; - iUpper = a[0] + a[1]; - } - - /* If possible, improve on the iLower estimate using ($P:$L). */ - if( pLower ){ - int bOk; /* True if value is extracted from pExpr */ - Expr *pExpr = pLower->pExpr->pRight; - assert( (pLower->eOperator & (WO_GT|WO_GE))!=0 ); - rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk); - if( rc==SQLITE_OK && bOk ){ - tRowcnt iNew; - whereKeyStats(pParse, p, pRec, 0, a); - iNew = a[0] + ((pLower->eOperator & WO_GT) ? a[1] : 0); - if( iNew>iLower ) iLower = iNew; - nOut--; - } - } - - /* If possible, improve on the iUpper estimate using ($P:$U). */ - if( pUpper ){ - int bOk; /* True if value is extracted from pExpr */ - Expr *pExpr = pUpper->pExpr->pRight; - assert( (pUpper->eOperator & (WO_LT|WO_LE))!=0 ); - rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk); - if( rc==SQLITE_OK && bOk ){ - tRowcnt iNew; - whereKeyStats(pParse, p, pRec, 1, a); - iNew = a[0] + ((pUpper->eOperator & WO_LE) ? a[1] : 0); - if( iNewpRec = pRec; - if( rc==SQLITE_OK ){ - if( iUpper>iLower ){ - nNew = sqlite3LogEst(iUpper - iLower); + if( nEq==p->nKeyCol ){ + aff = SQLITE_AFF_INTEGER; }else{ - nNew = 10; assert( 10==sqlite3LogEst(2) ); + aff = p->pTable->aCol[p->aiColumn[nEq]].affinity; } - if( nNewaiRowLogEst[0]); + }else{ + /* Note: this call could be optimized away - since the same values must + ** have been requested when testing key $P in whereEqualScanEst(). */ + whereKeyStats(pParse, p, pRec, 0, a); + iLower = a[0]; + iUpper = a[0] + a[1]; } - pLoop->nOut = (LogEst)nOut; - WHERETRACE(0x10, ("range scan regions: %u..%u est=%d\n", - (u32)iLower, (u32)iUpper, nOut)); - return SQLITE_OK; + + /* If possible, improve on the iLower estimate using ($P:$L). */ + if( pLower ){ + int bOk; /* True if value is extracted from pExpr */ + Expr *pExpr = pLower->pExpr->pRight; + assert( (pLower->eOperator & (WO_GT|WO_GE))!=0 ); + rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk); + if( rc==SQLITE_OK && bOk ){ + tRowcnt iNew; + whereKeyStats(pParse, p, pRec, 0, a); + iNew = a[0] + ((pLower->eOperator & WO_GT) ? a[1] : 0); + if( iNew>iLower ) iLower = iNew; + nOut--; + } + } + + /* If possible, improve on the iUpper estimate using ($P:$U). */ + if( pUpper ){ + int bOk; /* True if value is extracted from pExpr */ + Expr *pExpr = pUpper->pExpr->pRight; + assert( (pUpper->eOperator & (WO_LT|WO_LE))!=0 ); + rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk); + if( rc==SQLITE_OK && bOk ){ + tRowcnt iNew; + whereKeyStats(pParse, p, pRec, 1, a); + iNew = a[0] + ((pUpper->eOperator & WO_LE) ? a[1] : 0); + if( iNewpRec = pRec; + if( rc==SQLITE_OK ){ + if( iUpper>iLower ){ + nNew = sqlite3LogEst(iUpper - iLower); + }else{ + nNew = 10; assert( 10==sqlite3LogEst(2) ); + } + if( nNewnOut = (LogEst)nOut; + WHERETRACE(0x10, ("range scan regions: %u..%u est=%d\n", + (u32)iLower, (u32)iUpper, nOut)); + return SQLITE_OK; + } + }else{ + int bDone = 0; + rc = whereRangeSkipScanEst(pParse, pLower, pUpper, pLoop, &bDone); + if( bDone ) return rc; } } #else From 9bec6fb3efce29aebf89a37f2fb134d16868dff9 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 26 Jun 2014 21:28:21 +0000 Subject: [PATCH 12/27] Revise the affinity returned for expressions flagged as 'generic'. Fix for [9a8b09f8e6]. FossilOrigin-Name: 92f7ad43dbfe4e02490df2f932c3c74fb89064d6 --- manifest | 15 +-- manifest.uuid | 2 +- src/expr.c | 2 +- test/tkt-9a8b09f8e6.test | 265 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 275 insertions(+), 9 deletions(-) create mode 100644 test/tkt-9a8b09f8e6.test diff --git a/manifest b/manifest index fea0a6e2cc..31eaa743e5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sshowstat4.c\sso\sthat\sit\sdecodes\stypecodes\s8\sand\s9\scorrectly. -D 2014-06-24T20:19:21.030 +C Revise\sthe\saffinity\sreturned\sfor\sexpressions\sflagged\sas\s'generic'.\s\sFix\sfor\s[9a8b09f8e6]. +D 2014-06-26T21:28:21.292 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -176,7 +176,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 0231df905e2c4abba4483ee18ffc05adc321df2a F src/date.c 593c744b2623971e45affd0bde347631bdfa4625 F src/delete.c bcf8f72126cea80fc3d5bc5494cf19b3f8935aaf -F src/expr.c 4f9e497c66e2f25a4d139357a778c84d5713207c +F src/expr.c 40d06d1543b1355aa02efa9666178f7642a96ed6 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c a549cff9fe8b736cdae21650ea0af6de29b77619 F src/func.c 3bc223ea36cd29a91c481485343d0ee4257ab8dc @@ -904,6 +904,7 @@ F test/tkt-868145d012.test a5f941107ece6a64410ca4755c6329b7eb57a356 F test/tkt-8c63ff0ec.test 258b7fc8d7e4e1cb5362c7d65c143528b9c4cbed F test/tkt-91e2e8ba6f.test 08c4f94ae07696b05c9b822da0b4e5337a2f54c5 F test/tkt-94c04eaadb.test f738c57c7f68ab8be1c054415af7774617cb6223 +F test/tkt-9a8b09f8e6.test 8b81b1fa5193246dbf5fe876929f71c3712ee755 F test/tkt-9d68c883.test 458f7d82a523d7644b54b497c986378a7d8c8b67 F test/tkt-9f2eb3abac.test 85bc63e749f050e6a61c8f9207f1eee65c9d3395 F test/tkt-a7b7803e.test 159ef554234fa1f9fb318c751b284bd1cf858da4 @@ -1180,7 +1181,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b4d9f6053d1d95fdc1eab8ce610b51e7df8d896d -R 508dd98757238bd14305734cabeeae37 -U drh -Z 96b01d8567714808bc64d5917b4d4853 +P 9ca737c0b41f87998d842e7772c3e483bb291c50 +R 4121a5e953ac74e556013274c6ab2f95 +U mistachkin +Z 9298eeb693f0be09657ca6e474114119 diff --git a/manifest.uuid b/manifest.uuid index 5313f68aef..1b2cca87bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9ca737c0b41f87998d842e7772c3e483bb291c50 \ No newline at end of file +92f7ad43dbfe4e02490df2f932c3c74fb89064d6 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 08c121e386..803d93f30d 100644 --- a/src/expr.c +++ b/src/expr.c @@ -33,7 +33,7 @@ char sqlite3ExprAffinity(Expr *pExpr){ int op; pExpr = sqlite3ExprSkipCollate(pExpr); - if( pExpr->flags & EP_Generic ) return SQLITE_AFF_NONE; + if( pExpr->flags & EP_Generic ) return 0; op = pExpr->op; if( op==TK_SELECT ){ assert( pExpr->flags&EP_xIsSelect ); diff --git a/test/tkt-9a8b09f8e6.test b/test/tkt-9a8b09f8e6.test new file mode 100644 index 0000000000..6bd3db5de0 --- /dev/null +++ b/test/tkt-9a8b09f8e6.test @@ -0,0 +1,265 @@ +# 2014 June 26 +# +# 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. +# +# This file implements tests to verify that ticket [9a8b09f8e6] has been +# fixed. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix tkt-9a8b09f8e6 + +do_test 1.1 { + execsql { + CREATE TABLE t1(x TEXT); + INSERT INTO t1 VALUES('1'); + } +} {} + +do_test 1.2 { + execsql { + CREATE TABLE t2(x INTEGER); + INSERT INTO t2 VALUES(1); + } +} {} + +do_test 1.3 { + execsql { + CREATE TABLE t3(x REAL); + INSERT INTO t3 VALUES(1.0); + } +} {} + +do_test 1.4 { + execsql { + CREATE TABLE t4(x REAL); + INSERT INTO t4 VALUES(1.11); + } +} {} + +do_test 2.1 { + execsql { + SELECT x FROM t1 WHERE x IN (1); + } +} {1} + +do_test 2.2 { + execsql { + SELECT x FROM t1 WHERE x IN (1.0); + } +} {} + +do_test 2.3 { + execsql { + SELECT x FROM t1 WHERE x IN ('1'); + } +} {1} + +do_test 2.4 { + execsql { + SELECT x FROM t1 WHERE x IN ('1.0'); + } +} {} + +do_test 2.5 { + execsql { + SELECT x FROM t1 WHERE 1 IN (x); + } +} {} + +do_test 2.6 { + execsql { + SELECT x FROM t1 WHERE 1.0 IN (x); + } +} {} + +do_test 2.7 { + execsql { + SELECT x FROM t1 WHERE '1' IN (x); + } +} {1} + +do_test 2.8 { + execsql { + SELECT x FROM t1 WHERE '1.0' IN (x); + } +} {} + +do_test 3.1 { + execsql { + SELECT x FROM t2 WHERE x IN (1); + } +} {1} + +do_test 3.2 { + execsql { + SELECT x FROM t2 WHERE x IN (1.0); + } +} {1} + +do_test 3.3 { + execsql { + SELECT x FROM t2 WHERE x IN ('1'); + } +} {1} + +do_test 3.4 { + execsql { + SELECT x FROM t2 WHERE x IN ('1.0'); + } +} {1} + +do_test 3.5 { + execsql { + SELECT x FROM t2 WHERE 1 IN (x); + } +} {1} + +do_test 3.6 { + execsql { + SELECT x FROM t2 WHERE 1.0 IN (x); + } +} {1} + +do_test 3.7 { + execsql { + SELECT x FROM t2 WHERE '1' IN (x); + } +} {} + +do_test 3.8 { + execsql { + SELECT x FROM t2 WHERE '1.0' IN (x); + } +} {} + +do_test 4.1 { + execsql { + SELECT x FROM t3 WHERE x IN (1); + } +} {1.0} + +do_test 4.2 { + execsql { + SELECT x FROM t3 WHERE x IN (1.0); + } +} {1.0} + +do_test 4.3 { + execsql { + SELECT x FROM t3 WHERE x IN ('1'); + } +} {1.0} + +do_test 4.4 { + execsql { + SELECT x FROM t3 WHERE x IN ('1.0'); + } +} {1.0} + +do_test 4.5 { + execsql { + SELECT x FROM t3 WHERE 1 IN (x); + } +} {1.0} + +do_test 4.6 { + execsql { + SELECT x FROM t3 WHERE 1.0 IN (x); + } +} {1.0} + +do_test 4.7 { + execsql { + SELECT x FROM t3 WHERE '1' IN (x); + } +} {} + +do_test 4.8 { + execsql { + SELECT x FROM t3 WHERE '1.0' IN (x); + } +} {} + +do_test 5.1 { + execsql { + SELECT x FROM t4 WHERE x IN (1); + } +} {} + +do_test 5.2 { + execsql { + SELECT x FROM t4 WHERE x IN (1.0); + } +} {} + +do_test 5.3 { + execsql { + SELECT x FROM t4 WHERE x IN ('1'); + } +} {} + +do_test 5.4 { + execsql { + SELECT x FROM t4 WHERE x IN ('1.0'); + } +} {} + +do_test 5.5 { + execsql { + SELECT x FROM t4 WHERE x IN (1.11); + } +} {1.11} + +do_test 5.6 { + execsql { + SELECT x FROM t4 WHERE x IN ('1.11'); + } +} {1.11} + +do_test 5.7 { + execsql { + SELECT x FROM t4 WHERE 1 IN (x); + } +} {} + +do_test 5.8 { + execsql { + SELECT x FROM t4 WHERE 1.0 IN (x); + } +} {} + +do_test 5.9 { + execsql { + SELECT x FROM t4 WHERE '1' IN (x); + } +} {} + +do_test 5.10 { + execsql { + SELECT x FROM t4 WHERE '1.0' IN (x); + } +} {} + +do_test 5.11 { + execsql { + SELECT x FROM t4 WHERE 1.11 IN (x); + } +} {1.11} + +do_test 5.12 { + execsql { + SELECT x FROM t4 WHERE '1.11' IN (x); + } +} {} + +finish_test From 2d84ac480b2bf35619570b9e17a7e39dd7dd2100 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 26 Jun 2014 21:32:09 +0000 Subject: [PATCH 13/27] Fix compilation issue when STAT4 is not enabled. FossilOrigin-Name: 74a5454a710e1b7d8575cec2f872e6110aefce17 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/where.c | 2 ++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 5a780681cb..3a8265365f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Attempt\sto\suse\ssqlite_stat4\sdata\sto\sestimate\sthe\snumber\sof\srows\svisited\sby\sa\srange\squery\sthat\suses\sa\sskip-scan.\sThis\scode\sis\slargely\suntested. -D 2014-06-26T20:21:46.005 +C Fix\scompilation\sissue\swhen\sSTAT4\sis\snot\senabled. +D 2014-06-26T21:32:09.075 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -296,7 +296,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 643abd2dce6650d537c240c1ecdfc4090271091f +F src/where.c 0396f040a1ffe31b1f63673c6cd6c469c5e4ce57 F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1180,10 +1180,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9ca737c0b41f87998d842e7772c3e483bb291c50 -R 48ab9caf5628261ea5cdb35094645ef7 -T *branch * stat4-skipscan -T *sym-stat4-skipscan * -T -sym-trunk * -U dan -Z a77d7df51663ffd17fb07ab0f5d5231a +P 01dc8102592427b71a18c2cb82301d2266dd59c2 +R 1ded9652c09c1b748cd5e7181ce5016c +U mistachkin +Z b89953846d49961fb37fc288882b8874 diff --git a/manifest.uuid b/manifest.uuid index 4422476212..7e63e6d9db 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -01dc8102592427b71a18c2cb82301d2266dd59c2 \ No newline at end of file +74a5454a710e1b7d8575cec2f872e6110aefce17 \ No newline at end of file diff --git a/src/where.c b/src/where.c index a500b5a024..a8c8bccde4 100644 --- a/src/where.c +++ b/src/where.c @@ -1999,6 +1999,7 @@ static LogEst whereRangeAdjust(WhereTerm *pTerm, LogEst nNew){ return nRet; } +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 /* ** This function is called to estimate the number of rows visited by a ** range-scan on a skip-scan index. For example: @@ -2091,6 +2092,7 @@ static int whereRangeSkipScanEst( return rc; } +#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */ /* ** This function is used to estimate the number of rows that will be visited From 5d249518652c86e9aec977f529da7aa199b4790f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 26 Jun 2014 22:17:21 +0000 Subject: [PATCH 14/27] Add some more IN operator tests. FossilOrigin-Name: fb32e374b75b160e7b535e732ced6c34dbb513eb --- manifest | 12 ++++----- manifest.uuid | 2 +- test/tkt-9a8b09f8e6.test | 58 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 31eaa743e5..27807f1cbc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revise\sthe\saffinity\sreturned\sfor\sexpressions\sflagged\sas\s'generic'.\s\sFix\sfor\s[9a8b09f8e6]. -D 2014-06-26T21:28:21.292 +C Add\ssome\smore\sIN\soperator\stests. +D 2014-06-26T22:17:21.764 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -904,7 +904,7 @@ F test/tkt-868145d012.test a5f941107ece6a64410ca4755c6329b7eb57a356 F test/tkt-8c63ff0ec.test 258b7fc8d7e4e1cb5362c7d65c143528b9c4cbed F test/tkt-91e2e8ba6f.test 08c4f94ae07696b05c9b822da0b4e5337a2f54c5 F test/tkt-94c04eaadb.test f738c57c7f68ab8be1c054415af7774617cb6223 -F test/tkt-9a8b09f8e6.test 8b81b1fa5193246dbf5fe876929f71c3712ee755 +F test/tkt-9a8b09f8e6.test b2ef151d0984b2ebf237760dbeaa50724e5a0667 F test/tkt-9d68c883.test 458f7d82a523d7644b54b497c986378a7d8c8b67 F test/tkt-9f2eb3abac.test 85bc63e749f050e6a61c8f9207f1eee65c9d3395 F test/tkt-a7b7803e.test 159ef554234fa1f9fb318c751b284bd1cf858da4 @@ -1181,7 +1181,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 9ca737c0b41f87998d842e7772c3e483bb291c50 -R 4121a5e953ac74e556013274c6ab2f95 +P 92f7ad43dbfe4e02490df2f932c3c74fb89064d6 +R 61cea95999002249f7da20d93ec0602d U mistachkin -Z 9298eeb693f0be09657ca6e474114119 +Z 2021f223ccdab7be5b0b3bf69eadf881 diff --git a/manifest.uuid b/manifest.uuid index 1b2cca87bd..9daab53ded 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -92f7ad43dbfe4e02490df2f932c3c74fb89064d6 \ No newline at end of file +fb32e374b75b160e7b535e732ced6c34dbb513eb \ No newline at end of file diff --git a/test/tkt-9a8b09f8e6.test b/test/tkt-9a8b09f8e6.test index 6bd3db5de0..d6b22efb21 100644 --- a/test/tkt-9a8b09f8e6.test +++ b/test/tkt-9a8b09f8e6.test @@ -46,6 +46,16 @@ do_test 1.4 { } } {} +do_test 1.5 { + execsql { + CREATE TABLE t5(x, y); + INSERT INTO t5 VALUES('1', 'one'); + INSERT INTO t5 VALUES(1, 'two'); + INSERT INTO t5 VALUES('1.0', 'three'); + INSERT INTO t5 VALUES(1.0, 'four'); + } +} {} + do_test 2.1 { execsql { SELECT x FROM t1 WHERE x IN (1); @@ -262,4 +272,52 @@ do_test 5.12 { } } {} +do_test 6.1 { + execsql { + SELECT x, y FROM t5 WHERE x IN (1); + } +} {1 two 1.0 four} + +do_test 6.2 { + execsql { + SELECT x, y FROM t5 WHERE x IN (1.0); + } +} {1 two 1.0 four} + +do_test 6.3 { + execsql { + SELECT x, y FROM t5 WHERE x IN ('1'); + } +} {1 one} + +do_test 6.4 { + execsql { + SELECT x, y FROM t5 WHERE x IN ('1.0'); + } +} {1.0 three} + +do_test 6.5 { + execsql { + SELECT x, y FROM t5 WHERE 1 IN (x); + } +} {1 two 1.0 four} + +do_test 6.6 { + execsql { + SELECT x, y FROM t5 WHERE 1.0 IN (x); + } +} {1 two 1.0 four} + +do_test 6.7 { + execsql { + SELECT x, y FROM t5 WHERE '1' IN (x); + } +} {1 one} + +do_test 6.8 { + execsql { + SELECT x, y FROM t5 WHERE '1.0' IN (x); + } +} {1.0 three} + finish_test From 4e42ba4a356f21306a84a2958ee1a66a7f285cfd Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 27 Jun 2014 20:14:25 +0000 Subject: [PATCH 15/27] Fix a couple of problems in estimating the number of rows visited by a range query that uses a skip-scan. FossilOrigin-Name: 219736f54dcd1448af3400e699f1c20755ac6876 --- manifest | 17 ++++---- manifest.uuid | 2 +- src/vdbemem.c | 2 +- src/where.c | 27 +++++++++---- test/skipscan5.test | 95 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 17 deletions(-) create mode 100644 test/skipscan5.test diff --git a/manifest b/manifest index 3a8265365f..14dfe69604 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompilation\sissue\swhen\sSTAT4\sis\snot\senabled. -D 2014-06-26T21:32:09.075 +C Fix\sa\scouple\sof\sproblems\sin\sestimating\sthe\snumber\sof\srows\svisited\sby\sa\srange\squery\sthat\suses\sa\sskip-scan. +D 2014-06-27T20:14:25.215 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -289,14 +289,14 @@ F src/vdbeInt.h e6d83e5bfd62fc6685ba1ed6153f7099f82de9f7 F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 F src/vdbeaux.c e493f38758c4b8f4ca2007cf6a700bd405d192f3 F src/vdbeblob.c 9205ce9d3b064d9600f8418a897fc88b5687d9ac -F src/vdbemem.c 8f28cb5bdd5b8748dba67aab5a07a47386fe40dc +F src/vdbemem.c 3f191d4113805e3c5e875b732c44c9d98bac0595 F src/vdbesort.c 44441d73b08b3a638dcdb725afffb87c6574ad27 F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767 F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 0396f040a1ffe31b1f63673c6cd6c469c5e4ce57 +F src/where.c fea270aeef23f978edac94b5591c74b0bf3ce884 F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -829,6 +829,7 @@ F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868 F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329 F test/skipscan1.test 28c7faa41a0d7265040ecb0a0abd90c0904270b2 F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a +F test/skipscan5.test 7eb78ace4e7145fb5005d47a8f837701d7027b85 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 40562fe6cac6d9827b7b42b86d45aedf12c15e24 F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5 @@ -1180,7 +1181,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 01dc8102592427b71a18c2cb82301d2266dd59c2 -R 1ded9652c09c1b748cd5e7181ce5016c -U mistachkin -Z b89953846d49961fb37fc288882b8874 +P 74a5454a710e1b7d8575cec2f872e6110aefce17 +R 02edb14d4ef805eea40e69e5acdf39b7 +U dan +Z bd7cb892a5b1d67344c0bf9079bc8afa diff --git a/manifest.uuid b/manifest.uuid index 7e63e6d9db..d621593f3a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -74a5454a710e1b7d8575cec2f872e6110aefce17 \ No newline at end of file +219736f54dcd1448af3400e699f1c20755ac6876 \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index 67dea9c282..634c881f2f 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1296,7 +1296,7 @@ int sqlite3Stat4Column( iHdr = getVarint32(a, nHdr); iField = nHdr; for(i=0; iu.btree.pIndex; int nEq = pLoop->u.btree.nEq; sqlite3 *db = pParse->db; - int nLower = 0; - int nUpper = 0; + int nLower = -1; + int nUpper = p->nSample+1; int rc = SQLITE_OK; u8 aff = p->pTable->aCol[ p->aiColumn[nEq] ].affinity; CollSeq *pColl; @@ -2058,9 +2058,11 @@ static int whereRangeSkipScanEst( pColl = sqlite3LocateCollSeq(pParse, p->azColl[nEq]); if( pLower ){ rc = sqlite3Stat4ValueFromExpr(pParse, pLower->pExpr->pRight, aff, &p1); + nLower = 0; } if( pUpper && rc==SQLITE_OK ){ rc = sqlite3Stat4ValueFromExpr(pParse, pUpper->pExpr->pRight, aff, &p2); + nUpper = p2 ? 0 : p->nSample; } if( p1 || p2 ){ @@ -2070,18 +2072,29 @@ static int whereRangeSkipScanEst( rc = sqlite3Stat4Column(db, p->aSample[i].p, p->aSample[i].n, nEq, &pVal); if( rc==SQLITE_OK && p1 ){ int res = sqlite3MemCompare(p1, pVal, pColl); - if( res<=0 ) nLower++; + if( res>=0 ) nLower++; } if( rc==SQLITE_OK && p2 ){ int res = sqlite3MemCompare(p2, pVal, pColl); - if( res<=0 ) nUpper++; + if( res>=0 ) nUpper++; } } - if( p2==0 ) nUpper = p->nSample; nDiff = (nUpper - nLower); if( nDiff<=0 ) nDiff = 1; - pLoop->nOut -= (sqlite3LogEst(p->nSample) - sqlite3LogEst(nDiff)); - *pbDone = 1; + + /* If there is both an upper and lower bound specified, and the + ** comparisons indicate that they are close together, use the fallback + ** method (assume that the scan visits 1/64 of the rows) for estimating + ** the number of rows visited. Otherwise, estimate the number of rows + ** using the method described in the header comment for this function. */ + if( nDiff!=1 || pUpper==0 || pLower==0 ){ + int nAdjust = (sqlite3LogEst(p->nSample) - sqlite3LogEst(nDiff)); + pLoop->nOut -= nAdjust; + *pbDone = 1; + WHERETRACE(0x10, ("range skip-scan regions: %u..%u adjust=%d est=%d\n", + (u32)nLower, (u32)nUpper, nAdjust*-1, pLoop->nOut)); + } + }else{ assert( *pbDone==0 ); } diff --git a/test/skipscan5.test b/test/skipscan5.test new file mode 100644 index 0000000000..b374302f83 --- /dev/null +++ b/test/skipscan5.test @@ -0,0 +1,95 @@ +# 2013-11-13 +# +# 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 tests of the "skip-scan" query strategy. In +# particular it tests that stat4 data can be used by a range query +# that uses the skip-scan approach. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix skipscan5 + +ifcapable !stat4 { + finish_test + return +} + +do_execsql_test 1.1 { + CREATE TABLE t1(a INT, b INT, c INT); + CREATE INDEX i1 ON t1(a, b); +} {} + +expr srand(4) +do_test 1.2 { + for {set i 0} {$i < 100} {incr i} { + set a [expr int(rand()*4.0) + 1] + set b [expr int(rand()*20.0) + 1] + execsql { INSERT INTO t1 VALUES($a, $b, NULL) } + } + execsql ANALYZE +} {} + +do_eqp_test 1.3 { + SELECT * FROM t1 WHERE b = 5; +} { + 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b=?)} +} + +do_eqp_test 1.4 { + SELECT * FROM t1 WHERE b > 12 AND b < 16; +} { + 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b>? AND b 2 AND b < 16; +} { + 0 0 0 {SCAN TABLE t1} +} + +do_eqp_test 1.6 { + SELECT * FROM t1 WHERE b > 18 AND b < 25; +} { + 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b>? AND b 18 AND b < 25; +} { + 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b>? AND b 15; +} { + 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b>?)} +} + +do_eqp_test 1.9 { + SELECT * FROM t1 WHERE b > 5; +} { + 0 0 0 {SCAN TABLE t1} +} + +do_eqp_test 1.10 { + SELECT * FROM t1 WHERE b < 5; +} { + 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b Date: Sat, 28 Jun 2014 14:28:06 +0000 Subject: [PATCH 16/27] Change the VDBE to export the sqlite3MemCompare() routine and thus free where.c from the dependency on vdbeInt.h. FossilOrigin-Name: d186d1ac3c47f0d814636c4b8386a6065a294750 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/vdbe.h | 1 + src/vdbeInt.h | 1 - src/where.c | 1 - 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index fc497fbfa9..620657f6c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sfixes\sfrom\strunk\swith\sthis\sbranch. -D 2014-06-28T14:25:32.570 +C Change\sthe\sVDBE\sto\sexport\sthe\ssqlite3MemCompare()\sroutine\sand\sthus\sfree\nwhere.c\sfrom\sthe\sdependency\son\svdbeInt.h. +D 2014-06-28T14:28:06.405 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -284,8 +284,8 @@ F src/utf.c a0314e637768a030e6e84a957d0c4f6ba910cc05 F src/util.c 049fe1d3c0e2209c1bee107aec2fcff6285f909f F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 F src/vdbe.c 9bfe6becfc094382ae213656fbe511055ad83a54 -F src/vdbe.h 394464909ed682334aa3d5831aae0c2fe2abef94 -F src/vdbeInt.h e6d83e5bfd62fc6685ba1ed6153f7099f82de9f7 +F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8 +F src/vdbeInt.h 5df5e9afe9b7839cd17256220fc4f7af84b8b1cd F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 F src/vdbeaux.c e493f38758c4b8f4ca2007cf6a700bd405d192f3 F src/vdbeblob.c 9205ce9d3b064d9600f8418a897fc88b5687d9ac @@ -296,7 +296,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c fea270aeef23f978edac94b5591c74b0bf3ce884 +F src/where.c 1f448161f1d9ec8cb68e2a8eb2e4a9756a877f69 F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1182,7 +1182,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 219736f54dcd1448af3400e699f1c20755ac6876 fb32e374b75b160e7b535e732ced6c34dbb513eb -R 638c04374a356a745d9c2d2f0fa602ad -U dan -Z fc19d5103e4b8e0f744c9b3dd9fc467e +P 6af219d1b83ec54b3fb4ad4e6216d9ad9ea0fc70 +R 0d122ee9efb300dc8d78b79e592143bf +U drh +Z 93fe23c37a7fe2b9652da5b4873aa7c3 diff --git a/manifest.uuid b/manifest.uuid index bcfbef8325..172499a547 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6af219d1b83ec54b3fb4ad4e6216d9ad9ea0fc70 \ No newline at end of file +d186d1ac3c47f0d814636c4b8386a6065a294750 \ No newline at end of file diff --git a/src/vdbe.h b/src/vdbe.h index 10a4140ee1..ef91010d80 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -209,6 +209,7 @@ void sqlite3VdbeSetVarmask(Vdbe*, int); #ifndef SQLITE_OMIT_TRACE char *sqlite3VdbeExpandSql(Vdbe*, const char*); #endif +int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*); int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*,int); diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 043b56da59..d629802a64 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -394,7 +394,6 @@ void sqlite3VdbeDeleteAuxData(Vdbe*, int, int); int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *); int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*); int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *); -int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); int sqlite3VdbeExec(Vdbe*); int sqlite3VdbeList(Vdbe*); int sqlite3VdbeHalt(Vdbe*); diff --git a/src/where.c b/src/where.c index 3cd566c46b..e431e9413e 100644 --- a/src/where.c +++ b/src/where.c @@ -18,7 +18,6 @@ */ #include "sqliteInt.h" #include "whereInt.h" -#include "vdbeInt.h" /* ** Return the estimated number of output rows from a WHERE clause From fa8874542c82254420e483650c9f49d94b413106 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 28 Jun 2014 15:26:10 +0000 Subject: [PATCH 17/27] Fix a problem with using stat4 samples of type text when estimating the rows visited by a range-query/skip-scan loop. FossilOrigin-Name: dfb09db6d412f3bc2a71bda393813783580dbad1 --- manifest | 18 +++++++-------- manifest.uuid | 2 +- src/vdbemem.c | 1 + src/where.c | 2 +- test/skipscan5.test | 56 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 620657f6c1..624fcba2fe 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sVDBE\sto\sexport\sthe\ssqlite3MemCompare()\sroutine\sand\sthus\sfree\nwhere.c\sfrom\sthe\sdependency\son\svdbeInt.h. -D 2014-06-28T14:28:06.405 +C Fix\sa\sproblem\swith\susing\sstat4\ssamples\sof\stype\stext\swhen\sestimating\sthe\srows\svisited\sby\sa\srange-query/skip-scan\sloop. +D 2014-06-28T15:26:10.708 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -289,14 +289,14 @@ F src/vdbeInt.h 5df5e9afe9b7839cd17256220fc4f7af84b8b1cd F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 F src/vdbeaux.c e493f38758c4b8f4ca2007cf6a700bd405d192f3 F src/vdbeblob.c 9205ce9d3b064d9600f8418a897fc88b5687d9ac -F src/vdbemem.c 3f191d4113805e3c5e875b732c44c9d98bac0595 +F src/vdbemem.c 8228bc32622716d26ffd902ceca7b31690744fef F src/vdbesort.c 44441d73b08b3a638dcdb725afffb87c6574ad27 F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767 F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 1f448161f1d9ec8cb68e2a8eb2e4a9756a877f69 +F src/where.c 84659c308426b20be4efada82a06a26dd6b8545e F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -829,7 +829,7 @@ F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868 F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329 F test/skipscan1.test 28c7faa41a0d7265040ecb0a0abd90c0904270b2 F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a -F test/skipscan5.test 7eb78ace4e7145fb5005d47a8f837701d7027b85 +F test/skipscan5.test 4b83d803bb17bf922569ce8c3637d0558d6abc83 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 40562fe6cac6d9827b7b42b86d45aedf12c15e24 F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5 @@ -1182,7 +1182,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6af219d1b83ec54b3fb4ad4e6216d9ad9ea0fc70 -R 0d122ee9efb300dc8d78b79e592143bf -U drh -Z 93fe23c37a7fe2b9652da5b4873aa7c3 +P d186d1ac3c47f0d814636c4b8386a6065a294750 +R 737af1ae1f9d5e706af49b9d72dc98eb +U dan +Z c44a7d177df302c14a246c1d5d1d90b5 diff --git a/manifest.uuid b/manifest.uuid index 172499a547..f498e3b5e9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d186d1ac3c47f0d814636c4b8386a6065a294750 \ No newline at end of file +dfb09db6d412f3bc2a71bda393813783580dbad1 \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index 634c881f2f..7e5c912f39 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1301,6 +1301,7 @@ int sqlite3Stat4Column( } iHdr = getVarint32(&a[iHdr], t); + pMem->enc = ENC(db); sqlite3VdbeSerialGet(&a[iField], t, pMem); } diff --git a/src/where.c b/src/where.c index e431e9413e..7610c20f9b 100644 --- a/src/where.c +++ b/src/where.c @@ -2091,7 +2091,7 @@ static int whereRangeSkipScanEst( pLoop->nOut -= nAdjust; *pbDone = 1; WHERETRACE(0x10, ("range skip-scan regions: %u..%u adjust=%d est=%d\n", - (u32)nLower, (u32)nUpper, nAdjust*-1, pLoop->nOut)); + nLower, nUpper, nAdjust*-1, pLoop->nOut)); } }else{ diff --git a/test/skipscan5.test b/test/skipscan5.test index b374302f83..6cf35f26a7 100644 --- a/test/skipscan5.test +++ b/test/skipscan5.test @@ -92,4 +92,60 @@ do_eqp_test 1.11 { 0 0 0 {SCAN TABLE t1} } +#------------------------------------------------------------------------- +# Test that range-query/skip-scan estimation works with text values. +# And on UTF-16 databases when there is no UTF-16 collation sequence +# available. + +proc test_collate {enc lhs rhs} { + string compare $lhs $rhs +} + +foreach {tn dbenc coll} { + 1 UTF-8 { add_test_collate db 0 0 1 } + 2 UTF-16 { add_test_collate db 1 0 0 } + 3 UTF-8 { add_test_collate db 0 1 0 } +} { + reset_db + eval $coll + + do_execsql_test 2.$tn.1 " PRAGMA encoding = '$dbenc' " + do_execsql_test 2.$tn.2 { + CREATE TABLE t2(a TEXT, b TEXT, c TEXT COLLATE test_collate, d TEXT); + CREATE INDEX i2 ON t2(a, b, c); + } + + set vocab(d) { :) } + set vocab(c) { a b c d e f g h i j k l m n o p q r s t } + set vocab(b) { one two three } + set vocab(a) { sql } + + do_test 2.$tn.3 { + for {set i 0} {$i < 100} {incr i} { + foreach var {a b c d} { + set $var [lindex $vocab($var) [expr $i % [llength $vocab($var)]]] + } + execsql { INSERT INTO t2 VALUES($a, $b, $c, $d) } + } + execsql ANALYZE + } {} + + foreach {tn2 q res} { + 1 { c BETWEEN 'd' AND 'e' } {/*ANY(a) AND ANY(b) AND c>? AND c 'q' } {/*ANY(a) AND ANY(b) AND c>?*/} + 4 { c > 'e' } {/*SCAN TABLE t2*/} + 5 { c < 'q' } {/*SCAN TABLE t2*/} + 4 { c < 'e' } {/*ANY(a) AND ANY(b) AND c Date: Sat, 28 Jun 2014 16:06:44 +0000 Subject: [PATCH 18/27] Add header comments on new routines. Rework the sqlite3Stat4Column() routine so that is (in theory) able to deal with corrupt samples. FossilOrigin-Name: ef5cdf949bb53a2958fa34e176b4b9eeda269de5 --- manifest | 14 ++++----- manifest.uuid | 2 +- src/vdbemem.c | 86 +++++++++++++++++++++++++++++++++------------------ 3 files changed, 64 insertions(+), 38 deletions(-) diff --git a/manifest b/manifest index 624fcba2fe..7600c076fe 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\susing\sstat4\ssamples\sof\stype\stext\swhen\sestimating\sthe\srows\svisited\sby\sa\srange-query/skip-scan\sloop. -D 2014-06-28T15:26:10.708 +C Add\sheader\scomments\son\snew\sroutines.\s\sRework\sthe\ssqlite3Stat4Column()\sroutine\nso\sthat\sis\s(in\stheory)\sable\sto\sdeal\swith\scorrupt\ssamples. +D 2014-06-28T16:06:44.822 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -289,7 +289,7 @@ F src/vdbeInt.h 5df5e9afe9b7839cd17256220fc4f7af84b8b1cd F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 F src/vdbeaux.c e493f38758c4b8f4ca2007cf6a700bd405d192f3 F src/vdbeblob.c 9205ce9d3b064d9600f8418a897fc88b5687d9ac -F src/vdbemem.c 8228bc32622716d26ffd902ceca7b31690744fef +F src/vdbemem.c d90a1e8acf8b63dc9d14cbbea12bfec6cec31394 F src/vdbesort.c 44441d73b08b3a638dcdb725afffb87c6574ad27 F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767 F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd @@ -1182,7 +1182,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P d186d1ac3c47f0d814636c4b8386a6065a294750 -R 737af1ae1f9d5e706af49b9d72dc98eb -U dan -Z c44a7d177df302c14a246c1d5d1d90b5 +P dfb09db6d412f3bc2a71bda393813783580dbad1 +R a461409aefe23981a1fbdd4418e17b64 +U drh +Z a2fad482dc40a73ef09e3690c963a5aa diff --git a/manifest.uuid b/manifest.uuid index f498e3b5e9..2e226ad371 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dfb09db6d412f3bc2a71bda393813783580dbad1 \ No newline at end of file +ef5cdf949bb53a2958fa34e176b4b9eeda269de5 \ No newline at end of file diff --git a/src/vdbemem.c b/src/vdbemem.c index 7e5c912f39..cf44aa7e2d 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1152,11 +1152,29 @@ void sqlite3AnalyzeFunctions(void){ } } +/* +** Attempt to extract a value from pExpr and use it to construct *ppVal. +** +** If pAlloc is not NULL, then an UnpackedRecord object is created for +** pAlloc if one does not exist and the new value is added to the +** UnpackedRecord object. +** +** A value is extracted in the following cases: +** +** * (pExpr==0). In this case the value is assumed to be an SQL NULL, +** +** * The expression is a bound variable, and this is a reprepare, or +** +** * The expression is a literal value. +** +** On success, *ppVal is made to point to the extracted value. The caller +** is responsible for ensuring that the value is eventually freed. +*/ static int stat4ValueFromExpr( Parse *pParse, /* Parse context */ Expr *pExpr, /* The expression to extract a value from */ u8 affinity, /* Affinity to use */ - struct ValueNewStat4Ctx *pAlloc,/* How to allocate space */ + struct ValueNewStat4Ctx *pAlloc,/* How to allocate space. Or NULL */ sqlite3_value **ppVal /* OUT: New value object (or NULL) */ ){ int rc = SQLITE_OK; @@ -1269,6 +1287,14 @@ int sqlite3Stat4ValueFromExpr( return stat4ValueFromExpr(pParse, pExpr, affinity, 0, ppVal); } +/* +** Extract the iCol-th column from the nRec-byte record in pRec. Write +** the column value into *ppVal. If *ppVal is initially NULL then a new +** sqlite3_value object is allocated. +** +** If *ppVal is initially NULL then the caller is responsible for +** ensuring that the value written into *ppVal is eventually freed. +*/ int sqlite3Stat4Column( sqlite3 *db, /* Database handle */ const void *pRec, /* Pointer to buffer containing record */ @@ -1276,37 +1302,37 @@ int sqlite3Stat4Column( int iCol, /* Column to extract */ sqlite3_value **ppVal /* OUT: Extracted value */ ){ - int rc = SQLITE_OK; - Mem *pMem = *ppVal; + u32 t; /* a column type code */ + int nHdr; /* Size of the header in the record */ + int iHdr; /* Next unread header byte */ + int iField; /* Next unread data byte */ + int szField; /* Size of the current data field */ + int i; /* Column index */ + u8 *a = (u8*)pRec; /* Typecast byte array */ + Mem *pMem = *ppVal; /* Write result into this Mem object */ + + assert( iCol>0 ); + iHdr = getVarint32(a, nHdr); + if( nHdr>nRec || iHdr>=nHdr ) return SQLITE_CORRUPT_BKPT; + iField = nHdr; + for(i=0; i<=iCol; i++){ + iHdr += getVarint32(&a[iHdr], t); + testcase( iHdr==nHdr ); + testcase( iHdr==nHdr+1 ); + if( iHdr>nHdr ) return SQLITE_CORRUPT_BKPT; + szField = sqlite3VdbeSerialTypeLen(t); + iField += szField; + } + testcase( iField==nRec ); + testcase( iField==nRec+1 ); + if( iField>nRec ) return SQLITE_CORRUPT_BKPT; if( pMem==0 ){ - pMem = (Mem*)sqlite3ValueNew(db); - if( pMem==0 ){ - rc = SQLITE_NOMEM; - } + pMem = *ppVal = sqlite3ValueNew(db); + if( pMem==0 ) return SQLITE_NOMEM; } - - if( rc==SQLITE_OK ){ - u32 t; - int nHdr; - int iHdr; - int iField; - int i; - u8 *a = (u8*)pRec; - - iHdr = getVarint32(a, nHdr); - iField = nHdr; - for(i=0; ienc = ENC(db); - sqlite3VdbeSerialGet(&a[iField], t, pMem); - } - - *ppVal = pMem; - return rc; + sqlite3VdbeSerialGet(&a[iField-szField], t, pMem); + pMem->enc = ENC(db); + return SQLITE_OK; } /* From 8e9028d0f862197aacd3f5213680f87275c1c67f Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 28 Jun 2014 17:35:15 +0000 Subject: [PATCH 19/27] Add further tests to skipscan5.test. FossilOrigin-Name: 4b8230e8fe93e73a615a46708aed5fa3557b6228 --- manifest | 14 ++--- manifest.uuid | 2 +- test/skipscan5.test | 135 ++++++++++++++++++++++++++++---------------- 3 files changed, 93 insertions(+), 58 deletions(-) diff --git a/manifest b/manifest index 7600c076fe..c6e5aaa9c2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sheader\scomments\son\snew\sroutines.\s\sRework\sthe\ssqlite3Stat4Column()\sroutine\nso\sthat\sis\s(in\stheory)\sable\sto\sdeal\swith\scorrupt\ssamples. -D 2014-06-28T16:06:44.822 +C Add\sfurther\stests\sto\sskipscan5.test. +D 2014-06-28T17:35:15.306 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -829,7 +829,7 @@ F test/shrink.test 8c70f62b6e8eb4d54533de6d65bd06b1b9a17868 F test/sidedelete.test f0ad71abe6233e3b153100f3b8d679b19a488329 F test/skipscan1.test 28c7faa41a0d7265040ecb0a0abd90c0904270b2 F test/skipscan2.test d1d1450952b7275f0b0a3a981f0230532743951a -F test/skipscan5.test 4b83d803bb17bf922569ce8c3637d0558d6abc83 +F test/skipscan5.test d8b9692b702745a0e41c23f9da6beac81df01196 F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f F test/softheap1.test 40562fe6cac6d9827b7b42b86d45aedf12c15e24 F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5 @@ -1182,7 +1182,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P dfb09db6d412f3bc2a71bda393813783580dbad1 -R a461409aefe23981a1fbdd4418e17b64 -U drh -Z a2fad482dc40a73ef09e3690c963a5aa +P ef5cdf949bb53a2958fa34e176b4b9eeda269de5 +R f17ac3e5a608781f5afc70c3d4b0020c +U dan +Z 86f494cb467655f573b06b5ade5b9c90 diff --git a/manifest.uuid b/manifest.uuid index 2e226ad371..fa3d4db391 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ef5cdf949bb53a2958fa34e176b4b9eeda269de5 \ No newline at end of file +4b8230e8fe93e73a615a46708aed5fa3557b6228 \ No newline at end of file diff --git a/test/skipscan5.test b/test/skipscan5.test index 6cf35f26a7..5d6d392998 100644 --- a/test/skipscan5.test +++ b/test/skipscan5.test @@ -38,64 +38,36 @@ do_test 1.2 { execsql ANALYZE } {} -do_eqp_test 1.3 { - SELECT * FROM t1 WHERE b = 5; +foreach {tn q res} { + 1 "b = 5" {/*ANY(a) AND b=?*/} + 2 "b > 12 AND b < 16" {/*ANY(a) AND b>? AND b 2 AND b < 16" {/*SCAN TABLE t1*/} + 4 "b > 18 AND b < 25" {/*ANY(a) AND b>? AND b 15" {/*ANY(a) AND b>?*/} + 6 "b > 5" {/*SCAN TABLE t1*/} + 7 "b < 15" {/*SCAN TABLE t1*/} + 8 "b < 5" {/*ANY(a) AND b b" {/*ANY(a) AND b '12' AND b < '16'" {/*ANY(a) AND b>? AND b '2' AND b < '16'" {/*SCAN TABLE t1*/} + 13 "b > '18' AND b < '25'" {/*ANY(a) AND b>? AND b '15'" {/*ANY(a) AND b>?*/} + 15 "b > '5'" {/*SCAN TABLE t1*/} + 16 "b < '15'" {/*SCAN TABLE t1*/} + 17 "b < '5'" {/*ANY(a) AND b b" {/*ANY(a) AND b 12 AND b < 16; -} { - 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b>? AND b 2 AND b < 16; -} { - 0 0 0 {SCAN TABLE t1} -} - -do_eqp_test 1.6 { - SELECT * FROM t1 WHERE b > 18 AND b < 25; -} { - 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b>? AND b 18 AND b < 25; -} { - 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b>? AND b 15; -} { - 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b>?)} -} - -do_eqp_test 1.9 { - SELECT * FROM t1 WHERE b > 5; -} { - 0 0 0 {SCAN TABLE t1} -} - -do_eqp_test 1.10 { - SELECT * FROM t1 WHERE b < 5; -} { - 0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b? AND b X'5555'" {/*ANY(a) AND b>?*/} + 5 "b > 'zzz'" {/*ANY(a) AND b>?*/} + 6 "b < 'zzz'" {/*SCAN TABLE t3*/} +} { + set sql "EXPLAIN QUERY PLAN SELECT * FROM t3 WHERE $q" + do_execsql_test 3.3.$tn $sql $res +} + finish_test From 6696ba3eab6a8a78ca72143aa8ed39809cecfa1b Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 28 Jun 2014 19:06:49 +0000 Subject: [PATCH 20/27] Add an OOM fault injection test for the new code on this branch. FossilOrigin-Name: c96de490ac77dd23c108004b95152cce4922fe27 --- manifest | 14 +++++----- manifest.uuid | 2 +- src/vdbeaux.c | 2 ++ test/mallocK.test | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c6e5aaa9c2..84b9befd7b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sfurther\stests\sto\sskipscan5.test. -D 2014-06-28T17:35:15.306 +C Add\san\sOOM\sfault\sinjection\stest\sfor\sthe\snew\scode\son\sthis\sbranch. +D 2014-06-28T19:06:49.846 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -287,7 +287,7 @@ F src/vdbe.c 9bfe6becfc094382ae213656fbe511055ad83a54 F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8 F src/vdbeInt.h 5df5e9afe9b7839cd17256220fc4f7af84b8b1cd F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 -F src/vdbeaux.c e493f38758c4b8f4ca2007cf6a700bd405d192f3 +F src/vdbeaux.c 8ce7dcdbb8c59e5c2194518ce3099b254ae94c15 F src/vdbeblob.c 9205ce9d3b064d9600f8418a897fc88b5687d9ac F src/vdbemem.c d90a1e8acf8b63dc9d14cbbea12bfec6cec31394 F src/vdbesort.c 44441d73b08b3a638dcdb725afffb87c6574ad27 @@ -693,7 +693,7 @@ F test/mallocG.test 0ff91b65c50bdaba680fb75d87fe4ad35bb7934f F test/mallocH.test 79b65aed612c9b3ed2dcdaa727c85895fd1bfbdb F test/mallocI.test a88c2b9627c8506bf4703d8397420043a786cdb6 F test/mallocJ.test b5d1839da331d96223e5f458856f8ffe1366f62e -F test/mallocK.test d79968641d1b70d88f6c01bdb9a7eb4a55582cc9 +F test/mallocK.test 3cff7c0f64735f6883bacdd294e45a6ed5714817 F test/malloc_common.tcl 58e54229c4132ef882a11fab6419ec4cd3073589 F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f @@ -1182,7 +1182,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ef5cdf949bb53a2958fa34e176b4b9eeda269de5 -R f17ac3e5a608781f5afc70c3d4b0020c +P 4b8230e8fe93e73a615a46708aed5fa3557b6228 +R 626c4988935b78bcb3d2f8f34291bc5b U dan -Z 86f494cb467655f573b06b5ade5b9c90 +Z 19d12a554b06297187fc9a292703f2d4 diff --git a/manifest.uuid b/manifest.uuid index fa3d4db391..d74a6bd2f9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4b8230e8fe93e73a615a46708aed5fa3557b6228 \ No newline at end of file +c96de490ac77dd23c108004b95152cce4922fe27 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 0a6b536720..de61b55c83 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -3589,6 +3589,7 @@ int sqlite3VdbeRecordCompare( ** value. */ assert( CORRUPT_DB || pPKey2->default_rc==vdbeRecordCompareDebug(nKey1, pKey1, pPKey2) + || pKeyInfo->db->mallocFailed ); return pPKey2->default_rc; } @@ -3754,6 +3755,7 @@ static int vdbeRecordCompareString( || (res<0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)<0) || (res>0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)>0) || CORRUPT_DB + || pPKey2->pKeyInfo->db->mallocFailed ); return res; } diff --git a/test/mallocK.test b/test/mallocK.test index 971bd56137..dcf00da9aa 100644 --- a/test/mallocK.test +++ b/test/mallocK.test @@ -16,6 +16,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl source $testdir/malloc_common.tcl +set testprefix mallocK set sql {SELECT * FROM t1, t2 WHERE (a=1 OR a=2)} for {set x 1} {$x<5} {incr x} { @@ -68,5 +69,70 @@ ifcapable vtab { } } +#------------------------------------------------------------------------- +# Test that OOM errors are correctly handled by the code that uses stat4 +# data to estimate the number of rows visited by a skip-scan range query. +# +add_alignment_test_collations db +do_execsql_test 6.0 { + CREATE TABLE t3(a TEXT, b TEXT COLLATE utf16_aligned, c); + INSERT INTO t3 VALUES('one', '.....', 0); + INSERT INTO t3 VALUES('one', '....x', 1); + INSERT INTO t3 VALUES('one', '...x.', 2); + INSERT INTO t3 VALUES('one', '...xx', 3); + INSERT INTO t3 VALUES('one', '..x..', 4); + INSERT INTO t3 VALUES('one', '..x.x', 5); + INSERT INTO t3 VALUES('one', '..xx.', 6); + INSERT INTO t3 VALUES('one', '..xxx', 7); + INSERT INTO t3 VALUES('one', '.x...', 8); + INSERT INTO t3 VALUES('one', '.x..x', 9); + INSERT INTO t3 VALUES('one', '.x.x.', 10); + INSERT INTO t3 VALUES('one', '.x.xx', 11); + INSERT INTO t3 VALUES('one', '.xx..', 12); + INSERT INTO t3 VALUES('one', '.xx.x', 13); + INSERT INTO t3 VALUES('one', '.xxx.', 14); + INSERT INTO t3 VALUES('one', '.xxxx', 15); + + INSERT INTO t3 VALUES('two', 'x....', 16); + INSERT INTO t3 VALUES('two', 'x...x', 17); + INSERT INTO t3 VALUES('two', 'x..x.', 18); + INSERT INTO t3 VALUES('two', 'x..xx', 19); + INSERT INTO t3 VALUES('two', 'x.x..', 20); + INSERT INTO t3 VALUES('two', 'x.x.x', 21); + INSERT INTO t3 VALUES('two', 'x.xx.', 22); + INSERT INTO t3 VALUES('two', 'x.xxx', 23); + INSERT INTO t3 VALUES('two', 'xx...', 24); + INSERT INTO t3 VALUES('two', 'xx..x', 25); + INSERT INTO t3 VALUES('two', 'xx.x.', 26); + INSERT INTO t3 VALUES('two', 'xx.xx', 27); + INSERT INTO t3 VALUES('two', 'xxx..', 28); + INSERT INTO t3 VALUES('two', 'xxx.x', 29); + INSERT INTO t3 VALUES('two', 'xxxx.', 30); + INSERT INTO t3 VALUES('two', 'xxxxx', 31); + + INSERT INTO t3 SELECT * FROM t3; + + CREATE INDEX i3 ON t3(a, b); + ANALYZE; + + SELECT 'x' > '.'; +} {1} + +ifcapable stat4 { + do_eqp_test 6.1 { + SELECT DISTINCT c FROM t3 WHERE b BETWEEN '.xx..' AND '.xxxx'; + } { + 0 0 0 {SEARCH TABLE t3 USING INDEX i3 (ANY(a) AND b>? AND b Date: Mon, 30 Jun 2014 11:14:26 +0000 Subject: [PATCH 21/27] Add makefile targets for various diagnostic tools, such as showstat4. Fix harmless compiler warnings in diagnostic tools. FossilOrigin-Name: 6f86d89b8800c50035da7809bff941d08a33a6a2 --- Makefile.in | 16 ++++++++++++++-- Makefile.msc | 16 ++++++++++++++++ main.mk | 20 ++++++++++++++++++-- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- tool/showdb.c | 4 ++-- tool/showjournal.c | 19 +++++++++---------- 7 files changed, 71 insertions(+), 28 deletions(-) diff --git a/Makefile.in b/Makefile.in index 72f7cfc007..b5768e83a6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -939,8 +939,20 @@ sqlite3_analyzer.c: sqlite3.c $(TOP)/src/test_stat.c $(TOP)/src/tclsqlite.c $(TO sqlite3_analyzer$(TEXE): sqlite3_analyzer.c $(LTLINK) sqlite3_analyzer.c -o $@ $(LIBTCL) $(TLIBS) -showdb$(TEXE): $(TOP)/tool/showdb.c sqlite3.c - $(LTLINK) -o $@ $(TOP)/tool/showdb.c sqlite3.c $(TLIBS) +showdb$(TEXE): $(TOP)/tool/showdb.c sqlite3.lo + $(LTLINK) -o $@ $(TOP)/tool/showdb.c sqlite3.lo $(TLIBS) + +showstat4$(TEXE): $(TOP)/tool/showstat4.c sqlite3.lo + $(LTLINK) -o $@ $(TOP)/tool/showstat4.c sqlite3.lo $(TLIBS) + +showjournal$(TEXE): $(TOP)/tool/showjournal.c sqlite3.lo + $(LTLINK) -o $@ $(TOP)/tool/showjournal.c sqlite3.lo $(TLIBS) + +showwal$(TEXE): $(TOP)/tool/showwal.c sqlite3.lo + $(LTLINK) -o $@ $(TOP)/tool/showwal.c sqlite3.lo $(TLIBS) + +rollback-test$(TEXE): $(TOP)/tool/rollback-test.c sqlite3.lo + $(LTLINK) -o $@ $(TOP)/tool/rollback-test.c sqlite3.lo $(TLIBS) LogEst$(TEXE): $(TOP)/tool/logest.c sqlite3.h $(LTLINK) -I. -o $@ $(TOP)/tool/logest.c diff --git a/Makefile.msc b/Makefile.msc index 409f7b3d28..55d26e3053 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1435,6 +1435,22 @@ showdb.exe: $(TOP)\tool\showdb.c $(SQLITE3C) $(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ $(TOP)\tool\showdb.c $(SQLITE3C) +showstat4.exe: $(TOP)\tool\showstat4.c $(SQLITE3C) + $(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ + $(TOP)\tool\showstat4.c $(SQLITE3C) + +showjournal.exe: $(TOP)\tool\showjournal.c $(SQLITE3C) + $(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ + $(TOP)\tool\showjournal.c $(SQLITE3C) + +showwal.exe: $(TOP)\tool\showwal.c $(SQLITE3C) + $(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ + $(TOP)\tool\showwal.c $(SQLITE3C) + +rollback-test.exe: $(TOP)\tool\rollback-test.c $(SQLITE3C) + $(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \ + $(TOP)\tool\rollback-test.c $(SQLITE3C) + LogEst.exe: $(TOP)\tool\logest.c sqlite3.h $(LTLINK) -Fe$@ $(TOP)\tool\LogEst.c diff --git a/main.mk b/main.mk index 30149eccab..62b6b22475 100644 --- a/main.mk +++ b/main.mk @@ -628,9 +628,25 @@ $(TEST_EXTENSION): $(TOP)/src/test_loadext.c extensiontest: testfixture$(EXE) $(TEST_EXTENSION) ./testfixture$(EXE) $(TOP)/test/loadext.test -showdb$(EXE): $(TOP)/tool/showdb.c sqlite3.c +showdb$(EXE): $(TOP)/tool/showdb.c sqlite3.o $(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o showdb$(EXE) \ - $(TOP)/tool/showdb.c sqlite3.c + $(TOP)/tool/showdb.c sqlite3.o $(THREADLIB) + +showstat4$(EXE): $(TOP)/tool/showstat4.c sqlite3.o + $(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o showstat4$(EXE) \ + $(TOP)/tool/showstat4.c sqlite3.o $(THREADLIB) + +showjournal$(EXE): $(TOP)/tool/showjournal.c sqlite3.o + $(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o showjournal$(EXE) \ + $(TOP)/tool/showjournal.c sqlite3.o $(THREADLIB) + +showwal$(EXE): $(TOP)/tool/showwal.c sqlite3.o + $(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o showwal$(EXE) \ + $(TOP)/tool/showwal.c sqlite3.o $(THREADLIB) + +rollback-test$(EXE): $(TOP)/tool/rollback-test.c sqlite3.o + $(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o rollback-test$(EXE) \ + $(TOP)/tool/rollback-test.c sqlite3.o $(THREADLIB) LogEst$(EXE): $(TOP)/tool/logest.c sqlite3.h $(TCC) -o LogEst$(EXE) $(TOP)/tool/logest.c diff --git a/manifest b/manifest index 27807f1cbc..5cda3a858e 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\ssome\smore\sIN\soperator\stests. -D 2014-06-26T22:17:21.764 +C Add\smakefile\stargets\sfor\svarious\sdiagnostic\stools,\ssuch\sas\sshowstat4.\nFix\sharmless\scompiler\swarnings\sin\sdiagnostic\stools. +D 2014-06-30T11:14:26.241 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 +F Makefile.in 1732320ecac3fee229d560d7ef2afa34681d1815 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc b2d3ac211b479fa5a6c9aaf3b9c49fdea900d228 +F Makefile.msc ad60c4d8be35f98fdcca614088b84a91612b2b4c F Makefile.vxworks 034289efa9d591b04b1a73598623119c306cbba0 F README.md 64f270c43c38c46de749e419c22f0ae2f4499fe8 F VERSION 9f823c026c6a32fc5f84d212a8aae0a221dba45c @@ -146,7 +146,7 @@ F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 7b1d0be0840f213405c977c87917241158126a33 +F main.mk 7850d834ca7f3c772e2b0087631868d5bfdeabb9 F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea F mkopcodeh.awk c6b3fa301db6ef7ac916b14c60868aeaec1337b5 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 @@ -1159,8 +1159,8 @@ F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c b018a8a69d07050fc0fe9afcf17313cdef0cc599 -F tool/showjournal.c b62cecaab86a4053d944c276bb5232e4d17ece02 +F tool/showdb.c 213e0288501b2cf67c1b2c72a9e5b8acda4738b3 +F tool/showjournal.c 053eb1cc774710c6890b7dd6293300cc297b16a5 F tool/showstat4.c c39279d6bd37cb999b634f0064f6f86ad7af008f F tool/showwal.c 3f7f7da5ec0cba51b1449a75f700493377da57b5 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe @@ -1181,7 +1181,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 92f7ad43dbfe4e02490df2f932c3c74fb89064d6 -R 61cea95999002249f7da20d93ec0602d -U mistachkin -Z 2021f223ccdab7be5b0b3bf69eadf881 +P fb32e374b75b160e7b535e732ced6c34dbb513eb +R 46fc4bdeeae8d59d2e02be8ec2b2e5ac +U drh +Z cf9f7f35abbae67619fbb464751389eb diff --git a/manifest.uuid b/manifest.uuid index 9daab53ded..2b01869e56 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fb32e374b75b160e7b535e732ced6c34dbb513eb \ No newline at end of file +6f86d89b8800c50035da7809bff941d08a33a6a2 \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index bf4af444b2..8dd387365c 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -66,7 +66,7 @@ static unsigned char *getContent(int ofst, int nByte){ if( aData==0 ) out_of_memory(); memset(aData, 0, nByte+32); lseek(db, ofst, SEEK_SET); - read(db, aData, nByte); + if( read(db, aData, nByte)=nByte ){ @@ -74,7 +73,7 @@ static unsigned print_decode_line( ** in global variables. */ static unsigned decode_journal_header(int iOfst){ - char *pHdr = read_content(64, iOfst); + unsigned char *pHdr = read_content(64, iOfst); unsigned nPage; printf("Header at offset %d:\n", iOfst); print_decode_line(pHdr, 0, 4, "Header part 1 (3654616569)"); @@ -101,12 +100,11 @@ static void print_page(int iOfst){ char zTitle[50]; aData = read_content(pageSize+8, iOfst); sprintf(zTitle, "page number for page at offset %d", iOfst); - print_decode_line(aData, 0, 4, zTitle); + print_decode_line(aData-iOfst, iOfst, 4, zTitle); free(aData); } int main(int argc, char **argv){ - int rc; int nPage, cnt; int iOfst; if( argc!=2 ){ @@ -136,4 +134,5 @@ int main(int argc, char **argv){ iOfst = (iOfst/sectorSize + 1)*sectorSize; } fclose(db); + return 0; } From 48be0c51d4ed30e9a3d9f492870796f4bd13b85f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 30 Jun 2014 13:32:39 +0000 Subject: [PATCH 22/27] Generate complete samples for sqlite_stat4 on WITHOUT ROWID tables. Ticket [b2fa5424e6fcb15b5] FossilOrigin-Name: 8cb43eddab83c68b2163441df70e0e9496d5fa33 --- manifest | 15 +++++++++------ manifest.uuid | 2 +- src/analyze.c | 7 ++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 5cda3a858e..cbc32f11a2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\smakefile\stargets\sfor\svarious\sdiagnostic\stools,\ssuch\sas\sshowstat4.\nFix\sharmless\scompiler\swarnings\sin\sdiagnostic\stools. -D 2014-06-30T11:14:26.241 +C Generate\scomplete\ssamples\sfor\ssqlite_stat4\son\sWITHOUT\sROWID\stables.\nTicket\s[b2fa5424e6fcb15b5] +D 2014-06-30T13:32:39.153 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 1732320ecac3fee229d560d7ef2afa34681d1815 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -161,7 +161,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 3d8b83c91651f53472ca17599dae3457b8b89494 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c b00900877f766f116f9e16116f1ccacdc21d82f1 -F src/analyze.c e8c8a9d20beb2ad156321330e8f4fea002d8deee +F src/analyze.c b53dddb5a1bc4c28877952cd9ea6943aea62215d F src/attach.c 3801129015ef59d76bf23c95ef9b0069d18a0c52 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c a729e63cf5cd1829507cb7b8e89f99b95141bb53 @@ -1181,7 +1181,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P fb32e374b75b160e7b535e732ced6c34dbb513eb -R 46fc4bdeeae8d59d2e02be8ec2b2e5ac +P 6f86d89b8800c50035da7809bff941d08a33a6a2 +R 63e5822670c3cf845c9d764a3e96a618 +T *branch * stat4-without-rowid +T *sym-stat4-without-rowid * +T -sym-trunk * U drh -Z cf9f7f35abbae67619fbb464751389eb +Z 2446f0a421b05370ddd23634c032efe0 diff --git a/manifest.uuid b/manifest.uuid index 2b01869e56..3cbe4903ed 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6f86d89b8800c50035da7809bff941d08a33a6a2 \ No newline at end of file +8cb43eddab83c68b2163441df70e0e9496d5fa33 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 4dcd7e8b8f..e112239a74 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -1045,7 +1045,7 @@ static void analyzeOneTable( ** the regPrev array and a trailing rowid (the rowid slot is required ** when building a record to insert into the sample column of ** the sqlite_stat4 table. */ - pParse->nMem = MAX(pParse->nMem, regPrev+nCol); + pParse->nMem = MAX(pParse->nMem, regPrev+pIdx->nColumn); /* Open a read-only cursor on the index being analyzed. */ assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) ); @@ -1186,11 +1186,12 @@ static void analyzeOneTable( sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, pIdx->aiColumn[0], regSample); #else - for(i=0; inColumn-1; + for(; i>=0; i--){ i16 iCol = pIdx->aiColumn[i]; sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, iCol, regCol+i); } - sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol+1, regSample); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, pIdx->nColumn, regSample); #endif sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp); sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid); From 971fd0713572a7b3c2420e516327bbe8c97711da Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 30 Jun 2014 13:56:34 +0000 Subject: [PATCH 23/27] Omit non-primary-key columns from the STAT4 samples for WITHOUT ROWID tables. Indexes, both rowid and without-rowid, still hold an exact copy of the index entry. FossilOrigin-Name: de826c31589258f0906f87d65796944103e36d5b --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/analyze.c | 11 ++++++++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index cbc32f11a2..e5da47ab1f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Generate\scomplete\ssamples\sfor\ssqlite_stat4\son\sWITHOUT\sROWID\stables.\nTicket\s[b2fa5424e6fcb15b5] -D 2014-06-30T13:32:39.153 +C Omit\snon-primary-key\scolumns\sfrom\sthe\sSTAT4\ssamples\sfor\sWITHOUT\sROWID\stables.\nIndexes,\sboth\srowid\sand\swithout-rowid,\sstill\shold\san\sexact\scopy\nof\sthe\sindex\sentry. +D 2014-06-30T13:56:34.968 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 1732320ecac3fee229d560d7ef2afa34681d1815 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -161,7 +161,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 3d8b83c91651f53472ca17599dae3457b8b89494 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c b00900877f766f116f9e16116f1ccacdc21d82f1 -F src/analyze.c b53dddb5a1bc4c28877952cd9ea6943aea62215d +F src/analyze.c 0f9ee2f88f7c564cedb16f8e0236f2d5ac8429aa F src/attach.c 3801129015ef59d76bf23c95ef9b0069d18a0c52 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c a729e63cf5cd1829507cb7b8e89f99b95141bb53 @@ -1181,10 +1181,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6f86d89b8800c50035da7809bff941d08a33a6a2 -R 63e5822670c3cf845c9d764a3e96a618 -T *branch * stat4-without-rowid -T *sym-stat4-without-rowid * -T -sym-trunk * +P 8cb43eddab83c68b2163441df70e0e9496d5fa33 +R 76a8cf4e27cd1a26fe3722da49c987a3 U drh -Z 2446f0a421b05370ddd23634c032efe0 +Z d18fb0d5c10defb46f6f8aaff06ea5cb diff --git a/manifest.uuid b/manifest.uuid index 3cbe4903ed..96bf983d21 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8cb43eddab83c68b2163441df70e0e9496d5fa33 \ No newline at end of file +de826c31589258f0906f87d65796944103e36d5b \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index e112239a74..9a2b38f2b7 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -1166,6 +1166,7 @@ static void analyzeOneTable( int regSampleRowid = regCol + nCol; int addrNext; int addrIsNull; + int nSampleCol; u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound; pParse->nMem = MAX(pParse->nMem, regCol+nCol+1); @@ -1186,12 +1187,16 @@ static void analyzeOneTable( sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, pIdx->aiColumn[0], regSample); #else - i = HasRowid(pTab) ? nCol-1 : pIdx->nColumn-1; - for(; i>=0; i--){ + if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){ + nSampleCol = pIdx->nKeyCol; + }else{ + nSampleCol = pIdx->nColumn; + } + for(i=nSampleCol-1; i>=0; i--){ i16 iCol = pIdx->aiColumn[i]; sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, iCol, regCol+i); } - sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, pIdx->nColumn, regSample); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nSampleCol, regSample); #endif sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp); sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid); From 39129ce8d9cb0101bad783fa06365332e0ddd83d Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 30 Jun 2014 15:23:57 +0000 Subject: [PATCH 24/27] Fix where.c so that the primary key values appended to every index entry on a WITHOUT ROWID table may be used when useful. FossilOrigin-Name: 6624a61d16e47ad691c4195ca8a1d68b7348118d --- manifest | 16 +++++----- manifest.uuid | 2 +- src/where.c | 20 ++++++------- test/without_rowid1.test | 64 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index e5da47ab1f..91948b0449 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\snon-primary-key\scolumns\sfrom\sthe\sSTAT4\ssamples\sfor\sWITHOUT\sROWID\stables.\nIndexes,\sboth\srowid\sand\swithout-rowid,\sstill\shold\san\sexact\scopy\nof\sthe\sindex\sentry. -D 2014-06-30T13:56:34.968 +C Fix\swhere.c\sso\sthat\sthe\sprimary\skey\svalues\sappended\sto\severy\sindex\sentry\son\sa\sWITHOUT\sROWID\stable\smay\sbe\sused\swhen\suseful. +D 2014-06-30T15:23:57.908 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 1732320ecac3fee229d560d7ef2afa34681d1815 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -296,7 +296,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c 7b9e13cff91a2f14ac61e6a1bc3a83b5113e6298 +F src/where.c da15506cd52de8717836921da8ebd9109228f94e F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1122,7 +1122,7 @@ F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d F test/with1.test 268081a6b14817a262ced4d0ee34d4d2a1dd2068 F test/with2.test ee227a663586aa09771cafd4fa269c5217eaf775 F test/withM.test e97f2a8c506ab3ea9eab94e6f6072f6cc924c991 -F test/without_rowid1.test e00a0a9dc9f0be651f011d61e8a32b7add5afb30 +F test/without_rowid1.test 7862e605753c8d25329f665fa09072e842183151 F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99 F test/without_rowid3.test eac3d5c8a1924725b58503a368f2cbd24fd6c8a0 F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a @@ -1181,7 +1181,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8cb43eddab83c68b2163441df70e0e9496d5fa33 -R 76a8cf4e27cd1a26fe3722da49c987a3 -U drh -Z d18fb0d5c10defb46f6f8aaff06ea5cb +P de826c31589258f0906f87d65796944103e36d5b +R 8442f880f57a242b77225992393b657c +U dan +Z 6c9f8a4d0a3c007f8c2ac1857a8d9913 diff --git a/manifest.uuid b/manifest.uuid index 96bf983d21..cff31f409b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -de826c31589258f0906f87d65796944103e36d5b \ No newline at end of file +6624a61d16e47ad691c4195ca8a1d68b7348118d \ No newline at end of file diff --git a/src/where.c b/src/where.c index fd5831872b..2ec5caf99d 100644 --- a/src/where.c +++ b/src/where.c @@ -544,7 +544,7 @@ static WhereTerm *whereScanInit( if( pIdx && iColumn>=0 ){ pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity; for(j=0; pIdx->aiColumn[j]!=iColumn; j++){ - if( NEVER(j>=pIdx->nKeyCol) ) return 0; + if( NEVER(j>pIdx->nColumn) ) return 0; } pScan->zCollName = pIdx->azColl[j]; }else{ @@ -2645,7 +2645,7 @@ static char *explainIndexRange(sqlite3 *db, WhereLoop *pLoop, Table *pTab){ txt.db = db; sqlite3StrAccumAppend(&txt, " (", 2); for(i=0; inKeyCol ) ? "rowid" : aCol[aiColumn[i]].zName; + char *z = aiColumn[i] < 0 ? "rowid" : aCol[aiColumn[i]].zName; if( i>=nSkip ){ explainAppendTerm(&txt, i, z, "="); }else{ @@ -2658,11 +2658,11 @@ static char *explainIndexRange(sqlite3 *db, WhereLoop *pLoop, Table *pTab){ j = i; if( pLoop->wsFlags&WHERE_BTM_LIMIT ){ - char *z = (j==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[j]].zName; + char *z = aiColumn[j] < 0 ? "rowid" : aCol[aiColumn[j]].zName; explainAppendTerm(&txt, i++, z, ">"); } if( pLoop->wsFlags&WHERE_TOP_LIMIT ){ - char *z = (j==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[j]].zName; + char *z = aiColumn[j] < 0 ? "rowid" : aCol[aiColumn[j]].zName; explainAppendTerm(&txt, i, z, "<"); } sqlite3StrAccumAppend(&txt, ")", 1); @@ -4164,12 +4164,9 @@ static int whereLoopAddBtreeIndex( } if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); - assert( pNew->u.btree.nEq<=pProbe->nKeyCol ); - if( pNew->u.btree.nEq < pProbe->nKeyCol ){ - iCol = pProbe->aiColumn[pNew->u.btree.nEq]; - }else{ - iCol = -1; - } + assert( pNew->u.btree.nEqnColumn ); + iCol = pProbe->aiColumn[pNew->u.btree.nEq]; + pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, iCol, opMask, pProbe); saved_nEq = pNew->u.btree.nEq; @@ -4359,7 +4356,7 @@ static int whereLoopAddBtreeIndex( } if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 - && pNew->u.btree.nEq<(pProbe->nKeyCol + (pProbe->zName!=0)) + && pNew->u.btree.nEqnColumn ){ whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn); } @@ -4506,6 +4503,7 @@ static int whereLoopAddBtree( Index *pFirst; /* First of real indices on the table */ memset(&sPk, 0, sizeof(Index)); sPk.nKeyCol = 1; + sPk.nColumn = 1; sPk.aiColumn = &aiColumnPk; sPk.aiRowLogEst = aiRowEstPk; sPk.onError = OE_Replace; diff --git a/test/without_rowid1.test b/test/without_rowid1.test index bdd03c57bb..9d7a6430fe 100644 --- a/test/without_rowid1.test +++ b/test/without_rowid1.test @@ -213,5 +213,69 @@ do_execsql_test 4.1 { do_execsql_test 4.2 { SELECT t42.rowid FROM t42, t41; } {1} + + +#-------------------------------------------------------------------------- +# The following tests verify that the trailing PK fields added to each +# entry in an index on a WITHOUT ROWID table are used correctly. +# +do_execsql_test 5.0 { + CREATE TABLE t45(a PRIMARY KEY, b, c) WITHOUT ROWID; + CREATE INDEX i45 ON t45(b); + + INSERT INTO t45 VALUES(2, 'one', 'x'); + INSERT INTO t45 VALUES(4, 'one', 'x'); + INSERT INTO t45 VALUES(6, 'one', 'x'); + INSERT INTO t45 VALUES(8, 'one', 'x'); + INSERT INTO t45 VALUES(10, 'one', 'x'); + + INSERT INTO t45 VALUES(1, 'two', 'x'); + INSERT INTO t45 VALUES(3, 'two', 'x'); + INSERT INTO t45 VALUES(5, 'two', 'x'); + INSERT INTO t45 VALUES(7, 'two', 'x'); + INSERT INTO t45 VALUES(9, 'two', 'x'); +} + +do_eqp_test 5.1 { + SELECT * FROM t45 WHERE b=? AND a>? +} {/*USING INDEX i45 (b=? AND a>?)*/} + +do_execsql_test 5.2 { + SELECT * FROM t45 WHERE b='two' AND a>4 +} {5 two x 7 two x 9 two x} + +do_execsql_test 5.3 { + SELECT * FROM t45 WHERE b='one' AND a<8 +} { 2 one x 4 one x 6 one x } + +do_execsql_test 5.4 { + CREATE TABLE t46(a, b, c, d, PRIMARY KEY(a, b)) WITHOUT ROWID; + WITH r(x) AS ( + SELECT 1 UNION ALL SELECT x+1 FROM r WHERE x<100 + ) + INSERT INTO t46 SELECT x / 20, x % 20, x % 10, x FROM r; +} + +set queries { + 1 2 "c = 5 AND a = 1" {/*i46 (c=? AND a=?)*/} + 2 6 "c = 4 AND a < 3" {/*i46 (c=? AND a= 3" {/*i46 (c=? AND a>?)*/} + 4 1 "c = 2 AND a = 1 AND b<10" {/*i46 (c=? AND a=? AND b5" {/*i46 (c=? AND a=? AND b>?)*/} +} + +foreach {tn cnt where eqp} $queries { + do_execsql_test 5.5.$tn.1 "SELECT count(*) FROM t46 WHERE $where" $cnt +} + +do_execsql_test 5.6 { + CREATE INDEX i46 ON t46(c); +} + +foreach {tn cnt where eqp} $queries { + do_execsql_test 5.7.$tn.1 "SELECT count(*) FROM t46 WHERE $where" $cnt + do_eqp_test 5.7.$tn.2 "SELECT count(*) FROM t46 WHERE $where" $eqp +} + finish_test From ec9e55d35818a428140fd31a6004efb039175311 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 30 Jun 2014 17:07:39 +0000 Subject: [PATCH 25/27] Fix the STAT4 information for WITHOUT ROWID tables. FossilOrigin-Name: 5d8628fdffbcf837313958f0ee1ed8a2043d384e --- manifest | 14 +++++----- manifest.uuid | 2 +- src/analyze.c | 73 +++++++++++++++++++++++++++++---------------------- 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/manifest b/manifest index 91948b0449..0580d58225 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\swhere.c\sso\sthat\sthe\sprimary\skey\svalues\sappended\sto\severy\sindex\sentry\son\sa\sWITHOUT\sROWID\stable\smay\sbe\sused\swhen\suseful. -D 2014-06-30T15:23:57.908 +C Fix\sthe\sSTAT4\sinformation\sfor\sWITHOUT\sROWID\stables. +D 2014-06-30T17:07:39.466 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 1732320ecac3fee229d560d7ef2afa34681d1815 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -161,7 +161,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 3d8b83c91651f53472ca17599dae3457b8b89494 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c b00900877f766f116f9e16116f1ccacdc21d82f1 -F src/analyze.c 0f9ee2f88f7c564cedb16f8e0236f2d5ac8429aa +F src/analyze.c ec6e0691a6a23e0239dc733109b906ee04b89cc3 F src/attach.c 3801129015ef59d76bf23c95ef9b0069d18a0c52 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c a729e63cf5cd1829507cb7b8e89f99b95141bb53 @@ -1181,7 +1181,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P de826c31589258f0906f87d65796944103e36d5b -R 8442f880f57a242b77225992393b657c -U dan -Z 6c9f8a4d0a3c007f8c2ac1857a8d9913 +P 6624a61d16e47ad691c4195ca8a1d68b7348118d +R 54d510c828cc71c8f4dcbc102dfc2a66 +U drh +Z 6aa7249d11aa6d73980f37e6212dc38c diff --git a/manifest.uuid b/manifest.uuid index cff31f409b..6c0650f1c9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6624a61d16e47ad691c4195ca8a1d68b7348118d \ No newline at end of file +5d8628fdffbcf837313958f0ee1ed8a2043d384e \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 9a2b38f2b7..364f3b7131 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -246,6 +246,7 @@ static void openStatTable( assert( i1 ); /* >1 because it includes the rowid column */ + assert( nCol>0 ); nColUp = sizeof(tRowcnt)<8 ? (nCol+1)&~1 : nCol; + nKeyCol = sqlite3_value_int(argv[1]); + assert( nKeyCol<=nCol ); + assert( nKeyCol>0 ); /* Allocate the space required for the Stat4Accum object */ n = sizeof(*p) @@ -415,6 +429,7 @@ static void statInit( p->db = db; p->nRow = 0; p->nCol = nCol; + p->nKeyCol = nKeyCol; p->current.anDLt = (tRowcnt*)&p[1]; p->current.anEq = &p->current.anDLt[nColUp]; @@ -425,9 +440,9 @@ static void statInit( p->iGet = -1; p->mxSample = mxSample; - p->nPSample = (tRowcnt)(sqlite3_value_int64(argv[1])/(mxSample/3+1) + 1); + p->nPSample = (tRowcnt)(sqlite3_value_int64(argv[2])/(mxSample/3+1) + 1); p->current.anLt = &p->current.anEq[nColUp]; - p->iPrn = nCol*0x689e962d ^ sqlite3_value_int(argv[1])*0xd0944565; + p->iPrn = nCol*0x689e962d ^ sqlite3_value_int(argv[2])*0xd0944565; /* Set up the Stat4Accum.a[] and aBest[] arrays */ p->a = (struct Stat4Sample*)&p->current.anLt[nColUp]; @@ -450,7 +465,7 @@ static void statInit( sqlite3_result_blob(context, p, sizeof(p), stat4Destructor); } static const FuncDef statInitFuncdef = { - 1+IsStat34, /* nArg */ + 2+IsStat34, /* nArg */ SQLITE_UTF8, /* funcFlags */ 0, /* pUserData */ 0, /* pNext */ @@ -691,7 +706,7 @@ static void statPush( UNUSED_PARAMETER( argc ); UNUSED_PARAMETER( context ); - assert( p->nCol>1 ); /* Includes rowid field */ + assert( p->nCol>0 ); assert( iChngnCol ); if( p->nRow==0 ){ @@ -819,7 +834,7 @@ static void statGet( char *z; int i; - char *zRet = sqlite3MallocZero(p->nCol * 25); + char *zRet = sqlite3MallocZero( (p->nKeyCol+1)*25 ); if( zRet==0 ){ sqlite3_result_error_nomem(context); return; @@ -827,7 +842,7 @@ static void statGet( sqlite3_snprintf(24, zRet, "%llu", (u64)p->nRow); z = zRet + sqlite3Strlen30(zRet); - for(i=0; i<(p->nCol-1); i++){ + for(i=0; inKeyCol; i++){ u64 nDistinct = p->current.anDLt[i] + 1; u64 iVal = (p->nRow + nDistinct - 1) / nDistinct; sqlite3_snprintf(24, z, " %llu", iVal); @@ -996,18 +1011,19 @@ static void analyzeOneTable( if( pOnlyIdx && pOnlyIdx!=pIdx ) continue; if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0; - VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName)); - nCol = pIdx->nKeyCol; + if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){ + nCol = pIdx->nKeyCol; + zIdxName = pTab->zName; + }else{ + nCol = pIdx->nColumn; + zIdxName = pIdx->zName; + } aGotoChng = sqlite3DbMallocRaw(db, sizeof(int)*(nCol+1)); if( aGotoChng==0 ) continue; /* Populate the register containing the index name. */ - if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){ - zIdxName = pTab->zName; - }else{ - zIdxName = pIdx->zName; - } sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, zIdxName, 0); + VdbeComment((v, "Analysis for %s.%s", pTab->zName, zIdxName)); /* ** Pseudo-code for loop that calls stat_push(): @@ -1045,7 +1061,7 @@ static void analyzeOneTable( ** the regPrev array and a trailing rowid (the rowid slot is required ** when building a record to insert into the sample column of ** the sqlite_stat4 table. */ - pParse->nMem = MAX(pParse->nMem, regPrev+pIdx->nColumn); + pParse->nMem = MAX(pParse->nMem, regPrev+nCol); /* Open a read-only cursor on the index being analyzed. */ assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) ); @@ -1061,12 +1077,13 @@ static void analyzeOneTable( ** The second argument is only used for STAT3 and STAT4 */ #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 - sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+2); + sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+3); #endif - sqlite3VdbeAddOp2(v, OP_Integer, nCol+1, regStat4+1); + sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1); + sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2); sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4+1, regStat4); sqlite3VdbeChangeP4(v, -1, (char*)&statInitFuncdef, P4_FUNCDEF); - sqlite3VdbeChangeP5(v, 1+IsStat34); + sqlite3VdbeChangeP5(v, 2+IsStat34); /* Implementation of the following: ** @@ -1166,10 +1183,9 @@ static void analyzeOneTable( int regSampleRowid = regCol + nCol; int addrNext; int addrIsNull; - int nSampleCol; u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound; - pParse->nMem = MAX(pParse->nMem, regCol+nCol+1); + pParse->nMem = MAX(pParse->nMem, regCol+nCol); addrNext = sqlite3VdbeCurrentAddr(v); callStatGet(v, regStat4, STAT_GET_ROWID, regSampleRowid); @@ -1187,16 +1203,11 @@ static void analyzeOneTable( sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, pIdx->aiColumn[0], regSample); #else - if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){ - nSampleCol = pIdx->nKeyCol; - }else{ - nSampleCol = pIdx->nColumn; - } - for(i=nSampleCol-1; i>=0; i--){ + for(i=0; iaiColumn[i]; sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, iCol, regCol+i); } - sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nSampleCol, regSample); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol, regSample); #endif sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp); sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid); From fd984b81146f7e909b9e0ecbfad80cbcc6b25343 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 30 Jun 2014 18:02:20 +0000 Subject: [PATCH 26/27] Fix a problem in where.c with using the stat4 sample data of an index on a WITHOUT ROWID table. FossilOrigin-Name: 053a210e3169732c58f84cb54c9b6f6df3a8f4ea --- manifest | 16 +++++------ manifest.uuid | 2 +- src/where.c | 4 +-- test/analyze9.test | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 0580d58225..73bea2a8c4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sSTAT4\sinformation\sfor\sWITHOUT\sROWID\stables. -D 2014-06-30T17:07:39.466 +C Fix\sa\sproblem\sin\swhere.c\swith\susing\sthe\sstat4\ssample\sdata\sof\san\sindex\son\sa\sWITHOUT\sROWID\stable. +D 2014-06-30T18:02:20.849 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 1732320ecac3fee229d560d7ef2afa34681d1815 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -296,7 +296,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 264df50a1b33124130b23180ded2e2c5663c652a F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45 -F src/where.c da15506cd52de8717836921da8ebd9109228f94e +F src/where.c 2bc0226fced128686c432748324351beb127829b F src/whereInt.h 929c1349b5355fd44f22cee5c14d72b3329c58a6 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -316,7 +316,7 @@ F test/analyze5.test 765c4e284aa69ca172772aa940946f55629bc8c4 F test/analyze6.test d31defa011a561b938b4608d3538c1b4e0b5e92c F test/analyze7.test bb1409afc9e8629e414387ef048b8e0e3e0bdc4f F test/analyze8.test 093d15c1c888eed5034304a98c992f7360130b88 -F test/analyze9.test 623e02a99a78fa12fe5def2fd559032d5d887e0f +F test/analyze9.test 93619368fff2db833747a6dfa9b1146a82e5d4d2 F test/analyzeA.test 1a5c40079894847976d983ca39c707aaa44b6944 F test/analyzeB.test 8bf35ee0a548aea831bf56762cb8e7fdb1db083d F test/async.test 1d0e056ba1bb9729283a0f22718d3a25e82c277b @@ -1181,7 +1181,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6624a61d16e47ad691c4195ca8a1d68b7348118d -R 54d510c828cc71c8f4dcbc102dfc2a66 -U drh -Z 6aa7249d11aa6d73980f37e6212dc38c +P 5d8628fdffbcf837313958f0ee1ed8a2043d384e +R 48fee5f306f007e5e5bc0779449b568d +U dan +Z 6e1427ceae354dbee93842f8dd267647 diff --git a/manifest.uuid b/manifest.uuid index 6c0650f1c9..e4cd819c16 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5d8628fdffbcf837313958f0ee1ed8a2043d384e \ No newline at end of file +053a210e3169732c58f84cb54c9b6f6df3a8f4ea \ No newline at end of file diff --git a/src/where.c b/src/where.c index 2ec5caf99d..57c5a2ad14 100644 --- a/src/where.c +++ b/src/where.c @@ -2201,7 +2201,7 @@ static int whereEqualScanEst( int bOk; assert( nEq>=1 ); - assert( nEq<=(p->nKeyCol+1) ); + assert( nEq<=p->nColumn ); assert( p->aSample!=0 ); assert( p->nSample>0 ); assert( pBuilder->nRecValidp->nKeyCol ){ + if( nEq>=p->nColumn ){ *pnRow = 1; return SQLITE_OK; } diff --git a/test/analyze9.test b/test/analyze9.test index f25e5924e6..d0d3b3524f 100644 --- a/test/analyze9.test +++ b/test/analyze9.test @@ -953,4 +953,72 @@ for {set i 0} {$i<16} {incr i} { } {1} } +#------------------------------------------------------------------------- +# +reset_db + +do_execsql_test 21.0 { + CREATE TABLE t2(a, b); + CREATE INDEX i2 ON t2(a); +} + +do_test 21.1 { + for {set i 1} {$i < 100} {incr i} { + execsql { + INSERT INTO t2 VALUES(CASE WHEN $i < 80 THEN 'one' ELSE 'two' END, $i) + } + } + execsql ANALYZE +} {} + +# Condition (a='one') matches 80% of the table. (rowid<10) reduces this to +# 10%, but (rowid<50) only reduces it to 50%. So in the first case below +# the index is used. In the second, it is not. +# +do_eqp_test 21.2 { + SELECT * FROM t2 WHERE a='one' AND rowid < 10 +} {/*USING INDEX i2 (a=? AND rowid45 AND x<96) THEN 'B' ELSE 'A' END, /* Column "a" */ + x, /* Column "b" */ + CASE WHEN (x<51) THEN 'one' ELSE 'two' END, /* Column "c" */ + x /* Column "d" */ + FROM r; + + CREATE INDEX i3 ON t3(c); + CREATE INDEX i4 ON t3(d); + ANALYZE; +} + +# Expression (c='one' AND a='B') matches 5 table rows. But (c='one' AND a=A') +# matches 45. Expression (d Date: Mon, 30 Jun 2014 19:28:57 +0000 Subject: [PATCH 27/27] Bump the version number to 3.8.6. FossilOrigin-Name: f925e9baafea625f63105f8013abb3807b418379 --- VERSION | 2 +- configure | 18 +++++++++--------- manifest | 15 +++++++-------- manifest.uuid | 2 +- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/VERSION b/VERSION index 0cbfaed0d9..2e14a9557d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.8.5 +3.8.6 diff --git a/configure b/configure index 8be06033f0..8748a98406 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.62 for sqlite 3.8.5. +# Generated by GNU Autoconf 2.62 for sqlite 3.8.6. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. @@ -743,8 +743,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.8.5' -PACKAGE_STRING='sqlite 3.8.5' +PACKAGE_VERSION='3.8.6' +PACKAGE_STRING='sqlite 3.8.6' PACKAGE_BUGREPORT='' # Factoring default headers for most tests. @@ -1483,7 +1483,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.8.5 to adapt to many kinds of systems. +\`configure' configures sqlite 3.8.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1548,7 +1548,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.8.5:";; + short | recursive ) echo "Configuration of sqlite 3.8.6:";; esac cat <<\_ACEOF @@ -1664,7 +1664,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.8.5 +sqlite configure 3.8.6 generated by GNU Autoconf 2.62 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1678,7 +1678,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.8.5, which was +It was created by sqlite $as_me 3.8.6, which was generated by GNU Autoconf 2.62. Invocation command line was $ $0 $@ @@ -14021,7 +14021,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.8.5, which was +This file was extended by sqlite $as_me 3.8.6, which was generated by GNU Autoconf 2.62. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14074,7 +14074,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -sqlite config.status 3.8.5 +sqlite config.status 3.8.6 configured by $0, generated by GNU Autoconf 2.62, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/manifest b/manifest index bbfeca06e9..d5d65422e5 100644 --- a/manifest +++ b/manifest @@ -1,12 +1,12 @@ -C Attempt\sto\suse\sSTAT4\sinformation\sto\sestimate\sthe\sselectivity\sof\sWHERE\sclause\nterms\swhen\susing\sthe\sskip-scan\soptimization. -D 2014-06-30T19:07:58.197 +C Bump\sthe\sversion\snumber\sto\s3.8.6. +D 2014-06-30T19:28:57.595 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 1732320ecac3fee229d560d7ef2afa34681d1815 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc ad60c4d8be35f98fdcca614088b84a91612b2b4c F Makefile.vxworks 034289efa9d591b04b1a73598623119c306cbba0 F README.md 64f270c43c38c46de749e419c22f0ae2f4499fe8 -F VERSION 9f823c026c6a32fc5f84d212a8aae0a221dba45c +F VERSION 1c877615a9db323e3cd301e3d57d853f9d5c4a07 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F addopcodes.awk 9eb448a552d5c0185cf62c463f9c173cedae3811 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 @@ -38,7 +38,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 0921066a13130082764ab4ab6456f7b5bebe56de F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 5de98fac90452f876511fee8a35565a55dfb191f x +F configure 513f1e2464c3673bcdb5471b13d98e7eeb6f5ca2 x F configure.ac 4cf9f60785143fa141b10962ccc885d973792e9a F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html 334dbf6621b8fb8790297ec1abf3cfa4621709d1 @@ -1182,8 +1182,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P bc2de8095fa9c385db0adf22ca55b0298a33c284 c96de490ac77dd23c108004b95152cce4922fe27 -R 55c9ac9304448ee4805a54515b7a2134 -T +closed c96de490ac77dd23c108004b95152cce4922fe27 +P d09ca6d5efad3e4cfa93a4dc711e6ba6079d4b4b +R 0b9fd011a99704759c36a48aebd29593 U drh -Z bab166b6f1bf8cfb185d9041a405176e +Z 99f7c1257c18120424d63d4c4b9a073c diff --git a/manifest.uuid b/manifest.uuid index 91daee692f..708593f343 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d09ca6d5efad3e4cfa93a4dc711e6ba6079d4b4b \ No newline at end of file +f925e9baafea625f63105f8013abb3807b418379 \ No newline at end of file