Merge in all version 3.8.9 changes from trunk.
FossilOrigin-Name: 301218704cfb6eebac32828b7b2dbc6803c63a26
This commit is contained in:
+47
-10
@@ -2502,26 +2502,33 @@ static int fts3DoclistOrMerge(
|
||||
**
|
||||
** The right-hand input doclist is overwritten by this function.
|
||||
*/
|
||||
static void fts3DoclistPhraseMerge(
|
||||
static int fts3DoclistPhraseMerge(
|
||||
int bDescDoclist, /* True if arguments are desc */
|
||||
int nDist, /* Distance from left to right (1=adjacent) */
|
||||
char *aLeft, int nLeft, /* Left doclist */
|
||||
char *aRight, int *pnRight /* IN/OUT: Right/output doclist */
|
||||
char **paRight, int *pnRight /* IN/OUT: Right/output doclist */
|
||||
){
|
||||
sqlite3_int64 i1 = 0;
|
||||
sqlite3_int64 i2 = 0;
|
||||
sqlite3_int64 iPrev = 0;
|
||||
char *aRight = *paRight;
|
||||
char *pEnd1 = &aLeft[nLeft];
|
||||
char *pEnd2 = &aRight[*pnRight];
|
||||
char *p1 = aLeft;
|
||||
char *p2 = aRight;
|
||||
char *p;
|
||||
int bFirstOut = 0;
|
||||
char *aOut = aRight;
|
||||
char *aOut;
|
||||
|
||||
assert( nDist>0 );
|
||||
|
||||
if( bDescDoclist ){
|
||||
aOut = sqlite3_malloc(*pnRight + FTS3_VARINT_MAX);
|
||||
if( aOut==0 ) return SQLITE_NOMEM;
|
||||
}else{
|
||||
aOut = aRight;
|
||||
}
|
||||
p = aOut;
|
||||
|
||||
fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);
|
||||
fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);
|
||||
|
||||
@@ -2550,6 +2557,12 @@ static void fts3DoclistPhraseMerge(
|
||||
}
|
||||
|
||||
*pnRight = (int)(p - aOut);
|
||||
if( bDescDoclist ){
|
||||
sqlite3_free(aRight);
|
||||
*paRight = aOut;
|
||||
}
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2674,8 +2687,22 @@ static int fts3TermSelectMerge(
|
||||
){
|
||||
if( pTS->aaOutput[0]==0 ){
|
||||
/* If this is the first term selected, copy the doclist to the output
|
||||
** buffer using memcpy(). */
|
||||
pTS->aaOutput[0] = sqlite3_malloc(nDoclist);
|
||||
** buffer using memcpy().
|
||||
**
|
||||
** Add FTS3_VARINT_MAX bytes of unused space to the end of the
|
||||
** allocation. This is so as to ensure that the buffer is big enough
|
||||
** to hold the current doclist AND'd with any other doclist. If the
|
||||
** doclists are stored in order=ASC order, this padding would not be
|
||||
** required (since the size of [doclistA AND doclistB] is always less
|
||||
** than or equal to the size of [doclistA] in that case). But this is
|
||||
** not true for order=DESC. For example, a doclist containing (1, -1)
|
||||
** may be smaller than (-1), as in the first example the -1 may be stored
|
||||
** as a single-byte delta, whereas in the second it must be stored as a
|
||||
** FTS3_VARINT_MAX byte varint.
|
||||
**
|
||||
** Similar padding is added in the fts3DoclistOrMerge() function.
|
||||
*/
|
||||
pTS->aaOutput[0] = sqlite3_malloc(nDoclist + FTS3_VARINT_MAX + 1);
|
||||
pTS->anOutput[0] = nDoclist;
|
||||
if( pTS->aaOutput[0] ){
|
||||
memcpy(pTS->aaOutput[0], aDoclist, nDoclist);
|
||||
@@ -3931,14 +3958,17 @@ static void fts3EvalAllocateReaders(
|
||||
** This function assumes that pList points to a buffer allocated using
|
||||
** sqlite3_malloc(). This function takes responsibility for eventually
|
||||
** freeing the buffer.
|
||||
**
|
||||
** SQLITE_OK is returned if successful, or SQLITE_NOMEM if an error occurs.
|
||||
*/
|
||||
static void fts3EvalPhraseMergeToken(
|
||||
static int fts3EvalPhraseMergeToken(
|
||||
Fts3Table *pTab, /* FTS Table pointer */
|
||||
Fts3Phrase *p, /* Phrase to merge pList/nList into */
|
||||
int iToken, /* Token pList/nList corresponds to */
|
||||
char *pList, /* Pointer to doclist */
|
||||
int nList /* Number of bytes in pList */
|
||||
){
|
||||
int rc = SQLITE_OK;
|
||||
assert( iToken!=p->iDoclistToken );
|
||||
|
||||
if( pList==0 ){
|
||||
@@ -3977,13 +4007,16 @@ static void fts3EvalPhraseMergeToken(
|
||||
nDiff = p->iDoclistToken - iToken;
|
||||
}
|
||||
|
||||
fts3DoclistPhraseMerge(pTab->bDescIdx, nDiff, pLeft, nLeft, pRight,&nRight);
|
||||
rc = fts3DoclistPhraseMerge(
|
||||
pTab->bDescIdx, nDiff, pLeft, nLeft, &pRight, &nRight
|
||||
);
|
||||
sqlite3_free(pLeft);
|
||||
p->doclist.aAll = pRight;
|
||||
p->doclist.nAll = nRight;
|
||||
}
|
||||
|
||||
if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4009,7 +4042,7 @@ static int fts3EvalPhraseLoad(
|
||||
char *pThis = 0;
|
||||
rc = fts3TermSelect(pTab, pToken, p->iColumn, &nThis, &pThis);
|
||||
if( rc==SQLITE_OK ){
|
||||
fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);
|
||||
rc = fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);
|
||||
}
|
||||
}
|
||||
assert( pToken->pSegcsr==0 );
|
||||
@@ -4811,9 +4844,13 @@ static int fts3EvalSelectDeferred(
|
||||
char *pList = 0;
|
||||
rc = fts3TermSelect(pTab, pToken, pTC->iCol, &nList, &pList);
|
||||
assert( rc==SQLITE_OK || pList==0 );
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = fts3EvalPhraseMergeToken(
|
||||
pTab, pTC->pPhrase, pTC->iToken,pList,nList
|
||||
);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
int nCount;
|
||||
fts3EvalPhraseMergeToken(pTab, pTC->pPhrase, pTC->iToken,pList,nList);
|
||||
nCount = fts3DoclistCountDocids(
|
||||
pTC->pPhrase->doclist.aAll, pTC->pPhrase->doclist.nAll
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
C Merge\sall\srecent\strunk\sfixes\sand\senhancements\sinto\sthe\sapple-osx\sbranch.
|
||||
D 2015-04-01T16:13:35.905
|
||||
C Merge\sin\sall\sversion\s3.8.9\schanges\sfrom\strunk.
|
||||
D 2015-04-08T12:47:26.858
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 4cab9a06c126df8330e76b95d890f99cf20e0de6
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@@ -78,7 +78,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 d3f6f0e95d366f3c2028d916c36a0844bf805840
|
||||
F ext/fts3/fts3.c 23bd9d37a777342f5c22a648e9b4b005dde9e58f
|
||||
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
|
||||
F ext/fts3/fts3Int.h 394858c12a17740f7a1f6bd372c4606d4425a8d1
|
||||
F ext/fts3/fts3_aux.c 5c211e17a64885faeb16b9ba7772f9d5445c2365
|
||||
@@ -217,7 +217,7 @@ F src/os.c 5822c2b843a77219bba1e28887cdc816b27ca29d
|
||||
F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
|
||||
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
|
||||
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
|
||||
F src/os_unix.c 895648d4453400e599aa13f5547b96931264ac84
|
||||
F src/os_unix.c bd7b5374a279f8fc0f0cc7d827709117e4293268
|
||||
F src/os_win.c 93f8662844dc935280a1851d15c823f1e6857408
|
||||
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
|
||||
F src/pager.c 694caffb16891a96608193968d7c9a8fa9a71240
|
||||
@@ -229,17 +229,17 @@ F src/pcache1.c 69d137620a305f814398bd29a0c998038c0695e9
|
||||
F src/pragma.c 21af63d913216da9ee45774bc381b9bd781d3a63
|
||||
F src/pragma.h 09c89bca58e9a44de2116cc8272b8d454657129f
|
||||
F src/prepare.c 01740b0d6b8f5c6da421a86c300464ff5b53e167
|
||||
F src/printf.c 8da9a2687a396daa19860f4dc90975d319304744
|
||||
F src/printf.c 8ae1fa9d30c1200a9268a390ba9e9cea9197b27a
|
||||
F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
|
||||
F src/resolve.c f4d79e31ffa5820c2e3d1740baa5e9b190425f2b
|
||||
F src/resolve.c 41aa91af56d960e9414ce1d7c17cfb68e0d1c6cb
|
||||
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
|
||||
F src/select.c ca8b52422e9c525ab62304526aee4b7b15df8795
|
||||
F src/select.c 7d05c857d13eb8fffc08e3489e1cd27513ef4b6a
|
||||
F src/shell.c 84a1593bd86aaa14f4da8a8f9b16fbc239d262aa
|
||||
F src/sqlite.h.in 1d97dd551627efe9284ec65251cbf862fcb1a96d
|
||||
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
||||
F src/sqlite3_private.h a81a9c5f97c095cc3e86914a05f8fabe0011f4a1
|
||||
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
|
||||
F src/sqliteInt.h f0fb2d8e3b297b2a75c6b0e11defb036a04c27ff
|
||||
F src/sqliteInt.h 160114e383d3d47beb3e5501751a5a4a3c795cce
|
||||
F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46
|
||||
F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179
|
||||
F src/table.c e7a09215315a978057fb42c640f890160dbcc45e
|
||||
@@ -489,7 +489,7 @@ F test/e_update.test 312cb8f5ccfe41515a6bb092f8ea562a9bd54d52
|
||||
F test/e_uri.test 5ae33760fb2039c61aa2d90886f1664664173585
|
||||
F test/e_vacuum.test 5bfbdc21b65c0abf24398d0ba31dc88d93ca77a9
|
||||
F test/e_wal.test ae9a593207a77d711443ee69ffe081fda9243625
|
||||
F test/e_walauto.test ca70cf75c07a6cb1874ced101dd426da76625649
|
||||
F test/e_walauto.test 6544af03423abc61b53cfb976839385ddc2a0a70
|
||||
F test/e_walckpt.test 65e29b6631e51f210f83e4ff11571e647ba93608
|
||||
F test/e_walhook.test da3ea8b3483d1af72190337bda50155a91a4b664
|
||||
F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
|
||||
@@ -592,13 +592,13 @@ F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a
|
||||
F test/fts3expr3.test 9e91b8edbcb197bf2e92161aa7696446d96dce5f
|
||||
F test/fts3expr4.test e1be1248566f43c252d4404d52914f1fc4bfa065
|
||||
F test/fts3fault.test cb72dccb0a3b9f730f16c5240f3fcb9303eb1660
|
||||
F test/fts3fault2.test 3198eef2804deea7cac8403e771d9cbcb752d887
|
||||
F test/fts3fault2.test f953bb3cf903988172270a9a0aafd5a890b0f98f
|
||||
F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641
|
||||
F test/fts3join.test 53e66a0c21eb568580674a43b21c059acb26f499
|
||||
F test/fts3malloc.test b0e4c133b8d61d4f6d112d8110f8320e9e453ef6
|
||||
F test/fts3matchinfo.test 58544fa4d254000fa4e7f494b0a832f7ba61d45e
|
||||
F test/fts3near.test 7e3354d46f155a822b59c0e957fd2a70c1d7e905
|
||||
F test/fts3prefix.test 9f68e3598a139c23ec47d09299420e0fc4c72a83
|
||||
F test/fts3prefix.test fa794eaab0bdae466494947b0b153d7844478ab2
|
||||
F test/fts3prefix2.test e1f0a822ca661dced7f12ce392e14eaf65609dce
|
||||
F test/fts3query.test c838b18f2b859e15fd31c64be3d79ef1556803ca
|
||||
F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0
|
||||
@@ -802,7 +802,7 @@ F test/permutations.test f9cc1dd987986c9d4949211c7a4ed55ec9aecba1
|
||||
F test/pragma.test 2886007790614c52f5e1489936f82a4b6be42927
|
||||
F test/pragma2.test f624a496a95ee878e81e59961eade66d5c00c028
|
||||
F test/pragma3.test 6f849ccffeee7e496d2f2b5e74152306c0b8757c
|
||||
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
|
||||
F test/printf.test b3ff34e73d59124140eaf89f7672e21bc2ca5fcc
|
||||
F test/printf2.test b4acd4bf8734243257f01ddefa17c4fb090acc8a
|
||||
F test/progress.test a282973d1d17f08071bc58a77d6b80f2a81c354d
|
||||
F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
|
||||
@@ -850,7 +850,7 @@ F test/select6.test 39eac4a5c03650b2b473c532882273283ee8b7a0
|
||||
F test/select7.test 7fd2ef598cfabb6b9ff6ac13973b91d0527df49d
|
||||
F test/select8.test 391de11bdd52339c30580dabbbbe97e3e9a3c79d
|
||||
F test/select9.test aebc2bb0c3bc44606125033cbcaac2c8d1f33a95
|
||||
F test/selectA.test 64b88a80271c1710966e50e633380696b60a12a4
|
||||
F test/selectA.test e452bdb975f488ea46d091382a9185b5853ed2c7
|
||||
F test/selectB.test 954e4e49cf1f896d61794e440669e03a27ceea25
|
||||
F test/selectC.test 871fb55d884d3de5943c4057ebd22c2459e71977
|
||||
F test/selectD.test b0f02a04ef7737decb24e08be2c39b9664b43394
|
||||
@@ -1149,7 +1149,7 @@ F test/wal9.test 378e76a9ad09cd9bee06c172ad3547b0129a6750
|
||||
F test/wal_common.tcl 15f152fd55703975878741beca6cfa4209d5b3b3
|
||||
F test/walbak.test 67339b9e54db0cdaaf21287349bc8056e2919f96
|
||||
F test/walbig.test 3ca3d94751b80054eed5bda20a1339ae1f619483
|
||||
F test/walblock.test ffc761cd467a93ccd8cd998a23be2f21b95a83b1
|
||||
F test/walblock.test be48f3a75eff0b4456209f26b3ce186c2015497d
|
||||
F test/walcksum.test 932d12a2a36fb2765560d35e7eaa1e5f0b198385
|
||||
F test/walcrash.test 011e05e9170da888851cb9ec4276bb1894ad32e3
|
||||
F test/walcrash2.test 6eb6842d34cc5955726264c80566963c32a9cbea
|
||||
@@ -1232,6 +1232,7 @@ F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a
|
||||
F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5
|
||||
F tool/showdb.c 63cdef19e7fbca0c164b096ef8aef3bb9e9dd222
|
||||
F tool/showjournal.c 053eb1cc774710c6890b7dd6293300cc297b16a5
|
||||
F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68
|
||||
F tool/showstat4.c 9515faa8ec176599d4a8288293ba8ec61f7b728a
|
||||
F tool/showwal.c 85cb36d4fe3e93e2fbd63e786e0d1ce42d0c4fad
|
||||
F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe
|
||||
@@ -1253,7 +1254,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 4d42bf5e18485be302cf5a3f81d900d7921b4315 30011ad2f55cfcacaf23a58ebcc17b17a7b9355e
|
||||
R 49944d24f9d93632056be499ef9e2452
|
||||
P 71b6f507f1c5feb897b8162c468ecf2547a3d50e 8a8ffc862e96f57aa698f93de10dee28e69f6e09
|
||||
R 44db3ba6874f6ad63a13081e1a0a07f5
|
||||
U drh
|
||||
Z 990ae49055e64b21819fb2da01d2e197
|
||||
Z 6fa29a6db82c1af802c818900a14f266
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
71b6f507f1c5feb897b8162c468ecf2547a3d50e
|
||||
301218704cfb6eebac32828b7b2dbc6803c63a26
|
||||
+1
-1
@@ -4491,7 +4491,7 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
|
||||
unixFile *pFile = (unixFile*)id;
|
||||
switch( op ){
|
||||
case SQLITE_FCNTL_WAL_BLOCK: {
|
||||
pFile->ctrlFlags |= UNIXFILE_BLOCK;
|
||||
/* pFile->ctrlFlags |= UNIXFILE_BLOCK; // Deferred feature */
|
||||
return SQLITE_OK;
|
||||
}
|
||||
case SQLITE_FCNTL_LOCKSTATE: {
|
||||
|
||||
+23
-9
@@ -261,15 +261,19 @@ void sqlite3VXPrintf(
|
||||
}
|
||||
if( width<0 ){
|
||||
flag_leftjustify = 1;
|
||||
width = -width;
|
||||
width = width >= -2147483647 ? -width : 0;
|
||||
}
|
||||
c = *++fmt;
|
||||
}else{
|
||||
unsigned wx = 0;
|
||||
while( c>='0' && c<='9' ){
|
||||
width = width*10 + c - '0';
|
||||
wx = wx*10 + c - '0';
|
||||
c = *++fmt;
|
||||
}
|
||||
testcase( wx>0x7fffffff );
|
||||
width = wx & 0x7fffffff;
|
||||
}
|
||||
|
||||
/* Get the precision */
|
||||
if( c=='.' ){
|
||||
precision = 0;
|
||||
@@ -280,13 +284,18 @@ void sqlite3VXPrintf(
|
||||
}else{
|
||||
precision = va_arg(ap,int);
|
||||
}
|
||||
if( precision<0 ) precision = -precision;
|
||||
c = *++fmt;
|
||||
if( precision<0 ){
|
||||
precision = precision >= -2147483647 ? -precision : -1;
|
||||
}
|
||||
}else{
|
||||
unsigned px = 0;
|
||||
while( c>='0' && c<='9' ){
|
||||
precision = precision*10 + c - '0';
|
||||
px = px*10 + c - '0';
|
||||
c = *++fmt;
|
||||
}
|
||||
testcase( px>0x7fffffff );
|
||||
precision = px & 0x7fffffff;
|
||||
}
|
||||
}else{
|
||||
precision = -1;
|
||||
@@ -450,7 +459,8 @@ void sqlite3VXPrintf(
|
||||
else prefix = 0;
|
||||
}
|
||||
if( xtype==etGENERIC && precision>0 ) precision--;
|
||||
for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1){}
|
||||
testcase( precision>0xfff );
|
||||
for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}
|
||||
if( xtype==etFLOAT ) realvalue += rounder;
|
||||
/* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
|
||||
exp = 0;
|
||||
@@ -505,8 +515,9 @@ void sqlite3VXPrintf(
|
||||
}else{
|
||||
e2 = exp;
|
||||
}
|
||||
if( MAX(e2,0)+precision+width > etBUFSIZE - 15 ){
|
||||
bufpt = zExtra = sqlite3Malloc( MAX(e2,0)+precision+width+15 );
|
||||
if( MAX(e2,0)+(i64)precision+(i64)width > etBUFSIZE - 15 ){
|
||||
bufpt = zExtra
|
||||
= sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );
|
||||
if( bufpt==0 ){
|
||||
setStrAccumError(pAccum, STRACCUM_NOMEM);
|
||||
return;
|
||||
@@ -738,7 +749,7 @@ void sqlite3VXPrintf(
|
||||
*/
|
||||
static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
|
||||
char *zNew;
|
||||
assert( p->nChar+N >= p->nAlloc ); /* Only called if really needed */
|
||||
assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */
|
||||
if( p->accError ){
|
||||
testcase(p->accError==STRACCUM_TOOBIG);
|
||||
testcase(p->accError==STRACCUM_NOMEM);
|
||||
@@ -787,7 +798,10 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
|
||||
** Append N copies of character c to the given string buffer.
|
||||
*/
|
||||
void sqlite3AppendChar(StrAccum *p, int N, char c){
|
||||
if( p->nChar+N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ) return;
|
||||
testcase( p->nChar + (i64)N > 0x7fffffff );
|
||||
if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){
|
||||
return;
|
||||
}
|
||||
while( (N--)>0 ) p->zText[p->nChar++] = c;
|
||||
}
|
||||
|
||||
|
||||
@@ -1186,6 +1186,20 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
|
||||
sqlite3ResolveExprNames(&sNC, p->pOffset) ){
|
||||
return WRC_Abort;
|
||||
}
|
||||
|
||||
/* If the SF_Converted flags is set, then this Select object was
|
||||
** was created by the convertCompoundSelectToSubquery() function.
|
||||
** In this case the ORDER BY clause (p->pOrderBy) should be resolved
|
||||
** as if it were part of the sub-query, not the parent. This block
|
||||
** moves the pOrderBy down to the sub-query. It will be moved back
|
||||
** after the names have been resolved. */
|
||||
if( p->selFlags & SF_Converted ){
|
||||
Select *pSub = p->pSrc->a[0].pSelect;
|
||||
assert( p->pSrc->nSrc==1 && isCompound==0 && p->pOrderBy );
|
||||
assert( pSub->pPrior && pSub->pOrderBy==0 );
|
||||
pSub->pOrderBy = p->pOrderBy;
|
||||
p->pOrderBy = 0;
|
||||
}
|
||||
|
||||
/* Recursively resolve names in all subqueries
|
||||
*/
|
||||
@@ -1268,6 +1282,17 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
|
||||
sNC.pNext = 0;
|
||||
sNC.ncFlags |= NC_AllowAgg;
|
||||
|
||||
/* If this is a converted compound query, move the ORDER BY clause from
|
||||
** the sub-query back to the parent query. At this point each term
|
||||
** within the ORDER BY clause has been transformed to an integer value.
|
||||
** These integers will be replaced by copies of the corresponding result
|
||||
** set expressions by the call to resolveOrderGroupBy() below. */
|
||||
if( p->selFlags & SF_Converted ){
|
||||
Select *pSub = p->pSrc->a[0].pSelect;
|
||||
p->pOrderBy = pSub->pOrderBy;
|
||||
pSub->pOrderBy = 0;
|
||||
}
|
||||
|
||||
/* Process the ORDER BY clause for singleton SELECT statements.
|
||||
** The ORDER BY clause for compounds SELECT statements is handled
|
||||
** below, after all of the result-sets for all of the elements of
|
||||
|
||||
@@ -3884,6 +3884,8 @@ static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){
|
||||
p->pPrior = 0;
|
||||
p->pNext = 0;
|
||||
p->selFlags &= ~SF_Compound;
|
||||
assert( (p->selFlags & SF_Converted)==0 );
|
||||
p->selFlags |= SF_Converted;
|
||||
assert( pNew->pPrior!=0 );
|
||||
pNew->pPrior->pNext = pNew;
|
||||
pNew->pLimit = 0;
|
||||
|
||||
@@ -2399,6 +2399,7 @@ struct Select {
|
||||
#define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
|
||||
#define SF_Recursive 0x0800 /* The recursive part of a recursive CTE */
|
||||
#define SF_MinMaxAgg 0x1000 /* Aggregate containing min() or max() */
|
||||
#define SF_Converted 0x2000 /* By convertCompoundSelectToSubquery() */
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,6 +15,14 @@ source $testdir/tester.tcl
|
||||
source $testdir/wal_common.tcl
|
||||
set testprefix e_walauto
|
||||
|
||||
# Do not run this test on OpenBSD, as it depends on read() and mmap both
|
||||
# accessing the same coherent view of the "test.db-shm" file. This doesn't
|
||||
# work on OpenBSD.
|
||||
#
|
||||
if {$tcl_platform(os) == "OpenBSD"} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
proc read_nbackfill {} {
|
||||
seek $::shmfd 96
|
||||
|
||||
@@ -155,4 +155,23 @@ ifcapable fts3_unicode {
|
||||
}
|
||||
}
|
||||
|
||||
reset_db
|
||||
do_test 6.0 {
|
||||
execsql {
|
||||
CREATE VIRTUAL TABLE t6 USING fts4(x,order=DESC);
|
||||
INSERT INTO t6(docid, x) VALUES(-1,'a b');
|
||||
INSERT INTO t6(docid, x) VALUES(1, 'b');
|
||||
}
|
||||
faultsim_save_and_close
|
||||
} {}
|
||||
|
||||
do_faultsim_test 6.1 -faults oom* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
db eval {SELECT * FROM sqlite_master}
|
||||
} -body {
|
||||
execsql { SELECT docid FROM t6 WHERE t6 MATCH '"a* b"' }
|
||||
} -test {
|
||||
faultsim_test_result {0 -1}
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -274,4 +274,22 @@ do_execsql_test 6.5.2 {
|
||||
SELECT md5sum(quote(root)) FROM t1_segdir;
|
||||
} [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}]
|
||||
|
||||
|
||||
do_execsql_test 7.0 {
|
||||
CREATE VIRTUAL TABLE t6 USING fts4(x,order=DESC);
|
||||
INSERT INTO t6(docid, x) VALUES(-1,'a b');
|
||||
INSERT INTO t6(docid, x) VALUES(1, 'b');
|
||||
}
|
||||
do_execsql_test 7.1 {
|
||||
SELECT docid FROM t6 WHERE t6 MATCH '"a* b"';
|
||||
} {-1}
|
||||
do_execsql_test 7.2 {
|
||||
SELECT docid FROM t6 WHERE t6 MATCH 'a*';
|
||||
} {-1}
|
||||
do_execsql_test 7.3 {
|
||||
SELECT docid FROM t6 WHERE t6 MATCH 'a* b';
|
||||
} {-1}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -472,6 +472,18 @@ do_test printf-1.16.7 {
|
||||
sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\
|
||||
0xff676981 0xff676981 0xff676981
|
||||
} {abc: (-9999999) (0xff676981) (037731664601) :xyz}
|
||||
do_test printf-1.17.1 {
|
||||
sqlite3_mprintf_int {abd: %2147483647d %2147483647x %2147483647o} 1 1 1
|
||||
} {}
|
||||
do_test printf-1.17.2 {
|
||||
sqlite3_mprintf_int {abd: %*d %x} 2147483647 1 1
|
||||
} {}
|
||||
do_test printf-1.17.3 {
|
||||
sqlite3_mprintf_int {abd: %*d %x} -2147483648 1 1
|
||||
} {abd: 1 1}
|
||||
do_test printf-1.17.4 {
|
||||
sqlite3_mprintf_int {abd: %.2147483648d %x %x} 1 1 1
|
||||
} {/.*/}
|
||||
do_test printf-2.1.1.1 {
|
||||
sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 0.001
|
||||
} {abc: (0.0) :xyz}
|
||||
@@ -526,6 +538,9 @@ do_test printf-2.1.2.8 {
|
||||
do_test printf-2.1.2.9 {
|
||||
sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 1.0e-20
|
||||
} {abc: 1 1 (1e-20) :xyz}
|
||||
do_test printf-2.1.2.10 {
|
||||
sqlite3_mprintf_double {abc: %*.*f} 2000000000 1000000000 1.0e-20
|
||||
} {abc: }
|
||||
do_test printf-2.1.3.1 {
|
||||
sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 1.0
|
||||
} {abc: (1.0) :xyz}
|
||||
@@ -3466,6 +3481,15 @@ do_test printf-3.5 {
|
||||
do_test printf-3.6 {
|
||||
sqlite3_mprintf_str {%d %d A String: (%-30s)} 1 2 {This is the string}
|
||||
} [format {%d %d A String: (%-30s)} 1 2 {This is the string}]
|
||||
do_test printf-3.7 {
|
||||
sqlite3_mprintf_str {%d A String: (%*s)} 1 2147483647 {This is the string}
|
||||
} []
|
||||
do_test printf-3.8 {
|
||||
sqlite3_mprintf_str {%d A String: (%*s)} 1 -2147483648 {This is the string}
|
||||
} {1 A String: (This is the string)}
|
||||
do_test printf-3.9 {
|
||||
sqlite3_mprintf_str {%d A String: (%.*s)} 1 -2147483648 {This is the string}
|
||||
} {1 A String: (This is the string)}
|
||||
do_test snprintf-3.11 {
|
||||
sqlite3_snprintf_str 2 {x%d %d %s} 10 10 {This is the string}
|
||||
} {x}
|
||||
@@ -3685,6 +3709,9 @@ do_test printf-13.5 {
|
||||
do_test printf-13.6 {
|
||||
sqlite3_mprintf_hexdouble %.20f fff8000000000000
|
||||
} {NaN}
|
||||
do_test printf-13.7 {
|
||||
sqlite3_mprintf_hexdouble %2147483648.10000f 4693b8b5b5056e17
|
||||
} {/100000000000000000000000000000000.00/}
|
||||
|
||||
do_test printf-14.1 {
|
||||
sqlite3_mprintf_str {abc-%y-123} 0 0 {not used}
|
||||
|
||||
@@ -1375,4 +1375,64 @@ do_execsql_test 4.2.2 {
|
||||
} {/2 . 3 . 4 . 5 . 6 . 7 ./}
|
||||
|
||||
|
||||
proc strip_rnd {explain} {
|
||||
regexp -all {sqlite_sq_[0123456789ABCDEF]*} $explain sqlite_sq
|
||||
}
|
||||
|
||||
proc do_same_test {tn q1 args} {
|
||||
set r2 [strip_rnd [db eval "EXPLAIN $q1"]]
|
||||
set i 1
|
||||
foreach q $args {
|
||||
set tst [subst -nocommands {strip_rnd [db eval "EXPLAIN $q"]}]
|
||||
uplevel do_test $tn.$i [list $tst] [list $r2]
|
||||
incr i
|
||||
}
|
||||
}
|
||||
|
||||
do_execsql_test 5.0 {
|
||||
CREATE TABLE t8(a, b);
|
||||
CREATE TABLE t9(c, d);
|
||||
} {}
|
||||
|
||||
do_same_test 5.1 {
|
||||
SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY a;
|
||||
} {
|
||||
SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY t8.a;
|
||||
} {
|
||||
SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY 1;
|
||||
} {
|
||||
SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY c;
|
||||
} {
|
||||
SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY t9.c;
|
||||
}
|
||||
|
||||
do_same_test 5.2 {
|
||||
SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY a COLLATE NOCASE
|
||||
} {
|
||||
SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY t8.a COLLATE NOCASE
|
||||
} {
|
||||
SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY 1 COLLATE NOCASE
|
||||
} {
|
||||
SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY c COLLATE NOCASE
|
||||
} {
|
||||
SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY t9.c COLLATE NOCASE
|
||||
}
|
||||
|
||||
do_same_test 5.3 {
|
||||
SELECT a, b FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY b, c COLLATE NOCASE
|
||||
} {
|
||||
SELECT a, b FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY 2, 1 COLLATE NOCASE
|
||||
} {
|
||||
SELECT a, b FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY d, a COLLATE NOCASE
|
||||
} {
|
||||
SELECT a, b FROM t8 EXCEPT SELECT * FROM t9 ORDER BY t9.d, c COLLATE NOCASE
|
||||
} {
|
||||
SELECT * FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY d, t8.a COLLATE NOCASE
|
||||
}
|
||||
|
||||
do_catchsql_test 5.4 {
|
||||
SELECT * FROM t8 UNION SELECT * FROM t9 ORDER BY a+b COLLATE NOCASE
|
||||
} {1 {1st ORDER BY term does not match any column in the result set}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
+1
-4
@@ -15,6 +15,7 @@ source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
source $testdir/wal_common.tcl
|
||||
|
||||
finish_test; return; # Feature currently not implemented.
|
||||
ifcapable !wal {finish_test ; return }
|
||||
if {$::tcl_platform(platform)!="unix"} { finish_test ; return }
|
||||
set testprefix walblock
|
||||
@@ -111,7 +112,3 @@ do_test "1.2.3.(blocking 0.5 seconds)" {
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
** This file implements a simple command-line utility that shows all of the
|
||||
** Posix Advisory Locks on a file.
|
||||
**
|
||||
** Usage:
|
||||
**
|
||||
** showlocks FILENAME
|
||||
**
|
||||
** To compile: gcc -o showlocks showlocks.c
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* This utility only looks for locks in the first 2 billion bytes */
|
||||
#define MX_LCK 2147483647
|
||||
|
||||
/*
|
||||
** Print all locks on the inode of "fd" that occur in between
|
||||
** lwr and upr, inclusive.
|
||||
*/
|
||||
static int showLocksInRange(int fd, off_t lwr, off_t upr){
|
||||
int cnt = 0;
|
||||
struct flock x;
|
||||
|
||||
x.l_type = F_WRLCK;
|
||||
x.l_whence = SEEK_SET;
|
||||
x.l_start = lwr;
|
||||
x.l_len = upr-lwr;
|
||||
fcntl(fd, F_GETLK, &x);
|
||||
if( x.l_type==F_UNLCK ) return 0;
|
||||
printf("start: %-12d len: %-5d pid: %-5d type: %s\n",
|
||||
(int)x.l_start, (int)x.l_len,
|
||||
x.l_pid, x.l_type==F_WRLCK ? "WRLCK" : "RDLCK");
|
||||
cnt++;
|
||||
if( x.l_start>lwr ){
|
||||
cnt += showLocksInRange(fd, lwr, x.l_start-1);
|
||||
}
|
||||
if( x.l_start+x.l_len<upr ){
|
||||
cnt += showLocksInRange(fd, x.l_start+x.l_len+1, upr);
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int fd;
|
||||
int cnt;
|
||||
|
||||
if( argc!=2 ){
|
||||
fprintf(stderr, "Usage: %s FILENAME\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
fd = open(argv[1], O_RDWR, 0);
|
||||
if( fd<0 ){
|
||||
fprintf(stderr, "%s: cannot open %s\n", argv[0], argv[1]);
|
||||
return 1;
|
||||
}
|
||||
cnt = showLocksInRange(fd, 0, MX_LCK);
|
||||
if( cnt==0 ) printf("no locks\n");
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user