Change vdbeSorterExtendFile() so that it makes a best effort to create the

PMA file of the desired size, but does not return an error if unable.

FossilOrigin-Name: 217814bc4b53fab7bdad433e24e8aef8998c38fe
This commit is contained in:
drh
2014-04-04 02:13:26 +00:00
parent 1aca5caa88
commit 6b5d4759ce
3 changed files with 13 additions and 16 deletions
+6 -6
View File
@@ -1,5 +1,5 @@
C Merge\sall\srecent\schanges\sfrom\strunk.
D 2014-04-03T16:42:21.478
C Change\svdbeSorterExtendFile()\sso\sthat\sit\smakes\sa\sbest\seffort\sto\screate\sthe\nPMA\sfile\sof\sthe\sdesired\ssize,\sbut\sdoes\snot\sreturn\san\serror\sif\sunable.
D 2014-04-04T02:13:26.507
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in ad0921c4b2780d01868cf69b419a4f102308d125
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -286,7 +286,7 @@ F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4
F src/vdbeaux.c d8dc38965507a34b0e150c0d7fc82b02f8cf25ea
F src/vdbeblob.c 15377abfb59251bccedd5a9c7d014a895f0c04aa
F src/vdbemem.c 6fc77594c60f6155404f3f8d71bf36d1fdeb4447
F src/vdbesort.c 252d7ab7620649945b53289510a172bc73133f17
F src/vdbesort.c 8da916fc74e78edd5bc95653206942e01710ac09
F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767
F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd
F src/wal.c 76e7fc6de229bea8b30bb2539110f03a494dc3a8
@@ -1161,7 +1161,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P 9d3351b8d713232133dad149c73fb2a27c72abb1 d5513dfa23baa0b0a095aaf17d19aacd30dcef61
R 6137d1586a278eeecb535398f89aa582
P a0910079adde95245680dee59b43613b60903f10
R ae0d06309ee79fa9e2b8e2b495c941f2
U drh
Z 41afe239279763eb22b85c89d966d688
Z 2dc7a665c4d0ee5a145d17c4c35dd575
+1 -1
View File
@@ -1 +1 @@
a0910079adde95245680dee59b43613b60903f10
217814bc4b53fab7bdad433e24e8aef8998c38fe
+6 -9
View File
@@ -1017,17 +1017,15 @@ static void vdbePmaWriteVarint(PmaWriter *p, u64 iVal){
** Whether or not the file does end up memory mapped of course depends on
** the specific VFS implementation.
*/
static int vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFile, i64 nByte){
int rc = SQLITE_OK;
static void vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFile, i64 nByte){
if( nByte<=(i64)(db->nMaxSorterMmap) ){
rc = sqlite3OsTruncate(pFile, nByte);
int rc = sqlite3OsTruncate(pFile, nByte);
if( rc==SQLITE_OK ){
void *p = 0;
sqlite3OsFetch(pFile, 0, nByte, &p);
sqlite3OsUnfetch(pFile, 0, p);
}
}
return rc;
}
#else
# define vdbeSorterExtendFile(x,y,z) SQLITE_OK
@@ -1064,7 +1062,7 @@ static int vdbeSorterListToPMA(SortSubtask *pTask){
/* Try to get the file to memory map */
if( rc==SQLITE_OK ){
rc = vdbeSorterExtendFile(pTask->db,
vdbeSorterExtendFile(pTask->db,
pTask->pTemp1, pTask->iTemp1Off + pTask->nInMemory + 9
);
}
@@ -1213,16 +1211,15 @@ static void *vdbeSortSubtaskMain(void *pCtx){
/* Open a second temp file to write merged data to */
rc = vdbeSorterOpenTempFile(pTask->db->pVfs, &pTemp2);
if( rc==SQLITE_OK ){
rc = vdbeSorterExtendFile(pTask->db, pTemp2, pTask->iTemp1Off);
}
if( rc!=SQLITE_OK ){
vdbeSorterExtendFile(pTask->db, pTemp2, pTask->iTemp1Off);
}else{
vdbeMergeEngineFree(pMerger);
break;
}
/* This loop runs once for each output PMA. Each output PMA is made
** of data merged from up to SORTER_MAX_MERGE_COUNT input PMAs. */
for(i=0; i<pTask->nPMA; i+=SORTER_MAX_MERGE_COUNT){
for(i=0; rc==SQLITE_OK && i<pTask->nPMA; i+=SORTER_MAX_MERGE_COUNT){
PmaWriter writer; /* Object for writing data to pTemp2 */
i64 nOut = 0; /* Bytes of data in output PMA */
int bEof = 0;