Merge trunk changes, including fixes for compiler warnings in fts5 code, with this branch.

FossilOrigin-Name: 7190d79ba452ceb1af77ce1375278b097816a8be
This commit is contained in:
dan 2015-07-16 20:24:42 +00:00
commit 3baaacae03
17 changed files with 144 additions and 110 deletions

View File

@ -83,7 +83,7 @@ struct Fts5ExprPhrase {
Fts5ExprNode *pNode; /* FTS5_STRING node this phrase is part of */
Fts5Buffer poslist; /* Current position list */
int nTerm; /* Number of entries in aTerm[] */
Fts5ExprTerm aTerm[0]; /* Terms that make up this phrase */
Fts5ExprTerm aTerm[1]; /* Terms that make up this phrase */
};
/*
@ -104,7 +104,7 @@ struct Fts5ExprNearset {
int nNear; /* NEAR parameter */
Fts5ExprColset *pColset; /* Columns to search (NULL -> all columns) */
int nPhrase; /* Number of entries in aPhrase[] array */
Fts5ExprPhrase *apPhrase[0]; /* Array of phrase pointers */
Fts5ExprPhrase *apPhrase[1]; /* Array of phrase pointers */
};

View File

@ -66,9 +66,16 @@ struct Fts5HashEntry {
int iCol; /* Column of last value written */
int iPos; /* Position of last value written */
i64 iRowid; /* Rowid of last value written */
char zKey[0]; /* Nul-terminated entry key */
char zKey[8]; /* Nul-terminated entry key */
};
/*
** Size of Fts5HashEntry without the zKey[] array.
*/
#define FTS5_HASHENTRYSIZE (sizeof(Fts5HashEntry)-8)
/*
** Allocate a new hash table.
*/
@ -220,7 +227,7 @@ int sqlite3Fts5HashWrite(
/* If an existing hash entry cannot be found, create a new one. */
if( p==0 ){
int nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;
int nByte = FTS5_HASHENTRYSIZE + (nToken+1) + 1 + 64;
if( nByte<128 ) nByte = 128;
if( (pHash->nEntry*2)>=pHash->nSlot ){
@ -231,13 +238,13 @@ int sqlite3Fts5HashWrite(
p = (Fts5HashEntry*)sqlite3_malloc(nByte);
if( !p ) return SQLITE_NOMEM;
memset(p, 0, sizeof(Fts5HashEntry));
memset(p, 0, FTS5_HASHENTRYSIZE);
p->nAlloc = nByte;
p->zKey[0] = bByte;
memcpy(&p->zKey[1], pToken, nToken);
assert( iHash==fts5HashKey(pHash->nSlot, p->zKey, nToken+1) );
p->zKey[nToken+1] = '\0';
p->nData = nToken+1 + 1 + sizeof(Fts5HashEntry);
p->nData = nToken+1 + 1 + FTS5_HASHENTRYSIZE;
p->nData += sqlite3Fts5PutVarint(&((u8*)p)[p->nData], iRowid);
p->iSzPoslist = p->nData;
p->nData += 1;
@ -417,7 +424,7 @@ int sqlite3Fts5HashQuery(
if( p ){
fts5HashAddPoslistSize(p);
*ppDoclist = (const u8*)&p->zKey[nTerm+1];
*pnDoclist = p->nData - (sizeof(*p) + nTerm + 1);
*pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1);
}else{
*ppDoclist = 0;
*pnDoclist = 0;
@ -454,7 +461,7 @@ void sqlite3Fts5HashScanEntry(
fts5HashAddPoslistSize(p);
*pzTerm = p->zKey;
*ppDoclist = (const u8*)&p->zKey[nTerm+1];
*pnDoclist = p->nData - (sizeof(*p) + nTerm + 1);
*pnDoclist = p->nData - (FTS5_HASHENTRYSIZE + nTerm + 1);
}else{
*pzTerm = 0;
*ppDoclist = 0;

View File

@ -370,7 +370,7 @@ struct Fts5Structure {
u64 nWriteCounter; /* Total leaves written to level 0 */
int nSegment; /* Total segments in this structure */
int nLevel; /* Number of levels in this index */
Fts5StructureLevel aLevel[0]; /* Array of nLevel level objects */
Fts5StructureLevel aLevel[1]; /* Array of nLevel level objects */
};
/*
@ -921,7 +921,7 @@ static int fts5StructureDecode(
i += fts5GetVarint32(&pData[i], nSegment);
nByte = (
sizeof(Fts5Structure) + /* Main structure */
sizeof(Fts5StructureLevel) * (nLevel) /* aLevel[] array */
sizeof(Fts5StructureLevel) * (nLevel-1) /* aLevel[] array */
);
pRet = (Fts5Structure*)sqlite3Fts5MallocZero(&rc, nByte);
@ -3072,7 +3072,7 @@ static void fts5ChunkIterate(
** returned in this case.
*/
static int fts5AllocateSegid(Fts5Index *p, Fts5Structure *pStruct){
u32 iSegid = 0;
int iSegid = 0;
if( p->rc==SQLITE_OK ){
if( pStruct->nSegment>=FTS5_MAX_SEGMENT ){
@ -3081,8 +3081,7 @@ static int fts5AllocateSegid(Fts5Index *p, Fts5Structure *pStruct){
while( iSegid==0 ){
int iLvl, iSeg;
sqlite3_randomness(sizeof(u32), (void*)&iSegid);
iSegid = (iSegid % ((1 << FTS5_DATA_ID_B) - 2)) + 1;
assert( iSegid>0 && iSegid<=65535 );
iSegid = iSegid & ((1 << FTS5_DATA_ID_B)-1);
for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
if( iSegid==pStruct->aLevel[iLvl].aSeg[iSeg].iSegid ){
@ -3094,7 +3093,7 @@ static int fts5AllocateSegid(Fts5Index *p, Fts5Structure *pStruct){
}
}
return (int)iSegid;
return iSegid;
}
/*

View File

@ -145,7 +145,7 @@ struct Fts5Sorter {
i64 iRowid; /* Current rowid */
const u8 *aPoslist; /* Position lists for current row */
int nIdx; /* Number of entries in aIdx[] */
int aIdx[0]; /* Offsets into aPoslist for current row */
int aIdx[1]; /* Offsets into aPoslist for current row */
};
@ -808,7 +808,7 @@ static int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
const char *zRankArgs = pCsr->zRankArgs;
nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
nByte = sizeof(Fts5Sorter) + sizeof(int) * nPhrase;
nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1);
pSorter = (Fts5Sorter*)sqlite3_malloc(nByte);
if( pSorter==0 ) return SQLITE_NOMEM;
memset(pSorter, 0, nByte);

View File

@ -1,5 +1,5 @@
C Use\sa\sWITHOUT\sROWID\stable\sto\sindex\sfts5\sbtree\sleaves.\sThis\sis\sfaster\sto\squery\sand\sonly\sslightly\slarger\sthan\sstoring\sbtree\snodes\swithin\san\sintkey\stable.
D 2015-07-15T19:46:02.242
C Merge\strunk\schanges,\sincluding\sfixes\sfor\scompiler\swarnings\sin\sfts5\scode,\swith\sthis\sbranch.
D 2015-07-16T20:24:42.461
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 6e8af213d49e6325bf283ebed7662254f8e15bda
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -110,10 +110,10 @@ F ext/fts5/fts5Int.h 8d9bce1847a10df2e4ed9492ea4f3868276748fb
F ext/fts5/fts5_aux.c 044cb176a815f4388308738437f6e130aa384fb0
F ext/fts5/fts5_buffer.c 80f9ba4431848cb857e3d2158f5280093dcd8015
F ext/fts5/fts5_config.c fdfa63ae8e527ecfaa50f94063c610429cc887cf
F ext/fts5/fts5_expr.c d2e148345639c5a5583e0daa39a639bf298ae6a7
F ext/fts5/fts5_hash.c 219f4edd72e5cf95b19c33f1058809a18fad5229
F ext/fts5/fts5_index.c 7fe8e8afdb872b55726263b2a82288ebabda969c
F ext/fts5/fts5_main.c 8f279999deb204b0c7760464f60f88666046398b
F ext/fts5/fts5_expr.c ac0614f843cf5c80a85c4c6aa44bbede62a51bb2
F ext/fts5/fts5_hash.c ff07722c73587c12781213133edbdb22cd156378
F ext/fts5/fts5_index.c 60c688801ce59f421c6073da047a3ebc0b3ec079
F ext/fts5/fts5_main.c 0de7ba81488d2c502c8e794eaf7983d468e4c6e9
F ext/fts5/fts5_storage.c 877399c557f273a725b5e4fc26f07e67ca90570a
F ext/fts5/fts5_tcl.c 85eb4e0d0fefa9420b78151496ad4599a1783e20
F ext/fts5/fts5_tokenize.c 30f97a8c74683797b4cd233790444fbefb3b0708
@ -319,20 +319,20 @@ F src/pager.h 6d435f563b3f7fcae4b84433b76a6ac2730036e2
F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8
F src/pcache.c cde06aa50962595e412d497e22fd2e07878ba1f0
F src/pcache.h 9968603796240cdf83da7e7bef76edf90619cea9
F src/pcache1.c 3f4c87cf913f2de8189026d9a5223ddaf55eaf6b
F src/pragma.c c1f4d012ea9f6b1ce52d341b2cd0ad72d560afd7
F src/pragma.h b8632d7cdda7b25323fa580e3e558a4f0d4502cc
F src/pcache1.c d08939800abf3031bd0affd5a13fbc4d7ba3fb68
F src/pragma.c e52084b37a08a88f258830518461e94627af2621
F src/pragma.h 631a91c8b0e6ca8f051a1d8a4a0da4150e04620a
F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1
F src/printf.c 2bc439ff20a4aad0e0ad50a37a67b5eae7d20edc
F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
F src/resolve.c 2d47554370de8de6dd5be060cef9559eec315005
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
F src/select.c d3c04f01549317afbe02455c4ca9465100e9c5fe
F src/select.c 57ef3d98c4400b93eea318813be41b2af2da2217
F src/shell.c 8af3cced094aebb5f57a8ad739b9dafc7867eed7
F src/sqlite.h.in 3d951bf985839de7fcf4d3f69568bb4df2641abe
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
F src/sqlite3ext.h be1a718b7d2ce40ceba725ae92c8eb5f18003066
F src/sqliteInt.h 61e6e8e6f37a665452f677f2d82f9c2c4cecdbd2
F src/sqliteInt.h c67d0a1368484dd156e7d13caa62862adc2ebefa
F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46
F src/status.c f266ad8a2892d659b74f0f50cb6a88b6e7c12179
F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e
@ -823,7 +823,7 @@ F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9
F test/malloc.test 21c213365f2cca95ab2d7dc078dc8525f96065f8
F test/malloc3.test e3b32c724b5a124b57cb0ed177f675249ad0c66a
F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
F test/malloc5.test e9a9116f80ab6b7a9ca258876c6f3dedb08cb08b
F test/malloc5.test 21f6552bacb9efe649e6ba10a52f2cedaecce242
F test/malloc6.test 2f039d9821927eacae43e1831f815e157659a151
F test/malloc7.test 7c68a32942858bc715284856c5507446bba88c3a
F test/malloc8.test 9b7a3f8cb9cf0b12fff566e80a980b1767bd961d
@ -900,8 +900,8 @@ F test/pagerfault2.test caf4c7facb914fd3b03a17b31ae2b180c8d6ca1f
F test/pagerfault3.test 1003fcda009bf48a8e22a516e193b6ef0dd1bbd8
F test/pageropt.test 6b8f6a123a5572c195ad4ae40f2987007923bbd6
F test/pagesize.test 5769fc62d8c890a83a503f67d47508dfdc543305
F test/pcache.test b09104b03160aca0d968d99e8cd2c5b1921a993d
F test/pcache2.test ec3ae192f444ee6a0a80d1fd80d99695d884bfb3
F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
F test/pcache2.test c70d92547550136ba6f818e6a44fe246d2738604
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
F test/permutations.test 6a88fd9ca15b804e9c20990773262ca67494058f
F test/pragma.test be7195f0aa72bdb8a512133e9640ac40f15b57a2
@ -1327,10 +1327,10 @@ F tool/logest.c eef612f8adf4d0993dafed0416064cf50d5d33c6
F tool/mkautoconfamal.sh d1a2da0e15b2ed33d60af35c7e9d483f13a8eb9f
F tool/mkkeywordhash.c dfff09dbbfaf950e89af294f48f902181b144670
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
F tool/mkpragmatab.tcl 40c287d3f929ece67da6e9e7c49885789960accf
F tool/mkpragmatab.tcl 84af2b180484323a2ea22a2279e8bd9e3e1e492e
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
F tool/mksqlite3c-noext.tcl 69bae8ce4aa52d2ff82d4a8a856bf283ec035b2e
F tool/mksqlite3c.tcl d79e450048b0bbf04d53677e01c249a012981182
F tool/mksqlite3c-noext.tcl 87240b09c20042999b41d5fabe091b7111287835
F tool/mksqlite3c.tcl f29898d34f1dcd77ccc4e6fd7dcc2f9ebb54622f
F tool/mksqlite3h.tcl 44730d586c9031638cdd2eb443b801c0d2dbd9f8
F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
F tool/mkvsix.tcl 3b58b9398f91c7dbf18d49eb87cefeee9efdbce1
@ -1365,10 +1365,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 110cd84f5e842c4dcd9b9398cea211e25f36b3aa
R 6be01aa6bafcfd1604a2d6d0b1df9b9e
T *branch * fts5-btree-index
T *sym-fts5-btree-index *
T -sym-trunk *
P 862418e3506d4b7cca9c44d58c2eb9dc915d75c9 e9bf275cd969eca6fb41384d3637528d6a19f819
R 13b93e3f59e7dab4e2705105f60947d5
U dan
Z 0f1494b26034248995977524e0d0424a
Z 0c71c25a3e3a21d59d6227b0b3745fb8

View File

@ -1 +1 @@
862418e3506d4b7cca9c44d58c2eb9dc915d75c9
7190d79ba452ceb1af77ce1375278b097816a8be

View File

@ -191,6 +191,7 @@ static SQLITE_WSD struct PCacheGlobal {
*/
int isInit; /* True if initialized */
int separateCache; /* Use a new PGroup for each PCache */
int nInitPage; /* Initial bulk allocation size */
int szSlot; /* Size of each free slot */
int nSlot; /* The number of pcache slots */
int nReserve; /* Try to keep nFreeSlot above this */
@ -259,6 +260,43 @@ void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){
}
}
/*
** Try to initialize the pCache->pFree and pCache->pBulk fields. Return
** true if pCache->pFree ends up containing one or more free pages.
*/
static int pcache1InitBulk(PCache1 *pCache){
i64 szBulk;
char *zBulk;
if( pcache1.nInitPage==0 ) return 0;
/* Do not bother with a bulk allocation if the cache size very small */
if( pCache->nMax<3 ) return 0;
sqlite3BeginBenignMalloc();
if( pcache1.nInitPage>0 ){
szBulk = pCache->szAlloc * (i64)pcache1.nInitPage;
}else{
szBulk = -1024 * (i64)pcache1.nInitPage;
}
if( szBulk > pCache->szAlloc*(i64)pCache->nMax ){
szBulk = pCache->szAlloc*pCache->nMax;
}
zBulk = pCache->pBulk = sqlite3Malloc( szBulk );
sqlite3EndBenignMalloc();
if( zBulk ){
int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;
int i;
for(i=0; i<nBulk; i++){
PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage];
pX->page.pBuf = zBulk;
pX->page.pExtra = &pX[1];
pX->isBulkLocal = 1;
pX->pNext = pCache->pFree;
pCache->pFree = pX;
zBulk += pCache->szAlloc;
}
}
return pCache->pFree!=0;
}
/*
** Malloc function used within this file to allocate space from the buffer
** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no
@ -359,7 +397,7 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache){
void *pPg;
assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
if( pCache->pFree ){
if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){
p = pCache->pFree;
pCache->pFree = p->pNext;
p->pNext = 0;
@ -563,7 +601,8 @@ static void pcache1RemoveFromHash(PgHdr1 *pPage, int freeFlag){
** If there are currently more than nMaxPage pages allocated, try
** to recycle pages to reduce the number allocated to nMaxPage.
*/
static void pcache1EnforceMaxPage(PGroup *pGroup){
static void pcache1EnforceMaxPage(PCache1 *pCache){
PGroup *pGroup = pCache->pGroup;
assert( sqlite3_mutex_held(pGroup->mutex) );
while( pGroup->nCurrentPage>pGroup->nMaxPage && pGroup->pLruTail ){
PgHdr1 *p = pGroup->pLruTail;
@ -572,6 +611,10 @@ static void pcache1EnforceMaxPage(PGroup *pGroup){
pcache1PinPage(p);
pcache1RemoveFromHash(p, 1);
}
if( pCache->nPage==0 && pCache->pBulk ){
sqlite3_free(pCache->pBulk);
pCache->pBulk = pCache->pFree = 0;
}
}
/*
@ -647,6 +690,14 @@ static int pcache1Init(void *NotUsed){
pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM);
}
#endif
if( pcache1.separateCache
&& sqlite3GlobalConfig.nPage!=0
&& sqlite3GlobalConfig.pPage==0
){
pcache1.nInitPage = sqlite3GlobalConfig.nPage;
}else{
pcache1.nInitPage = 0;
}
pcache1.grp.mxPinned = 10;
pcache1.isInit = 1;
return SQLITE_OK;
@ -701,36 +752,6 @@ static sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){
pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
}
pcache1LeaveMutex(pGroup);
/* Try to initialize the local bulk pagecache line allocation if using
** separate caches and if nPage!=0 */
if( pcache1.separateCache
&& sqlite3GlobalConfig.nPage!=0
&& sqlite3GlobalConfig.pPage==0
){
int szBulk;
char *zBulk;
sqlite3BeginBenignMalloc();
if( sqlite3GlobalConfig.nPage>0 ){
szBulk = pCache->szAlloc * sqlite3GlobalConfig.nPage;
}else{
szBulk = -1024*sqlite3GlobalConfig.nPage;
}
zBulk = pCache->pBulk = sqlite3Malloc( szBulk );
sqlite3EndBenignMalloc();
if( zBulk ){
int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;
int i;
for(i=0; i<nBulk; i++){
PgHdr1 *pX = (PgHdr1*)&zBulk[szPage];
pX->page.pBuf = zBulk;
pX->page.pExtra = &pX[1];
pX->isBulkLocal = 1;
pX->pNext = pCache->pFree;
pCache->pFree = pX;
zBulk += pCache->szAlloc;
}
}
}
if( pCache->nHash==0 ){
pcache1Destroy((sqlite3_pcache*)pCache);
pCache = 0;
@ -753,7 +774,7 @@ static void pcache1Cachesize(sqlite3_pcache *p, int nMax){
pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
pCache->nMax = nMax;
pCache->n90pct = pCache->nMax*9/10;
pcache1EnforceMaxPage(pGroup);
pcache1EnforceMaxPage(pCache);
pcache1LeaveMutex(pGroup);
}
}
@ -771,7 +792,7 @@ static void pcache1Shrink(sqlite3_pcache *p){
pcache1EnterMutex(pGroup);
savedMaxPage = pGroup->nMaxPage;
pGroup->nMaxPage = 0;
pcache1EnforceMaxPage(pGroup);
pcache1EnforceMaxPage(pCache);
pGroup->nMaxPage = savedMaxPage;
pcache1LeaveMutex(pGroup);
}
@ -1108,7 +1129,7 @@ static void pcache1Destroy(sqlite3_pcache *p){
assert( pGroup->nMinPage >= pCache->nMin );
pGroup->nMinPage -= pCache->nMin;
pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
pcache1EnforceMaxPage(pGroup);
pcache1EnforceMaxPage(pCache);
pcache1LeaveMutex(pGroup);
sqlite3_free(pCache->pBulk);
sqlite3_free(pCache->apHash);

View File

@ -721,6 +721,7 @@ void sqlite3Pragma(
case PragTyp_CACHE_SIZE: {
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
if( !zRight ){
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size);
}else{
int size = sqlite3Atoi(zRight);

View File

@ -86,7 +86,7 @@ static const struct sPragmaNames {
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{ /* zName: */ "cache_size",
/* ePragTyp: */ PragTyp_CACHE_SIZE,
/* ePragFlag: */ PragFlag_NeedSchema,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)

View File

@ -1082,7 +1082,6 @@ static KeyInfo *keyInfoFromExprList(
return pInfo;
}
#ifndef SQLITE_OMIT_COMPOUND_SELECT
/*
** Name of the connection operator, used for error messages.
*/
@ -1096,7 +1095,6 @@ static const char *selectOpName(int id){
}
return z;
}
#endif /* SQLITE_OMIT_COMPOUND_SELECT */
#ifndef SQLITE_OMIT_EXPLAIN
/*
@ -2099,19 +2097,6 @@ static int multiSelectOrderBy(
SelectDest *pDest /* What to do with query results */
);
/*
** Error message for when two or more terms of a compound select have different
** size result sets.
*/
void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){
if( p->selFlags & SF_Values ){
sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms");
}else{
sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
" do not have the same number of result columns", selectOpName(p->op));
}
}
/*
** Handle the special case of a compound-select that originates from a
** VALUES clause. By handling this as a special case, we avoid deep
@ -2538,6 +2523,19 @@ multi_select_end:
}
#endif /* SQLITE_OMIT_COMPOUND_SELECT */
/*
** Error message for when two or more terms of a compound select have different
** size result sets.
*/
void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){
if( p->selFlags & SF_Values ){
sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms");
}else{
sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
" do not have the same number of result columns", selectOpName(p->op));
}
}
/*
** Code an output subroutine for a coroutine implementation of a
** SELECT statment.

View File

@ -754,7 +754,9 @@ extern const int sqlite3one;
# if defined(__linux__) \
|| defined(_WIN32) \
|| (defined(__APPLE__) && defined(__MACH__)) \
|| defined(__sun)
|| defined(__sun) \
|| defined(__FreeBSD__) \
|| defined(__DragonFly__)
# define SQLITE_MAX_MMAP_SIZE 0x7fff0000 /* 2147418112 */
# else
# define SQLITE_MAX_MMAP_SIZE 0

View File

@ -41,6 +41,7 @@ ifcapable !memorymanage {
sqlite3_soft_heap_limit 0
sqlite3 db test.db
db eval {PRAGMA cache_size=1}
do_test malloc5-1.1 {
# Simplest possible test. Call sqlite3_release_memory when there is exactly
@ -61,15 +62,14 @@ do_test malloc5-1.2 {
# not the case before version 3.6.2).
#
sqlite3 db2 test.db
execsql { SELECT * FROM sqlite_master } db2
execsql {PRAGMA cache_size=2; SELECT * FROM sqlite_master } db2
} {}
do_test malloc5-1.3 {
# Call [sqlite3_release_memory] when there is exactly one unused page
# in the cache belonging to db2.
#
set ::pgalloc [sqlite3_release_memory]
expr $::pgalloc > 0
} {1}
} {0}
# The sizes of memory allocations from system malloc() might vary,
# depending on the memory allocator algorithms used. The following
@ -231,6 +231,7 @@ do_test malloc5-4.1 {
expr $nMaxBytes > 1000000
} {1}
do_test malloc5-4.2 {
db eval {PRAGMA cache_size=1}
db cache flush
sqlite3_release_memory
sqlite3_soft_heap_limit 100000
@ -302,7 +303,7 @@ do_test malloc5-6.1.1 {
sqlite3 db test.db
execsql {
PRAGMA page_size=1024;
PRAGMA default_cache_size=10;
PRAGMA default_cache_size=2;
}
execsql {
PRAGMA temp_store = memory;
@ -325,24 +326,25 @@ do_test malloc5-6.1.1 {
}
forcecopy test.db test2.db
sqlite3 db2 test2.db
db2 eval {PRAGMA cache_size=2}
list \
[expr ([file size test.db]/1024)>20] [expr ([file size test2.db]/1024)>20]
} {1 1}
do_test malloc5-6.1.2 {
list [execsql {PRAGMA cache_size}] [execsql {PRAGMA cache_size} db2]
} {10 10}
} {2 2}
do_test malloc5-6.2.1 {
execsql {SELECT * FROM abc} db2
execsql {SELECT * FROM abc} db
expr [nPage db] + [nPage db2]
} {20}
} {4}
do_test malloc5-6.2.2 {
# If we now try to reclaim some memory, it should come from the db2 cache.
sqlite3_release_memory 3000
expr [nPage db] + [nPage db2]
} {17}
} {4}
do_test malloc5-6.2.3 {
# Access the db2 cache again, so that all the db2 pages have been used
# more recently than all the db pages. Then try to reclaim 3000 bytes.
@ -350,7 +352,7 @@ do_test malloc5-6.2.3 {
execsql { SELECT * FROM abc } db2
sqlite3_release_memory 3000
expr [nPage db] + [nPage db2]
} {17}
} {4}
do_test malloc5-6.3.1 {
# Now open a transaction and update 2 pages in the db2 cache. Then
@ -367,19 +369,19 @@ do_test malloc5-6.3.1 {
} db2
execsql { SELECT * FROM abc } db
expr [nPage db] + [nPage db2]
} {20}
} {4}
do_test malloc5-6.3.2 {
# Try to release 7700 bytes. This should release all the
# non-dirty pages held by db2.
sqlite3_release_memory [expr 7*1132]
list [nPage db] [nPage db2]
} {10 3}
} {1 3}
do_test malloc5-6.3.3 {
# Try to release another 1000 bytes. This should come fromt the db
# cache, since all three pages held by db2 are either in-use or diry.
sqlite3_release_memory 1000
list [nPage db] [nPage db2]
} {9 3}
} {1 3}
do_test malloc5-6.3.4 {
# Now release 9900 more (about 9 pages worth). This should expunge
# the rest of the db cache. But the db2 cache remains intact, because
@ -390,20 +392,20 @@ do_test malloc5-6.3.4 {
sqlite3_release_memory 9900
}
list [nPage db] [nPage db2]
} {0 3}
} {1 3}
do_test malloc5-6.3.5 {
# But if we are really insistent, SQLite will consent to call sync()
# if there is no other option. UPDATE: As of 3.6.2, SQLite will not
# call sync() in this scenario. So no further memory can be reclaimed.
sqlite3_release_memory 1000
list [nPage db] [nPage db2]
} {0 3}
} {1 3}
do_test malloc5-6.3.6 {
# The referenced page (page 1 of the db2 cache) will not be freed no
# matter how much memory we ask for:
sqlite3_release_memory 31459
list [nPage db] [nPage db2]
} {0 3}
} {1 3}
db2 close

