From 50133dea285803571214c3459f1ce4d79eea25ec Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 27 Jan 2017 17:02:26 +0000 Subject: [PATCH 01/43] Fix a problem causing the pre-update hook to be invoked by DROP TABLE statements. FossilOrigin-Name: fbb6bf1b69cfd581b4ffd778c344e3fbd9c9406f --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/delete.c | 4 +++- test/hook.test | 10 ++++++---- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 1c84aea007..55464d8c36 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Alternative\sICU\sfix\s(compare\sto\scheck-in\s[50e60cb4])\sthat\savoids\scasting\nintegers\sto\spointers. -D 2017-01-27T13:14:12.467 +C Fix\sa\sproblem\scausing\sthe\spre-update\shook\sto\sbe\sinvoked\sby\sDROP\sTABLE\nstatements. +D 2017-01-27T17:02:26.115 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -342,7 +342,7 @@ F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 9f2296a4e5d26ebf0e0d95a0af4628f1ea694e7a F src/date.c dc3f1391d9297f8c748132813aaffcb117090d6e F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d -F src/delete.c 8a444fea8340989d6b1be2e122c55bfc61ce69be +F src/delete.c 0d9d5549d42e79ce4d82ff1db1e6c81e36d2f67c F src/expr.c f06f41e5e5daca10fb090e70a2502dcc0dbc992b F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae @@ -832,7 +832,7 @@ F test/gcfault.test dd28c228a38976d6336a3fc42d7e5f1ad060cb8c F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 F test/hexlit.test 4a6a5f46e3c65c4bf1fa06f5dd5a9507a5627751 F test/hidden.test 23c1393a79e846d68fd902d72c85d5e5dcf98711 -F test/hook.test f6a48d33817f0ca1a39a4d6605fe7e9da8077522 +F test/hook.test dbc0b87756e1e20e7497b56889c9e9cd2f8cc2b5 F test/icu.test 73956798bace8982909c00476b216714a6d0559a F test/ieee754.test 806fc0ce7f305f57e3331eaceeddcfec9339e607 F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 @@ -1547,7 +1547,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 58f02e6eae8fc9e2577fe435b0282fb46af3960d -R 4a4a07080dc840a599a4cd01566373f4 -U drh -Z 816a99767333ba2de388be8cc7b0ed87 +P d9752c8f7c55426fd7d2b877c5cc3784f93b5349 +R 7c4166e1e335b0337f6f8b4996b52965 +U dan +Z 241b65c68385a1329b03731baa61f118 diff --git a/manifest.uuid b/manifest.uuid index 92d5c8ac0b..e1bf32dbf9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d9752c8f7c55426fd7d2b877c5cc3784f93b5349 \ No newline at end of file +fbb6bf1b69cfd581b4ffd778c344e3fbd9c9406f \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index 1d31622237..0683f9b9dd 100644 --- a/src/delete.c +++ b/src/delete.c @@ -715,7 +715,9 @@ void sqlite3GenerateRowDelete( u8 p5 = 0; sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,iIdxNoSeek); sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0)); - sqlite3VdbeAppendP4(v, (char*)pTab, P4_TABLE); + if( pParse->nested==0 ){ + sqlite3VdbeAppendP4(v, (char*)pTab, P4_TABLE); + } if( eMode!=ONEPASS_OFF ){ sqlite3VdbeChangeP5(v, OPFLAG_AUXDELETE); } diff --git a/test/hook.test b/test/hook.test index 0c24ec7313..9ba220cded 100644 --- a/test/hook.test +++ b/test/hook.test @@ -849,10 +849,12 @@ do_preupdate_test 7.6.4 { } # No preupdate callbacks for modifying sqlite_master. -do_preupdate_test 8.1 { - CREATE TABLE x1(x, y); -} { -} +do_preupdate_test 8.1 { CREATE TABLE x1(x, y); } { } +do_preupdate_test 8.2 { ALTER TABLE x1 ADD COLUMN z } { } +do_preupdate_test 8.3 { ALTER TABLE x1 RENAME TO y1 } { } +do_preupdate_test 8.4 { CREATE INDEX y1x ON y1(x) } { } +do_preupdate_test 8.5 { CREATE VIEW v1 AS SELECT * FROM y1 } { } +do_preupdate_test 8.6 { DROP TABLE y1 } { } #------------------------------------------------------------------------- reset_db From cc04dacb8545a29a7f22a228277c69dbbe8628ba Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 27 Jan 2017 19:27:38 +0000 Subject: [PATCH 02/43] Add the sha1.c loadable extension that implements the sha1() and sha1_query() SQL functions. FossilOrigin-Name: 24e77c1cef163a9822635570b3211789ff23d5c9 --- ext/misc/sha1.c | 399 ++++++++++++++++++++++++++++++++++++++++++++++++ manifest | 13 +- manifest.uuid | 2 +- 3 files changed, 407 insertions(+), 7 deletions(-) create mode 100644 ext/misc/sha1.c diff --git a/ext/misc/sha1.c b/ext/misc/sha1.c new file mode 100644 index 0000000000..dbf15a95ef --- /dev/null +++ b/ext/misc/sha1.c @@ -0,0 +1,399 @@ +/* +** 2017-01-27 +** +** 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 SQLite extension implements a functions that compute SHA1 hashes. +** Two SQL functions are implemented: +** +** sha1(X) +** sha1_query(Y) +** +** The sha1(X) function computes the SHA1 hash of the input X, or NULL if +** X is NULL. +** +** The sha1_query(Y) function evalutes all queries in the SQL statements of Y +** and returns a hash of their results. +*/ +#include "sqlite3ext.h" +SQLITE_EXTENSION_INIT1 +#include +#include +#include + +/****************************************************************************** +** The Hash Engine +*/ +/* Context for the SHA1 hash */ +typedef struct SHA1Context SHA1Context; +struct SHA1Context { + unsigned int state[5]; + unsigned int count[2]; + unsigned char buffer[64]; +}; + + +#if __GNUC__ && (defined(__i386__) || defined(__x86_64__)) +/* + * GCC by itself only generates left rotates. Use right rotates if + * possible to be kinder to dinky implementations with iterative rotate + * instructions. + */ +#define SHA_ROT(op, x, k) \ + ({ unsigned int y; asm(op " %1,%0" : "=r" (y) : "I" (k), "0" (x)); y; }) +#define rol(x,k) SHA_ROT("roll", x, k) +#define ror(x,k) SHA_ROT("rorl", x, k) + +#else +/* Generic C equivalent */ +#define SHA_ROT(x,l,r) ((x) << (l) | (x) >> (r)) +#define rol(x,k) SHA_ROT(x,k,32-(k)) +#define ror(x,k) SHA_ROT(x,32-(k),k) +#endif + + +#define blk0le(i) (block[i] = (ror(block[i],8)&0xFF00FF00) \ + |(rol(block[i],8)&0x00FF00FF)) +#define blk0be(i) block[i] +#define blk(i) (block[i&15] = rol(block[(i+13)&15]^block[(i+8)&15] \ + ^block[(i+2)&15]^block[i&15],1)) + +/* + * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1 + * + * Rl0() for little-endian and Rb0() for big-endian. Endianness is + * determined at run-time. + */ +#define Rl0(v,w,x,y,z,i) \ + z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=ror(w,2); +#define Rb0(v,w,x,y,z,i) \ + z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=ror(w,2); +#define R1(v,w,x,y,z,i) \ + z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=ror(w,2); +#define R2(v,w,x,y,z,i) \ + z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=ror(w,2); +#define R3(v,w,x,y,z,i) \ + z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=ror(w,2); +#define R4(v,w,x,y,z,i) \ + z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=ror(w,2); + +/* + * Hash a single 512-bit block. This is the core of the algorithm. + */ +#define a qq[0] +#define b qq[1] +#define c qq[2] +#define d qq[3] +#define e qq[4] + +void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){ + unsigned int qq[5]; /* a, b, c, d, e; */ + static int one = 1; + unsigned int block[16]; + memcpy(block, buffer, 64); + memcpy(qq,state,5*sizeof(unsigned int)); + + /* Copy p->state[] to working vars */ + /* + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + */ + + /* 4 rounds of 20 operations each. Loop unrolled. */ + if( 1 == *(unsigned char*)&one ){ + Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3); + Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7); + Rl0(c,d,e,a,b, 8); Rl0(b,c,d,e,a, 9); Rl0(a,b,c,d,e,10); Rl0(e,a,b,c,d,11); + Rl0(d,e,a,b,c,12); Rl0(c,d,e,a,b,13); Rl0(b,c,d,e,a,14); Rl0(a,b,c,d,e,15); + }else{ + Rb0(a,b,c,d,e, 0); Rb0(e,a,b,c,d, 1); Rb0(d,e,a,b,c, 2); Rb0(c,d,e,a,b, 3); + Rb0(b,c,d,e,a, 4); Rb0(a,b,c,d,e, 5); Rb0(e,a,b,c,d, 6); Rb0(d,e,a,b,c, 7); + Rb0(c,d,e,a,b, 8); Rb0(b,c,d,e,a, 9); Rb0(a,b,c,d,e,10); Rb0(e,a,b,c,d,11); + Rb0(d,e,a,b,c,12); Rb0(c,d,e,a,b,13); Rb0(b,c,d,e,a,14); Rb0(a,b,c,d,e,15); + } + R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); + R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); + R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); + R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); + R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); + R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); + R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); + R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); + R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); + R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); + R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); + R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); + R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); + R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); + R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); + R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); + + /* Add the working vars back into context.state[] */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; +} + + +/* Initialize a SHA1 context */ +static void hash_init(SHA1Context *p){ + /* SHA1 initialization constants */ + p->state[0] = 0x67452301; + p->state[1] = 0xEFCDAB89; + p->state[2] = 0x98BADCFE; + p->state[3] = 0x10325476; + p->state[4] = 0xC3D2E1F0; + p->count[0] = p->count[1] = 0; +} + +/* Add new content to the SHA1 hash */ +static void hash_step( + SHA1Context *p, /* Add content to this context */ + const unsigned char *data, /* Data to be added */ + unsigned int len /* Number of bytes in data */ +){ + unsigned int i, j; + + j = p->count[0]; + if( (p->count[0] += len << 3) < j ){ + p->count[1] += (len>>29)+1; + } + j = (j >> 3) & 63; + if( (j + len) > 63 ){ + (void)memcpy(&p->buffer[j], data, (i = 64-j)); + SHA1Transform(p->state, p->buffer); + for(; i + 63 < len; i += 64){ + SHA1Transform(p->state, &data[i]); + } + j = 0; + }else{ + i = 0; + } + (void)memcpy(&p->buffer[j], &data[i], len - i); +} + +/* Compute a string using sqlite3_vsnprintf() and hash it */ +static void hash_step_vformat( + SHA1Context *p, /* Add content to this context */ + const char *zFormat, + ... +){ + va_list ap; + int n; + char zBuf[50]; + va_start(ap, zFormat); + sqlite3_vsnprintf(sizeof(zBuf),zBuf,zFormat,ap); + va_end(ap); + n = (int)strlen(zBuf); + hash_step(p, (unsigned char*)zBuf, n); +} + + +/* Add padding and compute the message digest. Render the +** message digest as lower-case hexadecimal and put it into +** zOut[]. zOut[] must be at least 41 bytes long. */ +static void hash_finish( + SHA1Context *p, /* The SHA1 context to finish and render */ + char *zOut /* Store hexadecimal hash here */ +){ + unsigned int i; + unsigned char finalcount[8]; + unsigned char digest[20]; + static const char zEncode[] = "0123456789abcdef"; + + for (i = 0; i < 8; i++){ + finalcount[i] = (unsigned char)((p->count[(i >= 4 ? 0 : 1)] + >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ + } + hash_step(p, (const unsigned char *)"\200", 1); + while ((p->count[0] & 504) != 448){ + hash_step(p, (const unsigned char *)"\0", 1); + } + hash_step(p, finalcount, 8); /* Should cause a SHA1Transform() */ + for (i = 0; i < 20; i++){ + digest[i] = (unsigned char)((p->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); + } + for(i=0; i<20; i++){ + zOut[i*2] = zEncode[(digest[i]>>4)&0xf]; + zOut[i*2+1] = zEncode[digest[i] & 0xf]; + } + zOut[i*2]= 0; +} +/* End of the hashing logic +*****************************************************************************/ + +/* +** Implementation of the sha1(X) function. +** +** Return a lower-case hexadecimal rendering of the SHA1 hash of the +** argument X. If X is a BLOB, it is hashed as is. For all other +** types of input, X is converted into a UTF-8 string and the string +** is hash without the trailing 0x00 terminator. The hash of a NULL +** value is NULL. +*/ +static void sha1Func( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + SHA1Context cx; + int eType = sqlite3_value_type(argv[0]); + int nByte = sqlite3_value_bytes(argv[0]); + char zOut[44]; + + if( eType==SQLITE_NULL ) return; + hash_init(&cx); + if( eType==SQLITE_BLOB ){ + hash_step(&cx, sqlite3_value_blob(argv[0]), nByte); + }else{ + hash_step(&cx, sqlite3_value_text(argv[0]), nByte); + } + hash_finish(&cx, zOut); + sqlite3_result_text(context, zOut, 40, SQLITE_TRANSIENT); +} + +/* +** Implementation of the sha1_query(SQL) function. +** +** This function compiles and runs the SQL statement(s) given in the +** argument. The results are hashed using SHA1 and that hash is returned. +** +** The original SQL text is included as part of the hash. +** +** The hash is not just a concatenation of the outputs. Each query +** is delimited and each row and value within the query is delimited, +** with all values being marked with their datatypes. +*/ +static void sha1QueryFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + sqlite3 *db = sqlite3_context_db_handle(context); + const char *zSql = (const char*)sqlite3_value_text(argv[0]); + sqlite3_stmt *pStmt = 0; + int nCol; /* Number of columns in the result set */ + int i; /* Loop counter */ + int rc; + int n; + const char *z; + SHA1Context cx; + char zOut[44]; + + if( zSql==0 ) return; + hash_init(&cx); + while( zSql[0] ){ + rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zSql); + if( rc ){ + char *zMsg = sqlite3_mprintf("error SQL statement [%s]: %s", + zSql, sqlite3_errmsg(db)); + sqlite3_finalize(pStmt); + sqlite3_result_error(context, zMsg, -1); + sqlite3_free(zMsg); + return; + } + if( !sqlite3_stmt_readonly(pStmt) ){ + char *zMsg = sqlite3_mprintf("non-query: [%s]", sqlite3_sql(pStmt)); + sqlite3_finalize(pStmt); + sqlite3_result_error(context, zMsg, -1); + sqlite3_free(zMsg); + return; + } + nCol = sqlite3_column_count(pStmt); + z = sqlite3_sql(pStmt); + n = (int)strlen(z); + hash_step_vformat(&cx,"S%d:",n); + hash_step(&cx,(unsigned char*)z,n); + + /* Compute a hash over the result of the query */ + while( SQLITE_ROW==sqlite3_step(pStmt) ){ + hash_step(&cx,(const unsigned char*)"R",1); + for(i=0; i=1; j--){ + x[j] = u & 0xff; + u >>= 8; + } + x[0] = 'I'; + hash_step(&cx, x, 9); + break; + } + case SQLITE_FLOAT: { + sqlite3_uint64 u; + int j; + unsigned char x[8]; + double r = sqlite3_column_double(pStmt,i); + memcpy(&u, &r, 8); + for(j=8; j>=1; j--){ + x[j] = u & 0xff; + u >>= 8; + } + x[0] = 'F'; + hash_step(&cx,x,9); + break; + } + case SQLITE_TEXT: { + int n = sqlite3_column_bytes(pStmt, i); + const unsigned char *z = sqlite3_column_text(pStmt, i); + hash_step_vformat(&cx,"T%d:",n); + hash_step(&cx, z, n); + break; + } + case SQLITE_BLOB: { + int n = sqlite3_column_bytes(pStmt, i); + const unsigned char *z = sqlite3_column_blob(pStmt, i); + hash_step_vformat(&cx,"B%d:",n); + hash_step(&cx, z, n); + break; + } + } + } + } + sqlite3_finalize(pStmt); + } + hash_finish(&cx, zOut); + sqlite3_result_text(context, zOut, 40, SQLITE_TRANSIENT); +} + + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int sqlite3_sha_init( + sqlite3 *db, + char **pzErrMsg, + const sqlite3_api_routines *pApi +){ + int rc = SQLITE_OK; + SQLITE_EXTENSION_INIT2(pApi); + (void)pzErrMsg; /* Unused parameter */ + rc = sqlite3_create_function(db, "sha1", 1, SQLITE_UTF8, 0, + sha1Func, 0, 0); + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function(db, "sha1_query", 1, SQLITE_UTF8, 0, + sha1QueryFunc, 0, 0); + } + return rc; +} diff --git a/manifest b/manifest index 55464d8c36..5468756e11 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\scausing\sthe\spre-update\shook\sto\sbe\sinvoked\sby\sDROP\sTABLE\nstatements. -D 2017-01-27T17:02:26.115 +C Add\sthe\ssha1.c\sloadable\sextension\sthat\simplements\sthe\ssha1()\sand\ssha1_query()\nSQL\sfunctions. +D 2017-01-27T19:27:38.700 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -222,6 +222,7 @@ F ext/misc/remember.c 8440f8d0b452c5cdefb62b57135ccd1267aa729d F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a F ext/misc/scrub.c 1c5bfb8b0cd18b602fcb55755e84abf0023ac2fb F ext/misc/series.c e11e534ada797d5b816d7e7a93c022306563ca35 +F ext/misc/sha1.c b2e4eb8e26f09701ec15548395baf698f00e5895 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c a4723b6aff748a417b5091b68a46443265c40f0d F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 @@ -1547,7 +1548,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P d9752c8f7c55426fd7d2b877c5cc3784f93b5349 -R 7c4166e1e335b0337f6f8b4996b52965 -U dan -Z 241b65c68385a1329b03731baa61f118 +P fbb6bf1b69cfd581b4ffd778c344e3fbd9c9406f +R 389e8cfe151c91b893dde5f7934ffeac +U drh +Z 4597f51eb6c4ecdd76ade7480dc74dac diff --git a/manifest.uuid b/manifest.uuid index e1bf32dbf9..4866d1d1f8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fbb6bf1b69cfd581b4ffd778c344e3fbd9c9406f \ No newline at end of file +24e77c1cef163a9822635570b3211789ff23d5c9 \ No newline at end of file From 2d2e4f389584fec0b27100107b18bb835ddeba94 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 28 Jan 2017 06:50:15 +0000 Subject: [PATCH 03/43] Fix a typo in the docs for sqlite3_update_hook(). FossilOrigin-Name: 7c029655cc3369a1e46741fdd3701d36d420b28b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 5468756e11..41ba2e4d2c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssha1.c\sloadable\sextension\sthat\simplements\sthe\ssha1()\sand\ssha1_query()\nSQL\sfunctions. -D 2017-01-27T19:27:38.700 +C Fix\sa\stypo\sin\sthe\sdocs\sfor\ssqlite3_update_hook(). +D 2017-01-28T06:50:15.642 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -393,7 +393,7 @@ F src/resolve.c f9bc0de45a30a450da47b3766de00be89bf9be79 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 3856db523b942062bca8722ba03b61c324ff94d6 F src/shell.c a84e453c213f3e0d6935a582024da4e242f85a19 -F src/sqlite.h.in 1971ab9709e010d52a02a1a6276d5a2f9b947476 +F src/sqlite.h.in eefd49aa3aae3b4acd7d7e2f8f9b0db8ae0aff3b F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae F src/sqliteInt.h 341ce9e5b0397771fa6bd9dadb8ef4cbbd6224d0 @@ -1548,7 +1548,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fbb6bf1b69cfd581b4ffd778c344e3fbd9c9406f -R 389e8cfe151c91b893dde5f7934ffeac -U drh -Z 4597f51eb6c4ecdd76ade7480dc74dac +P 24e77c1cef163a9822635570b3211789ff23d5c9 +R f1c881d122d9ce415eab840d4253340a +U dan +Z 83c68a9a3025b00f2574a4c70122bf9b diff --git a/manifest.uuid b/manifest.uuid index 4866d1d1f8..140867e588 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -24e77c1cef163a9822635570b3211789ff23d5c9 \ No newline at end of file +7c029655cc3369a1e46741fdd3701d36d420b28b \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 87d5d121cb..0bf386f72a 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5417,7 +5417,7 @@ void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); ** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified. ** ** ^In the current implementation, the update hook -** is not invoked when duplication rows are deleted because of an +** is not invoked when conflicting rows are deleted because of an ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook ** invoked when rows are deleted using the [truncate optimization]. ** The exceptions defined in this paragraph might change in a future From 27c846773497d27eb6f04f7f7b03d073b99b319d Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 28 Jan 2017 13:40:55 +0000 Subject: [PATCH 04/43] In the speed-check.sh script, automatically invoke "fossil test-diff --tk" on the cachegrind output against trunk, if not generating a trunk run. FossilOrigin-Name: aa1ab37100a91ab4bb91d50a1267c26967efcb21 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/speed-check.sh | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 41ba2e4d2c..3e4c3fcfe4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\sthe\sdocs\sfor\ssqlite3_update_hook(). -D 2017-01-28T06:50:15.642 +C In\sthe\sspeed-check.sh\sscript,\sautomatically\sinvoke\s"fossil\stest-diff\s--tk"\son\nthe\scachegrind\soutput\sagainst\strunk,\sif\snot\sgenerating\sa\strunk\srun. +D 2017-01-28T13:40:55.453 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -1508,7 +1508,7 @@ F tool/showstat4.c b14159aa062f661b394ba37b6b7b94bfb8012ab9 F tool/showwal.c ec79959834f7b21f1e0a2aa52bb7c056d2203977 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/spaceanal.tcl ab7d9bf68062907282a64b3e12ccbfad47193c5a -F tool/speed-check.sh 65ac2f5b00771b9dcefb95bebae1aab76c537ea3 +F tool/speed-check.sh 9630ba0468b609c52f48309243d4eb6e9c34deda F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff @@ -1548,7 +1548,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 24e77c1cef163a9822635570b3211789ff23d5c9 -R f1c881d122d9ce415eab840d4253340a -U dan -Z 83c68a9a3025b00f2574a4c70122bf9b +P 7c029655cc3369a1e46741fdd3701d36d420b28b +R e044c4e027113b10098b21316c3901f3 +U drh +Z 82ae1e57a20d4dbe9187373cc6493ae1 diff --git a/manifest.uuid b/manifest.uuid index 140867e588..fc7ceb70f4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c029655cc3369a1e46741fdd3701d36d420b28b \ No newline at end of file +aa1ab37100a91ab4bb91d50a1267c26967efcb21 \ No newline at end of file diff --git a/tool/speed-check.sh b/tool/speed-check.sh index c6f587e177..1e1389f2fd 100644 --- a/tool/speed-check.sh +++ b/tool/speed-check.sh @@ -142,3 +142,6 @@ fi if test $doExplain -eq 1; then ./speedtest1 --explain $SPEEDTEST_OPTS | ./sqlite3 >explain-$NAME.txt fi +if test "$NAME" != "trunk"; then + fossil test-diff --tk cout-trunk.txt cout-$NAME.txt +fi From 6034d476186cda5b18f6003b8c3f66cb0e216d16 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 28 Jan 2017 15:26:14 +0000 Subject: [PATCH 05/43] Updates to the sqlite3_blob documentation. No changes to code. FossilOrigin-Name: 426b440a5745f9c431c6a3d9ba542af61a6a83fb --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 3e4c3fcfe4..6c861e5ee0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\sspeed-check.sh\sscript,\sautomatically\sinvoke\s"fossil\stest-diff\s--tk"\son\nthe\scachegrind\soutput\sagainst\strunk,\sif\snot\sgenerating\sa\strunk\srun. -D 2017-01-28T13:40:55.453 +C Updates\sto\sthe\ssqlite3_blob\sdocumentation.\s\sNo\schanges\sto\scode. +D 2017-01-28T15:26:14.397 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -393,7 +393,7 @@ F src/resolve.c f9bc0de45a30a450da47b3766de00be89bf9be79 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 3856db523b942062bca8722ba03b61c324ff94d6 F src/shell.c a84e453c213f3e0d6935a582024da4e242f85a19 -F src/sqlite.h.in eefd49aa3aae3b4acd7d7e2f8f9b0db8ae0aff3b +F src/sqlite.h.in a14cd1f946b9565c4d801c4adeeaa4543fbd6eb4 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae F src/sqliteInt.h 341ce9e5b0397771fa6bd9dadb8ef4cbbd6224d0 @@ -1548,7 +1548,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7c029655cc3369a1e46741fdd3701d36d420b28b -R e044c4e027113b10098b21316c3901f3 +P aa1ab37100a91ab4bb91d50a1267c26967efcb21 +R e94128da2458d76e1f9232d83fbb5c60 U drh -Z 82ae1e57a20d4dbe9187373cc6493ae1 +Z 85ea4b53c0f0f74a70744dcf483d3a5b diff --git a/manifest.uuid b/manifest.uuid index fc7ceb70f4..6d893bf0fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -aa1ab37100a91ab4bb91d50a1267c26967efcb21 \ No newline at end of file +426b440a5745f9c431c6a3d9ba542af61a6a83fb \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 0bf386f72a..d80de6d519 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -6199,6 +6199,12 @@ typedef struct sqlite3_blob sqlite3_blob; ** [database connection] error code and message accessible via ** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. ** +** A BLOB referenced by sqlite3_blob_open() and be read using the +** [sqlite3_blob_read()] interface and modified by using +** [sqlite3_blob_write()]. The [BLOB handle] can be moved to a +** different row of the same table using the [sqlite3_blob_reopen()] +** interface. However, the column, table, or database of a [BLOB handle] +** cannot be changed once after the [BLOB handle] is opened. ** ** ^(If the row that a BLOB handle points to is modified by an ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects @@ -6222,6 +6228,10 @@ typedef struct sqlite3_blob sqlite3_blob; ** ** To avoid a resource leak, every open [BLOB handle] should eventually ** be released by a call to [sqlite3_blob_close()]. +** +** See also: [sqlite3_blob_close()], +** [sqlite3_blob_reopen()], [sqlite3_blob_read()], +** [sqlite3_blob_bytes()], [sqlite3_blob_write()]. */ int sqlite3_blob_open( sqlite3*, @@ -6237,11 +6247,11 @@ int sqlite3_blob_open( ** CAPI3REF: Move a BLOB Handle to a New Row ** METHOD: sqlite3_blob ** -** ^This function is used to move an existing blob handle so that it points +** ^This function is used to move an existing [BLOB handle] so that it points ** to a different row of the same database table. ^The new row is identified ** by the rowid value passed as the second argument. Only the row can be ** changed. ^The database, table and column on which the blob handle is open -** remain the same. Moving an existing blob handle to a new row can be +** remain the same. Moving an existing [BLOB handle] to a new row is ** faster than closing the existing handle and opening a new one. ** ** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] - From f64ece143c4d71a5d8f8a67cd643cd0ef683c29e Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 28 Jan 2017 19:45:34 +0000 Subject: [PATCH 06/43] Avoid redundant table b-tree cursor seeks in UPDATE statements that use the two-pass strategy. FossilOrigin-Name: dc555b1039c6930f6d15355c698ff917a85e8056 --- ext/session/session1.test | 19 +++++++++++++++++++ manifest | 22 +++++++++++----------- manifest.uuid | 2 +- src/sqliteInt.h | 2 +- src/update.c | 2 +- src/wherecode.c | 5 ++++- test/update2.test | 25 +++++++++++++++++++++++++ 7 files changed, 62 insertions(+), 15 deletions(-) diff --git a/ext/session/session1.test b/ext/session/session1.test index 09d35af7fc..5216824bdd 100644 --- a/ext/session/session1.test +++ b/ext/session/session1.test @@ -582,4 +582,23 @@ do_iterator_test 11.2 * { } { } +reset_db +do_execsql_test 12.1 { + CREATE TABLE t1(r INTEGER PRIMARY KEY, a, b); + CREATE INDEX i1 ON t1(a); + INSERT INTO t1 VALUES(1, 1, 1); + INSERT INTO t1 VALUES(2, 1, 2); + INSERT INTO t1 VALUES(3, 1, 3); +} + +do_iterator_test 12.2 * { + UPDATE t1 SET b='one' WHERE a=1; +} { + {UPDATE t1 0 X.. {i 1 {} {} i 1} {{} {} {} {} t one}} + {UPDATE t1 0 X.. {i 2 {} {} i 2} {{} {} {} {} t one}} + {UPDATE t1 0 X.. {i 3 {} {} i 3} {{} {} {} {} t one}} +} + + + finish_test diff --git a/manifest b/manifest index 6c861e5ee0..ddbf2ea5df 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Updates\sto\sthe\ssqlite3_blob\sdocumentation.\s\sNo\schanges\sto\scode. -D 2017-01-28T15:26:14.397 +C Avoid\sredundant\stable\sb-tree\scursor\sseeks\sin\sUPDATE\sstatements\sthat\suse\sthe\ntwo-pass\sstrategy. +D 2017-01-28T19:45:34.617 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -288,7 +288,7 @@ F ext/rtree/sqlite3rtree.h 9c5777af3d2921c7b4ae4954e8e5697502289d28 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F ext/session/changeset.c 4ccbaa4531944c24584bf6a61ba3a39c62b6267a -F ext/session/session1.test e5125b216d1e8c91e0984b361b0b68529e7c5dfb +F ext/session/session1.test 482e9b861169d0b7e283e1563a28c0fa32779fa5 F ext/session/session2.test 284de45abae4cc1082bc52012ee81521d5ac58e0 F ext/session/session3.test a7a9ce59b8d1e49e2cc23d81421ac485be0eea01 F ext/session/session4.test 457b02bdc349eb01151e54de014df77abd3c08c8 @@ -396,7 +396,7 @@ F src/shell.c a84e453c213f3e0d6935a582024da4e242f85a19 F src/sqlite.h.in a14cd1f946b9565c4d801c4adeeaa4543fbd6eb4 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae -F src/sqliteInt.h 341ce9e5b0397771fa6bd9dadb8ef4cbbd6224d0 +F src/sqliteInt.h c246370f9d8de3af36052d7860cd35c0e2daea6a F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 @@ -454,7 +454,7 @@ F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 5c2f516876fc27fbd7753913f032f49eb89e83b5 F src/treeview.c 4e44ade3bfe59d82005039f72e09333ce2b4162c F src/trigger.c c9f0810043b265724fdb1bdd466894f984dfc182 -F src/update.c b356b29d04c71f33c779f2cb557cf953819bdd7a +F src/update.c 456d4a4656f8a03c2abc88a51b19172197400e58 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c a88b0466fddf445ce752226d4698ca3faada620a F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16 @@ -474,7 +474,7 @@ F src/wal.h 06b2a0b599cc0f53ea97f497cf8c6b758c999f71 F src/walker.c 91a6df7435827e41cff6bb7df50ea00934ee78b0 F src/where.c bc71775e23d23334e8f449aa31012d692dc09cb2 F src/whereInt.h 2bcc3d176e6091cb8f50a30b65c006e88a73614d -F src/wherecode.c e04ac8f24c3ac8621df6c3be3ac8c7d4fa893745 +F src/wherecode.c 99a8ced164c75edf41b3a865a75381c9adb38b28 F src/whereexpr.c 35ad025389a632a3987a35617c878be3b3d70dc6 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1355,7 +1355,7 @@ F test/unique2.test 3674e9f2a3f1fbbfd4772ac74b7a97090d0f77d2 F test/unixexcl.test d936ba2b06794018e136418addd59a2354eeae97 F test/unordered.test ca7adce0419e4ca0c50f039885e76ed2c531eda8 F test/update.test 6c68446b8a0a33d522a7c72b320934596a2d7d32 -F test/update2.test 7f72ef307d58be09a8ef61db23a7ef60e5af019d +F test/update2.test 81772e5c9b93d1006d66d65e9a1327281bdec4e8 F test/uri.test 3481026f00ade6dfe8adb7acb6e1e47b04369568 F test/uri2.test 9d3ba7a53ee167572d53a298ee4a5d38ec4a8fb7 F test/userauth01.test e740a2697a7b40d7c5003a7d7edaee16acd349a9 @@ -1548,7 +1548,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P aa1ab37100a91ab4bb91d50a1267c26967efcb21 -R e94128da2458d76e1f9232d83fbb5c60 -U drh -Z 85ea4b53c0f0f74a70744dcf483d3a5b +P 426b440a5745f9c431c6a3d9ba542af61a6a83fb +R cb9f34739a33405b5f0617b1ee3426fc +U dan +Z 2ac8b1778a518257277e1132fa6dad3a diff --git a/manifest.uuid b/manifest.uuid index 6d893bf0fe..0e49c05605 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -426b440a5745f9c431c6a3d9ba542af61a6a83fb \ No newline at end of file +dc555b1039c6930f6d15355c698ff917a85e8056 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 7ea8748b73..3f0da18e9c 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2592,7 +2592,7 @@ struct SrcList { #define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */ #define WHERE_SEEK_TABLE 0x0400 /* Do not defer seeks on main table */ #define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */ - /* 0x1000 not currently used */ +#define WHERE_SEEK_UNIQ_TABLE 0x1000 /* Do not defer seeks if unique */ /* 0x2000 not currently used */ #define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */ /* 0x8000 not currently used */ diff --git a/src/update.c b/src/update.c index 45af001c3e..8fca7eb988 100644 --- a/src/update.c +++ b/src/update.c @@ -392,7 +392,7 @@ void sqlite3Update( ** be deleted as a result of REPLACE conflict handling. Any of these ** things might disturb a cursor being used to scan through the table ** or index, causing a single-pass approach to malfunction. */ - flags = WHERE_ONEPASS_DESIRED | WHERE_SEEK_TABLE; + flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE; if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){ flags |= WHERE_ONEPASS_MULTIROW; } diff --git a/src/wherecode.c b/src/wherecode.c index 032c56fef3..58e040628a 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1591,7 +1591,10 @@ Bitmask sqlite3WhereCodeOneLoopStart( if( omitTable ){ /* pIdx is a covering index. No need to access the main table. */ }else if( HasRowid(pIdx->pTable) ){ - if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE)!=0 ){ + if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || ( + (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE) + && (pWInfo->eOnePass==ONEPASS_SINGLE) + )){ iRowidReg = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg); sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); diff --git a/test/update2.test b/test/update2.test index 61ac9792da..6a359d11a9 100644 --- a/test/update2.test +++ b/test/update2.test @@ -176,5 +176,30 @@ foreach {tn sql} { } } +#------------------------------------------------------------------------- +# +do_execsql_test 5.0 { + CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c); + CREATE INDEX x1c ON x1(b, c); + INSERT INTO x1 VALUES(1, 'a', 1); + INSERT INTO x1 VALUES(2, 'a', 2); + INSERT INTO x1 VALUES(3, 'a', 3); +} + +do_execsql_test 5.1.1 { + UPDATE x1 SET c=c+1 WHERE b='a'; +} + +do_execsql_test 5.1.2 { + SELECT * FROM x1; +} {1 a 2 2 a 3 3 a 4} + +do_test 5.2 { + catch { array unset A } + db eval { EXPLAIN UPDATE x1 SET c=c+1 WHERE b='a' } { incr A($opcode) } + set A(NotExists) +} {1} + + finish_test From 51b15c3871a264dc4867eeda97faed19f86bdb2b Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 28 Jan 2017 19:53:51 +0000 Subject: [PATCH 07/43] Fix a couple comment typos. No changes to code. FossilOrigin-Name: 2a2e7d86b275c970726f642a37a098950a3b906e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index ddbf2ea5df..02a68de80a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sredundant\stable\sb-tree\scursor\sseeks\sin\sUPDATE\sstatements\sthat\suse\sthe\ntwo-pass\sstrategy. -D 2017-01-28T19:45:34.617 +C Fix\sa\scouple\scomment\stypos.\s\sNo\schanges\sto\scode. +D 2017-01-28T19:53:51.613 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -393,7 +393,7 @@ F src/resolve.c f9bc0de45a30a450da47b3766de00be89bf9be79 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 3856db523b942062bca8722ba03b61c324ff94d6 F src/shell.c a84e453c213f3e0d6935a582024da4e242f85a19 -F src/sqlite.h.in a14cd1f946b9565c4d801c4adeeaa4543fbd6eb4 +F src/sqlite.h.in 8fd2b1a4e4aac023d4533313442528b81105fab3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae F src/sqliteInt.h c246370f9d8de3af36052d7860cd35c0e2daea6a @@ -1548,7 +1548,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 426b440a5745f9c431c6a3d9ba542af61a6a83fb -R cb9f34739a33405b5f0617b1ee3426fc -U dan -Z 2ac8b1778a518257277e1132fa6dad3a +P dc555b1039c6930f6d15355c698ff917a85e8056 +R 85ad9229fc7d18817a896fd231c69045 +U mistachkin +Z 8ca9913e082eb1ea0368f4a7e44ff324 diff --git a/manifest.uuid b/manifest.uuid index 0e49c05605..d337122ecd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dc555b1039c6930f6d15355c698ff917a85e8056 \ No newline at end of file +2a2e7d86b275c970726f642a37a098950a3b906e \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index d80de6d519..b0ec7f7e15 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -6199,12 +6199,12 @@ typedef struct sqlite3_blob sqlite3_blob; ** [database connection] error code and message accessible via ** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. ** -** A BLOB referenced by sqlite3_blob_open() and be read using the +** A BLOB referenced by sqlite3_blob_open() may be read using the ** [sqlite3_blob_read()] interface and modified by using ** [sqlite3_blob_write()]. The [BLOB handle] can be moved to a ** different row of the same table using the [sqlite3_blob_reopen()] ** interface. However, the column, table, or database of a [BLOB handle] -** cannot be changed once after the [BLOB handle] is opened. +** cannot be changed after the [BLOB handle] is opened. ** ** ^(If the row that a BLOB handle points to is modified by an ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects From d26cc54183849acb2f53537e67e5968ada4619d9 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 28 Jan 2017 20:46:37 +0000 Subject: [PATCH 08/43] In the amalgamation, allocate the parser engine object from stack rather than from heap, for improved performance. This only happens in the amalgamation, since otherwise the sqlite3RunParser() routine does not know the object size. FossilOrigin-Name: 4fe879d4b5da6ae0688a7a99004683a234966597 --- manifest | 20 +++++++------- manifest.uuid | 2 +- src/parse.y | 13 +++++++++ src/sqliteInt.h | 6 +++-- src/tokenize.c | 12 +++++++++ tool/lempar.c | 71 ++++++++++++++++++++++++++++++------------------- 6 files changed, 84 insertions(+), 40 deletions(-) diff --git a/manifest b/manifest index 02a68de80a..332ad282a9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scouple\scomment\stypos.\s\sNo\schanges\sto\scode. -D 2017-01-28T19:53:51.613 +C In\sthe\samalgamation,\sallocate\sthe\sparser\sengine\sobject\sfrom\sstack\srather\sthan\nfrom\sheap,\sfor\simproved\sperformance.\s\sThis\sonly\shappens\sin\sthe\samalgamation,\nsince\sotherwise\sthe\ssqlite3RunParser()\sroutine\sdoes\snot\sknow\sthe\sobject\ssize. +D 2017-01-28T20:46:37.958 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -380,7 +380,7 @@ F src/os_win.c cf90abd4e50d9f56d2c20ce8e005aff55d7bd8e9 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c ff1232b3088a39806035ecfac4fffeb22717d80b F src/pager.h f2a99646c5533ffe11afa43e9e0bea74054e4efa -F src/parse.y 29153738a7322054359320eb00b5a4cd44389f20 +F src/parse.y 591704fce84f814d9a3642774c1f011d38f4149c F src/pcache.c 51070ec9b8251bbf9c6ea3d35fd96a458752929e F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c e3967219b2a92b9edcb9324a4ba75009090d3953 @@ -396,7 +396,7 @@ F src/shell.c a84e453c213f3e0d6935a582024da4e242f85a19 F src/sqlite.h.in 8fd2b1a4e4aac023d4533313442528b81105fab3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae -F src/sqliteInt.h c246370f9d8de3af36052d7860cd35c0e2daea6a +F src/sqliteInt.h fd6815792077b7dc69f5167117cc5727fe95ed5a F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 @@ -451,7 +451,7 @@ F src/test_windirent.c 17f91f5f2aa1bb7328abb49414c363b5d2a9d3ff F src/test_windirent.h 5d67483a55442e31e1bde0f4a230e6e932ad5906 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c 5c2f516876fc27fbd7753913f032f49eb89e83b5 +F src/tokenize.c 25ccc63ae2c4163933221f3181c9982b47cd08d2 F src/treeview.c 4e44ade3bfe59d82005039f72e09333ce2b4162c F src/trigger.c c9f0810043b265724fdb1bdd466894f984dfc182 F src/update.c 456d4a4656f8a03c2abc88a51b19172197400e58 @@ -1476,7 +1476,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/lemon.c 5ccba178a8e8a4b21e1c9232944d23973da38ad7 -F tool/lempar.c 320d630b44da693407684c64d9fa91a163419dac +F tool/lempar.c db1bdb4821f2d8fbd76e577cf3ab18642c8d08d1 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1548,7 +1548,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P dc555b1039c6930f6d15355c698ff917a85e8056 -R 85ad9229fc7d18817a896fd231c69045 -U mistachkin -Z 8ca9913e082eb1ea0368f4a7e44ff324 +P 2a2e7d86b275c970726f642a37a098950a3b906e +R 9e84d1f95c544016e0312212ee6f639c +U drh +Z 9df531d71c0beb5e9e8a394dca7276a3 diff --git a/manifest.uuid b/manifest.uuid index d337122ecd..87236c5ed3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2a2e7d86b275c970726f642a37a098950a3b906e \ No newline at end of file +4fe879d4b5da6ae0688a7a99004683a234966597 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index c9dbc767cd..9cada2a1be 100644 --- a/src/parse.y +++ b/src/parse.y @@ -65,6 +65,19 @@ */ #define YYPARSEFREENEVERNULL 1 +/* +** In the amalgamation, the parse.c file generated by lemon and the +** tokenize.c file are concatenated. In that case, sqlite3RunParser() +** has access to the the size of the yyParser object and so the parser +** engine can be allocated from stack. In that case, only the +** sqlite3ParserInit() and sqlite3ParserFinalize() routines are invoked +** and the sqlite3ParserAlloc() and sqlite3ParserFree() routines can be +** omitted. +*/ +#ifdef SQLITE_AMALGAMATION +# define sqlite3Parser_ENGINEALWAYSONSTACK 1 +#endif + /* ** Alternative datatype for the argument to the malloc() routine passed ** into sqlite3ParserAlloc(). The default is size_t. diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 3f0da18e9c..4b7bdf5937 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4073,8 +4073,10 @@ char sqlite3IndexColumnAffinity(sqlite3*, Index*, int); /* ** The interface to the LEMON-generated parser */ -void *sqlite3ParserAlloc(void*(*)(u64)); -void sqlite3ParserFree(void*, void(*)(void*)); +#ifndef SQLITE_AMALGAMATION + void *sqlite3ParserAlloc(void*(*)(u64)); + void sqlite3ParserFree(void*, void(*)(void*)); +#endif void sqlite3Parser(void*, int, Token, Parse*); #ifdef YYTRACKMAXSTACKDEPTH int sqlite3ParserStackPeak(void*); diff --git a/src/tokenize.c b/src/tokenize.c index c400dcd554..7bb1179e20 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -481,6 +481,9 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ int lastTokenParsed = -1; /* type of the previous token */ sqlite3 *db = pParse->db; /* The database connection */ int mxSqlLen; /* Max length of an SQL string */ +#ifdef sqlite3Parser_ENGINEALWAYSONSTACK + unsigned char zSpace[sizeof(yyParser)]; /* Space for parser engine object */ +#endif assert( zSql!=0 ); mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH]; @@ -492,11 +495,16 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ i = 0; assert( pzErrMsg!=0 ); /* sqlite3ParserTrace(stdout, "parser: "); */ +#ifdef sqlite3Parser_ENGINEALWAYSONSTACK + pEngine = zSpace; + sqlite3ParserInit(pEngine); +#else pEngine = sqlite3ParserAlloc(sqlite3Malloc); if( pEngine==0 ){ sqlite3OomFault(db); return SQLITE_NOMEM_BKPT; } +#endif assert( pParse->pNewTable==0 ); assert( pParse->pNewTrigger==0 ); assert( pParse->nVar==0 ); @@ -548,7 +556,11 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ ); sqlite3_mutex_leave(sqlite3MallocMutex()); #endif /* YYDEBUG */ +#ifdef sqlite3Parser_ENGINEALWAYSONSTACK + sqlite3ParserFinalize(pEngine); +#else sqlite3ParserFree(pEngine, sqlite3_free); +#endif if( db->mallocFailed ){ pParse->rc = SQLITE_NOMEM_BKPT; } diff --git a/tool/lempar.c b/tool/lempar.c index dab8343f3a..21ed9d79ab 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -316,6 +316,31 @@ static int yyGrowStack(yyParser *p){ # define YYMALLOCARGTYPE size_t #endif +/* Initialize a new parser that has already been allocated. +*/ +void ParseInit(void *yypParser){ + yyParser *pParser = (yyParser*)yypParser; +#ifdef YYTRACKMAXSTACKDEPTH + pParser->yyhwm = 0; +#endif +#if YYSTACKDEPTH<=0 + pParser->yytos = NULL; + pParser->yystack = NULL; + pParser->yystksz = 0; + if( yyGrowStack(pParser) ){ + pParser->yystack = &pParser->yystk0; + pParser->yystksz = 1; + } +#endif +#ifndef YYNOERRORRECOVERY + pParser->yyerrcnt = -1; +#endif + pParser->yytos = pParser->yystack; + pParser->yystack[0].stateno = 0; + pParser->yystack[0].major = 0; +} + +#ifndef Parse_ENGINEALWAYSONSTACK /* ** This function allocates a new parser. ** The only argument is a pointer to a function which works like @@ -331,28 +356,11 @@ static int yyGrowStack(yyParser *p){ void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ yyParser *pParser; pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); - if( pParser ){ -#ifdef YYTRACKMAXSTACKDEPTH - pParser->yyhwm = 0; -#endif -#if YYSTACKDEPTH<=0 - pParser->yytos = NULL; - pParser->yystack = NULL; - pParser->yystksz = 0; - if( yyGrowStack(pParser) ){ - pParser->yystack = &pParser->yystk0; - pParser->yystksz = 1; - } -#endif -#ifndef YYNOERRORRECOVERY - pParser->yyerrcnt = -1; -#endif - pParser->yytos = pParser->yystack; - pParser->yystack[0].stateno = 0; - pParser->yystack[0].major = 0; - } + if( pParser ) ParseInit(pParser); return pParser; } +#endif /* Parse_ENGINEALWAYSONSTACK */ + /* The following function deletes the "minor type" or semantic value ** associated with a symbol. The symbol can be either a terminal @@ -406,6 +414,18 @@ static void yy_pop_parser_stack(yyParser *pParser){ yy_destructor(pParser, yytos->major, &yytos->minor); } +/* +** Clear all secondary memory allocations from the parser +*/ +void ParseFinalize(void *p){ + yyParser *pParser = (yyParser*)p; + while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser); +#if YYSTACKDEPTH<=0 + if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack); +#endif +} + +#ifndef Parse_ENGINEALWAYSONSTACK /* ** Deallocate and destroy a parser. Destructors are called for ** all stack elements before shutting the parser down. @@ -418,16 +438,13 @@ void ParseFree( void *p, /* The parser to be deleted */ void (*freeProc)(void*) /* Function used to reclaim memory */ ){ - yyParser *pParser = (yyParser*)p; #ifndef YYPARSEFREENEVERNULL - if( pParser==0 ) return; + if( p==0 ) return; #endif - while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser); -#if YYSTACKDEPTH<=0 - if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack); -#endif - (*freeProc)((void*)pParser); + ParseFinalize(p); + (*freeProc)(p); } +#endif /* Parse_ENGINEALWAYSONSTACK */ /* ** Return the peak depth of the stack for a parser. From e7eeeb99f7827fc2838cf730adfb58f5419a41e7 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 30 Jan 2017 11:38:19 +0000 Subject: [PATCH 09/43] Fix building with SQLITE_OMIT_FOREIGN_KEY defined. FossilOrigin-Name: e93d2c49a44af994ff10cc9cc7eafacd5a4f73ab --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 332ad282a9..229623bcc5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sthe\samalgamation,\sallocate\sthe\sparser\sengine\sobject\sfrom\sstack\srather\sthan\nfrom\sheap,\sfor\simproved\sperformance.\s\sThis\sonly\shappens\sin\sthe\samalgamation,\nsince\sotherwise\sthe\ssqlite3RunParser()\sroutine\sdoes\snot\sknow\sthe\sobject\ssize. -D 2017-01-28T20:46:37.958 +C Fix\sbuilding\swith\sSQLITE_OMIT_FOREIGN_KEY\sdefined. +D 2017-01-30T11:38:19.468 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -396,7 +396,7 @@ F src/shell.c a84e453c213f3e0d6935a582024da4e242f85a19 F src/sqlite.h.in 8fd2b1a4e4aac023d4533313442528b81105fab3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae -F src/sqliteInt.h fd6815792077b7dc69f5167117cc5727fe95ed5a +F src/sqliteInt.h 6f29b23415ce207c2fda61054bf244b74f96359c F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 @@ -1548,7 +1548,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2a2e7d86b275c970726f642a37a098950a3b906e -R 9e84d1f95c544016e0312212ee6f639c -U drh -Z 9df531d71c0beb5e9e8a394dca7276a3 +P 4fe879d4b5da6ae0688a7a99004683a234966597 +R c0ed5c24fdff676195cd77401e89700b +U dan +Z 6d1b138d17ccacee0c622f2ed331ca89 diff --git a/manifest.uuid b/manifest.uuid index 87236c5ed3..eec33fc0a4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4fe879d4b5da6ae0688a7a99004683a234966597 \ No newline at end of file +e93d2c49a44af994ff10cc9cc7eafacd5a4f73ab \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 4b7bdf5937..4a28ebcd5a 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4186,6 +4186,7 @@ const char *sqlite3JournalModename(int); #define sqlite3FkDropTable(a,b,c) #define sqlite3FkOldmask(a,b) 0 #define sqlite3FkRequired(a,b,c,d) 0 + #define sqlite3FkReferences(a) 0 #endif #ifndef SQLITE_OMIT_FOREIGN_KEY void sqlite3FkDelete(sqlite3 *, Table*); From cb9a364390f2db2bb9340045e7973d3f639110bb Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 30 Jan 2017 19:44:53 +0000 Subject: [PATCH 10/43] Experimental change to invoke the preupdate hook when WITHOUT ROWID tables are written. FossilOrigin-Name: 856f8604c59c8fdd9bfb7d86fc0e212f091ab49a --- ext/session/session1.test | 245 +++++++++++++++++++----------------- ext/session/sessionwor.test | 57 +++++++++ manifest | 27 ++-- manifest.uuid | 2 +- src/insert.c | 17 ++- src/vdbe.c | 13 +- src/vdbeInt.h | 1 + src/vdbeapi.c | 6 + src/vdbeaux.c | 11 +- test/hook2.test | 218 ++++++++++++++++++++++++++++++++ 10 files changed, 458 insertions(+), 139 deletions(-) create mode 100644 ext/session/sessionwor.test create mode 100644 test/hook2.test diff --git a/ext/session/session1.test b/ext/session/session1.test index 5216824bdd..c96c248c5e 100644 --- a/ext/session/session1.test +++ b/ext/session/session1.test @@ -20,46 +20,61 @@ ifcapable !session {finish_test; return} set testprefix session1 -do_execsql_test 1.0 { - CREATE TABLE t1(x PRIMARY KEY, y); +# Run all tests in this file twice. Once with "WITHOUT ROWID", and once +# with regular rowid tables. +# +foreach {tn trailing} { + 1 "" + 2 " WITHOUT ROWID " +} { +eval [string map [list %WR% $trailing] { + +db close +forcedelete test.db test.db2 +reset_db + +do_execsql_test $tn.1.0 { + CREATE TABLE t1(x PRIMARY KEY, y) %WR%; INSERT INTO t1 VALUES('abc', 'def'); } #------------------------------------------------------------------------- # Test creating, attaching tables to and deleting session objects. # -do_test 1.1 { sqlite3session S db main } {S} -do_test 1.2 { S delete } {} -do_test 1.3 { sqlite3session S db main } {S} -do_test 1.4 { S attach t1 } {} -do_test 1.5 { S delete } {} -do_test 1.6 { sqlite3session S db main } {S} -do_test 1.7 { S attach t1 ; S attach t2 ; S attach t3 } {} -do_test 1.8 { S attach t1 ; S attach t2 ; S attach t3 } {} -do_test 1.9 { S delete } {} -do_test 1.10 { +do_test $tn.1.1 { sqlite3session S db main } {S} +do_test $tn.1.2 { S delete } {} +do_test $tn.1.3 { sqlite3session S db main } {S} +do_test $tn.1.4 { S attach t1 } {} +do_test $tn.1.5 { S delete } {} +do_test $tn.1.6 { sqlite3session S db main } {S} +do_test $tn.1.7 { S attach t1 ; S attach t2 ; S attach t3 } {} +do_test $tn.1.8 { S attach t1 ; S attach t2 ; S attach t3 } {} +do_test $tn.1.9 { S delete } {} +do_test $tn.1.10 { sqlite3session S db main S attach t1 execsql { INSERT INTO t1 VALUES('ghi', 'jkl') } } {} -do_test 1.11 { S delete } {} -do_test 1.12 { - sqlite3session S db main - S attach t1 - execsql { INSERT INTO t1 VALUES('mno', 'pqr') } - execsql { UPDATE t1 SET x = 111 WHERE rowid = 1 } - execsql { DELETE FROM t1 WHERE rowid = 2 } -} {} -do_test 1.13 { - S changeset - S delete -} {} +do_test $tn.1.11 { S delete } {} +if {$tn==1} { + do_test $tn.1.12 { + sqlite3session S db main + S attach t1 + execsql { INSERT INTO t1 VALUES('mno', 'pqr') } + execsql { UPDATE t1 SET x = 111 WHERE rowid = 1 } + execsql { DELETE FROM t1 WHERE rowid = 2 } + } {} + do_test $tn.1.13 { + S changeset + S delete + } {} +} #------------------------------------------------------------------------- # Simple changeset tests. Also test the sqlite3changeset_invert() # function. # -do_test 2.1.1 { +do_test $tn.2.1.1 { execsql { DELETE FROM t1 } sqlite3session S db main S attach t1 @@ -67,36 +82,36 @@ do_test 2.1.1 { execsql { INSERT INTO t1 VALUES(2, 'Ayutthaya') } execsql { INSERT INTO t1 VALUES(3, 'Thonburi') } } {} -do_changeset_test 2.1.2 S { +do_changeset_test $tn.2.1.2 S { {INSERT t1 0 X. {} {i 1 t Sukhothai}} {INSERT t1 0 X. {} {i 2 t Ayutthaya}} {INSERT t1 0 X. {} {i 3 t Thonburi}} } -do_changeset_invert_test 2.1.3 S { +do_changeset_invert_test $tn.2.1.3 S { {DELETE t1 0 X. {i 1 t Sukhothai} {}} {DELETE t1 0 X. {i 2 t Ayutthaya} {}} {DELETE t1 0 X. {i 3 t Thonburi} {}} } -do_test 2.1.4 { S delete } {} +do_test $tn.2.1.4 { S delete } {} -do_test 2.2.1 { +do_test $tn.2.2.1 { sqlite3session S db main S attach t1 execsql { DELETE FROM t1 WHERE 1 } } {} -do_changeset_test 2.2.2 S { +do_changeset_test $tn.2.2.2 S { {DELETE t1 0 X. {i 1 t Sukhothai} {}} {DELETE t1 0 X. {i 2 t Ayutthaya} {}} {DELETE t1 0 X. {i 3 t Thonburi} {}} } -do_changeset_invert_test 2.2.3 S { +do_changeset_invert_test $tn.2.2.3 S { {INSERT t1 0 X. {} {i 1 t Sukhothai}} {INSERT t1 0 X. {} {i 2 t Ayutthaya}} {INSERT t1 0 X. {} {i 3 t Thonburi}} } -do_test 2.2.4 { S delete } {} +do_test $tn.2.2.4 { S delete } {} -do_test 2.3.1 { +do_test $tn.2.3.1 { execsql { DELETE FROM t1 } sqlite3session S db main execsql { INSERT INTO t1 VALUES(1, 'Sukhothai') } @@ -110,7 +125,7 @@ do_test 2.3.1 { } } {} -do_changeset_test 2.3.2 S { +do_changeset_test $tn.2.3.2 S { {INSERT t1 0 X. {} {i 10 t Sukhothai}} {DELETE t1 0 X. {i 1 t Sukhothai} {}} {UPDATE t1 0 X. {i 2 t Ayutthaya} {{} {} t Surin}} @@ -118,24 +133,24 @@ do_changeset_test 2.3.2 S { {INSERT t1 0 X. {} {i 20 t Thapae}} } -do_changeset_invert_test 2.3.3 S { +do_changeset_invert_test $tn.2.3.3 S { {DELETE t1 0 X. {i 10 t Sukhothai} {}} {INSERT t1 0 X. {} {i 1 t Sukhothai}} {UPDATE t1 0 X. {i 2 t Surin} {{} {} t Ayutthaya}} {INSERT t1 0 X. {} {i 3 t Thonburi}} {DELETE t1 0 X. {i 20 t Thapae} {}} } -do_test 2.3.4 { S delete } {} +do_test $tn.2.3.4 { S delete } {} -do_test 2.4.1 { +do_test $tn.2.4.1 { sqlite3session S db main S attach t1 execsql { INSERT INTO t1 VALUES(100, 'Bangkok') } execsql { DELETE FROM t1 WHERE x = 100 } } {} -do_changeset_test 2.4.2 S {} -do_changeset_invert_test 2.4.3 S {} -do_test 2.4.4 { S delete } {} +do_changeset_test $tn.2.4.2 S {} +do_changeset_invert_test $tn.2.4.3 S {} +do_test $tn.2.4.4 { S delete } {} #------------------------------------------------------------------------- # Test the application of simple changesets. These tests also test that @@ -189,16 +204,16 @@ proc do_db2_test {testname sql {result {}}} { # Test INSERT changesets. # -do_test 3.1.0 { - execsql { CREATE TABLE t1(a PRIMARY KEY, b NOT NULL) } db2 +do_test $tn.3.1.0 { + execsql { CREATE TABLE t1(a PRIMARY KEY, b NOT NULL) %WR% } db2 execsql { - CREATE TABLE t1(a PRIMARY KEY, b); + CREATE TABLE t1(a PRIMARY KEY, b) %WR%; INSERT INTO t1 VALUES(1, 'one'); INSERT INTO t1 VALUES(2, 'two'); } db } {} -do_db2_test 3.1.1 "INSERT INTO t1 VALUES(6, 'VI')" -do_conflict_test 3.1.2 -tables t1 -sql { +do_db2_test $tn.3.1.1 "INSERT INTO t1 VALUES(6, 'VI')" +do_conflict_test $tn.3.1.2 -tables t1 -sql { INSERT INTO t1 VALUES(3, 'three'); INSERT INTO t1 VALUES(4, 'four'); INSERT INTO t1 VALUES(5, 'five'); @@ -210,34 +225,34 @@ do_conflict_test 3.1.2 -tables t1 -sql { {INSERT t1 CONSTRAINT {i 8 n {}}} } -do_db2_test 3.1.3 "SELECT * FROM t1" { - 6 VI 3 three 4 four 5 five 7 seven +do_db2_test $tn.3.1.3 "SELECT * FROM t1 ORDER BY a" { + 3 three 4 four 5 five 6 VI 7 seven } -do_execsql_test 3.1.4 "SELECT * FROM t1" { +do_execsql_test $tn.3.1.4 "SELECT * FROM t1" { 1 one 2 two 3 three 4 four 5 five 6 six 7 seven 8 {} } # Test DELETE changesets. # -do_execsql_test 3.2.1 { +do_execsql_test $tn.3.2.1 { PRAGMA foreign_keys = on; - CREATE TABLE t2(a PRIMARY KEY, b); + CREATE TABLE t2(a PRIMARY KEY, b)%WR%; CREATE TABLE t3(c, d REFERENCES t2); INSERT INTO t2 VALUES(1, 'one'); INSERT INTO t2 VALUES(2, 'two'); INSERT INTO t2 VALUES(3, 'three'); INSERT INTO t2 VALUES(4, 'four'); } -do_db2_test 3.2.2 { +do_db2_test $tn.3.2.2 { PRAGMA foreign_keys = on; - CREATE TABLE t2(a PRIMARY KEY, b); + CREATE TABLE t2(a PRIMARY KEY, b)%WR%; CREATE TABLE t3(c, d REFERENCES t2); INSERT INTO t2 VALUES(1, 'one'); INSERT INTO t2 VALUES(2, 'two'); INSERT INTO t2 VALUES(4, 'five'); INSERT INTO t3 VALUES('i', 1); } -do_conflict_test 3.2.3 -tables t2 -sql { +do_conflict_test $tn.3.2.3 -tables t2 -sql { DELETE FROM t2 WHERE a = 1; DELETE FROM t2 WHERE a = 2; DELETE FROM t2 WHERE a = 3; @@ -247,26 +262,26 @@ do_conflict_test 3.2.3 -tables t2 -sql { {DELETE t2 DATA {i 4 t four} {i 4 t five}} {FOREIGN_KEY 1} } -do_execsql_test 3.2.4 "SELECT * FROM t2" {} -do_db2_test 3.2.5 "SELECT * FROM t2" {4 five} +do_execsql_test $tn.3.2.4 "SELECT * FROM t2" {} +do_db2_test $tn.3.2.5 "SELECT * FROM t2" {4 five} # Test UPDATE changesets. # -do_execsql_test 3.3.1 { - CREATE TABLE t4(a, b, c, PRIMARY KEY(b, c)); +do_execsql_test $tn.3.3.1 { + CREATE TABLE t4(a, b, c, PRIMARY KEY(b, c))%WR%; INSERT INTO t4 VALUES(1, 2, 3); INSERT INTO t4 VALUES(4, 5, 6); INSERT INTO t4 VALUES(7, 8, 9); INSERT INTO t4 VALUES(10, 11, 12); } -do_db2_test 3.3.2 { - CREATE TABLE t4(a NOT NULL, b, c, PRIMARY KEY(b, c)); +do_db2_test $tn.3.3.2 { + CREATE TABLE t4(a NOT NULL, b, c, PRIMARY KEY(b, c))%WR%; INSERT INTO t4 VALUES(0, 2, 3); INSERT INTO t4 VALUES(4, 5, 7); INSERT INTO t4 VALUES(7, 8, 9); INSERT INTO t4 VALUES(10, 11, 12); } -do_conflict_test 3.3.3 -tables t4 -sql { +do_conflict_test $tn.3.3.3 -tables t4 -sql { UPDATE t4 SET a = -1 WHERE b = 2; UPDATE t4 SET a = -1 WHERE b = 5; UPDATE t4 SET a = NULL WHERE c = 9; @@ -276,8 +291,8 @@ do_conflict_test 3.3.3 -tables t4 -sql { {UPDATE t4 NOTFOUND {i 4 i 5 i 6} {i -1 {} {} {} {}}} {UPDATE t4 CONSTRAINT {i 7 i 8 i 9} {n {} {} {} {} {}}} } -do_db2_test 3.3.4 { SELECT * FROM t4 } {0 2 3 4 5 7 7 8 9 x 11 12} -do_execsql_test 3.3.5 { SELECT * FROM t4 } {-1 2 3 -1 5 6 {} 8 9 x 11 12} +do_db2_test $tn.3.3.4 { SELECT * FROM t4 } {0 2 3 4 5 7 7 8 9 x 11 12} +do_execsql_test $tn.3.3.5 { SELECT * FROM t4 } {-1 2 3 -1 5 6 {} 8 9 x 11 12} #------------------------------------------------------------------------- # This next block of tests verifies that values returned by the conflict @@ -297,16 +312,16 @@ proc xConflict {args} { return $::conflict_return } -foreach {tn conflict_return after} { +foreach {tn2 conflict_return after} { 1 OMIT {1 2 value1 4 5 7 10 x x} 2 REPLACE {1 2 value1 4 5 value2 10 8 9} } { test_reset - do_test 4.$tn.1 { + do_test $tn.4.$tn2.1 { foreach db {db db2} { execsql { - CREATE TABLE t1(a, b, c, PRIMARY KEY(a)); + CREATE TABLE t1(a, b, c, PRIMARY KEY(a))%WR%; INSERT INTO t1 VALUES(1, 2, 3); INSERT INTO t1 VALUES(4, 5, 6); INSERT INTO t1 VALUES(7, 8, 9); @@ -318,7 +333,7 @@ foreach {tn conflict_return after} { } db2 } {} - do_conflict_test 4.$tn.2 -tables t1 -sql { + do_conflict_test $tn.4.$tn2.2 -tables t1 -sql { UPDATE t1 SET c = 'value1' WHERE a = 1; -- no conflict UPDATE t1 SET c = 'value2' WHERE a = 4; -- DATA conflict UPDATE t1 SET a = 10 WHERE a = 7; -- CONFLICT conflict @@ -327,19 +342,19 @@ foreach {tn conflict_return after} { {UPDATE t1 DATA {i 4 {} {} i 6} {{} {} {} {} t value2} {i 4 i 5 i 7}} } - do_db2_test 4.$tn.3 "SELECT * FROM t1 ORDER BY a" $after + do_db2_test $tn.4.$tn2.3 "SELECT * FROM t1 ORDER BY a" $after } -foreach {tn conflict_return} { +foreach {tn2 conflict_return} { 1 OMIT 2 REPLACE } { test_reset - do_test 5.$tn.1 { + do_test $tn.5.$tn2.1 { # Create an identical schema in both databases. set schema { - CREATE TABLE "'foolish name'"(x, y, z, PRIMARY KEY(x, y)); + CREATE TABLE "'foolish name'"(x, y, z, PRIMARY KEY(x, y))%WR%; } execsql $schema db execsql $schema db2 @@ -354,7 +369,7 @@ foreach {tn conflict_return} { } {} - do_conflict_test 5.$tn.2 -tables {{'foolish name'}} -sql { + do_conflict_test $tn.5.$tn2.2 -tables {{'foolish name'}} -sql { INSERT INTO "'foolish name'" VALUES('one', 'two', 2); } -conflicts { {INSERT {'foolish name'} CONFLICT {t one t two i 2} {t one t two t i}} @@ -362,14 +377,14 @@ foreach {tn conflict_return} { set res(REPLACE) {one one ii one two 2 two two ii} set res(OMIT) {one one ii one two i two two ii} - do_db2_test 5.$tn.3 { + do_db2_test $tn.5.$tn2.3 { SELECT * FROM "'foolish name'" ORDER BY x, y } $res($conflict_return) - do_test 5.$tn.1 { + do_test $tn.5.$tn2.1 { set schema { - CREATE TABLE d1("z""z" PRIMARY KEY, y); + CREATE TABLE d1("z""z" PRIMARY KEY, y)%WR%; INSERT INTO d1 VALUES(1, 'one'); INSERT INTO d1 VALUES(2, 'two'); } @@ -382,7 +397,7 @@ foreach {tn conflict_return} { } {} - do_conflict_test 5.$tn.2 -tables d1 -sql { + do_conflict_test $tn.5.$tn2.2 -tables d1 -sql { DELETE FROM d1 WHERE "z""z" = 2; } -conflicts { {DELETE d1 DATA {i 2 t two} {i 2 t TWO}} @@ -390,7 +405,7 @@ foreach {tn conflict_return} { set res(REPLACE) {1 one} set res(OMIT) {1 one 2 TWO} - do_db2_test 5.$tn.3 "SELECT * FROM d1" $res($conflict_return) + do_db2_test $tn.5.$tn2.3 "SELECT * FROM d1" $res($conflict_return) } #------------------------------------------------------------------------- @@ -398,10 +413,10 @@ foreach {tn conflict_return} { # test_reset set schema { - CREATE TABLE t1(a COLLATE nocase PRIMARY KEY, b); - CREATE TABLE t2(a, b PRIMARY KEY); + CREATE TABLE t1(a COLLATE nocase PRIMARY KEY, b)%WR%; + CREATE TABLE t2(a, b PRIMARY KEY)%WR%; } -do_test 6.0 { +do_test $tn.6.0 { execsql $schema db execsql $schema db2 execsql { @@ -411,7 +426,7 @@ do_test 6.0 { } {} set conflict_return "" -do_conflict_test 6.1 -tables {t1 t2} -sql { +do_conflict_test $tn.6.1 -tables {t1 t2} -sql { INSERT INTO t1 VALUES('1', '2'); INSERT INTO t1 VALUES('A', 'B'); INSERT INTO t2 VALUES('A', 'B'); @@ -419,8 +434,8 @@ do_conflict_test 6.1 -tables {t1 t2} -sql { {INSERT t1 CONFLICT {t A t B} {t a t b}} } -do_db2_test 6.2 "SELECT * FROM t1" {a b 1 2} -do_db2_test 6.3 "SELECT * FROM t2" {a b A B} +do_db2_test $tn.6.2 "SELECT * FROM t1 ORDER BY a" {1 2 a b} +do_db2_test $tn.6.3 "SELECT * FROM t2 ORDER BY a" {A B a b} #------------------------------------------------------------------------- # Test that session objects are not confused by changes to table in @@ -429,10 +444,10 @@ do_db2_test 6.3 "SELECT * FROM t2" {a b A B} catch { db2 close } drop_all_tables forcedelete test.db2 -do_iterator_test 7.1 * { +do_iterator_test $tn.7.1 * { ATTACH 'test.db2' AS aux; - CREATE TABLE main.t1(x PRIMARY KEY, y); - CREATE TABLE aux.t1(x PRIMARY KEY, y); + CREATE TABLE main.t1(x PRIMARY KEY, y)%WR%; + CREATE TABLE aux.t1(x PRIMARY KEY, y)%WR%; INSERT INTO main.t1 VALUES('one', 1); INSERT INTO main.t1 VALUES('two', 2); @@ -446,10 +461,10 @@ do_iterator_test 7.1 * { #------------------------------------------------------------------------- # Test the sqlite3session_isempty() function. # -do_test 8.1 { +do_test $tn.8.1 { execsql { - CREATE TABLE t5(x PRIMARY KEY, y); - CREATE TABLE t6(x PRIMARY KEY, y); + CREATE TABLE t5(x PRIMARY KEY, y)%WR%; + CREATE TABLE t6(x PRIMARY KEY, y)%WR%; INSERT INTO t5 VALUES('a', 'b'); INSERT INTO t6 VALUES('a', 'b'); } @@ -458,20 +473,20 @@ do_test 8.1 { S isempty } {1} -do_test 8.2 { +do_test $tn.8.2 { execsql { DELETE FROM t5 } S isempty } {0} -do_test 8.3 { +do_test $tn.8.3 { S delete sqlite3session S db main S attach t5 execsql { DELETE FROM t5 } S isempty } {1} -do_test 8.4 { S delete } {} +do_test $tn.8.4 { S delete } {} -do_test 8.5 { +do_test $tn.8.5 { sqlite3session S db main S attach t5 S attach t6 @@ -479,7 +494,7 @@ do_test 8.5 { S isempty } {0} -do_test 8.6 { +do_test $tn.8.6 { S delete sqlite3session S db main S attach t5 @@ -487,20 +502,20 @@ do_test 8.6 { execsql { INSERT INTO t6 VALUES(1, 2) } S isempty } {0} -do_test 8.7 { S delete } {} +do_test $tn.8.7 { S delete } {} #------------------------------------------------------------------------- # -do_execsql_test 9.1 { - CREATE TABLE t7(a, b, c, d, e PRIMARY KEY, f, g); +do_execsql_test $tn.9.1 { + CREATE TABLE t7(a, b, c, d, e PRIMARY KEY, f, g)%WR%; INSERT INTO t7 VALUES(1, 1, 1, 1, 1, 1, 1); } -do_test 9.2 { +do_test $tn.9.2 { sqlite3session S db main S attach * execsql { UPDATE t7 SET b=2, d=2 } } {} -do_changeset_test 9.2 S {{UPDATE t7 0 ....X.. {{} {} i 1 {} {} i 1 i 1 {} {} {} {}} {{} {} i 2 {} {} i 2 {} {} {} {} {} {}}}} +do_changeset_test $tn.9.2 S {{UPDATE t7 0 ....X.. {{} {} i 1 {} {} i 1 i 1 {} {} {} {}} {{} {} i 2 {} {} i 2 {} {} {} {} {} {}}}} S delete catch { db2 close } @@ -509,9 +524,9 @@ catch { db2 close } # reset_db set tblname [string repeat tblname123 100] -do_test 10.1.1 { +do_test $tn.10.1.1 { execsql " - CREATE TABLE $tblname (a PRIMARY KEY, b); + CREATE TABLE $tblname (a PRIMARY KEY, b)%WR%; INSERT INTO $tblname VALUES('xyz', 'def'); " sqlite3session S db main @@ -522,18 +537,18 @@ do_test 10.1.1 { " } {} breakpoint -do_changeset_test 10.1.2 S " +do_changeset_test $tn.10.1.2 S " {INSERT $tblname 0 X. {} {t uvw t abc}} {DELETE $tblname 0 X. {t xyz t def} {}} " -do_test 10.1.4 { S delete } {} +do_test $tn.10.1.4 { S delete } {} #--------------------------------------------------------------- reset_db -do_execsql_test 11.1 { +do_execsql_test $tn.11.1 { CREATE TABLE t1(a, b); } -do_test 11.2 { +do_test $tn.11.2 { sqlite3session S db main S attach t1 execsql { @@ -550,9 +565,9 @@ S delete # reset_db set tblname [string repeat tblname123 100] -do_test 10.1.1 { +do_test $tn.10.1.1 { execsql " - CREATE TABLE $tblname (a PRIMARY KEY, b); + CREATE TABLE $tblname (a PRIMARY KEY, b)%WR%; INSERT INTO $tblname VALUES('xyz', 'def'); " sqlite3session S db main @@ -563,35 +578,35 @@ do_test 10.1.1 { " } {} breakpoint -do_changeset_test 10.1.2 S " +do_changeset_test $tn.10.1.2 S " {INSERT $tblname 0 X. {} {t uvw t abc}} {DELETE $tblname 0 X. {t xyz t def} {}} " -do_test 10.1.4 { S delete } {} +do_test $tn.10.1.4 { S delete } {} #------------------------------------------------------------------------- # Test the effect of updating a column from 0.0 to 0.0. # reset_db -do_execsql_test 11.1 { - CREATE TABLE t1(a INTEGER PRIMARY KEY, b REAL); +do_execsql_test $tn.11.1 { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b REAL)%WR%; INSERT INTO t1 VALUES(1, 0.0); } -do_iterator_test 11.2 * { +do_iterator_test $tn.11.2 * { UPDATE t1 SET b = 0.0; } { } reset_db -do_execsql_test 12.1 { - CREATE TABLE t1(r INTEGER PRIMARY KEY, a, b); +do_execsql_test $tn.12.1 { + CREATE TABLE t1(r INTEGER PRIMARY KEY, a, b)%WR%; CREATE INDEX i1 ON t1(a); INSERT INTO t1 VALUES(1, 1, 1); INSERT INTO t1 VALUES(2, 1, 2); INSERT INTO t1 VALUES(3, 1, 3); } -do_iterator_test 12.2 * { +do_iterator_test $tn.12.2 * { UPDATE t1 SET b='one' WHERE a=1; } { {UPDATE t1 0 X.. {i 1 {} {} i 1} {{} {} {} {} t one}} @@ -599,6 +614,8 @@ do_iterator_test 12.2 * { {UPDATE t1 0 X.. {i 3 {} {} i 3} {{} {} {} {} t one}} } +}] +} finish_test diff --git a/ext/session/sessionwor.test b/ext/session/sessionwor.test new file mode 100644 index 0000000000..d906a92b62 --- /dev/null +++ b/ext/session/sessionwor.test @@ -0,0 +1,57 @@ +# 2017 Jan 31 +# +# 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. +# +#*********************************************************************** +# +# The focus of this file is testing the session module. Specifically, +# testing support for WITHOUT ROWID tables. +# + +if {![info exists testdir]} { + set testdir [file join [file dirname [info script]] .. .. test] +} +source [file join [file dirname [info script]] session_common.tcl] +source $testdir/tester.tcl +ifcapable !session {finish_test; return} + +set testprefix sessionwor + +proc test_reset {} { + catch { db close } + catch { db2 close } + forcedelete test.db test.db2 + sqlite3 db test.db + sqlite3 db2 test.db2 +} + + +do_execsql_test 1.0 { + CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT ROWID; +} + +do_iterator_test 1.1 t1 { + INSERT INTO t1 VALUES('one', 'two'); +} { + {INSERT t1 0 X. {} {t one t two}} +} + +do_iterator_test 1.2 t1 { + UPDATE t1 SET b='three' +} { + {UPDATE t1 0 X. {t one t two} {{} {} t three}} +} + +do_iterator_test 1.3 t1 { + DELETE FROM t1; +} { + {DELETE t1 0 X. {t one t three} {}} +} + +finish_test + diff --git a/manifest b/manifest index 229623bcc5..c93ba97d64 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sbuilding\swith\sSQLITE_OMIT_FOREIGN_KEY\sdefined. -D 2017-01-30T11:38:19.468 +C Experimental\schange\sto\sinvoke\sthe\spreupdate\shook\swhen\sWITHOUT\sROWID\stables\sare\nwritten. +D 2017-01-30T19:44:53.682 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -288,7 +288,7 @@ F ext/rtree/sqlite3rtree.h 9c5777af3d2921c7b4ae4954e8e5697502289d28 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F ext/session/changeset.c 4ccbaa4531944c24584bf6a61ba3a39c62b6267a -F ext/session/session1.test 482e9b861169d0b7e283e1563a28c0fa32779fa5 +F ext/session/session1.test c8a50e0e8581dc1a00e832aa59bb61f180404d44 F ext/session/session2.test 284de45abae4cc1082bc52012ee81521d5ac58e0 F ext/session/session3.test a7a9ce59b8d1e49e2cc23d81421ac485be0eea01 F ext/session/session4.test 457b02bdc349eb01151e54de014df77abd3c08c8 @@ -306,6 +306,7 @@ F ext/session/sessionG.test 01ef705096a9d3984eebdcca79807a211dee1b60 F ext/session/session_common.tcl 9b696a341cf1d3744823715ed92bb19749b6c3d4 F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7 F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0 +F ext/session/sessionwor.test 2f3744236dc8b170a695b7d8ddc8c743c7e79fdc F ext/session/sqlite3session.c c61a43396368ec00dc127f7bc647e9bd6a4ee5fb F ext/session/sqlite3session.h 9345166bd8f80562145586cf817f707de5ecada2 F ext/session/test_session.c eb0bd6c1ea791c1d66ee4ef94c16500dad936386 @@ -353,7 +354,7 @@ F src/hash.c 63d0ee752a3b92d4695b2b1f5259c4621b2cfebd F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 -F src/insert.c 8183e1778ec42d26732bec8c98aeffa8af13038f +F src/insert.c 444354c23d4d140a57d6eb46f34e376a7f8f62e8 F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e F src/loadext.c a68d8d1d14cf7488bb29dc5311cb1ce9a4404258 F src/main.c e207b81542d13b9f13d61e78ca441f9781f055b0 @@ -458,11 +459,11 @@ F src/update.c 456d4a4656f8a03c2abc88a51b19172197400e58 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c a88b0466fddf445ce752226d4698ca3faada620a F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16 -F src/vdbe.c c27cc34be1d9169c1c191238025781684bdcd4ec +F src/vdbe.c 57f41c8c74ceb757abbd4cda72c44fc40d57f425 F src/vdbe.h 59998ffd71d7caa8886bc78dafaf8caeccd4c13c -F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e -F src/vdbeapi.c 7a65f10684982daecfce50f557f2632b7f20b198 -F src/vdbeaux.c 6847b02aa2db536ed15d90f1fdc2923afef93c5b +F src/vdbeInt.h 4e4b15b2e1330e1636e4e01974eab2b0b985092f +F src/vdbeapi.c 3e4a8893feeb78620f4aac4ac5b85d92255b97e1 +F src/vdbeaux.c b9a36e530e6525ca9d9a685bc7b1d01fa77b5cf8 F src/vdbeblob.c 2b3d1ad915dbe5dc92c48759dc18fa8c697e78e5 F src/vdbemem.c 3b5a9a5b375458d3e12a50ae1aaa41eeec2175fd F src/vdbesort.c eda25cb2d1727efca6f7862fea32b8aa33c0face @@ -834,6 +835,7 @@ F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 F test/hexlit.test 4a6a5f46e3c65c4bf1fa06f5dd5a9507a5627751 F test/hidden.test 23c1393a79e846d68fd902d72c85d5e5dcf98711 F test/hook.test dbc0b87756e1e20e7497b56889c9e9cd2f8cc2b5 +F test/hook2.test b9ff3b8c6519fb67f33192f1afe86e7782ee4ac8 F test/icu.test 73956798bace8982909c00476b216714a6d0559a F test/ieee754.test 806fc0ce7f305f57e3331eaceeddcfec9339e607 F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8 @@ -1548,7 +1550,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4fe879d4b5da6ae0688a7a99004683a234966597 -R c0ed5c24fdff676195cd77401e89700b +P e93d2c49a44af994ff10cc9cc7eafacd5a4f73ab +R f7cc20c31f0badea537c676e1225b282 +T *branch * preupdate-without-rowid +T *sym-preupdate-without-rowid * +T -sym-trunk * U dan -Z 6d1b138d17ccacee0c622f2ed331ca89 +Z 812bce2fe1496eddb1cec5705157fb44 diff --git a/manifest.uuid b/manifest.uuid index eec33fc0a4..67552c1672 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e93d2c49a44af994ff10cc9cc7eafacd5a4f73ab \ No newline at end of file +856f8604c59c8fdd9bfb7d86fc0e212f091ab49a \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 5370ef77ed..894bfc2cc1 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1730,16 +1730,23 @@ void sqlite3CompleteInsertion( sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2); VdbeCoverage(v); } - sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iIdxCur+i, aRegIdx[i], - aRegIdx[i]+1, - pIdx->uniqNotNull ? pIdx->nKeyCol: pIdx->nColumn); - pik_flags = 0; - if( useSeekResult ) pik_flags = OPFLAG_USESEEKRESULT; + pik_flags = (useSeekResult ? OPFLAG_USESEEKRESULT : 0); if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){ assert( pParse->nested==0 ); pik_flags |= OPFLAG_NCHANGE; pik_flags |= (update_flags & OPFLAG_SAVEPOSITION); +#ifdef SQLITE_ENABLE_PREUPDATE_HOOK + if( update_flags==0 ){ + sqlite3VdbeAddOp4(v, OP_InsertInt, + iIdxCur+i, aRegIdx[i], 0, (char*)pTab, P4_TABLE + ); + sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP); + } +#endif } + sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iIdxCur+i, aRegIdx[i], + aRegIdx[i]+1, + pIdx->uniqNotNull ? pIdx->nKeyCol: pIdx->nColumn); sqlite3VdbeChangeP5(v, pik_flags); } if( !HasRowid(pTab) ) return; diff --git a/src/vdbe.c b/src/vdbe.c index ded4462398..5462e541c5 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4384,7 +4384,7 @@ case OP_InsertInt: { assert( pC!=0 ); assert( pC->eCurType==CURTYPE_BTREE ); assert( pC->uc.pCursor!=0 ); - assert( pC->isTable ); + assert( (pOp->p5 & OPFLAG_ISNOOP) || pC->isTable ); assert( pOp->p4type==P4_TABLE || pOp->p4type>=P4_STATIC ); REGISTER_TRACE(pOp->p2, pData); @@ -4400,11 +4400,10 @@ case OP_InsertInt: { } if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){ - assert( pC->isTable ); assert( pC->iDb>=0 ); zDb = db->aDb[pC->iDb].zDbSName; pTab = pOp->p4.pTab; - assert( HasRowid(pTab) ); + assert( (pOp->p5 & OPFLAG_ISNOOP) || HasRowid(pTab) ); op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT); }else{ pTab = 0; /* Not needed. Silence a comiler warning. */ @@ -4419,6 +4418,7 @@ case OP_InsertInt: { ){ sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey, pOp->p2); } + if( pOp->p5 & OPFLAG_ISNOOP ) break; #endif if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++; @@ -4531,8 +4531,11 @@ case OP_Delete: { #ifdef SQLITE_ENABLE_PREUPDATE_HOOK /* Invoke the pre-update-hook if required. */ - if( db->xPreUpdateCallback && pOp->p4.pTab && HasRowid(pTab) ){ - assert( !(opflags & OPFLAG_ISUPDATE) || (aMem[pOp->p3].flags & MEM_Int) ); + if( db->xPreUpdateCallback && pOp->p4.pTab ){ + assert( !(opflags & OPFLAG_ISUPDATE) + || HasRowid(pTab)==0 + || (aMem[pOp->p3].flags & MEM_Int) + ); sqlite3VdbePreUpdateHook(p, pC, (opflags & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_DELETE, zDb, pTab, pC->movetoTarget, diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 3e6bb06889..989cdfd346 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -434,6 +434,7 @@ struct PreUpdate { i64 iKey2; /* Second key value passed to hook */ Mem *aNew; /* Array of new.* values */ Table *pTab; /* Schema object being upated */ + Index *pPk; /* PK index if pTab is WITHOUT ROWID */ }; /* diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 7ecdac87c3..6eb97f1d1d 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -1669,6 +1669,9 @@ int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ rc = SQLITE_MISUSE_BKPT; goto preupdate_old_out; } + if( p->pPk ){ + iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx); + } if( iIdx>=p->pCsr->nField || iIdx<0 ){ rc = SQLITE_RANGE; goto preupdate_old_out; @@ -1754,6 +1757,9 @@ int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ rc = SQLITE_MISUSE_BKPT; goto preupdate_new_out; } + if( p->pPk && p->op!=SQLITE_UPDATE ){ + iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx); + } if( iIdx>=p->pCsr->nField || iIdx<0 ){ rc = SQLITE_RANGE; goto preupdate_new_out; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 23c31d4029..68f6a5acc8 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -4620,10 +4620,15 @@ void sqlite3VdbePreUpdateHook( assert( db->pPreUpdate==0 ); memset(&preupdate, 0, sizeof(PreUpdate)); - if( op==SQLITE_UPDATE ){ - iKey2 = v->aMem[iReg].u.i; + if( HasRowid(pTab)==0 ){ + iKey1 = iKey2 = 0; + preupdate.pPk = sqlite3PrimaryKeyIndex(pTab); }else{ - iKey2 = iKey1; + if( op==SQLITE_UPDATE ){ + iKey2 = v->aMem[iReg].u.i; + }else{ + iKey2 = iKey1; + } } assert( pCsr->nField==pTab->nCol diff --git a/test/hook2.test b/test/hook2.test new file mode 100644 index 0000000000..9ae1103a7d --- /dev/null +++ b/test/hook2.test @@ -0,0 +1,218 @@ +# 2017 Jan 30 +# +# 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. +# +#*********************************************************************** +# The tests in this file focus on the pre-update hook. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set ::testprefix hook2 + +ifcapable !preupdate { + finish_test + return +} + +#------------------------------------------------------------------------- +proc do_preupdate_test {tn sql x} { + set X [list] + foreach elem $x {lappend X $elem} + uplevel do_test $tn [list " + set ::preupdate \[list\] + execsql { $sql } + set ::preupdate + "] [list $X] +} + +proc preupdate_hook {args} { + set type [lindex $args 0] + eval lappend ::preupdate $args + if {$type != "INSERT"} { + for {set i 0} {$i < [db preupdate count]} {incr i} { + lappend ::preupdate [db preupdate old $i] + } + } + if {$type != "DELETE"} { + for {set i 0} {$i < [db preupdate count]} {incr i} { + set rc [catch { db preupdate new $i } v] + lappend ::preupdate $v + } + } +} + +#------------------------------------------------------------------------- +# Simple tests - INSERT, UPDATE and DELETE on a WITHOUT ROWID table. +# +db preupdate hook preupdate_hook +do_execsql_test 1.0 { + CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT ROWID; +} +do_preupdate_test 1.1 { + INSERT INTO t1 VALUES('one', 1); +} { + INSERT main t1 0 0 one 1 +} +do_preupdate_test 1.2 { + UPDATE t1 SET b=2 WHERE a='one'; +} { + UPDATE main t1 0 0 one 1 one 2 +} +do_preupdate_test 1.3 { + DELETE FROM t1 WHERE a='one'; +} { + DELETE main t1 0 0 one 2 +} + +#------------------------------------------------------------------------- +# Some more complex tests for the pre-update callback on WITHOUT ROWID +# tables. +# +# 2.1.1 - INSERT statement. +# 2.1.2 - INSERT INTO ... SELECT statement. +# 2.1.3 - REPLACE INTO ... (PK conflict) +# 2.1.4 - REPLACE INTO ... (other index conflicts) +# 2.1.5 - REPLACE INTO ... (both PK and other index conflicts) +# +# 2.2.1 - DELETE statement. +# 2.2.2 - DELETE statement that uses the truncate optimization. +# +# 2.3.1 - UPDATE statement. +# 2.3.2 - UPDATE statement that modifies the PK. +# 2.3.3 - UPDATE OR REPLACE ... (PK conflict). +# 2.3.4 - UPDATE OR REPLACE ... (other index conflicts) +# 2.3.4 - UPDATE OR REPLACE ... (both PK and other index conflicts) +# +do_execsql_test 2.0 { + CREATE TABLE t2(a DEFAULT 4, b, c, PRIMARY KEY(b, c)) WITHOUT ROWID; + CREATE UNIQUE INDEX t2a ON t2(a); +} + +do_preupdate_test 2.1.1 { + INSERT INTO t2(b, c) VALUES(1, 1); +} { + INSERT main t2 0 0 4 1 1 +} + +do_execsql_test 2.1.2.0 { + CREATE TABLE d1(a DEFAULT 4, b, c, PRIMARY KEY(b, c)) WITHOUT ROWID; + CREATE UNIQUE INDEX d1a ON d1(a); + INSERT INTO d1 VALUES(1, 2, 3); + INSERT INTO d1 VALUES(11, 12, 13); +} +do_preupdate_test 2.1.2.1 { + INSERT INTO t2 SELECT * FROM d1; +} { + INSERT main t2 0 0 1 2 3 + INSERT main t2 0 0 11 12 13 +} +do_preupdate_test 2.1.2.2 { + INSERT INTO t2 SELECT a+20, b+20, c+20 FROM d1; +} { + INSERT main t2 0 0 21 22 23 + INSERT main t2 0 0 31 32 33 +} +do_execsql_test 2.1.2.3 { + SELECT * FROM t2 ORDER BY b, c; +} { + 4 1 1 + 1 2 3 + 11 12 13 + 21 22 23 + 31 32 33 +} +do_preupdate_test 2.1.3 { + REPLACE INTO t2 VALUES(45, 22, 23); +} { + DELETE main t2 0 0 21 22 23 + INSERT main t2 0 0 45 22 23 +} +do_preupdate_test 2.1.4 { + REPLACE INTO t2 VALUES(11, 100, 100); +} { + DELETE main t2 0 0 11 12 13 + INSERT main t2 0 0 11 100 100 +} +do_preupdate_test 2.1.5 { + REPLACE INTO t2(c, b) VALUES(33, 32) +} { + DELETE main t2 0 0 4 1 1 + DELETE main t2 0 0 31 32 33 + INSERT main t2 0 0 4 32 33 +} + +do_execsql_test 2.2.0 { + SELECT * FROM t2 ORDER BY b,c; +} { + 1 2 3 + 45 22 23 + 4 32 33 + 11 100 100 +} +do_preupdate_test 2.2.1 { + DELETE FROM t2 WHERE b=22; +} { + DELETE main t2 0 0 45 22 23 +} +do_preupdate_test 2.2.2 { + DELETE FROM t2; +} { + DELETE main t2 0 0 1 2 3 + DELETE main t2 0 0 4 32 33 + DELETE main t2 0 0 11 100 100 +} + +do_execsql_test 2.3.0 { + CREATE TABLE t3(x, y PRIMARY KEY, z UNIQUE) WITHOUT ROWID; + INSERT INTO t3 VALUES('a', 'b', 'c'); + INSERT INTO t3 VALUES('d', 'e', 'f'); + + INSERT INTO t3 VALUES(1, 1, 1); + INSERT INTO t3 VALUES(2, 2, 2); + INSERT INTO t3 VALUES(3, 3, 3); +} + +do_preupdate_test 2.3.1 { + UPDATE t3 SET x=4 WHERE y IN ('b', 'e', 'x'); +} { + UPDATE main t3 0 0 a b c 4 b c + UPDATE main t3 0 0 d e f 4 e f +} + +do_preupdate_test 2.3.2 { + UPDATE t3 SET y=y||y WHERE z IN('c', 'f'); +} { + UPDATE main t3 0 0 4 b c 4 bb c + UPDATE main t3 0 0 4 e f 4 ee f +} + +do_preupdate_test 2.3.3 { + UPDATE OR REPLACE t3 SET y='bb' WHERE z='f' +} { + DELETE main t3 0 0 4 bb c + UPDATE main t3 0 0 4 ee f 4 bb f +} + +do_preupdate_test 2.3.4 { + UPDATE OR REPLACE t3 SET z=2 WHERE y=1; +} { + DELETE main t3 0 0 2 2 2 + UPDATE main t3 0 0 1 1 1 1 1 2 +} + +do_preupdate_test 2.3.5 { + UPDATE OR REPLACE t3 SET z=2, y='bb' WHERE y=3; +} { + DELETE main t3 0 0 1 1 2 + DELETE main t3 0 0 4 bb f + UPDATE main t3 0 0 3 3 3 3 bb 2 +} + + +finish_test From 18814dfb7eb1811c7e993860a52246bee3743b94 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Jan 2017 03:52:34 +0000 Subject: [PATCH 11/43] Performance optimization in sqlite3ExprAssignVarNumber(). FossilOrigin-Name: 5987ca1ff94ed3c1666f783bb15b16158aa7e1db --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/expr.c | 8 +++++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 229623bcc5..96a31247b7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sbuilding\swith\sSQLITE_OMIT_FOREIGN_KEY\sdefined. -D 2017-01-30T11:38:19.468 +C Performance\soptimization\sin\ssqlite3ExprAssignVarNumber(). +D 2017-01-31T03:52:34.839 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -344,7 +344,7 @@ F src/ctime.c 9f2296a4e5d26ebf0e0d95a0af4628f1ea694e7a F src/date.c dc3f1391d9297f8c748132813aaffcb117090d6e F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 0d9d5549d42e79ce4d82ff1db1e6c81e36d2f67c -F src/expr.c f06f41e5e5daca10fb090e70a2502dcc0dbc992b +F src/expr.c 27ac552489a34fc85202084dda32d0a2a0664bfb F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae F src/func.c c67273e1ec08abbdcc14c189892a3ff6eeece86b @@ -1548,7 +1548,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4fe879d4b5da6ae0688a7a99004683a234966597 -R c0ed5c24fdff676195cd77401e89700b -U dan -Z 6d1b138d17ccacee0c622f2ed331ca89 +P e93d2c49a44af994ff10cc9cc7eafacd5a4f73ab +R e1972f457267c7c1c09dde68002ccdbd +U drh +Z 4723986ca78be7a36581ca020c177062 diff --git a/manifest.uuid b/manifest.uuid index eec33fc0a4..5663814ec3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e93d2c49a44af994ff10cc9cc7eafacd5a4f73ab \ No newline at end of file +5987ca1ff94ed3c1666f783bb15b16158aa7e1db \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 154d078ff7..9bf8936765 100644 --- a/src/expr.c +++ b/src/expr.c @@ -967,7 +967,13 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){ /* Wildcard of the form "?nnn". Convert "nnn" to an integer and ** use it as the variable number */ i64 i; - int bOk = 0==sqlite3Atoi64(&z[1], &i, n-1, SQLITE_UTF8); + int bOk; + if( n==2 ){ /*OPTIMIZATION-IF-TRUE*/ + i = z[1]-'0'; /* The common case of ?N for a single digit N */ + bOk = 1; + }else{ + bOk = 0==sqlite3Atoi64(&z[1], &i, n-1, SQLITE_UTF8); + } x = (ynVar)i; testcase( i==0 ); testcase( i==1 ); From 8e74e7ba4c54ca46412bbfe3689d589a4b0d625a Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Jan 2017 12:41:48 +0000 Subject: [PATCH 12/43] Further minor enhancement and size reduction in sqlite3ExprAssignVarNumber(). FossilOrigin-Name: eacfdcf25796ea29b5e63499c3d7397498305ad9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/expr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 96a31247b7..5c0df4b7d4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\soptimization\sin\ssqlite3ExprAssignVarNumber(). -D 2017-01-31T03:52:34.839 +C Further\sminor\senhancement\sand\ssize\sreduction\sin\s\nsqlite3ExprAssignVarNumber(). +D 2017-01-31T12:41:48.800 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -344,7 +344,7 @@ F src/ctime.c 9f2296a4e5d26ebf0e0d95a0af4628f1ea694e7a F src/date.c dc3f1391d9297f8c748132813aaffcb117090d6e F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 0d9d5549d42e79ce4d82ff1db1e6c81e36d2f67c -F src/expr.c 27ac552489a34fc85202084dda32d0a2a0664bfb +F src/expr.c d7ef6fdb70bc18259d7d36b22aa0bc4845c5c5b9 F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae F src/func.c c67273e1ec08abbdcc14c189892a3ff6eeece86b @@ -1548,7 +1548,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e93d2c49a44af994ff10cc9cc7eafacd5a4f73ab -R e1972f457267c7c1c09dde68002ccdbd +P 5987ca1ff94ed3c1666f783bb15b16158aa7e1db +R 877cd166cfa1886b85d3c173dceec467 U drh -Z 4723986ca78be7a36581ca020c177062 +Z 12e7b02d2001dbb9bba0a7e780630702 diff --git a/manifest.uuid b/manifest.uuid index 5663814ec3..e94ba71f96 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5987ca1ff94ed3c1666f783bb15b16158aa7e1db \ No newline at end of file +eacfdcf25796ea29b5e63499c3d7397498305ad9 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 9bf8936765..18035bd421 100644 --- a/src/expr.c +++ b/src/expr.c @@ -974,7 +974,6 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){ }else{ bOk = 0==sqlite3Atoi64(&z[1], &i, n-1, SQLITE_UTF8); } - x = (ynVar)i; testcase( i==0 ); testcase( i==1 ); testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 ); @@ -984,6 +983,7 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){ db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]); return; } + x = (ynVar)i; if( x>pParse->nVar ){ pParse->nVar = (int)x; doAdd = 1; From 1379521f4a6ef1ee68abb457a56f81292af69cb0 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Jan 2017 15:27:04 +0000 Subject: [PATCH 13/43] Fix a typo in a comment. FossilOrigin-Name: bd22bf9cbe028e9811ca3afaadafd90312cb0fc9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5c0df4b7d4..8e4b6f544a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\sminor\senhancement\sand\ssize\sreduction\sin\s\nsqlite3ExprAssignVarNumber(). -D 2017-01-31T12:41:48.800 +C Fix\sa\stypo\sin\sa\scomment. +D 2017-01-31T15:27:04.928 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -458,7 +458,7 @@ F src/update.c 456d4a4656f8a03c2abc88a51b19172197400e58 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c a88b0466fddf445ce752226d4698ca3faada620a F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16 -F src/vdbe.c c27cc34be1d9169c1c191238025781684bdcd4ec +F src/vdbe.c a5bcdb61862cd995126ec4993121e04fe409c6e0 F src/vdbe.h 59998ffd71d7caa8886bc78dafaf8caeccd4c13c F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e F src/vdbeapi.c 7a65f10684982daecfce50f557f2632b7f20b198 @@ -1548,7 +1548,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5987ca1ff94ed3c1666f783bb15b16158aa7e1db -R 877cd166cfa1886b85d3c173dceec467 +P eacfdcf25796ea29b5e63499c3d7397498305ad9 +R 08311637f9a8170c29c38d1bfabeb653 U drh -Z 12e7b02d2001dbb9bba0a7e780630702 +Z 855f1082721037fd6fefeb16ca2ac959 diff --git a/manifest.uuid b/manifest.uuid index e94ba71f96..61e2f28112 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eacfdcf25796ea29b5e63499c3d7397498305ad9 \ No newline at end of file +bd22bf9cbe028e9811ca3afaadafd90312cb0fc9 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index ded4462398..0e3a6f5baa 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -4407,7 +4407,7 @@ case OP_InsertInt: { assert( HasRowid(pTab) ); op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT); }else{ - pTab = 0; /* Not needed. Silence a comiler warning. */ + pTab = 0; /* Not needed. Silence a compiler warning. */ zDb = 0; /* Not needed. Silence a compiler warning. */ } From 9dc7ad1d7e1286fe0d3d30117adae154c6abf6de Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Jan 2017 15:29:05 +0000 Subject: [PATCH 14/43] Add the "stat" command to kvtest.c. Also add the --variance option to the "init" command. Add the tool/kvtest-speed.sh script used for doing performance testing on key/value access patterns. FossilOrigin-Name: b63deed600b1a457a6960ebad5645f4de9c56e5d --- manifest | 13 +++---- manifest.uuid | 2 +- test/kvtest.c | 80 ++++++++++++++++++++++++++++++++++++++++++-- tool/kvtest-speed.sh | 36 ++++++++++++++++++++ 4 files changed, 121 insertions(+), 10 deletions(-) create mode 100644 tool/kvtest-speed.sh diff --git a/manifest b/manifest index 8e4b6f544a..e0848cf122 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\sa\scomment. -D 2017-01-31T15:27:04.928 +C Add\sthe\s"stat"\scommand\sto\skvtest.c.\s\sAlso\sadd\sthe\s--variance\soption\sto\sthe\n"init"\scommand.\s\sAdd\sthe\stool/kvtest-speed.sh\sscript\sused\sfor\sdoing\s\nperformance\stesting\son\skey/value\saccess\spatterns. +D 2017-01-31T15:29:05.242 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -899,7 +899,7 @@ F test/json101.test c0897616f32d95431f37fd291cb78742181980ac F test/json102.test bf3fe7a706d30936a76a0f7a0375e1e8e73aff5a F test/json103.test c5f6b85e69de05f6b3195f9f9d5ce9cd179099a0 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff -F test/kvtest.c dc6e5e9066fa5e19f7368c7dfbe8c6b9642a706f +F test/kvtest.c 7a3c38ee56b9cc45dc5a5edc50fd9bc9425659a9 F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 F test/like.test 0603f4fa0dad50987f70032c05800cbfa8985302 @@ -1475,6 +1475,7 @@ F tool/fuzzershell.c dbf6c26eef936ec78cb0707570de3a4308b2507e F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce +F tool/kvtest-speed.sh d6c7c2b5787f44c3be2ed01c8463223032ee598b F tool/lemon.c 5ccba178a8e8a4b21e1c9232944d23973da38ad7 F tool/lempar.c db1bdb4821f2d8fbd76e577cf3ab18642c8d08d1 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 @@ -1548,7 +1549,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P eacfdcf25796ea29b5e63499c3d7397498305ad9 -R 08311637f9a8170c29c38d1bfabeb653 +P bd22bf9cbe028e9811ca3afaadafd90312cb0fc9 +R 561f5ef3a58c98c17f69cad51ae91935 U drh -Z 855f1082721037fd6fefeb16ca2ac959 +Z 35fd92fc5491c4b603aa832f4a4ebf7a diff --git a/manifest.uuid b/manifest.uuid index 61e2f28112..69a91341ca 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bd22bf9cbe028e9811ca3afaadafd90312cb0fc9 \ No newline at end of file +b63deed600b1a457a6960ebad5645f4de9c56e5d \ No newline at end of file diff --git a/test/kvtest.c b/test/kvtest.c index 765a7ee968..2a108aa470 100644 --- a/test/kvtest.c +++ b/test/kvtest.c @@ -67,13 +67,19 @@ static const char zHelp[] = "\n" " Generate a new test database file named DBFILE containing N\n" " BLOBs each of size M bytes. The page size of the new database\n" -" file will be X\n" +" file will be X. Additional options:\n" +"\n" +" --variance V Randomly vary M by plus or minus V\n" "\n" " kvtest export DBFILE DIRECTORY\n" "\n" " Export all the blobs in the kv table of DBFILE into separate\n" " files in DIRECTORY.\n" "\n" +" kvtest stat DBFILE\n" +"\n" +" Display summary information about DBFILE\n" +"\n" " kvtest run DBFILE [options]\n" "\n" " Run a performance test. DBFILE can be either the name of a\n" @@ -251,6 +257,7 @@ static int initMain(int argc, char **argv){ int i, rc; int nCount = 1000; int sz = 10000; + int iVariance = 0; int pgsz = 4096; sqlite3 *db; char *zSql; @@ -275,6 +282,11 @@ static int initMain(int argc, char **argv){ if( sz<1 ) fatalError("the --size must be positive"); continue; } + if( strcmp(z, "-variance")==0 ){ + if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]); + iVariance = integerValue(argv[++i]); + continue; + } if( strcmp(z, "-pagesize")==0 ){ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]); pgsz = integerValue(argv[++i]); @@ -296,9 +308,9 @@ static int initMain(int argc, char **argv){ "BEGIN;\n" "CREATE TABLE kv(k INTEGER PRIMARY KEY, v BLOB);\n" "WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<%d)" - " INSERT INTO kv(k,v) SELECT x, randomblob(%d) FROM c;\n" + " INSERT INTO kv(k,v) SELECT x, randomblob(%d+(random()%%(%d))) FROM c;\n" "COMMIT;\n", - pgsz, nCount, sz + pgsz, nCount, sz, iVariance ); rc = sqlite3_exec(db, zSql, 0, 0, &zErrMsg); if( rc ) fatalError("database create failed: %s", zErrMsg); @@ -307,6 +319,65 @@ static int initMain(int argc, char **argv){ return 0; } +/* +** Analyze an existing database file. Report its content. +*/ +static int statMain(int argc, char **argv){ + char *zDb; + int i, rc; + sqlite3 *db; + char *zSql; + sqlite3_stmt *pStmt; + + assert( strcmp(argv[1],"stat")==0 ); + assert( argc>=3 ); + zDb = argv[2]; + for(i=3; i&1 | tee summary-kvtest-$NAME.txt +mv cachegrind.out.[1-9][0-9]* cachegrind.out.$NAME +cg_anno.tcl cachegrind.out.$NAME >cout-kvtest-sql-$NAME.txt + +# Second run using the sqlite3_blob object +rm cachegrind.out.[1-9][0-9]* +valgrind --tool=cachegrind ./kvtest run kvtest.db $KVARGS --blob-api 2>&1 | tee -a summary-kvtest-$NAME.txt +mv cachegrind.out.[1-9][0-9]* cachegrind.out.$NAME +cg_anno.tcl cachegrind.out.$NAME >cout-kvtest-$NAME.txt + +# Diff the sqlite3_blob API analysis for non-trunk runs. +if test "$NAME" != "trunk"; then + fossil test-diff --tk cout-kvtest-trunk.txt cout-kvtest-$NAME.txt & +fi From 78a9e92ecf15afb4a3550c8bb8f998928fae3314 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Jan 2017 16:34:51 +0000 Subject: [PATCH 15/43] Remove an unnecessary initialization of the pOp variable in sqlite3VdbeExec(). FossilOrigin-Name: 02f6293f278f7b0a0f4876f5c6a0f4dc42620d79 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e0848cf122..6b12ff4cc5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"stat"\scommand\sto\skvtest.c.\s\sAlso\sadd\sthe\s--variance\soption\sto\sthe\n"init"\scommand.\s\sAdd\sthe\stool/kvtest-speed.sh\sscript\sused\sfor\sdoing\s\nperformance\stesting\son\skey/value\saccess\spatterns. -D 2017-01-31T15:29:05.242 +C Remove\san\sunnecessary\sinitialization\sof\sthe\spOp\svariable\sin\ssqlite3VdbeExec(). +D 2017-01-31T16:34:51.236 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -458,7 +458,7 @@ F src/update.c 456d4a4656f8a03c2abc88a51b19172197400e58 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c a88b0466fddf445ce752226d4698ca3faada620a F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16 -F src/vdbe.c a5bcdb61862cd995126ec4993121e04fe409c6e0 +F src/vdbe.c 7c53c4b66e5fdf4a59272a7af3826d6a36eb72ae F src/vdbe.h 59998ffd71d7caa8886bc78dafaf8caeccd4c13c F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e F src/vdbeapi.c 7a65f10684982daecfce50f557f2632b7f20b198 @@ -1549,7 +1549,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bd22bf9cbe028e9811ca3afaadafd90312cb0fc9 -R 561f5ef3a58c98c17f69cad51ae91935 +P b63deed600b1a457a6960ebad5645f4de9c56e5d +R 30ecebc065226e07a2ed70b2eff6d7d3 U drh -Z 35fd92fc5491c4b603aa832f4a4ebf7a +Z 105450e93cb94372d4615eab06f395ed diff --git a/manifest.uuid b/manifest.uuid index 69a91341ca..7c7400a4e6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b63deed600b1a457a6960ebad5645f4de9c56e5d \ No newline at end of file +02f6293f278f7b0a0f4876f5c6a0f4dc42620d79 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 0e3a6f5baa..c6918c5f2a 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -562,7 +562,7 @@ int sqlite3VdbeExec( Vdbe *p /* The VDBE */ ){ Op *aOp = p->aOp; /* Copy of p->aOp */ - Op *pOp = aOp; /* Current operation */ + Op *pOp; /* Current operation */ #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE) Op *pOrigOp; /* Value of pOp at the top of the loop */ #endif From d59bcbdee7241f103b0ec9ed456d0ce3637ac2b0 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Jan 2017 16:43:36 +0000 Subject: [PATCH 16/43] Remove another unnecessary local variable initialization from sqlite3VdbeExec() FossilOrigin-Name: 2361b03b61311aab9b9ec9de040bbb73be31be0d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 6b12ff4cc5..763bbd12a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunnecessary\sinitialization\sof\sthe\spOp\svariable\sin\ssqlite3VdbeExec(). -D 2017-01-31T16:34:51.236 +C Remove\sanother\sunnecessary\slocal\svariable\sinitialization\sfrom\ssqlite3VdbeExec() +D 2017-01-31T16:43:36.486 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -458,7 +458,7 @@ F src/update.c 456d4a4656f8a03c2abc88a51b19172197400e58 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c a88b0466fddf445ce752226d4698ca3faada620a F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16 -F src/vdbe.c 7c53c4b66e5fdf4a59272a7af3826d6a36eb72ae +F src/vdbe.c c0e9bd3fc0f1909e76930e88860ec66edc201d62 F src/vdbe.h 59998ffd71d7caa8886bc78dafaf8caeccd4c13c F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e F src/vdbeapi.c 7a65f10684982daecfce50f557f2632b7f20b198 @@ -1549,7 +1549,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b63deed600b1a457a6960ebad5645f4de9c56e5d -R 30ecebc065226e07a2ed70b2eff6d7d3 +P 02f6293f278f7b0a0f4876f5c6a0f4dc42620d79 +R f0488c71d9bf7cc95008ff5cdb6232cc U drh -Z 105450e93cb94372d4615eab06f395ed +Z 567d0d39f344217652f484cd397a1b36 diff --git a/manifest.uuid b/manifest.uuid index 7c7400a4e6..1b110b97c9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -02f6293f278f7b0a0f4876f5c6a0f4dc42620d79 \ No newline at end of file +2361b03b61311aab9b9ec9de040bbb73be31be0d \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index c6918c5f2a..b133c7ec85 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -597,7 +597,7 @@ int sqlite3VdbeExec( } assert( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_BUSY ); assert( p->bIsReader || p->readOnly!=0 ); - p->rc = SQLITE_OK; +// p->rc = SQLITE_OK; p->iCurrentTime = 0; assert( p->explain==0 ); p->pResultSet = 0; From 0caad09585bd83f287fcb31c968d656c4dbe9fda Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Jan 2017 16:49:01 +0000 Subject: [PATCH 17/43] Remove a C99-style comment. Fixes to the kvtest-speed.sh script. FossilOrigin-Name: 91eb6b628e278d20eccc647293e5b30765163e12 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbe.c | 1 - tool/kvtest-speed.sh | 5 ++--- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 763bbd12a7..3c10f176f0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sanother\sunnecessary\slocal\svariable\sinitialization\sfrom\ssqlite3VdbeExec() -D 2017-01-31T16:43:36.486 +C Remove\sa\sC99-style\scomment.\s\sFixes\sto\sthe\skvtest-speed.sh\sscript. +D 2017-01-31T16:49:01.913 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -458,7 +458,7 @@ F src/update.c 456d4a4656f8a03c2abc88a51b19172197400e58 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c a88b0466fddf445ce752226d4698ca3faada620a F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16 -F src/vdbe.c c0e9bd3fc0f1909e76930e88860ec66edc201d62 +F src/vdbe.c d3765f4d8f667b8d10232b2a1d0498497f3ac09f F src/vdbe.h 59998ffd71d7caa8886bc78dafaf8caeccd4c13c F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e F src/vdbeapi.c 7a65f10684982daecfce50f557f2632b7f20b198 @@ -1475,7 +1475,7 @@ F tool/fuzzershell.c dbf6c26eef936ec78cb0707570de3a4308b2507e F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/kvtest-speed.sh d6c7c2b5787f44c3be2ed01c8463223032ee598b +F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f F tool/lemon.c 5ccba178a8e8a4b21e1c9232944d23973da38ad7 F tool/lempar.c db1bdb4821f2d8fbd76e577cf3ab18642c8d08d1 F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 @@ -1549,7 +1549,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 02f6293f278f7b0a0f4876f5c6a0f4dc42620d79 -R f0488c71d9bf7cc95008ff5cdb6232cc +P 2361b03b61311aab9b9ec9de040bbb73be31be0d +R 085c25b2bd73ed43799df664becffebf U drh -Z 567d0d39f344217652f484cd397a1b36 +Z 9d1629688efb4c919cbb0184aee51efa diff --git a/manifest.uuid b/manifest.uuid index 1b110b97c9..80341cb011 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2361b03b61311aab9b9ec9de040bbb73be31be0d \ No newline at end of file +91eb6b628e278d20eccc647293e5b30765163e12 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index b133c7ec85..049c8243f6 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -597,7 +597,6 @@ int sqlite3VdbeExec( } assert( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_BUSY ); assert( p->bIsReader || p->readOnly!=0 ); -// p->rc = SQLITE_OK; p->iCurrentTime = 0; assert( p->explain==0 ); p->pResultSet = 0; diff --git a/tool/kvtest-speed.sh b/tool/kvtest-speed.sh index 8dc852bef5..5f2c8345be 100644 --- a/tool/kvtest-speed.sh +++ b/tool/kvtest-speed.sh @@ -21,11 +21,10 @@ gcc -g -Os -I. $OPTS $* kvtest.c sqlite3.c -o kvtest # First run using SQL rm cachegrind.out.[1-9][0-9]* valgrind --tool=cachegrind ./kvtest run kvtest.db $KVARGS 2>&1 | tee summary-kvtest-$NAME.txt -mv cachegrind.out.[1-9][0-9]* cachegrind.out.$NAME -cg_anno.tcl cachegrind.out.$NAME >cout-kvtest-sql-$NAME.txt +mv cachegrind.out.[1-9][0-9]* cachegrind.out.sql-$NAME +cg_anno.tcl cachegrind.out.sql-$NAME >cout-kvtest-sql-$NAME.txt # Second run using the sqlite3_blob object -rm cachegrind.out.[1-9][0-9]* valgrind --tool=cachegrind ./kvtest run kvtest.db $KVARGS --blob-api 2>&1 | tee -a summary-kvtest-$NAME.txt mv cachegrind.out.[1-9][0-9]* cachegrind.out.$NAME cg_anno.tcl cachegrind.out.$NAME >cout-kvtest-$NAME.txt From 610e17bd91bca66ec7c03d7e60c2024e32ac989b Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 31 Jan 2017 17:31:30 +0000 Subject: [PATCH 18/43] Add a speed-test program for the sessions module. FossilOrigin-Name: 25f1275fe3e940c1d9a7b013cb3744304b2eda1e --- ext/session/session_speed_test.c | 360 +++++++++++++++++++++++++++++++ manifest | 11 +- manifest.uuid | 2 +- 3 files changed, 367 insertions(+), 6 deletions(-) create mode 100644 ext/session/session_speed_test.c diff --git a/ext/session/session_speed_test.c b/ext/session/session_speed_test.c new file mode 100644 index 0000000000..14b97ea07b --- /dev/null +++ b/ext/session/session_speed_test.c @@ -0,0 +1,360 @@ +/* +** 2017 January 31 +** +** 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 contains the source code for a standalone program used to +** test the performance of the sessions module. Compile and run: +** +** ./session_speed_test -help +** +** for details. +*/ + +#include "sqlite3.h" +#include +#include +#include +#include +#include + +/************************************************************************* +** Start of generic command line parser. +*/ +#define CMDLINE_BARE 0 +#define CMDLINE_INTEGER 1 +#define CMDLINE_STRING 2 +#define CMDLINE_BOOLEAN 3 + +typedef struct CmdLineOption CmdLineOption; +struct CmdLineOption { + const char *zText; /* Name of command line option */ + const char *zHelp; /* Help text for option */ + int eType; /* One of the CMDLINE_* values */ + int iOff; /* Offset of output variable */ +}; + +#define CMDLINE_INT32(x,y,z) {x, y, CMDLINE_INTEGER, z} +#define CMDLINE_BOOL(x,y,z) {x, y, CMDLINE_BOOLEAN, z} +#define CMDLINE_TEXT(x,y,z) {x, y, CMDLINE_STRING, z} +#define CMDLINE_NONE(x,y,z) {x, y, CMDLINE_BARE, z} + +static void option_requires_argument_error(CmdLineOption *pOpt){ + fprintf(stderr, "Option requires a%s argument: %s\n", + pOpt->eType==CMDLINE_INTEGER ? "n integer" : + pOpt->eType==CMDLINE_STRING ? " string" : " boolean", + pOpt->zText + ); + exit(1); +} + +static void ambiguous_option_error(const char *zArg){ + fprintf(stderr, "Option is ambiguous: %s\n", zArg); + exit(1); +} + +static void unknown_option_error( + const char *zArg, + CmdLineOption *aOpt, + const char *zHelp +){ + int i; + fprintf(stderr, "Unknown option: %s\n", zArg); + fprintf(stderr, "\nOptions are:\n"); + fprintf(stderr, " % -30sEcho command line options\n", "-cmdline:verbose"); + for(i=0; aOpt[i].zText; i++){ + int eType = aOpt[i].eType; + char *zOpt = sqlite3_mprintf("%s %s", aOpt[i].zText, + eType==CMDLINE_BARE ? "" : + eType==CMDLINE_INTEGER ? "N" : + eType==CMDLINE_BOOLEAN ? "BOOLEAN" : "TEXT" + ); + fprintf(stderr, " % -30s%s\n", zOpt, aOpt[i].zHelp); + sqlite3_free(zOpt); + } + if( zHelp ){ + fprintf(stderr, "\n%s\n", zHelp); + } + exit(1); +} + +static int get_integer_option(CmdLineOption *pOpt, const char *zArg){ + int i = 0; + int iRet = 0; + int bSign = 1; + if( zArg[0]=='-' ){ + bSign = -1; + i = 1; + } + while( zArg[i] ){ + if( zArg[i]<'0' || zArg[i]>'9' ) option_requires_argument_error(pOpt); + iRet = iRet*10 + (zArg[i] - '0'); + i++; + } + return (iRet*bSign); +} + +static int get_boolean_option(CmdLineOption *pOpt, const char *zArg){ + if( 0==sqlite3_stricmp(zArg, "true") ) return 1; + if( 0==sqlite3_stricmp(zArg, "1") ) return 1; + if( 0==sqlite3_stricmp(zArg, "0") ) return 0; + if( 0==sqlite3_stricmp(zArg, "false") ) return 0; + option_requires_argument_error(pOpt); + return 0; +} + +static void parse_command_line( + int argc, + char **argv, + int iStart, + CmdLineOption *aOpt, + void *pStruct, + const char *zHelp +){ + char *pOut = (char*)pStruct; + int bVerbose = 0; + int iArg; + + for(iArg=iStart; iArgzText, zArg, nArg) ){ + if( nMatch ){ + ambiguous_option_error(zArg); + } + nMatch++; + if( pOpt->eType==CMDLINE_BARE ){ + *(int*)(&pOut[pOpt->iOff]) = 1; + }else{ + iArg++; + if( iArg==argc ){ + option_requires_argument_error(pOpt); + } + switch( pOpt->eType ){ + case CMDLINE_INTEGER: + *(int*)(&pOut[pOpt->iOff]) = get_integer_option(pOpt, argv[iArg]); + break; + case CMDLINE_STRING: + *(const char**)(&pOut[pOpt->iOff]) = argv[iArg]; + break; + case CMDLINE_BOOLEAN: + *(int*)(&pOut[pOpt->iOff]) = get_boolean_option(pOpt, argv[iArg]); + break; + } + } + } + } + + if( nMatch==0 && 0==sqlite3_strnicmp("-cmdline:verbose", zArg, nArg) ){ + bVerbose = 1; + nMatch = 1; + } + + if( nMatch==0 ){ + unknown_option_error(zArg, aOpt, zHelp); + } + } + + if( bVerbose ){ + int iOpt; + fprintf(stdout, "Options are: "); + for(iOpt=0; aOpt[iOpt].zText; iOpt++){ + CmdLineOption *pOpt = &aOpt[iOpt]; + if( pOpt->eType!=CMDLINE_BARE || *(int*)(&pOut[pOpt->iOff]) ){ + fprintf(stdout, "%s ", pOpt->zText); + } + switch( pOpt->eType ){ + case CMDLINE_INTEGER: + fprintf(stdout, "%d ", *(int*)(&pOut[pOpt->iOff])); + break; + case CMDLINE_BOOLEAN: + fprintf(stdout, "%d ", *(int*)(&pOut[pOpt->iOff])); + break; + case CMDLINE_STRING: + fprintf(stdout, "%s ", *(const char**)(&pOut[pOpt->iOff])); + break; + } + } + fprintf(stdout, "\n"); + } +} +/* +** End of generic command line parser. +*************************************************************************/ + +static void abort_due_to_error(int rc){ + fprintf(stderr, "Error: %d\n"); + exit(-1); +} + +static void execsql(sqlite3 *db, const char *zSql){ + int rc = sqlite3_exec(db, zSql, 0, 0, 0); + if( rc!=SQLITE_OK ) abort_due_to_error(rc); +} + +static int xConflict(void *pCtx, int eConflict, sqlite3_changeset_iter *p){ + return SQLITE_CHANGESET_ABORT; +} + +static void run_test( + sqlite3 *db, + sqlite3 *db2, + int nRow, + const char *zSql +){ + sqlite3_session *pSession = 0; + sqlite3_stmt *pStmt = 0; + int rc; + int i; + int nChangeset; + void *pChangeset; + + /* Attach a session object to database db */ + rc = sqlite3session_create(db, "main", &pSession); + if( rc!=SQLITE_OK ) abort_due_to_error(rc); + + /* Configure the session to capture changes on all tables */ + rc = sqlite3session_attach(pSession, 0); + if( rc!=SQLITE_OK ) abort_due_to_error(rc); + + /* Prepare the SQL statement */ + rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); + if( rc!=SQLITE_OK ) abort_due_to_error(rc); + + /* Open a transaction */ + execsql(db, "BEGIN"); + + /* Execute the SQL statement nRow times */ + for(i=0; i Date: Tue, 31 Jan 2017 19:02:15 +0000 Subject: [PATCH 19/43] Simplifications to blobSeekToRow(). FossilOrigin-Name: 495ea824093ff535734c22c3115384c08f855c02 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeblob.c | 5 +---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 3c10f176f0..fa96e1cee3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sa\sC99-style\scomment.\s\sFixes\sto\sthe\skvtest-speed.sh\sscript. -D 2017-01-31T16:49:01.913 +C Simplifications\sto\sblobSeekToRow(). +D 2017-01-31T19:02:15.083 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -463,7 +463,7 @@ F src/vdbe.h 59998ffd71d7caa8886bc78dafaf8caeccd4c13c F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e F src/vdbeapi.c 7a65f10684982daecfce50f557f2632b7f20b198 F src/vdbeaux.c 6847b02aa2db536ed15d90f1fdc2923afef93c5b -F src/vdbeblob.c 2b3d1ad915dbe5dc92c48759dc18fa8c697e78e5 +F src/vdbeblob.c 359891617358deefc85bef7bcf787fa6b77facb9 F src/vdbemem.c 3b5a9a5b375458d3e12a50ae1aaa41eeec2175fd F src/vdbesort.c eda25cb2d1727efca6f7862fea32b8aa33c0face F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834 @@ -1549,7 +1549,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 2361b03b61311aab9b9ec9de040bbb73be31be0d -R 085c25b2bd73ed43799df664becffebf +P 91eb6b628e278d20eccc647293e5b30765163e12 +R 793d15c782afd1bb1c67c16147a858a7 U drh -Z 9d1629688efb4c919cbb0184aee51efa +Z 0d3326b5592bbe49f8801dfaea3a7026 diff --git a/manifest.uuid b/manifest.uuid index 80341cb011..fb73fe6210 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -91eb6b628e278d20eccc647293e5b30765163e12 \ No newline at end of file +495ea824093ff535734c22c3115384c08f855c02 \ No newline at end of file diff --git a/src/vdbeblob.c b/src/vdbeblob.c index 810f78860f..5692c1c606 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -55,7 +55,6 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){ int rc; /* Error code */ char *zErr = 0; /* Error message */ Vdbe *v = (Vdbe *)p->pStmt; - sqlite3 *db = v->db; /* Set the value of register r[1] in the SQL statement to integer iRow. ** This is done directly as a performance optimization @@ -69,9 +68,7 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){ ** counter is faster. */ if( v->pc>3 ){ v->pc = 3; - db->nVdbeExec++; - rc = sqlite3VdbeExec((Vdbe*)p->pStmt); - db->nVdbeExec--; + rc = sqlite3VdbeExec(v); }else{ rc = sqlite3_step(p->pStmt); } From fcbd6cdb41a8f338ed3c953405b4256cdfaba6c2 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 31 Jan 2017 21:22:03 +0000 Subject: [PATCH 20/43] R-TREE optimization: unwrap the coordinate decode loop in rtreeCallbackConstraint(). FossilOrigin-Name: 0bf7b51896ec441f62490964c7a44a3c75c6b7e2 --- ext/rtree/rtree.c | 10 +++++++--- manifest | 13 ++++++------- manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index c7de6ac123..d69c966ddd 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -966,10 +966,14 @@ static int rtreeCallbackConstraint( if( pConstraint->op==RTREE_QUERY && pSearch->iLevel==1 ){ pInfo->iRowid = readInt64(pCellData); } - pCellData += 8; - for(i=0; i=2 && (nCoord&1)==0 ); + i = 0; + do{ + pCellData += 8; RTREE_DECODE_COORD(eInt, pCellData, aCoord[i]); - } + RTREE_DECODE_COORD(eInt, (pCellData+4), aCoord[i+1]); + i+= 2; + }while( iop==RTREE_MATCH ){ rc = pConstraint->u.xGeom((sqlite3_rtree_geometry*)pInfo, nCoord, aCoord, &i); diff --git a/manifest b/manifest index a8c339e791..cb6735cb6d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Very\ssmall\sperformance\simprovements\sand\ssize\sreductions\sin\s\nsqlite3VdbeExec()\sand\sblobSeekToRow(). -D 2017-01-31T19:10:42.671 +C R-TREE\soptimization:\sunwrap\sthe\scoordinate\sdecode\sloop\sin\nrtreeCallbackConstraint(). +D 2017-01-31T21:22:03.245 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 078fc27417b48aaebe988621bf96ef0e1645b201 +F ext/rtree/rtree.c 81fea8b100c6195f8a42119109d6ec2016e613f3 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -1549,8 +1549,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b63deed600b1a457a6960ebad5645f4de9c56e5d 495ea824093ff535734c22c3115384c08f855c02 -R 793d15c782afd1bb1c67c16147a858a7 -T +closed 495ea824093ff535734c22c3115384c08f855c02 +P 85dddf2b453b8afaf1f485b96084d31e22f97dda +R 80f20a76d631de95caa5095989ae297f U drh -Z c7f2b5c04f4a8cad3ed5cf73468bb400 +Z d89e7b06786861fbe2704ca06b1411f8 diff --git a/manifest.uuid b/manifest.uuid index 321250201a..0415fad4fb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -85dddf2b453b8afaf1f485b96084d31e22f97dda \ No newline at end of file +0bf7b51896ec441f62490964c7a44a3c75c6b7e2 \ No newline at end of file From 35497fccbe358dda7b95e1a4c109020725877f0b Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 1 Feb 2017 01:34:15 +0000 Subject: [PATCH 21/43] Improved comments on the statGet() implementation in ANALYZE. No changes to code. FossilOrigin-Name: 9663eea2a16bb4eec71476d307a3722a768308c3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/analyze.c | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index cb6735cb6d..cd07701b23 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C R-TREE\soptimization:\sunwrap\sthe\scoordinate\sdecode\sloop\sin\nrtreeCallbackConstraint(). -D 2017-01-31T21:22:03.245 +C Improved\scomments\son\sthe\sstatGet()\simplementation\sin\sANALYZE.\s\sNo\schanges\nto\scode. +D 2017-02-01T01:34:15.043 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -328,7 +328,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 3b23977620ce9662ac54443f65b87ba996e36121 -F src/analyze.c 317dbaf31c16050582b09bf4f323b4e0f1813251 +F src/analyze.c ac7a5d7e3cee07d074697904e00e4a8ab7b2b4f5 F src/attach.c 8c476f8bd5d2afe11d925f890d30e527e5b0ce43 F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b @@ -1549,7 +1549,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 85dddf2b453b8afaf1f485b96084d31e22f97dda -R 80f20a76d631de95caa5095989ae297f +P 0bf7b51896ec441f62490964c7a44a3c75c6b7e2 +R bb550435b988e435dcc2fd1779602487 U drh -Z d89e7b06786861fbe2704ca06b1411f8 +Z 36c251bda157d6101f2fb97842697f89 diff --git a/manifest.uuid b/manifest.uuid index 0415fad4fb..1081a26f59 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0bf7b51896ec441f62490964c7a44a3c75c6b7e2 \ No newline at end of file +9663eea2a16bb4eec71476d307a3722a768308c3 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index c079132f4a..890ae7c3b2 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -797,6 +797,12 @@ static const FuncDef statPushFuncdef = { ** The content to returned is determined by the parameter J ** which is one of the STAT_GET_xxxx values defined above. ** +** The stat_get(P,J) function is not available to generic SQL. It is +** inserted as part of a manually constructed bytecode program. (See +** the callStatGet() routine below.) It is guaranteed that the P +** parameter will always be a poiner to a Stat4Accum object, never a +** NULL. +** ** If neither STAT3 nor STAT4 are enabled, then J is always ** STAT_GET_STAT1 and is hence omitted and this routine becomes ** a one-parameter function, stat_get(P), that always returns the From 14494fa712d71370eb92e15c4e4db20534fcd832 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 1 Feb 2017 02:25:28 +0000 Subject: [PATCH 22/43] More RTREE performance optimizations related to decoding values. FossilOrigin-Name: c5395e7496d0cd593f5e16ee5f6719d020dc0c66 --- ext/rtree/rtree.c | 18 +++++++++++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index d69c966ddd..f1db60b22f 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -370,12 +370,20 @@ static int readInt16(u8 *p){ return (p[0]<<8) + p[1]; } static void readCoord(u8 *p, RtreeCoord *pCoord){ +#if defined(SQLITE_BYTEORDER) && SQLITE_BYTEORDER==1234 + memcpy(&pCoord->u, p, 4); + pCoord->u = ((pCoord->u>>24)&0xff)|((pCoord->u>>8)&0xff00)| + ((pCoord->u&0xff)<<24)|((pCoord->u&0xff00)<<8); +#elif defined(SQLITE_BYTEORDER) && SQLITE_BYTEORDER==4321 + memcpy(&pCoord->u, p, 4); +#else pCoord->u = ( (((u32)p[0]) << 24) + (((u32)p[1]) << 16) + (((u32)p[2]) << 8) + (((u32)p[3]) << 0) ); +#endif } static i64 readInt64(u8 *p){ return ( @@ -736,13 +744,21 @@ static void nodeGetCell( ){ u8 *pData; RtreeCoord *pCoord; - int ii; + int ii = 0; pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell); pData = pNode->zData + (12 + pRtree->nBytesPerCell*iCell); pCoord = pCell->aCoord; + do{ + readCoord(pData, &pCoord[ii]); + readCoord(pData+4, &pCoord[ii+1]); + pData += 8; + ii += 2; + }while( iinDim*2 ); +#if 0 for(ii=0; iinDim*2; ii++){ readCoord(&pData[ii*4], &pCoord[ii]); } +#endif } diff --git a/manifest b/manifest index cd07701b23..3a5177423f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\scomments\son\sthe\sstatGet()\simplementation\sin\sANALYZE.\s\sNo\schanges\nto\scode. -D 2017-02-01T01:34:15.043 +C More\sRTREE\sperformance\soptimizations\srelated\sto\sdecoding\svalues. +D 2017-02-01T02:25:28.535 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 81fea8b100c6195f8a42119109d6ec2016e613f3 +F ext/rtree/rtree.c f66b3d232ea98285548107caaac55f110a0b6709 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -1549,7 +1549,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0bf7b51896ec441f62490964c7a44a3c75c6b7e2 -R bb550435b988e435dcc2fd1779602487 +P 9663eea2a16bb4eec71476d307a3722a768308c3 +R 5d2055e5a67aa8455e161eeb4945e6a1 U drh -Z 36c251bda157d6101f2fb97842697f89 +Z 3923bc85bfbb1c570a9230cd663fc66b diff --git a/manifest.uuid b/manifest.uuid index 1081a26f59..becf54d88b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9663eea2a16bb4eec71476d307a3722a768308c3 \ No newline at end of file +c5395e7496d0cd593f5e16ee5f6719d020dc0c66 \ No newline at end of file From f6c69221e3b5f48fceb5e3664746716ea7e31f46 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 1 Feb 2017 14:19:43 +0000 Subject: [PATCH 23/43] Update the documentation comment in sqlite.h.in for sqlite3_preupdate_hook(). FossilOrigin-Name: 7f8570208c06c056d426e9299d9930181a0464f8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 24 ++++++++++++++---------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 01669f9e0e..b3f47391f1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Changes\sso\sthat\sthe\spre-update\shook\sand\sthe\ssessions\smodule\swork\swith\sWITHOUT\nROWID\stables. -D 2017-02-01T14:10:24.369 +C Update\sthe\sdocumentation\scomment\sin\ssqlite.h.in\sfor\ssqlite3_preupdate_hook(). +D 2017-02-01T14:19:43.743 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -395,7 +395,7 @@ F src/resolve.c f9bc0de45a30a450da47b3766de00be89bf9be79 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 3856db523b942062bca8722ba03b61c324ff94d6 F src/shell.c a84e453c213f3e0d6935a582024da4e242f85a19 -F src/sqlite.h.in 8fd2b1a4e4aac023d4533313442528b81105fab3 +F src/sqlite.h.in 751ff125eb159c8f92c182b8df980a5e4f50e966 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae F src/sqliteInt.h 6f29b23415ce207c2fda61054bf244b74f96359c @@ -1552,7 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P c5395e7496d0cd593f5e16ee5f6719d020dc0c66 25f1275fe3e940c1d9a7b013cb3744304b2eda1e -R f7a2435ee7007416912dcdfda9016a2c +P 964bdc27f8f1b1db2e5c0c2a65c8156614cbe087 +R c3a8e9059dd92e8c282633700ca50a30 U dan -Z 84db606ff358cb3acbf24f0cef50dec1 +Z fded3ef392ff672f8205c955a05c2af4 diff --git a/manifest.uuid b/manifest.uuid index f45e6e6220..dda985aaff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -964bdc27f8f1b1db2e5c0c2a65c8156614cbe087 \ No newline at end of file +7f8570208c06c056d426e9299d9930181a0464f8 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index b0ec7f7e15..eaa75fc249 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -8180,7 +8180,7 @@ int sqlite3_db_cacheflush(sqlite3*); ** ** ^The [sqlite3_preupdate_hook()] interface registers a callback function ** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation -** on a [rowid table]. +** on a database table. ** ^At most one preupdate hook may be registered at a time on a single ** [database connection]; each call to [sqlite3_preupdate_hook()] overrides ** the previous setting. @@ -8189,9 +8189,9 @@ int sqlite3_db_cacheflush(sqlite3*); ** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as ** the first parameter to callbacks. ** -** ^The preupdate hook only fires for changes to [rowid tables]; the preupdate -** hook is not invoked for changes to [virtual tables] or [WITHOUT ROWID] -** tables. +** ^The preupdate hook only fires for changes to real database tables; the +** preupdate hook is not invoked for changes to [virtual tables] or to +** system tables like sqlite_master or sqlite_stat1. ** ** ^The second parameter to the preupdate callback is a pointer to ** the [database connection] that registered the preupdate hook. @@ -8205,12 +8205,16 @@ int sqlite3_db_cacheflush(sqlite3*); ** databases.)^ ** ^The fifth parameter to the preupdate callback is the name of the ** table that is being modified. -** ^The sixth parameter to the preupdate callback is the initial [rowid] of the -** row being changes for SQLITE_UPDATE and SQLITE_DELETE changes and is -** undefined for SQLITE_INSERT changes. -** ^The seventh parameter to the preupdate callback is the final [rowid] of -** the row being changed for SQLITE_UPDATE and SQLITE_INSERT changes and is -** undefined for SQLITE_DELETE changes. +** +** For an UPDATE or DELETE operation on a [rowid table], the sixth +** parameter passed to the preupdate callback is the initial [rowid] of the +** row being modified or deleted. For an INSERT operation on a rowid table, +** or any operation on a WITHOUT ROWID table, the value of the sixth +** parameter is undefined. For an INSERT or UPDATE on a rowid table the +** seventh parameter is the final rowid value of the row being inserted +** or updated. The value of the seventh parameter passed to the callback +** function is not defined for operations on WITHOUT ROWID tables, or for +** INSERT operations on rowid tables. ** ** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()], ** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces From 1650fcb1b5627ec7ab2a514b9a42920e8e739ac7 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 1 Feb 2017 15:19:29 +0000 Subject: [PATCH 24/43] Fix the build by making the OPFLAG_ISNOOP macro available unconditionally. FossilOrigin-Name: 510933cb24c5bf883265af3a6075e60a4b5ffa37 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 2 -- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index b3f47391f1..8145330051 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sdocumentation\scomment\sin\ssqlite.h.in\sfor\ssqlite3_preupdate_hook(). -D 2017-02-01T14:19:43.743 +C Fix\sthe\sbuild\sby\smaking\sthe\sOPFLAG_ISNOOP\smacro\savailable\sunconditionally. +D 2017-02-01T15:19:29.202 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -398,7 +398,7 @@ F src/shell.c a84e453c213f3e0d6935a582024da4e242f85a19 F src/sqlite.h.in 751ff125eb159c8f92c182b8df980a5e4f50e966 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae -F src/sqliteInt.h 6f29b23415ce207c2fda61054bf244b74f96359c +F src/sqliteInt.h 3724c48e82605b471bbf7e41109b5850c6e89f31 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 @@ -1552,7 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 964bdc27f8f1b1db2e5c0c2a65c8156614cbe087 -R c3a8e9059dd92e8c282633700ca50a30 -U dan -Z fded3ef392ff672f8205c955a05c2af4 +P 7f8570208c06c056d426e9299d9930181a0464f8 +R bbb1f490f7311ec1c087c3ef4607e5e0 +U drh +Z 645035379b970696e5aed344f8a4be19 diff --git a/manifest.uuid b/manifest.uuid index dda985aaff..0823e8bab6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7f8570208c06c056d426e9299d9930181a0464f8 \ No newline at end of file +510933cb24c5bf883265af3a6075e60a4b5ffa37 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 4a28ebcd5a..3faf9d3982 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3057,9 +3057,7 @@ struct AuthContext { #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ #define OPFLAG_APPEND 0x08 /* This is likely to be an append */ #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */ -#ifdef SQLITE_ENABLE_PREUPDATE_HOOK #define OPFLAG_ISNOOP 0x40 /* OP_Delete does pre-update-hook only */ -#endif #define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */ #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */ #define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */ From 03626e38127d4d0667eb23243c479719c1d30b9a Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 1 Feb 2017 15:24:32 +0000 Subject: [PATCH 25/43] Use compiler intrinsic functions (when available) for byteswapping in RTREE. FossilOrigin-Name: 82fcd54a5941c20895ffc22d8009c1ebdae44eda --- ext/rtree/rtree.c | 142 ++++++++++++++++++++++++++++++++++++++++------ manifest | 12 ++-- manifest.uuid | 2 +- 3 files changed, 131 insertions(+), 25 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index f1db60b22f..637fb79d05 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -362,6 +362,65 @@ struct RtreeMatchArg { # define MIN(x,y) ((x) > (y) ? (y) : (x)) #endif +/* What version of GCC is being used. 0 means GCC is not being used */ +#ifndef GCC_VERSION +#ifdef __GNUC__ +# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__) +#else +# define GCC_VERSION 0 +#endif +#endif + +/* What version of CLANG is being used. 0 means CLANG is not being used */ +#ifndef CLANG_VERSION +#if defined(__clang__) && !defined(_WIN32) +# define CLANG_VERSION \ + (__clang_major__*1000000+__clang_minor__*1000+__clang_patchlevel__) +#else +# define CLANG_VERSION 0 +#endif +#endif + +/* The testcase() macro should already be defined in the amalgamation. If +** it is not, make it a no-op. +*/ +#ifndef SQLITE_AMALGMATION +# define testcase(X) +#endif + +/* +** Macros to determine whether the machine is big or little endian, +** and whether or not that determination is run-time or compile-time. +** +** For best performance, an attempt is made to guess at the byte-order +** using C-preprocessor macros. If that is unsuccessful, or if +** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined +** at run-time. +*/ +#ifndef SQLITE_BYTEORDER +#if (defined(i386) || defined(__i386__) || defined(_M_IX86) || \ + defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ + defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ + defined(__arm__)) && !defined(SQLITE_RUNTIME_BYTEORDER) +# define SQLITE_BYTEORDER 1234 +#endif +#if (defined(sparc) || defined(__ppc__)) \ + && !defined(SQLITE_RUNTIME_BYTEORDER) +# define SQLITE_BYTEORDER 4321 +#endif +# define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */ +#endif + + +/* What version of MSVC is being used. 0 means MSVC is not being used */ +#ifndef MSVC_VERSION +#if defined(_MSC_VER) +# define MSVC_VERSION _MSC_VER +#else +# define MSVC_VERSION 0 +#endif +#endif + /* ** Functions to deserialize a 16 bit integer, 32 bit real number and ** 64 bit integer. The deserialized value is returned. @@ -370,12 +429,16 @@ static int readInt16(u8 *p){ return (p[0]<<8) + p[1]; } static void readCoord(u8 *p, RtreeCoord *pCoord){ -#if defined(SQLITE_BYTEORDER) && SQLITE_BYTEORDER==1234 - memcpy(&pCoord->u, p, 4); + assert( ((((char*)p) - (char*)0)&3)==0 ); /* p is always 4-byte aligned */ +#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 + pCoord->u = _byteswap_ulong(*(u32*)p); +#elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) + pCoord->u = __builtin_bswap32(*(u32*)p); +#elif SQLITE_BYTEORDER==1234 pCoord->u = ((pCoord->u>>24)&0xff)|((pCoord->u>>8)&0xff00)| ((pCoord->u&0xff)<<24)|((pCoord->u&0xff00)<<8); -#elif defined(SQLITE_BYTEORDER) && SQLITE_BYTEORDER==4321 - memcpy(&pCoord->u, p, 4); +#elif SQLITE_BYTEORDER==4321 + pCoord->u = *(u32*)p; #else pCoord->u = ( (((u32)p[0]) << 24) + @@ -386,6 +449,20 @@ static void readCoord(u8 *p, RtreeCoord *pCoord){ #endif } static i64 readInt64(u8 *p){ + testcase( ((((char*)p) - (char*)0)&7)!=0 ); /* not always 8-byte aligned */ +#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 + u64 x; + memcpy(&x, p, 8); + return (i64)_byteswap_uint64(x); +#elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) + u64 x; + memcpy(&x, p, 8); + return (i64)__builtin_bswap64(x); +#elif SQLITE_BYTEORDER==4321 + i64 x; + memcpy(&x, p, 8); + return x; +#else return ( (((i64)p[0]) << 56) + (((i64)p[1]) << 48) + @@ -396,6 +473,7 @@ static i64 readInt64(u8 *p){ (((i64)p[6]) << 8) + (((i64)p[7]) << 0) ); +#endif } /* @@ -410,16 +488,38 @@ static int writeInt16(u8 *p, int i){ } static int writeCoord(u8 *p, RtreeCoord *pCoord){ u32 i; + assert( ((((char*)p) - (char*)0)&3)==0 ); /* p is always 4-byte aligned */ assert( sizeof(RtreeCoord)==4 ); assert( sizeof(u32)==4 ); +#if SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) + i = __builtin_bswap32(pCoord->u); + memcpy(p, &i, 4); +#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 + i = _byteswap_ulong(pCoord->u); + memcpy(p, &i, 4); +#elif SQLITE_BYTEORDER==4321 + i = pCoord->u; + memcpy(p, &i, 4); +#else i = pCoord->u; p[0] = (i>>24)&0xFF; p[1] = (i>>16)&0xFF; p[2] = (i>> 8)&0xFF; p[3] = (i>> 0)&0xFF; +#endif return 4; } static int writeInt64(u8 *p, i64 i){ + testcase( ((((char*)p) - (char*)0)&7)!=0 ); /* Not always 8-byte aligned */ +#if SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) + i = (i64)__builtin_bswap64((u64)i); + memcpy(p, &i, 8); +#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 + i = (i64)_byteswap_uint64((u64)i); + memcpy(p, &i, 8); +#elif SQLITE_BYTEORDER==4321 + memcpy(p, &i, 8); +#else p[0] = (i>>56)&0xFF; p[1] = (i>>48)&0xFF; p[2] = (i>>40)&0xFF; @@ -428,6 +528,7 @@ static int writeInt64(u8 *p, i64 i){ p[5] = (i>>16)&0xFF; p[6] = (i>> 8)&0xFF; p[7] = (i>> 0)&0xFF; +#endif return 8; } @@ -754,11 +855,6 @@ static void nodeGetCell( pData += 8; ii += 2; }while( iinDim*2 ); -#if 0 - for(ii=0; iinDim*2; ii++){ - readCoord(&pData[ii*4], &pCoord[ii]); - } -#endif } @@ -927,15 +1023,22 @@ static int rtreeEof(sqlite3_vtab_cursor *cur){ ** false. a[] is the four bytes of the on-disk record to be decoded. ** Store the results in "r". ** -** There are three versions of this macro, one each for little-endian and -** big-endian processors and a third generic implementation. The endian- -** specific implementations are much faster and are preferred if the -** processor endianness is known at compile-time. The SQLITE_BYTEORDER -** macro is part of sqliteInt.h and hence the endian-specific -** implementation will only be used if this module is compiled as part -** of the amalgamation. +** There are five versions of this macro. The last one is generic. The +** other four are various architectures-specific optimizations. */ -#if defined(SQLITE_BYTEORDER) && SQLITE_BYTEORDER==1234 +#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 +#define RTREE_DECODE_COORD(eInt, a, r) { \ + RtreeCoord c; /* Coordinate decoded */ \ + c.u = _byteswap_ulong(*(u32*)a); \ + r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \ +} +#elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) +#define RTREE_DECODE_COORD(eInt, a, r) { \ + RtreeCoord c; /* Coordinate decoded */ \ + c.u = __builtin_bswap32(*(u32*)a); \ + r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \ +} +#elif SQLITE_BYTEORDER==1234 #define RTREE_DECODE_COORD(eInt, a, r) { \ RtreeCoord c; /* Coordinate decoded */ \ memcpy(&c.u,a,4); \ @@ -943,7 +1046,7 @@ static int rtreeEof(sqlite3_vtab_cursor *cur){ ((c.u&0xff)<<24)|((c.u&0xff00)<<8); \ r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \ } -#elif defined(SQLITE_BYTEORDER) && SQLITE_BYTEORDER==4321 +#elif SQLITE_BYTEORDER==4321 #define RTREE_DECODE_COORD(eInt, a, r) { \ RtreeCoord c; /* Coordinate decoded */ \ memcpy(&c.u,a,4); \ @@ -986,6 +1089,7 @@ static int rtreeCallbackConstraint( i = 0; do{ pCellData += 8; + assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */ RTREE_DECODE_COORD(eInt, pCellData, aCoord[i]); RTREE_DECODE_COORD(eInt, (pCellData+4), aCoord[i+1]); i+= 2; @@ -1029,6 +1133,7 @@ static void rtreeNonleafConstraint( assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE || p->op==RTREE_GT || p->op==RTREE_EQ ); + assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */ switch( p->op ){ case RTREE_LE: case RTREE_LT: @@ -1069,6 +1174,7 @@ static void rtreeLeafConstraint( assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE || p->op==RTREE_GT || p->op==RTREE_EQ ); pCellData += 8 + p->iCoord*4; + assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */ RTREE_DECODE_COORD(eInt, pCellData, xN); switch( p->op ){ case RTREE_LE: if( xN <= p->u.rValue ) return; break; diff --git a/manifest b/manifest index 8145330051..bc185a2197 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sbuild\sby\smaking\sthe\sOPFLAG_ISNOOP\smacro\savailable\sunconditionally. -D 2017-02-01T15:19:29.202 +C Use\scompiler\sintrinsic\sfunctions\s(when\savailable)\sfor\sbyteswapping\sin\sRTREE. +D 2017-02-01T15:24:32.835 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c f66b3d232ea98285548107caaac55f110a0b6709 +F ext/rtree/rtree.c d8ef14e964a9390197ba7e511aa47b89dc39416c F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -1552,7 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7f8570208c06c056d426e9299d9930181a0464f8 -R bbb1f490f7311ec1c087c3ef4607e5e0 +P 510933cb24c5bf883265af3a6075e60a4b5ffa37 +R 13778722a0ec2443f74339612adbbcf9 U drh -Z 645035379b970696e5aed344f8a4be19 +Z b1e5b219635e474580d8132f194fff51 diff --git a/manifest.uuid b/manifest.uuid index 0823e8bab6..6e2e6a9d62 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -510933cb24c5bf883265af3a6075e60a4b5ffa37 \ No newline at end of file +82fcd54a5941c20895ffc22d8009c1ebdae44eda \ No newline at end of file From 0e6f67b7545d37f47fa5bdd6907c857a73da3e57 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 1 Feb 2017 15:49:02 +0000 Subject: [PATCH 26/43] Precompute the nDim2 value in the Rtree object and use that to make loops over coordinates faster. FossilOrigin-Name: f1f3c8cc733a05c12dd980f2dfa0ab4ccd76c04b --- ext/rtree/rtree.c | 43 +++++++++++++++++++++++++------------------ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 637fb79d05..7e8b7b2b48 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -116,6 +116,7 @@ struct Rtree { sqlite3 *db; /* Host database connection */ int iNodeSize; /* Size in bytes of each node in the node table */ u8 nDim; /* Number of dimensions */ + u8 nDim2; /* Twice the number of dimensions */ u8 eCoordType; /* RTREE_COORD_REAL32 or RTREE_COORD_INT32 */ u8 nBytesPerCell; /* Bytes consumed per cell */ int iDepth; /* Current depth of the r-tree structure */ @@ -711,7 +712,7 @@ static void nodeOverwriteCell( int ii; u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell]; p += writeInt64(p, pCell->iRowid); - for(ii=0; ii<(pRtree->nDim*2); ii++){ + for(ii=0; iinDim2; ii++){ p += writeCoord(p, &pCell->aCoord[ii]); } pNode->isDirty = 1; @@ -854,7 +855,7 @@ static void nodeGetCell( readCoord(pData+4, &pCoord[ii+1]); pData += 8; ii += 2; - }while( iinDim*2 ); + }while( iinDim2 ); } @@ -1712,7 +1713,7 @@ static int rtreeFilter( if( rc!=SQLITE_OK ){ break; } - p->pInfo->nCoord = pRtree->nDim*2; + p->pInfo->nCoord = pRtree->nDim2; p->pInfo->anQueue = pCsr->anQueue; p->pInfo->mxLevel = pRtree->iDepth + 1; }else{ @@ -1878,10 +1879,11 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ ** Return the N-dimensional volumn of the cell stored in *p. */ static RtreeDValue cellArea(Rtree *pRtree, RtreeCell *p){ - RtreeDValue area = (RtreeDValue)1; + RtreeDValue area; int ii; - for(ii=0; ii<(pRtree->nDim*2); ii+=2){ - area = (area * (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]))); + area = DCOORD(p->aCoord[1]) - DCOORD(p->aCoord[0]); + for(ii=2; iinDim2; ii+=2){ + area *= DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]); } return area; } @@ -1891,9 +1893,10 @@ static RtreeDValue cellArea(Rtree *pRtree, RtreeCell *p){ ** of the objects size in each dimension. */ static RtreeDValue cellMargin(Rtree *pRtree, RtreeCell *p){ - RtreeDValue margin = (RtreeDValue)0; + RtreeDValue margin; int ii; - for(ii=0; ii<(pRtree->nDim*2); ii+=2){ + margin = DCOORD(p->aCoord[1]) - DCOORD(p->aCoord[0]); + for(ii=2; iinDim2; ii+=2){ margin += (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])); } return margin; @@ -1903,17 +1906,19 @@ static RtreeDValue cellMargin(Rtree *pRtree, RtreeCell *p){ ** Store the union of cells p1 and p2 in p1. */ static void cellUnion(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ - int ii; + int ii = 0; if( pRtree->eCoordType==RTREE_COORD_REAL32 ){ - for(ii=0; ii<(pRtree->nDim*2); ii+=2){ + do{ p1->aCoord[ii].f = MIN(p1->aCoord[ii].f, p2->aCoord[ii].f); p1->aCoord[ii+1].f = MAX(p1->aCoord[ii+1].f, p2->aCoord[ii+1].f); - } + ii += 2; + }while( iinDim2 ); }else{ - for(ii=0; ii<(pRtree->nDim*2); ii+=2){ + do{ p1->aCoord[ii].i = MIN(p1->aCoord[ii].i, p2->aCoord[ii].i); p1->aCoord[ii+1].i = MAX(p1->aCoord[ii+1].i, p2->aCoord[ii+1].i); - } + ii += 2; + }while( iinDim2 ); } } @@ -1924,7 +1929,7 @@ static void cellUnion(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ static int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ int ii; int isInt = (pRtree->eCoordType==RTREE_COORD_INT32); - for(ii=0; ii<(pRtree->nDim*2); ii+=2){ + for(ii=0; iinDim2; ii+=2){ RtreeCoord *a1 = &p1->aCoord[ii]; RtreeCoord *a2 = &p2->aCoord[ii]; if( (!isInt && (a2[0].fa1[1].f)) @@ -1959,7 +1964,7 @@ static RtreeDValue cellOverlap( for(ii=0; iinDim*2); jj+=2){ + for(jj=0; jjnDim2; jj+=2){ RtreeDValue x1, x2; x1 = MAX(DCOORD(p->aCoord[jj]), DCOORD(aCell[ii].aCoord[jj])); x2 = MIN(DCOORD(p->aCoord[jj+1]), DCOORD(aCell[ii].aCoord[jj+1])); @@ -3015,7 +3020,7 @@ static int rtreeUpdate( ** This problem was discovered after years of use, so we silently ignore ** these kinds of misdeclared tables to avoid breaking any legacy. */ - assert( nData<=(pRtree->nDim*2 + 3) ); + assert( nData<=(pRtree->nDim2 + 3) ); #ifndef SQLITE_RTREE_INT_ONLY if( pRtree->eCoordType==RTREE_COORD_REAL32 ){ @@ -3393,7 +3398,8 @@ static int rtreeInit( pRtree->zDb = (char *)&pRtree[1]; pRtree->zName = &pRtree->zDb[nDb+1]; pRtree->nDim = (argc-4)/2; - pRtree->nBytesPerCell = 8 + pRtree->nDim*4*2; + pRtree->nDim2 = argc - 4; + pRtree->nBytesPerCell = 8 + pRtree->nDim2*4; pRtree->eCoordType = eCoordType; memcpy(pRtree->zDb, argv[1], nDb); memcpy(pRtree->zName, argv[2], nName); @@ -3468,6 +3474,7 @@ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ memset(&node, 0, sizeof(RtreeNode)); memset(&tree, 0, sizeof(Rtree)); tree.nDim = sqlite3_value_int(apArg[0]); + tree.nDim2 = tree.nDim*2; tree.nBytesPerCell = 8 + 8 * tree.nDim; node.zData = (u8 *)sqlite3_value_blob(apArg[1]); @@ -3480,7 +3487,7 @@ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ nodeGetCell(&tree, &node, ii, &cell); sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid); nCell = (int)strlen(zCell); - for(jj=0; jj Date: Wed, 1 Feb 2017 16:41:30 +0000 Subject: [PATCH 27/43] Completely unroll the dimension loop inside of cellArea() in RTREE. FossilOrigin-Name: 3c4c0126c287f844220b65e00fec17c059fbb7c8 --- ext/rtree/rtree.c | 26 +++++++++++++++++++++----- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 7e8b7b2b48..4d67d67044 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1879,11 +1879,27 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ ** Return the N-dimensional volumn of the cell stored in *p. */ static RtreeDValue cellArea(Rtree *pRtree, RtreeCell *p){ - RtreeDValue area; - int ii; - area = DCOORD(p->aCoord[1]) - DCOORD(p->aCoord[0]); - for(ii=2; iinDim2; ii+=2){ - area *= DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]); + RtreeDValue area = (RtreeDValue)1; + assert( pRtree->nDim>=1 && pRtree->nDim<=5 ); +#ifndef SQLITE_RTREE_INT_ONLY + if( pRtree->eCoordType==RTREE_COORD_REAL32 ){ + switch( pRtree->nDim ){ + case 5: area = p->aCoord[9].f - p->aCoord[8].f; + case 4: area *= p->aCoord[7].f - p->aCoord[6].f; + case 3: area *= p->aCoord[5].f - p->aCoord[4].f; + case 2: area *= p->aCoord[3].f - p->aCoord[2].f; + default: area *= p->aCoord[1].f - p->aCoord[0].f; + } + }else +#endif + { + switch( pRtree->nDim ){ + case 5: area = p->aCoord[9].i - p->aCoord[8].i; + case 4: area *= p->aCoord[7].i - p->aCoord[6].i; + case 3: area *= p->aCoord[5].i - p->aCoord[4].i; + case 2: area *= p->aCoord[3].i - p->aCoord[2].i; + default: area *= p->aCoord[1].i - p->aCoord[0].i; + } } return area; } diff --git a/manifest b/manifest index 47d8c1d927..62887ba814 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Precompute\sthe\snDim2\svalue\sin\sthe\sRtree\sobject\sand\suse\sthat\sto\smake\sloops\nover\scoordinates\sfaster. -D 2017-02-01T15:49:02.390 +C Completely\sunroll\sthe\sdimension\sloop\sinside\sof\scellArea()\sin\sRTREE. +D 2017-02-01T16:41:30.471 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c bc73bae0af0d44f92b7d6cb513b719c1e89a7a20 +F ext/rtree/rtree.c 60df707ce5ae232351fc7fc8e916738b1a06bf26 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -1552,7 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 82fcd54a5941c20895ffc22d8009c1ebdae44eda -R 2d19b39f1fe0fa1365532dfac9c432a7 +P f1f3c8cc733a05c12dd980f2dfa0ab4ccd76c04b +R f244aabca54009b102530102725b0e43 U drh -Z 1d3fc5da859da34aeaaaf616405346d2 +Z 396b9b4a99bf06a5c73ba01696403f75 diff --git a/manifest.uuid b/manifest.uuid index 5d3a3937af..a4a1237e47 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f1f3c8cc733a05c12dd980f2dfa0ab4ccd76c04b \ No newline at end of file +3c4c0126c287f844220b65e00fec17c059fbb7c8 \ No newline at end of file From 31a13495153ece728af9641e4327f009088cab3f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 1 Feb 2017 17:08:56 +0000 Subject: [PATCH 28/43] Unwind the RTREE dimension loop inside of rtreeCallbackConstraint(). FossilOrigin-Name: 4854ea9c18e7d8066c90b41568d0fae97b01ea6d --- ext/rtree/rtree.c | 41 ++++++++++++++++++++++++++++++++--------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 4d67d67044..ac76c18485 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1078,6 +1078,7 @@ static int rtreeCallbackConstraint( sqlite3_rtree_query_info *pInfo = pConstraint->pInfo; /* Callback info */ int nCoord = pInfo->nCoord; /* No. of coordinates */ int rc; /* Callback return code */ + RtreeCoord c; /* Translator union */ sqlite3_rtree_dbl aCoord[RTREE_MAX_DIMENSIONS*2]; /* Decoded coordinates */ assert( pConstraint->op==RTREE_MATCH || pConstraint->op==RTREE_QUERY ); @@ -1086,15 +1087,37 @@ static int rtreeCallbackConstraint( if( pConstraint->op==RTREE_QUERY && pSearch->iLevel==1 ){ pInfo->iRowid = readInt64(pCellData); } - assert( nCoord>=2 && (nCoord&1)==0 ); - i = 0; - do{ - pCellData += 8; - assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */ - RTREE_DECODE_COORD(eInt, pCellData, aCoord[i]); - RTREE_DECODE_COORD(eInt, (pCellData+4), aCoord[i+1]); - i+= 2; - }while( iop==RTREE_MATCH ){ rc = pConstraint->u.xGeom((sqlite3_rtree_geometry*)pInfo, nCoord, aCoord, &i); diff --git a/manifest b/manifest index 62887ba814..8bb675991a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Completely\sunroll\sthe\sdimension\sloop\sinside\sof\scellArea()\sin\sRTREE. -D 2017-02-01T16:41:30.471 +C Unwind\sthe\sRTREE\sdimension\sloop\sinside\sof\srtreeCallbackConstraint(). +D 2017-02-01T17:08:56.249 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 60df707ce5ae232351fc7fc8e916738b1a06bf26 +F ext/rtree/rtree.c f2c8604fcdbe13f960c5f0b97acbc2a870b72bf2 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -1552,7 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f1f3c8cc733a05c12dd980f2dfa0ab4ccd76c04b -R f244aabca54009b102530102725b0e43 +P 3c4c0126c287f844220b65e00fec17c059fbb7c8 +R f35bf88856ef1a64759d9b647928073d U drh -Z 396b9b4a99bf06a5c73ba01696403f75 +Z 9add4b4d28dce63431ad3a0684bb5601 diff --git a/manifest.uuid b/manifest.uuid index a4a1237e47..8728c8d9a3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3c4c0126c287f844220b65e00fec17c059fbb7c8 \ No newline at end of file +4854ea9c18e7d8066c90b41568d0fae97b01ea6d \ No newline at end of file From 8c5e8feb35641dc8fc8b3512aa79fd0fcfff775e Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 1 Feb 2017 22:32:49 +0000 Subject: [PATCH 29/43] Add an option to the MSVC makefile to enable treating warnings as errors. FossilOrigin-Name: 6a378c29b43d61313ca9daa599e59d8eeeed9a27 --- Makefile.msc | 13 +++++++++++++ autoconf/Makefile.msc | 13 +++++++++++++ manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index d4aba301fb..4a29f913c8 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -24,6 +24,13 @@ USE_AMALGAMATION = 1 USE_FULLWARN = 0 !ENDIF +# Set this non-0 to enable treating warnings as errors (-WX, etc) when +# compiling. +# +!IFNDEF USE_FATAL_WARN +USE_FATAL_WARN = 0 +!ENDIF + # Set this non-0 to enable full runtime error checks (-RTC1, etc). This # has no effect if (any) optimizations are enabled. # @@ -493,6 +500,12 @@ TCC = $(CC) -nologo -W4 -DINCLUDE_MSVC_H=1 $(CCOPTS) $(TCCOPTS) TCC = $(CC) -nologo -W3 $(CCOPTS) $(TCCOPTS) !ENDIF +# Check if warnings should be treated as errors when compiling. +# +!IF $(USE_FATAL_WARN)!=0 +TCC = $(TCC) -WX +!ENDIF + TCC = $(TCC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -I$(TOP)\src -fp:precise RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -I$(TOP)\src $(RCOPTS) $(RCCOPTS) diff --git a/autoconf/Makefile.msc b/autoconf/Makefile.msc index b53e2370eb..32d03dbf35 100644 --- a/autoconf/Makefile.msc +++ b/autoconf/Makefile.msc @@ -24,6 +24,13 @@ TOP = . USE_FULLWARN = 0 !ENDIF +# Set this non-0 to enable treating warnings as errors (-WX, etc) when +# compiling. +# +!IFNDEF USE_FATAL_WARN +USE_FATAL_WARN = 0 +!ENDIF + # Set this non-0 to enable full runtime error checks (-RTC1, etc). This # has no effect if (any) optimizations are enabled. # @@ -454,6 +461,12 @@ TCC = $(CC) -nologo -W4 -DINCLUDE_MSVC_H=1 $(CCOPTS) $(TCCOPTS) TCC = $(CC) -nologo -W3 $(CCOPTS) $(TCCOPTS) !ENDIF +# Check if warnings should be treated as errors when compiling. +# +!IF $(USE_FATAL_WARN)!=0 +TCC = $(TCC) -WX +!ENDIF + TCC = $(TCC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -fp:precise RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) $(RCOPTS) $(RCCOPTS) diff --git a/manifest b/manifest index 8bb675991a..2bea70b5b4 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -C Unwind\sthe\sRTREE\sdimension\sloop\sinside\sof\srtreeCallbackConstraint(). -D 2017-02-01T17:08:56.249 +C Add\san\soption\sto\sthe\sMSVC\smakefile\sto\senable\streating\swarnings\sas\serrors. +D 2017-02-01T22:32:49.021 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 -F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da +F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 F README.md 8ecc12493ff9f820cdea6520a9016001cb2e59b7 F VERSION cddd8d88dc8202afa0ebc96da61fc4acbd1e96a5 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -11,7 +11,7 @@ F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am 1a47d071e3d5435f8f7ebff7eb6703848bbd65d4 -F autoconf/Makefile.msc b6d27f735911fd09a589d3c966936c47a5850c17 +F autoconf/Makefile.msc 3f29e0fc2a78e113250d79a5da375c1d8d8c06b0 F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7 F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1 F autoconf/configure.ac cacf2616abf6e4a569bde2ef365c143caeec40bc @@ -1552,7 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3c4c0126c287f844220b65e00fec17c059fbb7c8 -R f35bf88856ef1a64759d9b647928073d -U drh -Z 9add4b4d28dce63431ad3a0684bb5601 +P 4854ea9c18e7d8066c90b41568d0fae97b01ea6d +R edeb8ee1db3973795f07ac14a992bc66 +U mistachkin +Z 3bfb007e12a85d09e541803b4d02a604 diff --git a/manifest.uuid b/manifest.uuid index 8728c8d9a3..72864f657b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4854ea9c18e7d8066c90b41568d0fae97b01ea6d \ No newline at end of file +6a378c29b43d61313ca9daa599e59d8eeeed9a27 \ No newline at end of file From 2e525322172e49823cc72daa0e84e5a84b5d2f62 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 1 Feb 2017 22:43:08 +0000 Subject: [PATCH 30/43] Fix harmless compiler warnings seen with MSVC. FossilOrigin-Name: 997f765bc6706769ae15f3e719354473e02bd78b --- ext/fts3/fts3.c | 8 ++++---- ext/rtree/rtree.c | 14 +++++++------- manifest | 19 +++++++++++-------- manifest.uuid | 2 +- src/pragma.c | 2 +- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 748faefec5..c12e3d2156 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -1363,9 +1363,9 @@ static int fts3InitVtab( p->pTokenizer = pTokenizer; p->nMaxPendingData = FTS3_MAX_PENDING_DATA; p->bHasDocsize = (isFts4 && bNoDocsize==0); - p->bHasStat = isFts4; - p->bFts4 = isFts4; - p->bDescIdx = bDescIdx; + p->bHasStat = (u8)isFts4; + p->bFts4 = (u8)isFts4; + p->bDescIdx = (u8)bDescIdx; p->nAutoincrmerge = 0xff; /* 0xff means setting unknown */ p->zContentTbl = zContent; p->zLanguageid = zLanguageid; @@ -3422,7 +3422,7 @@ static int fts3SetHasStat(Fts3Table *p){ if( rc==SQLITE_OK ){ int bHasStat = (sqlite3_step(pStmt)==SQLITE_ROW); rc = sqlite3_finalize(pStmt); - if( rc==SQLITE_OK ) p->bHasStat = bHasStat; + if( rc==SQLITE_OK ) p->bHasStat = (u8)bHasStat; } sqlite3_free(zSql); }else{ diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index ac76c18485..ac84562590 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1515,7 +1515,7 @@ static int rtreeStepToLeaf(RtreeCursor *pCur){ if( rScoreeWithin = eWithin; + p->eWithin = (u8)eWithin; p->id = x.id; p->iCell = x.iCell; RTREE_QUEUE_TRACE(pCur, "PUSH-S:"); @@ -1703,7 +1703,7 @@ static int rtreeFilter( p->id = iNode; p->eWithin = PARTLY_WITHIN; rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell); - p->iCell = iCell; + p->iCell = (u8)iCell; RTREE_QUEUE_TRACE(pCsr, "PUSH-F1:"); }else{ pCsr->atEOF = 1; @@ -1751,7 +1751,7 @@ static int rtreeFilter( } if( rc==SQLITE_OK ){ RtreeSearchPoint *pNew; - pNew = rtreeSearchPointNew(pCsr, RTREE_ZERO, pRtree->iDepth+1); + pNew = rtreeSearchPointNew(pCsr, RTREE_ZERO, (u8)(pRtree->iDepth+1)); if( pNew==0 ) return SQLITE_NOMEM; pNew->id = 1; pNew->iCell = 0; @@ -1879,7 +1879,7 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ break; } zIdxStr[iIdx++] = op; - zIdxStr[iIdx++] = p->iColumn - 1 + '0'; + zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0'); pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2); pIdxInfo->aConstraintUsage[ii].omit = 1; } @@ -3436,10 +3436,10 @@ static int rtreeInit( pRtree->base.pModule = &rtreeModule; pRtree->zDb = (char *)&pRtree[1]; pRtree->zName = &pRtree->zDb[nDb+1]; - pRtree->nDim = (argc-4)/2; + pRtree->nDim = (u8)((argc-4)/2); pRtree->nDim2 = argc - 4; pRtree->nBytesPerCell = 8 + pRtree->nDim2*4; - pRtree->eCoordType = eCoordType; + pRtree->eCoordType = (u8)eCoordType; memcpy(pRtree->zDb, argv[1], nDb); memcpy(pRtree->zName, argv[2], nName); @@ -3512,7 +3512,7 @@ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ UNUSED_PARAMETER(nArg); memset(&node, 0, sizeof(RtreeNode)); memset(&tree, 0, sizeof(Rtree)); - tree.nDim = sqlite3_value_int(apArg[0]); + tree.nDim = (u8)sqlite3_value_int(apArg[0]); tree.nDim2 = tree.nDim*2; tree.nBytesPerCell = 8 + 8 * tree.nDim; node.zData = (u8 *)sqlite3_value_blob(apArg[1]); diff --git a/manifest b/manifest index 2bea70b5b4..1d0d458233 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\soption\sto\sthe\sMSVC\smakefile\sto\senable\streating\swarnings\sas\serrors. -D 2017-02-01T22:32:49.021 +C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. +D 2017-02-01T22:43:08.270 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -70,7 +70,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c e028eb13432f108d2e22cded019fc980700e4e00 +F ext/fts3/fts3.c 5a8cafedffd101e9946f8909ecf8d34aaa383b4d F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 89d0bd4595a0de384dac78e94b803de12586e8dd F ext/fts3/fts3_aux.c 9edc3655fcb287f0467d0a4b886a01c6185fe9f1 @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c f2c8604fcdbe13f960c5f0b97acbc2a870b72bf2 +F ext/rtree/rtree.c 880edfc9a342c130fb2e220c4d7471729e764334 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -386,7 +386,7 @@ F src/parse.y 591704fce84f814d9a3642774c1f011d38f4149c F src/pcache.c 51070ec9b8251bbf9c6ea3d35fd96a458752929e F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 F src/pcache1.c e3967219b2a92b9edcb9324a4ba75009090d3953 -F src/pragma.c 0e7a7c6f1c6fd8ff50c0fff65b8bb80174bc49c5 +F src/pragma.c 7831956012f5d764761fbd023e59b0ffc08f5e8d F src/pragma.h 61aa5389118594bebb28120a6720401aee34ce1a F src/prepare.c b1140c3d0cf59bc85ace00ce363153041b424b7a F src/printf.c ff10a9b9902cd2afe5f655f3013c6307d969b1fd @@ -1552,7 +1552,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4854ea9c18e7d8066c90b41568d0fae97b01ea6d -R edeb8ee1db3973795f07ac14a992bc66 +P 6a378c29b43d61313ca9daa599e59d8eeeed9a27 +R 1fd2d9b1d5e3d137e94e02ebe9288650 +T *branch * msvcWarn +T *sym-msvcWarn * +T -sym-trunk * U mistachkin -Z 3bfb007e12a85d09e541803b4d02a604 +Z c7bdc5431b2e37708dfabf3606031db2 diff --git a/manifest.uuid b/manifest.uuid index 72864f657b..365c5fd48f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a378c29b43d61313ca9daa599e59d8eeeed9a27 \ No newline at end of file +997f765bc6706769ae15f3e719354473e02bd78b \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 5251d0cd26..b1775a4082 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -279,7 +279,7 @@ const char *sqlite3JournalModename(int eMode){ ** Locate a pragma in the aPragmaName[] array. */ static const PragmaName *pragmaLocate(const char *zName){ - int upr, lwr, mid, rc; + int upr, lwr, mid = 0, rc; lwr = 0; upr = ArraySize(aPragmaName)-1; while( lwr<=upr ){ From 2fa517bf2a8dbc4e76464675a0e5ef5af776bfa3 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 1 Feb 2017 22:59:29 +0000 Subject: [PATCH 31/43] Fix C99-style variable declaration issue seen with older versions of MSVC. FossilOrigin-Name: 54d285464a222c59327eb6c917c1cc0125a55a27 --- ext/rtree/rtree.c | 5 ++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index ac76c18485..fe89835972 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -450,20 +450,23 @@ static void readCoord(u8 *p, RtreeCoord *pCoord){ #endif } static i64 readInt64(u8 *p){ - testcase( ((((char*)p) - (char*)0)&7)!=0 ); /* not always 8-byte aligned */ #if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 u64 x; + testcase( ((((char*)p) - (char*)0)&7)!=0 ); /* not always 8-byte aligned */ memcpy(&x, p, 8); return (i64)_byteswap_uint64(x); #elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) u64 x; + testcase( ((((char*)p) - (char*)0)&7)!=0 ); /* not always 8-byte aligned */ memcpy(&x, p, 8); return (i64)__builtin_bswap64(x); #elif SQLITE_BYTEORDER==4321 i64 x; + testcase( ((((char*)p) - (char*)0)&7)!=0 ); /* not always 8-byte aligned */ memcpy(&x, p, 8); return x; #else + testcase( ((((char*)p) - (char*)0)&7)!=0 ); /* not always 8-byte aligned */ return ( (((i64)p[0]) << 56) + (((i64)p[1]) << 48) + diff --git a/manifest b/manifest index 2bea70b5b4..aa07fecd68 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\soption\sto\sthe\sMSVC\smakefile\sto\senable\streating\swarnings\sas\serrors. -D 2017-02-01T22:32:49.021 +C Fix\sC99-style\svariable\sdeclaration\sissue\sseen\swith\solder\sversions\sof\sMSVC. +D 2017-02-01T22:59:29.767 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c f2c8604fcdbe13f960c5f0b97acbc2a870b72bf2 +F ext/rtree/rtree.c 58d3fa51e270b93e1d4ceb7ffb5c0f3b85cb4129 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -1552,7 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4854ea9c18e7d8066c90b41568d0fae97b01ea6d -R edeb8ee1db3973795f07ac14a992bc66 +P 6a378c29b43d61313ca9daa599e59d8eeeed9a27 +R 464fa6ae427ab1455a9a5204291b6a50 U mistachkin -Z 3bfb007e12a85d09e541803b4d02a604 +Z 85455f002136d0ca47deec93d577c815 diff --git a/manifest.uuid b/manifest.uuid index 72864f657b..93c65ce658 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a378c29b43d61313ca9daa599e59d8eeeed9a27 \ No newline at end of file +54d285464a222c59327eb6c917c1cc0125a55a27 \ No newline at end of file From 5f7b95f73b9b6e157a9cfb90836dbac42cd4c97b Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 1 Feb 2017 23:03:54 +0000 Subject: [PATCH 32/43] Backout the change in [02f6293f27] as it causes MSVC to complain. FossilOrigin-Name: aaae74d06f4865818465cfdb440258ae8a5b985a --- manifest | 13 +++++++------ manifest.uuid | 2 +- src/vdbe.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index aa07fecd68..257674eec1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sC99-style\svariable\sdeclaration\sissue\sseen\swith\solder\sversions\sof\sMSVC. -D 2017-02-01T22:59:29.767 +C Backout\sthe\schange\sin\s[02f6293f27]\sas\sit\scauses\sMSVC\sto\scomplain. +D 2017-02-01T23:03:54.479 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -460,7 +460,7 @@ F src/update.c 456d4a4656f8a03c2abc88a51b19172197400e58 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c a88b0466fddf445ce752226d4698ca3faada620a F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16 -F src/vdbe.c ec059d331da77cb2e3e8af3fb7e40443ed148fbd +F src/vdbe.c e7b1e860140f1d1803c6f4176b1e8f3801f3a290 F src/vdbe.h 59998ffd71d7caa8886bc78dafaf8caeccd4c13c F src/vdbeInt.h 4e4b15b2e1330e1636e4e01974eab2b0b985092f F src/vdbeapi.c 3e4a8893feeb78620f4aac4ac5b85d92255b97e1 @@ -1552,7 +1552,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6a378c29b43d61313ca9daa599e59d8eeeed9a27 -R 464fa6ae427ab1455a9a5204291b6a50 +P 54d285464a222c59327eb6c917c1cc0125a55a27 +Q -02f6293f278f7b0a0f4876f5c6a0f4dc42620d79 +R c167920e65eb1311d91ae6d6e9361130 U mistachkin -Z 85455f002136d0ca47deec93d577c815 +Z 464bc0b25a9ceacfcf91d7e8480e3c64 diff --git a/manifest.uuid b/manifest.uuid index 93c65ce658..6df479bdb3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -54d285464a222c59327eb6c917c1cc0125a55a27 \ No newline at end of file +aaae74d06f4865818465cfdb440258ae8a5b985a \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index c8b3db8cf2..cb8a039abb 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -562,7 +562,7 @@ int sqlite3VdbeExec( Vdbe *p /* The VDBE */ ){ Op *aOp = p->aOp; /* Copy of p->aOp */ - Op *pOp; /* Current operation */ + Op *pOp = aOp; /* Current operation */ #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE) Op *pOrigOp; /* Value of pOp at the top of the loop */ #endif From 2343c7eb3f0f6fbb4d3719a09ac31bfb33a357d4 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 2 Feb 2017 00:46:55 +0000 Subject: [PATCH 33/43] This is an experimental patch that ensures that all cursors have their position saved prior to starting a ROLLBACK TO. FossilOrigin-Name: 01d97e5b6502b1811b52a681f445e1aaae6c0ee6 --- manifest | 18 ++++++++++-------- manifest.uuid | 2 +- src/btree.c | 7 ++++++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 6459c8e5ad..4cc36f422d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. -D 2017-02-01T23:06:17.747 +C This\sis\san\sexperimental\spatch\sthat\sensures\sthat\sall\scursors\shave\stheir\sposition\nsaved\sprior\sto\sstarting\sa\sROLLBACK\sTO. +D 2017-02-02T00:46:55.000 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -336,7 +336,7 @@ F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca -F src/btree.c 6a63fa34e6fe86e87090e41963c0f2fcf9d3e16d +F src/btree.c 9fe65ab418d99e80289f024016b5e5e74c3059dd F src/btree.h e6d352808956ec163a17f832193a3e198b3fb0ac F src/btreeInt.h 10c4b77c2fb399580babbcc7cf652ac10dba796e F src/build.c 9e799f1edd910dfa8a0bc29bd390d35d310596af @@ -1552,8 +1552,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P aaae74d06f4865818465cfdb440258ae8a5b985a 997f765bc6706769ae15f3e719354473e02bd78b -R 939bce209d57b72db3d58f9894d61374 -T +closed 997f765bc6706769ae15f3e719354473e02bd78b -U mistachkin -Z c2a7081e9858115a573bd4695718af54 +P 0c66cf0f0a9ada2ddcb8d61001ef791b86226416 +R 329580c21139f900f64001f6acfc9557 +T *branch * savepoint-rollback +T *sym-savepoint-rollback * +T -sym-trunk * +U drh +Z 5087946e64391fb6ac59f69d722efdd6 diff --git a/manifest.uuid b/manifest.uuid index 0e34341685..9d5ad1c981 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0c66cf0f0a9ada2ddcb8d61001ef791b86226416 \ No newline at end of file +01d97e5b6502b1811b52a681f445e1aaae6c0ee6 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 45a1c5a0f8..de553423b8 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4038,7 +4038,12 @@ int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){ assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK ); assert( iSavepoint>=0 || (iSavepoint==-1 && op==SAVEPOINT_ROLLBACK) ); sqlite3BtreeEnter(p); - rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint); + if( op==SAVEPOINT_ROLLBACK ){ + rc = saveAllCursors(pBt, 0, 0); + } + if( rc==SQLITE_OK ){ + rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint); + } if( rc==SQLITE_OK ){ if( iSavepoint<0 && (pBt->btsFlags & BTS_INITIALLY_EMPTY)!=0 ){ pBt->nPage = 0; From 6d683c5c6e7cfbd3393f64e6520caef5a5921a53 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 2 Feb 2017 02:28:45 +0000 Subject: [PATCH 34/43] Use the sqlite3_blob interface for reading values from the %_node shadow table in RTREE. This is a work in progress. There are still some minor problems. FossilOrigin-Name: fc4917d730b29b0bf60fea5e0166728635783e9c --- ext/rtree/rtree.c | 106 ++++++++++++++++++++++++++++++++++------------ manifest | 18 ++++---- manifest.uuid | 2 +- 3 files changed, 88 insertions(+), 38 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 66cca987da..eae9ef819a 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -133,6 +133,9 @@ struct Rtree { RtreeNode *pDeleted; int iReinsertHeight; /* Height of sub-trees Reinsert() has run on */ + /* Blob I/O on xxx_node */ + sqlite3_blob *pNodeBlob; + /* Statements to read/write/delete a record from xxx_node */ sqlite3_stmt *pReadNode; sqlite3_stmt *pWriteNode; @@ -615,6 +618,16 @@ static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){ return pNode; } +/* +** Clear the Rtree.pNodeBlob object +*/ +static void nodeBlobReset(Rtree *pRtree){ + if( pRtree->pNodeBlob ){ + sqlite3_blob_close(pRtree->pNodeBlob); + pRtree->pNodeBlob = 0; + } +} + /* ** Obtain a reference to an r-tree node. */ @@ -624,9 +637,8 @@ static int nodeAcquire( RtreeNode *pParent, /* Either the parent node or NULL */ RtreeNode **ppNode /* OUT: Acquired node */ ){ - int rc; - int rc2 = SQLITE_OK; - RtreeNode *pNode; + int rc = SQLITE_OK; + RtreeNode *pNode = 0; /* Check if the requested node is already in the hash table. If so, ** increase its reference count and return it. @@ -642,28 +654,42 @@ static int nodeAcquire( return SQLITE_OK; } - sqlite3_bind_int64(pRtree->pReadNode, 1, iNode); - rc = sqlite3_step(pRtree->pReadNode); - if( rc==SQLITE_ROW ){ - const u8 *zBlob = sqlite3_column_blob(pRtree->pReadNode, 0); - if( pRtree->iNodeSize==sqlite3_column_bytes(pRtree->pReadNode, 0) ){ - pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize); - if( !pNode ){ - rc2 = SQLITE_NOMEM; - }else{ - pNode->pParent = pParent; - pNode->zData = (u8 *)&pNode[1]; - pNode->nRef = 1; - pNode->iNode = iNode; - pNode->isDirty = 0; - pNode->pNext = 0; - memcpy(pNode->zData, zBlob, pRtree->iNodeSize); - nodeReference(pParent); - } + if( pRtree->pNodeBlob ){ + sqlite3_blob *pBlob = pRtree->pNodeBlob; + pRtree->pNodeBlob = 0; + rc = sqlite3_blob_reopen(pBlob, iNode); + pRtree->pNodeBlob = pBlob; + if( rc ){ + nodeBlobReset(pRtree); + if( rc==SQLITE_NOMEM ) return rc; + } + } + if( pRtree->pNodeBlob==0 ){ + char *zTab = sqlite3_mprintf("%s_node", pRtree->zName); + if( zTab==0 ) return SQLITE_NOMEM; + rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, zTab, "data", iNode, 0, + &pRtree->pNodeBlob); + sqlite3_free(zTab); + } + if( rc ){ + nodeBlobReset(pRtree); + *ppNode = 0; + }else if( pRtree->iNodeSize==sqlite3_blob_bytes(pRtree->pNodeBlob) ){ + pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize); + if( !pNode ){ + rc = SQLITE_NOMEM; + }else{ + pNode->pParent = pParent; + pNode->zData = (u8 *)&pNode[1]; + pNode->nRef = 1; + pNode->iNode = iNode; + pNode->isDirty = 0; + pNode->pNext = 0; + rc = sqlite3_blob_read(pRtree->pNodeBlob, pNode->zData, + pRtree->iNodeSize, 0); + nodeReference(pParent); } } - rc = sqlite3_reset(pRtree->pReadNode); - if( rc==SQLITE_OK ) rc = rc2; /* If the root node was just loaded, set pRtree->iDepth to the height ** of the r-tree structure. A height of zero means all data is stored on @@ -909,6 +935,7 @@ static void rtreeReference(Rtree *pRtree){ static void rtreeRelease(Rtree *pRtree){ pRtree->nBusy--; if( pRtree->nBusy==0 ){ + nodeBlobReset(pRtree); sqlite3_finalize(pRtree->pReadNode); sqlite3_finalize(pRtree->pWriteNode); sqlite3_finalize(pRtree->pDeleteNode); @@ -947,6 +974,7 @@ static int rtreeDestroy(sqlite3_vtab *pVtab){ if( !zCreate ){ rc = SQLITE_NOMEM; }else{ + nodeBlobReset(pRtree); rc = sqlite3_exec(pRtree->db, zCreate, 0, 0, 0); sqlite3_free(zCreate); } @@ -3152,6 +3180,27 @@ constraint: return rc; } +/* +** Called when a transaction starts. +** This is a no-op. But the Virtual Table mechanism needs a method +** here or else it will never call the xRollback and xCommit methods, +** and those methods are necessary for clearing the sqlite3_blob object. +*/ +static int rtreeBeginTransaction(sqlite3_vtab *pVtab){ + (void)pVtab; + return SQLITE_OK; +} + +/* +** Called when a transaction completes (either by COMMIT or ROLLBACK). +** The sqlite3_blob object should be released at this point. +*/ +static int rtreeEndTransaction(sqlite3_vtab *pVtab){ + Rtree *pRtree = (Rtree *)pVtab; + nodeBlobReset(pRtree); + return SQLITE_OK; +} + /* ** The xRename method for rtree module virtual tables. */ @@ -3173,6 +3222,7 @@ static int rtreeRename(sqlite3_vtab *pVtab, const char *zNewName){ return rc; } + /* ** This function populates the pRtree->nRowEst variable with an estimate ** of the number of rows in the virtual table. If possible, this is based @@ -3232,15 +3282,15 @@ static sqlite3_module rtreeModule = { rtreeColumn, /* xColumn - read data */ rtreeRowid, /* xRowid - read data */ rtreeUpdate, /* xUpdate - write data */ - 0, /* xBegin - begin transaction */ + rtreeBeginTransaction, /* xBegin - begin transaction */ 0, /* xSync - sync transaction */ - 0, /* xCommit - commit transaction */ - 0, /* xRollback - rollback transaction */ + rtreeEndTransaction, /* xCommit - commit transaction */ + rtreeEndTransaction, /* xRollback - rollback transaction */ 0, /* xFindFunction - function overloading */ rtreeRename, /* xRename - rename the table */ 0, /* xSavepoint */ 0, /* xRelease */ - 0 /* xRollbackTo */ + 0, /* xRollbackTo */ }; static int rtreeSqlInit( @@ -3440,7 +3490,7 @@ static int rtreeInit( pRtree->zDb = (char *)&pRtree[1]; pRtree->zName = &pRtree->zDb[nDb+1]; pRtree->nDim = (u8)((argc-4)/2); - pRtree->nDim2 = argc - 4; + pRtree->nDim2 = pRtree->nDim*2; pRtree->nBytesPerCell = 8 + pRtree->nDim2*4; pRtree->eCoordType = (u8)eCoordType; memcpy(pRtree->zDb, argv[1], nDb); diff --git a/manifest b/manifest index 4cc36f422d..65dc3b7b4d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C This\sis\san\sexperimental\spatch\sthat\sensures\sthat\sall\scursors\shave\stheir\sposition\nsaved\sprior\sto\sstarting\sa\sROLLBACK\sTO. -D 2017-02-02T00:46:55.000 +C Use\sthe\ssqlite3_blob\sinterface\sfor\sreading\svalues\sfrom\sthe\s%_node\sshadow\ntable\sin\sRTREE.\s\sThis\sis\sa\swork\sin\sprogress.\s\sThere\sare\sstill\ssome\sminor\nproblems. +D 2017-02-02T02:28:45.543 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 70f2488eef5c04dccf15a52cbd4961492124f825 +F ext/rtree/rtree.c 73c4308585c47a7500b9e98617e45a62f8564ddb F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -1552,10 +1552,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 0c66cf0f0a9ada2ddcb8d61001ef791b86226416 -R 329580c21139f900f64001f6acfc9557 -T *branch * savepoint-rollback -T *sym-savepoint-rollback * -T -sym-trunk * +P 01d97e5b6502b1811b52a681f445e1aaae6c0ee6 +R 79c2c34c9473af6d4e0161547969b398 +T *branch * rtree-sqlite3_blob +T *sym-rtree-sqlite3_blob * +T -sym-savepoint-rollback * U drh -Z 5087946e64391fb6ac59f69d722efdd6 +Z fc394298cc4191cf41d9c752fa550c9c diff --git a/manifest.uuid b/manifest.uuid index 9d5ad1c981..099f46fdff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -01d97e5b6502b1811b52a681f445e1aaae6c0ee6 \ No newline at end of file +fc4917d730b29b0bf60fea5e0166728635783e9c \ No newline at end of file From 2033d1c8ca2698a874709b87c04caba559985985 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 2 Feb 2017 14:40:06 +0000 Subject: [PATCH 35/43] Change RTREE so that the sqlite3_blob object is closed whenever the cursor count drops to zero and there is not a pending write transaction. FossilOrigin-Name: 9bb4eafe1a60176ed2e731bb7e3067c0b8a46615 --- ext/rtree/rtree.c | 26 +++++++++++++++++++------- ext/rtree/rtreeA.test | 2 +- manifest | 17 +++++++---------- manifest.uuid | 2 +- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index eae9ef819a..92ddcf526e 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -119,11 +119,13 @@ struct Rtree { u8 nDim2; /* Twice the number of dimensions */ u8 eCoordType; /* RTREE_COORD_REAL32 or RTREE_COORD_INT32 */ u8 nBytesPerCell; /* Bytes consumed per cell */ + u8 inWrTrans; /* True if inside write transaction */ int iDepth; /* Current depth of the r-tree structure */ char *zDb; /* Name of database containing r-tree table */ char *zName; /* Name of r-tree table */ - int nBusy; /* Current number of users of this structure */ + u32 nBusy; /* Current number of users of this structure */ i64 nRowEst; /* Estimated number of rows in this table */ + u32 nCursor; /* Number of open cursors */ /* List of nodes removed during a CondenseTree operation. List is ** linked together via the pointer normally used for hash chains - @@ -622,7 +624,7 @@ static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){ ** Clear the Rtree.pNodeBlob object */ static void nodeBlobReset(Rtree *pRtree){ - if( pRtree->pNodeBlob ){ + if( pRtree->pNodeBlob && pRtree->inWrTrans==0 && pRtree->nCursor==0 ){ sqlite3_blob_close(pRtree->pNodeBlob); pRtree->pNodeBlob = 0; } @@ -661,7 +663,7 @@ static int nodeAcquire( pRtree->pNodeBlob = pBlob; if( rc ){ nodeBlobReset(pRtree); - if( rc==SQLITE_NOMEM ) return rc; + if( rc==SQLITE_NOMEM ) return SQLITE_NOMEM; } } if( pRtree->pNodeBlob==0 ){ @@ -674,6 +676,9 @@ static int nodeAcquire( if( rc ){ nodeBlobReset(pRtree); *ppNode = 0; + /* If unable to open an sqlite3_blob on the desired row, that can only + ** be because the shadow tables hold erroneous data. */ + if( rc==SQLITE_ERROR ) rc = SQLITE_CORRUPT_VTAB; }else if( pRtree->iNodeSize==sqlite3_blob_bytes(pRtree->pNodeBlob) ){ pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize); if( !pNode ){ @@ -935,6 +940,8 @@ static void rtreeReference(Rtree *pRtree){ static void rtreeRelease(Rtree *pRtree){ pRtree->nBusy--; if( pRtree->nBusy==0 ){ + pRtree->inWrTrans = 0; + pRtree->nCursor = 0; nodeBlobReset(pRtree); sqlite3_finalize(pRtree->pReadNode); sqlite3_finalize(pRtree->pWriteNode); @@ -990,6 +997,7 @@ static int rtreeDestroy(sqlite3_vtab *pVtab){ */ static int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ int rc = SQLITE_NOMEM; + Rtree *pRtree = (Rtree *)pVTab; RtreeCursor *pCsr; pCsr = (RtreeCursor *)sqlite3_malloc(sizeof(RtreeCursor)); @@ -997,6 +1005,7 @@ static int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ memset(pCsr, 0, sizeof(RtreeCursor)); pCsr->base.pVtab = pVTab; rc = SQLITE_OK; + pRtree->nCursor++; } *ppCursor = (sqlite3_vtab_cursor *)pCsr; @@ -1029,10 +1038,13 @@ static int rtreeClose(sqlite3_vtab_cursor *cur){ Rtree *pRtree = (Rtree *)(cur->pVtab); int ii; RtreeCursor *pCsr = (RtreeCursor *)cur; + assert( pRtree->nCursor>0 ); freeCursorConstraints(pCsr); sqlite3_free(pCsr->aPoint); for(ii=0; iiaNode[ii]); sqlite3_free(pCsr); + pRtree->nCursor--; + nodeBlobReset(pRtree); return SQLITE_OK; } @@ -3182,12 +3194,11 @@ constraint: /* ** Called when a transaction starts. -** This is a no-op. But the Virtual Table mechanism needs a method -** here or else it will never call the xRollback and xCommit methods, -** and those methods are necessary for clearing the sqlite3_blob object. */ static int rtreeBeginTransaction(sqlite3_vtab *pVtab){ - (void)pVtab; + Rtree *pRtree = (Rtree *)pVtab; + assert( pRtree->inWrTrans==0 ); + pRtree->inWrTrans++; return SQLITE_OK; } @@ -3197,6 +3208,7 @@ static int rtreeBeginTransaction(sqlite3_vtab *pVtab){ */ static int rtreeEndTransaction(sqlite3_vtab *pVtab){ Rtree *pRtree = (Rtree *)pVtab; + pRtree->inWrTrans = 0; nodeBlobReset(pRtree); return SQLITE_OK; } diff --git a/ext/rtree/rtreeA.test b/ext/rtree/rtreeA.test index e377b013c1..84644e9ede 100644 --- a/ext/rtree/rtreeA.test +++ b/ext/rtree/rtreeA.test @@ -109,7 +109,7 @@ do_corruption_tests rtreeA-1.1 { } do_execsql_test rtreeA-1.2.0 { DROP TABLE t1_node } {} -do_corruption_tests rtreeA-1.2 -error "SQL logic error or missing database" { +do_corruption_tests rtreeA-1.2 -error "database disk image is malformed" { 1 "SELECT * FROM t1" 2 "SELECT * FROM t1 WHERE rowid=5" 3 "INSERT INTO t1 VALUES(1000, 1, 2, 3, 4)" diff --git a/manifest b/manifest index 65dc3b7b4d..5b06a60ca8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sthe\ssqlite3_blob\sinterface\sfor\sreading\svalues\sfrom\sthe\s%_node\sshadow\ntable\sin\sRTREE.\s\sThis\sis\sa\swork\sin\sprogress.\s\sThere\sare\sstill\ssome\sminor\nproblems. -D 2017-02-02T02:28:45.543 +C Change\sRTREE\sso\sthat\sthe\ssqlite3_blob\sobject\sis\sclosed\swhenever\sthe\scursor\ncount\sdrops\sto\szero\sand\sthere\sis\snot\sa\spending\swrite\stransaction. +D 2017-02-02T14:40:06.876 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 73c4308585c47a7500b9e98617e45a62f8564ddb +F ext/rtree/rtree.c df33d86df608a16516a95c6d184a5ed9988d2bc9 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -275,7 +275,7 @@ F ext/rtree/rtree6.test 773a90db2dce6a8353dd0d5b64bca69b29761196 F ext/rtree/rtree7.test 1fa710b9e6bf997a0c1a537b81be7bb6fded1971 F ext/rtree/rtree8.test db79c812f9e4a11f9b1f3f9934007884610a713a F ext/rtree/rtree9.test b5eb13849545dfd271a54ff16784cb00d8792aea -F ext/rtree/rtreeA.test ace05e729a36e342d40cf94e9efc7b4723d9dcdf +F ext/rtree/rtreeA.test ac8b503931f2f397cc3c3303354e1e085dcadb86 F ext/rtree/rtreeB.test c85f9ce78766c4e68b8b89fbf2979ee9cfa82b4e F ext/rtree/rtreeC.test c0a9c67f2efa98b6fae12acb8a28348d231a481d F ext/rtree/rtreeD.test bdfaaf26df8b4eea7364039aca9150bc1e1f8825 @@ -1552,10 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 01d97e5b6502b1811b52a681f445e1aaae6c0ee6 -R 79c2c34c9473af6d4e0161547969b398 -T *branch * rtree-sqlite3_blob -T *sym-rtree-sqlite3_blob * -T -sym-savepoint-rollback * +P fc4917d730b29b0bf60fea5e0166728635783e9c +R 0b53bd94b2e2abfad755fb806046ae11 U drh -Z fc394298cc4191cf41d9c752fa550c9c +Z 9c59d9d407f6159f87ae8b113cdc33c2 diff --git a/manifest.uuid b/manifest.uuid index 099f46fdff..0b51f62de3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fc4917d730b29b0bf60fea5e0166728635783e9c \ No newline at end of file +9bb4eafe1a60176ed2e731bb7e3067c0b8a46615 \ No newline at end of file From 413e207e316ae584dd2218905ab02522cc8e5a33 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 2 Feb 2017 15:35:54 +0000 Subject: [PATCH 36/43] The sqlite3_blob_close() interface can cause recursive invocations of nodeBlobReset() in RTREE. Make sure that does not cause problems. FossilOrigin-Name: 88333441cbf26bfde2acebf2a3f75b5ebbdfb0ae --- ext/rtree/rtree.c | 3 ++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 92ddcf526e..c5998d2548 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -625,8 +625,9 @@ static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){ */ static void nodeBlobReset(Rtree *pRtree){ if( pRtree->pNodeBlob && pRtree->inWrTrans==0 && pRtree->nCursor==0 ){ - sqlite3_blob_close(pRtree->pNodeBlob); + sqlite3_blob *pBlob = pRtree->pNodeBlob; pRtree->pNodeBlob = 0; + sqlite3_blob_close(pBlob); } } diff --git a/manifest b/manifest index 5b06a60ca8..f8a355c0e7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sRTREE\sso\sthat\sthe\ssqlite3_blob\sobject\sis\sclosed\swhenever\sthe\scursor\ncount\sdrops\sto\szero\sand\sthere\sis\snot\sa\spending\swrite\stransaction. -D 2017-02-02T14:40:06.876 +C The\ssqlite3_blob_close()\sinterface\scan\scause\srecursive\sinvocations\sof\nnodeBlobReset()\sin\sRTREE.\s\sMake\ssure\sthat\sdoes\snot\scause\sproblems. +D 2017-02-02T15:35:54.700 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c df33d86df608a16516a95c6d184a5ed9988d2bc9 +F ext/rtree/rtree.c 93fd417d6f566caa49a548c915a27125a1b405c3 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -1552,7 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P fc4917d730b29b0bf60fea5e0166728635783e9c -R 0b53bd94b2e2abfad755fb806046ae11 +P 9bb4eafe1a60176ed2e731bb7e3067c0b8a46615 +R 6cebe0517919da4320850125e35977ce U drh -Z 9c59d9d407f6159f87ae8b113cdc33c2 +Z 7ae516135e0fc0897102b9fc210a106c diff --git a/manifest.uuid b/manifest.uuid index 0b51f62de3..ee09db23cc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9bb4eafe1a60176ed2e731bb7e3067c0b8a46615 \ No newline at end of file +88333441cbf26bfde2acebf2a3f75b5ebbdfb0ae \ No newline at end of file From ce655a236773fafcd3ce751b23cd217a96e5467b Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 2 Feb 2017 16:08:27 +0000 Subject: [PATCH 37/43] Fix a potential uninitialized (though harmless) variable in RTREE. FossilOrigin-Name: a1c74e09d63aca630d022ed074866433eed6b493 --- ext/rtree/rtree.c | 6 +++--- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index c5998d2548..432c72781e 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1118,7 +1118,6 @@ static int rtreeCallbackConstraint( sqlite3_rtree_dbl *prScore, /* OUT: score for the cell */ int *peWithin /* OUT: visibility of the cell */ ){ - int i; /* Loop counter */ sqlite3_rtree_query_info *pInfo = pConstraint->pInfo; /* Callback info */ int nCoord = pInfo->nCoord; /* No. of coordinates */ int rc; /* Callback return code */ @@ -1163,9 +1162,10 @@ static int rtreeCallbackConstraint( } } if( pConstraint->op==RTREE_MATCH ){ + int eWithin = 0; rc = pConstraint->u.xGeom((sqlite3_rtree_geometry*)pInfo, - nCoord, aCoord, &i); - if( i==0 ) *peWithin = NOT_WITHIN; + nCoord, aCoord, &eWithin); + if( eWithin==0 ) *peWithin = NOT_WITHIN; *prScore = RTREE_ZERO; }else{ pInfo->aCoord = aCoord; diff --git a/manifest b/manifest index f8a355c0e7..0fcd596e1e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\ssqlite3_blob_close()\sinterface\scan\scause\srecursive\sinvocations\sof\nnodeBlobReset()\sin\sRTREE.\s\sMake\ssure\sthat\sdoes\snot\scause\sproblems. -D 2017-02-02T15:35:54.700 +C Fix\sa\spotential\suninitialized\s(though\sharmless)\svariable\sin\sRTREE. +D 2017-02-02T16:08:27.041 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 93fd417d6f566caa49a548c915a27125a1b405c3 +F ext/rtree/rtree.c e1b77d0f32241f3c09ab0bc7cf7be5d263902978 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -1552,7 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9bb4eafe1a60176ed2e731bb7e3067c0b8a46615 -R 6cebe0517919da4320850125e35977ce +P 88333441cbf26bfde2acebf2a3f75b5ebbdfb0ae +R 6c083917a4ecdc09328902e3d7d74ce0 U drh -Z 7ae516135e0fc0897102b9fc210a106c +Z 3e4bf024e32b2f321d57a48b2d7cd9ed diff --git a/manifest.uuid b/manifest.uuid index ee09db23cc..507bf4c42c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -88333441cbf26bfde2acebf2a3f75b5ebbdfb0ae \ No newline at end of file +a1c74e09d63aca630d022ed074866433eed6b493 \ No newline at end of file From 3accc7e1af59b89cc54df381ddf67dc96487103f Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 2 Feb 2017 16:30:25 +0000 Subject: [PATCH 38/43] Remove the unused pReadNode prepared statement from each RTREE object. FossilOrigin-Name: e51dc0ec60d45cd57564735b6b2bb254a588533e --- ext/rtree/rtree.c | 24 ++++++++++-------------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 432c72781e..9e6f0e082a 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -139,7 +139,6 @@ struct Rtree { sqlite3_blob *pNodeBlob; /* Statements to read/write/delete a record from xxx_node */ - sqlite3_stmt *pReadNode; sqlite3_stmt *pWriteNode; sqlite3_stmt *pDeleteNode; @@ -944,7 +943,6 @@ static void rtreeRelease(Rtree *pRtree){ pRtree->inWrTrans = 0; pRtree->nCursor = 0; nodeBlobReset(pRtree); - sqlite3_finalize(pRtree->pReadNode); sqlite3_finalize(pRtree->pWriteNode); sqlite3_finalize(pRtree->pDeleteNode); sqlite3_finalize(pRtree->pReadRowid); @@ -3315,10 +3313,9 @@ static int rtreeSqlInit( ){ int rc = SQLITE_OK; - #define N_STATEMENT 9 + #define N_STATEMENT 8 static const char *azSql[N_STATEMENT] = { - /* Read and write the xxx_node table */ - "SELECT data FROM '%q'.'%q_node' WHERE nodeno = :1", + /* Write the xxx_node table */ "INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(:1, :2)", "DELETE FROM '%q'.'%q_node' WHERE nodeno = :1", @@ -3356,15 +3353,14 @@ static int rtreeSqlInit( } } - appStmt[0] = &pRtree->pReadNode; - appStmt[1] = &pRtree->pWriteNode; - appStmt[2] = &pRtree->pDeleteNode; - appStmt[3] = &pRtree->pReadRowid; - appStmt[4] = &pRtree->pWriteRowid; - appStmt[5] = &pRtree->pDeleteRowid; - appStmt[6] = &pRtree->pReadParent; - appStmt[7] = &pRtree->pWriteParent; - appStmt[8] = &pRtree->pDeleteParent; + appStmt[0] = &pRtree->pWriteNode; + appStmt[1] = &pRtree->pDeleteNode; + appStmt[2] = &pRtree->pReadRowid; + appStmt[3] = &pRtree->pWriteRowid; + appStmt[4] = &pRtree->pDeleteRowid; + appStmt[5] = &pRtree->pReadParent; + appStmt[6] = &pRtree->pWriteParent; + appStmt[7] = &pRtree->pDeleteParent; rc = rtreeQueryStat1(db, pRtree); for(i=0; i Date: Thu, 2 Feb 2017 19:24:05 +0000 Subject: [PATCH 39/43] Fix issues in the sha1 extension seen with MSVC. FossilOrigin-Name: 5a0da77c22ebc7db5e63b1520d30f3ad97b9bb3b --- ext/misc/sha1.c | 42 +++++++++++++++++++++++++----------------- manifest | 13 ++++++------- manifest.uuid | 2 +- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/ext/misc/sha1.c b/ext/misc/sha1.c index dbf15a95ef..e2843bdefa 100644 --- a/ext/misc/sha1.c +++ b/ext/misc/sha1.c @@ -87,12 +87,6 @@ struct SHA1Context { /* * Hash a single 512-bit block. This is the core of the algorithm. */ -#define a qq[0] -#define b qq[1] -#define c qq[2] -#define d qq[3] -#define e qq[4] - void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){ unsigned int qq[5]; /* a, b, c, d, e; */ static int one = 1; @@ -100,6 +94,12 @@ void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){ memcpy(block, buffer, 64); memcpy(qq,state,5*sizeof(unsigned int)); +#define a qq[0] +#define b qq[1] +#define c qq[2] +#define d qq[3] +#define e qq[4] + /* Copy p->state[] to working vars */ /* a = state[0]; @@ -144,6 +144,12 @@ void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){ state[2] += c; state[3] += d; state[4] += e; + +#undef a +#undef b +#undef c +#undef d +#undef e } @@ -253,6 +259,7 @@ static void sha1Func( int nByte = sqlite3_value_bytes(argv[0]); char zOut[44]; + assert( argc==1 ); if( eType==SQLITE_NULL ) return; hash_init(&cx); if( eType==SQLITE_BLOB ){ @@ -292,6 +299,7 @@ static void sha1QueryFunc( SHA1Context cx; char zOut[44]; + assert( argc==1 ); if( zSql==0 ) return; hash_init(&cx); while( zSql[0] ){ @@ -343,7 +351,7 @@ static void sha1QueryFunc( case SQLITE_FLOAT: { sqlite3_uint64 u; int j; - unsigned char x[8]; + unsigned char x[9]; double r = sqlite3_column_double(pStmt,i); memcpy(&u, &r, 8); for(j=8; j>=1; j--){ @@ -355,17 +363,17 @@ static void sha1QueryFunc( break; } case SQLITE_TEXT: { - int n = sqlite3_column_bytes(pStmt, i); - const unsigned char *z = sqlite3_column_text(pStmt, i); - hash_step_vformat(&cx,"T%d:",n); - hash_step(&cx, z, n); + int n2 = sqlite3_column_bytes(pStmt, i); + const unsigned char *z2 = sqlite3_column_text(pStmt, i); + hash_step_vformat(&cx,"T%d:",n2); + hash_step(&cx, z2, n2); break; } case SQLITE_BLOB: { - int n = sqlite3_column_bytes(pStmt, i); - const unsigned char *z = sqlite3_column_blob(pStmt, i); - hash_step_vformat(&cx,"B%d:",n); - hash_step(&cx, z, n); + int n2 = sqlite3_column_bytes(pStmt, i); + const unsigned char *z2 = sqlite3_column_blob(pStmt, i); + hash_step_vformat(&cx,"B%d:",n2); + hash_step(&cx, z2, n2); break; } } @@ -382,8 +390,8 @@ static void sha1QueryFunc( __declspec(dllexport) #endif int sqlite3_sha_init( - sqlite3 *db, - char **pzErrMsg, + sqlite3 *db, + char **pzErrMsg, const sqlite3_api_routines *pApi ){ int rc = SQLITE_OK; diff --git a/manifest b/manifest index 6459c8e5ad..9d4630c832 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sseen\swith\sMSVC. -D 2017-02-01T23:06:17.747 +C Fix\sissues\sin\sthe\ssha1\sextension\sseen\swith\sMSVC. +D 2017-02-02T19:24:05.672 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -222,7 +222,7 @@ F ext/misc/remember.c 8440f8d0b452c5cdefb62b57135ccd1267aa729d F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a F ext/misc/scrub.c 1c5bfb8b0cd18b602fcb55755e84abf0023ac2fb F ext/misc/series.c e11e534ada797d5b816d7e7a93c022306563ca35 -F ext/misc/sha1.c b2e4eb8e26f09701ec15548395baf698f00e5895 +F ext/misc/sha1.c 0b9e9b855354910d3ca467bf39099d570e73db56 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c a4723b6aff748a417b5091b68a46443265c40f0d F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 @@ -1552,8 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P aaae74d06f4865818465cfdb440258ae8a5b985a 997f765bc6706769ae15f3e719354473e02bd78b -R 939bce209d57b72db3d58f9894d61374 -T +closed 997f765bc6706769ae15f3e719354473e02bd78b +P 0c66cf0f0a9ada2ddcb8d61001ef791b86226416 +R 531254e92dc453ecbaf40de729caeadd U mistachkin -Z c2a7081e9858115a573bd4695718af54 +Z 7da98715c0c2c155a034ba4275d6d8fe diff --git a/manifest.uuid b/manifest.uuid index 0e34341685..9e12c1be98 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0c66cf0f0a9ada2ddcb8d61001ef791b86226416 \ No newline at end of file +5a0da77c22ebc7db5e63b1520d30f3ad97b9bb3b \ No newline at end of file From a7466205ca7f5663605b48375ade5f7389d915a5 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 3 Feb 2017 14:44:52 +0000 Subject: [PATCH 40/43] Modify the sqlite3SelectDup() routine to avoid recursing on Select.pPrior. FossilOrigin-Name: a7674ead5be986c66f7d61d598adc7e5728bcd30 --- manifest | 18 +++++++++------- manifest.uuid | 2 +- src/expr.c | 60 +++++++++++++++++++++++++++++---------------------- 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/manifest b/manifest index a07bc6f332..24ce068e9c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sall\scursors\shave\stheir\spositions\ssaved\sprior\sto\srolling\sback\na\ssavepoint. -D 2017-02-02T20:32:28.731 +C Modify\sthe\ssqlite3SelectDup()\sroutine\sto\savoid\srecursing\son\sSelect.pPrior. +D 2017-02-03T14:44:52.406 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -346,7 +346,7 @@ F src/ctime.c 9f2296a4e5d26ebf0e0d95a0af4628f1ea694e7a F src/date.c dc3f1391d9297f8c748132813aaffcb117090d6e F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 0d9d5549d42e79ce4d82ff1db1e6c81e36d2f67c -F src/expr.c d7ef6fdb70bc18259d7d36b22aa0bc4845c5c5b9 +F src/expr.c d29114e9b709eaeaaa18553a5bbe60a19302aeef F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae F src/func.c c67273e1ec08abbdcc14c189892a3ff6eeece86b @@ -1552,8 +1552,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5a0da77c22ebc7db5e63b1520d30f3ad97b9bb3b 01d97e5b6502b1811b52a681f445e1aaae6c0ee6 -R f67fbd165c607c8ab8b9fb8cff6e4d0d -T +closed 01d97e5b6502b1811b52a681f445e1aaae6c0ee6 -U drh -Z d16d6898d272ff11e9984476ae1d9ef3 +P 8e03a8e95fada5c24d369672a71f6e02288051da +R c80f7dbbf5f0044354e4b463e716c13e +T *branch * recursive-selectdup +T *sym-recursive-selectdup * +T -sym-trunk * +U dan +Z f43da81961eb4c39992192293f7e5a2c diff --git a/manifest.uuid b/manifest.uuid index 792cc0b3a3..a72c232e1b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e03a8e95fada5c24d369672a71f6e02288051da \ No newline at end of file +a7674ead5be986c66f7d61d598adc7e5728bcd30 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 18035bd421..f1e8667b39 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1418,33 +1418,41 @@ IdList *sqlite3IdListDup(sqlite3 *db, IdList *p){ } return pNew; } -Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){ - Select *pNew, *pPrior; +Select *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){ + Select *pRet = 0; + Select *pNext = 0; + Select **pp = &pRet; + Select *p; + assert( db!=0 ); - if( p==0 ) return 0; - pNew = sqlite3DbMallocRawNN(db, sizeof(*p) ); - if( pNew==0 ) return 0; - pNew->pEList = sqlite3ExprListDup(db, p->pEList, flags); - pNew->pSrc = sqlite3SrcListDup(db, p->pSrc, flags); - pNew->pWhere = sqlite3ExprDup(db, p->pWhere, flags); - pNew->pGroupBy = sqlite3ExprListDup(db, p->pGroupBy, flags); - pNew->pHaving = sqlite3ExprDup(db, p->pHaving, flags); - pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, flags); - pNew->op = p->op; - pNew->pPrior = pPrior = sqlite3SelectDup(db, p->pPrior, flags); - if( pPrior ) pPrior->pNext = pNew; - pNew->pNext = 0; - pNew->pLimit = sqlite3ExprDup(db, p->pLimit, flags); - pNew->pOffset = sqlite3ExprDup(db, p->pOffset, flags); - pNew->iLimit = 0; - pNew->iOffset = 0; - pNew->selFlags = p->selFlags & ~SF_UsesEphemeral; - pNew->addrOpenEphm[0] = -1; - pNew->addrOpenEphm[1] = -1; - pNew->nSelectRow = p->nSelectRow; - pNew->pWith = withDup(db, p->pWith); - sqlite3SelectSetName(pNew, p->zSelName); - return pNew; + for(p=pDup; p; p=p->pPrior){ + Select *pNew = sqlite3DbMallocRawNN(db, sizeof(*p) ); + if( pNew==0 ) break; + pNew->pEList = sqlite3ExprListDup(db, p->pEList, flags); + pNew->pSrc = sqlite3SrcListDup(db, p->pSrc, flags); + pNew->pWhere = sqlite3ExprDup(db, p->pWhere, flags); + pNew->pGroupBy = sqlite3ExprListDup(db, p->pGroupBy, flags); + pNew->pHaving = sqlite3ExprDup(db, p->pHaving, flags); + pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, flags); + pNew->op = p->op; + pNew->pNext = pNext; + pNew->pPrior = 0; + pNew->pLimit = sqlite3ExprDup(db, p->pLimit, flags); + pNew->pOffset = sqlite3ExprDup(db, p->pOffset, flags); + pNew->iLimit = 0; + pNew->iOffset = 0; + pNew->selFlags = p->selFlags & ~SF_UsesEphemeral; + pNew->addrOpenEphm[0] = -1; + pNew->addrOpenEphm[1] = -1; + pNew->nSelectRow = p->nSelectRow; + pNew->pWith = withDup(db, p->pWith); + sqlite3SelectSetName(pNew, p->zSelName); + *pp = pNew; + pp = &pNew->pPrior; + pNext = pNew; + } + + return pRet; } #else Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){ From 59a40db3d2b5cbec56aa12cd0eee403a95c70933 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 3 Feb 2017 15:16:25 +0000 Subject: [PATCH 41/43] Improved tests for the carray() table-valued function. FossilOrigin-Name: 83a099f139aba03edac19c890a0019e922032a25 --- manifest | 13 ++++++------- manifest.uuid | 2 +- test/tabfunc01.test | 40 ++++++++++++++++++++++++---------------- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index a07bc6f332..b4fd3e2062 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sall\scursors\shave\stheir\spositions\ssaved\sprior\sto\srolling\sback\na\ssavepoint. -D 2017-02-02T20:32:28.731 +C Improved\stests\sfor\sthe\scarray()\stable-valued\sfunction. +D 2017-02-03T15:16:25.769 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -1155,7 +1155,7 @@ F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849 F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529 F test/syscall.test f59ba4e25f7ba4a4c031026cc2ef8b6e4b4c639c F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 -F test/tabfunc01.test 8b2ef53caa37854864c89e1e57e8a10efd4f5e43 +F test/tabfunc01.test 699251cb99651415218a891384510a685c7ab012 F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 @@ -1552,8 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 5a0da77c22ebc7db5e63b1520d30f3ad97b9bb3b 01d97e5b6502b1811b52a681f445e1aaae6c0ee6 -R f67fbd165c607c8ab8b9fb8cff6e4d0d -T +closed 01d97e5b6502b1811b52a681f445e1aaae6c0ee6 +P 8e03a8e95fada5c24d369672a71f6e02288051da +R 408679a2eb27f8712868946a0e8b1f65 U drh -Z d16d6898d272ff11e9984476ae1d9ef3 +Z 773cdc68fe82e971a45f4eb8ed248cd4 diff --git a/manifest.uuid b/manifest.uuid index 792cc0b3a3..14c0befdff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8e03a8e95fada5c24d369672a71f6e02288051da \ No newline at end of file +83a099f139aba03edac19c890a0019e922032a25 \ No newline at end of file diff --git a/test/tabfunc01.test b/test/tabfunc01.test index f25d070847..dcaafa420c 100644 --- a/test/tabfunc01.test +++ b/test/tabfunc01.test @@ -148,60 +148,68 @@ do_execsql_test tabfunc01-600 { do_test tabfunc01-700 { - set PTR [intarray_addr 5 7 13 17 23] + set PTR1 [intarray_addr 5 7 13 17 23] db eval { - SELECT b FROM t600, carray($PTR,5) WHERE a=value; + SELECT b FROM t600, carray($PTR1,5) WHERE a=value; } } {(005) (007) (013) (017) (023)} do_test tabfunc01-701 { db eval { - SELECT b FROM t600 WHERE a IN carray($PTR,5,'int32'); + SELECT b FROM t600 WHERE a IN carray($PTR1,5,'int32'); } } {(005) (007) (013) (017) (023)} do_test tabfunc01-702 { db eval { - SELECT b FROM t600 WHERE a IN carray($PTR,4,'int32'); + SELECT b FROM t600 WHERE a IN carray($PTR1,4,'int32'); } } {(005) (007) (013) (017)} do_catchsql_test tabfunc01-710 { - SELECT b FROM t600 WHERE a IN carray($PTR,5,'int33'); + SELECT b FROM t600 WHERE a IN carray($PTR1,5,'int33'); } {1 {unknown datatype: 'int33'}} do_test tabfunc01-720 { - set PTR [int64array_addr 5 7 13 17 23] + set PTR2 [int64array_addr 5 7 13 17 23] db eval { - SELECT b FROM t600, carray($PTR,5,'int64') WHERE a=value; + SELECT b FROM t600, carray($PTR2,5,'int64') WHERE a=value; } } {(005) (007) (013) (017) (023)} do_test tabfunc01-721 { db eval { - SELECT remember(123,$PTR); - SELECT value FROM carray($PTR,5,'int64'); + SELECT remember(123,$PTR2); + SELECT value FROM carray($PTR2,5,'int64'); } } {123 123 7 13 17 23} do_test tabfunc01-722 { - set PTR2 [expr {$PTR+16}] + set PTR3 [expr {$PTR2+16}] db eval { - SELECT remember(987,$PTR2); - SELECT value FROM carray($PTR,5,'int64'); + SELECT remember(987,$PTR3); + SELECT value FROM carray($PTR2,5,'int64'); } } {987 123 7 987 17 23} do_test tabfunc01-730 { - set PTR [doublearray_addr 5.0 7.0 13.0 17.0 23.0] + set PTR4 [doublearray_addr 5.0 7.0 13.0 17.0 23.0] db eval { - SELECT b FROM t600, carray($PTR,5,'double') WHERE a=value; + SELECT b FROM t600, carray($PTR4,5,'double') WHERE a=value; } } {(005) (007) (013) (017) (023)} do_test tabfunc01-740 { - set PTR [textarray_addr 5 7 13 17 23] + set PTR5 [textarray_addr x5 x7 x13 x17 x23] db eval { - SELECT b FROM t600, carray($PTR,5,'char*') WHERE a=value; + SELECT b FROM t600, carray($PTR5,5,'char*') WHERE a=trim(value,'x'); } } {(005) (007) (013) (017) (023)} +do_test tabfunc01-750 { + db eval { + SELECT aa.value, bb.value, '|' + FROM carray($PTR4,5,'double') AS aa + JOIN carray($PTR5,5,'char*') AS bb ON aa.rowid=bb.rowid; + } +} {5.0 x5 | 7.0 x7 | 13.0 x13 | 17.0 x17 | 23.0 x23 |} +# Free up memory allocations intarray_addr int64array_addr doublearray_addr From 067cd837fbe3014b8876dc4f752babcef0ce5506 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 3 Feb 2017 19:16:39 +0000 Subject: [PATCH 42/43] Avoid a performance problem when very large "VALUES(..), (..), (..)" terms are used in queries. FossilOrigin-Name: f5306ad6816cc377036685cdae227e762885229c --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/select.c | 28 ++++++++++++++++++---------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 24ce068e9c..9a2d78f7e1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sthe\ssqlite3SelectDup()\sroutine\sto\savoid\srecursing\son\sSelect.pPrior. -D 2017-02-03T14:44:52.406 +C Avoid\sa\sperformance\sproblem\swhen\svery\slarge\s"VALUES(..),\s(..),\s(..)"\sterms\sare\nused\sin\squeries. +D 2017-02-03T19:16:39.919 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -393,7 +393,7 @@ F src/printf.c ff10a9b9902cd2afe5f655f3013c6307d969b1fd F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c f9bc0de45a30a450da47b3766de00be89bf9be79 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac -F src/select.c 3856db523b942062bca8722ba03b61c324ff94d6 +F src/select.c d12f3539f80db38b09015561b569e0eb1c4b6c5f F src/shell.c a84e453c213f3e0d6935a582024da4e242f85a19 F src/sqlite.h.in 751ff125eb159c8f92c182b8df980a5e4f50e966 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1552,10 +1552,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8e03a8e95fada5c24d369672a71f6e02288051da -R c80f7dbbf5f0044354e4b463e716c13e -T *branch * recursive-selectdup -T *sym-recursive-selectdup * -T -sym-trunk * +P a7674ead5be986c66f7d61d598adc7e5728bcd30 +R 1275850dbdc882ce3db2a9a335b19414 U dan -Z f43da81961eb4c39992192293f7e5a2c +Z aab63e41186ee170ee1c431b74360517 diff --git a/manifest.uuid b/manifest.uuid index a72c232e1b..c0409900d6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a7674ead5be986c66f7d61d598adc7e5728bcd30 \ No newline at end of file +f5306ad6816cc377036685cdae227e762885229c \ No newline at end of file diff --git a/src/select.c b/src/select.c index ed6221309f..d817ebd074 100644 --- a/src/select.c +++ b/src/select.c @@ -4186,7 +4186,15 @@ static int withExpand( pCte->zCteErr = "circular reference: %s"; pSavedWith = pParse->pWith; pParse->pWith = pWith; - sqlite3WalkSelect(pWalker, bMayRecursive ? pSel->pPrior : pSel); + if( bMayRecursive ){ + Select *pPrior = pSel->pPrior; + assert( pPrior->pWith==0 ); + pPrior->pWith = pSel->pWith; + sqlite3WalkSelect(pWalker, pPrior); + pPrior->pWith = 0; + }else{ + sqlite3WalkSelect(pWalker, pSel); + } pParse->pWith = pWith; for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior); @@ -4230,10 +4238,12 @@ static int withExpand( */ static void selectPopWith(Walker *pWalker, Select *p){ Parse *pParse = pWalker->pParse; - With *pWith = findRightmost(p)->pWith; - if( pWith!=0 ){ - assert( pParse->pWith==pWith ); - pParse->pWith = pWith->pOuter; + if( pParse->pWith && p->pPrior==0 ){ + With *pWith = findRightmost(p)->pWith; + if( pWith!=0 ){ + assert( pParse->pWith==pWith ); + pParse->pWith = pWith->pOuter; + } } } #else @@ -4283,8 +4293,8 @@ static int selectExpander(Walker *pWalker, Select *p){ } pTabList = p->pSrc; pEList = p->pEList; - if( pWalker->xSelectCallback2==selectPopWith ){ - sqlite3WithPush(pParse, findRightmost(p)->pWith, 0); + if( p->pWith ){ + sqlite3WithPush(pParse, p->pWith, 0); } /* Make sure cursor numbers have been assigned to all entries in @@ -4571,9 +4581,7 @@ static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){ sqlite3WalkSelect(&w, pSelect); } w.xSelectCallback = selectExpander; - if( (pSelect->selFlags & SF_MultiValue)==0 ){ - w.xSelectCallback2 = selectPopWith; - } + w.xSelectCallback2 = selectPopWith; sqlite3WalkSelect(&w, pSelect); } From 010e312f8fd5f0e73ed83740c3778f3a4e354b35 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 4 Feb 2017 13:12:12 +0000 Subject: [PATCH 43/43] Close sqlite3_blob objects on xSync rather than waiting until xCommit. FossilOrigin-Name: 95ee745fceb4a48c683f34c404c380fe5e7d684a --- ext/rtree/rtree.c | 2 +- manifest | 15 +++++++++------ manifest.uuid | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 9e6f0e082a..c46bce7d37 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -3294,7 +3294,7 @@ static sqlite3_module rtreeModule = { rtreeRowid, /* xRowid - read data */ rtreeUpdate, /* xUpdate - write data */ rtreeBeginTransaction, /* xBegin - begin transaction */ - 0, /* xSync - sync transaction */ + rtreeEndTransaction, /* xSync - sync transaction */ rtreeEndTransaction, /* xCommit - commit transaction */ rtreeEndTransaction, /* xRollback - rollback transaction */ 0, /* xFindFunction - function overloading */ diff --git a/manifest b/manifest index ea1bf5a3bf..e59dba6295 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\sunused\spReadNode\sprepared\sstatement\sfrom\seach\sRTREE\sobject. -D 2017-02-02T16:30:25.555 +C Close\ssqlite3_blob\sobjects\son\sxSync\srather\sthan\swaiting\suntil\sxCommit. +D 2017-02-04T13:12:12.865 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc ba953c8921fc7e18333f61898007206de7e23964 @@ -264,7 +264,7 @@ F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318 F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c be9d44f5707c5a73887d3ac3ad14a355e9b92b58 +F ext/rtree/rtree.c ed39c157eab89ce014675f07601f2813c9f54e9c F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 42dadfc7b44a436cd74a1bebc0b9b689e4eaf7ec F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -1552,7 +1552,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a1c74e09d63aca630d022ed074866433eed6b493 -R b4b0a5df6a2ab40920c13363cd1d25e9 +P e51dc0ec60d45cd57564735b6b2bb254a588533e +R a16debe67e7399020e94d725cd2d4af7 +T *branch * rtree-blob-agressive-release +T *sym-rtree-blob-agressive-release * +T -sym-rtree-sqlite3_blob * U drh -Z 5406bbb7ccb82072da8c73ecd9c87865 +Z a61d538b0d9c1a9c54d88c1f71c254d7 diff --git a/manifest.uuid b/manifest.uuid index dda662b8b9..be149e116e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e51dc0ec60d45cd57564735b6b2bb254a588533e \ No newline at end of file +95ee745fceb4a48c683f34c404c380fe5e7d684a \ No newline at end of file