View File

@ -73,7 +73,7 @@ do_test pcache-1.4 {
do_test pcache-1.5 {
sqlite3 db2 test.db
execsql "PRAGMA cache_size=10" db2
execsql "PRAGMA cache_size; PRAGMA cache_size=10" db2
pcache_stats
} {current 11 max 22 min 20 recyclable 1}

View File

@ -36,13 +36,13 @@ do_test pcache2-1.1 {
do_test pcache2-1.2 {
forcedelete test.db test.db-journal
sqlite3 db test.db
db eval {PRAGMA cache_size=10}
db eval {PRAGMA cache_size=10; SELECT 1 FROM sqlite_master;}
lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
} {2}
do_test pcache2-1.3 {
forcedelete test2.db test2.db-journal
sqlite3 db2 test2.db
db2 eval {PRAGMA cache_size=50}
db2 eval {PRAGMA cache_size=50; SELECT 1 FROM sqlite_master;}
lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
} {4}

View File

@ -170,7 +170,6 @@ set pragma_def {
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
NAME: cache_size
FLAG: NeedSchema
IF: !defined(SQLITE_OMIT_PAGER_PRAGMAS)
NAME: mmap_size

View File

@ -180,6 +180,10 @@ proc copy_file {filename} {
copy_file tsrc/$hdr
section_comment "Continuing where we left off in $tail"
if {$linemacros} {puts $out "#line [expr {$ln+1}] \"$filename\""}
} else {
# Comment out the entire line, replacing any nested comment
# begin/end markers with the harmless substring "**".
puts $out "/* [string map [list /* ** */ **] $line] */"
}
} elseif {![info exists seen_hdr($hdr)]} {
if {![regexp {/\*\s+amalgamator:\s+dontcache\s+\*/} $line]} {

View File

@ -188,6 +188,10 @@ proc copy_file {filename} {
copy_file tsrc/$hdr
section_comment "Continuing where we left off in $tail"
if {$linemacros} {puts $out "#line [expr {$ln+1}] \"$filename\""}
} else {
# Comment out the entire line, replacing any nested comment
# begin/end markers with the harmless substring "**".
puts $out "/* [string map [list /* ** */ **] $line] */"
}
} elseif {![info exists seen_hdr($hdr)]} {
if {![regexp {/\*\s+amalgamator:\s+dontcache\s+\*/} $line]} {