Fossil SCM
Update the built-in SQLite to fix a harmless but annoying bug in the directory sync logic.
Commit
a4889252f173b17d70cb586991cefe6c6137e72a
Parent
13b68865c11338a…
2 files changed
+42
-37
+1
-1
+42
-37
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -325,11 +325,11 @@ | ||
| 325 | 325 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 326 | 326 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 327 | 327 | */ |
| 328 | 328 | #define SQLITE_VERSION "3.10.0" |
| 329 | 329 | #define SQLITE_VERSION_NUMBER 3010000 |
| 330 | -#define SQLITE_SOURCE_ID "2015-12-03 22:33:55 8534a46c06601ad35b97caee442371f24c718d0f" | |
| 330 | +#define SQLITE_SOURCE_ID "2015-12-07 18:18:33 e7ae120d04cffafd9bc2b4ecd68571c17e05ed72" | |
| 331 | 331 | |
| 332 | 332 | /* |
| 333 | 333 | ** CAPI3REF: Run-Time Library Version Numbers |
| 334 | 334 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 335 | 335 | ** |
| @@ -23130,11 +23130,11 @@ | ||
| 23130 | 23130 | }else{ |
| 23131 | 23131 | zNew = sqlite3_realloc64(zOld, p->nAlloc); |
| 23132 | 23132 | } |
| 23133 | 23133 | if( zNew ){ |
| 23134 | 23134 | assert( p->zText!=0 || p->nChar==0 ); |
| 23135 | - if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); | |
| 23135 | + if( p->zText==p->zBase && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); | |
| 23136 | 23136 | p->zText = zNew; |
| 23137 | 23137 | p->nAlloc = sqlite3DbMallocSize(p->db, zNew); |
| 23138 | 23138 | }else{ |
| 23139 | 23139 | sqlite3StrAccumReset(p); |
| 23140 | 23140 | setStrAccumError(p, STRACCUM_NOMEM); |
| @@ -30379,17 +30379,20 @@ | ||
| 30379 | 30379 | int ii; |
| 30380 | 30380 | int fd = -1; |
| 30381 | 30381 | char zDirname[MAX_PATHNAME+1]; |
| 30382 | 30382 | |
| 30383 | 30383 | sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename); |
| 30384 | - for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--); | |
| 30385 | - if( ii>1 ){ | |
| 30384 | + for(ii=(int)strlen(zDirname); ii>0 && zDirname[ii]!='/'; ii--); | |
| 30385 | + if( ii>0 ){ | |
| 30386 | 30386 | zDirname[ii] = '\0'; |
| 30387 | - fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); | |
| 30388 | - if( fd>=0 ){ | |
| 30389 | - OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); | |
| 30390 | - } | |
| 30387 | + }else{ | |
| 30388 | + if( zDirname[0]!='/' ) zDirname[0] = '.'; | |
| 30389 | + zDirname[1] = 0; | |
| 30390 | + } | |
| 30391 | + fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); | |
| 30392 | + if( fd>=0 ){ | |
| 30393 | + OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); | |
| 30391 | 30394 | } |
| 30392 | 30395 | *pFd = fd; |
| 30393 | 30396 | if( fd>=0 ) return SQLITE_OK; |
| 30394 | 30397 | return unixLogError(SQLITE_CANTOPEN_BKPT, "openDirectory", zDirname); |
| 30395 | 30398 | } |
| @@ -68716,34 +68719,35 @@ | ||
| 68716 | 68719 | ** NULL simply return pBuf. Only allocate new memory space when pBuf |
| 68717 | 68720 | ** is NULL. |
| 68718 | 68721 | ** |
| 68719 | 68722 | ** nByte is the number of bytes of space needed. |
| 68720 | 68723 | ** |
| 68721 | -** *ppFrom points to available space and pEnd points to the end of the | |
| 68722 | -** available space. When space is allocated, *ppFrom is advanced past | |
| 68723 | -** the end of the allocated space. | |
| 68724 | +** pFrom points to *pnFrom bytes of available space. New space is allocated | |
| 68725 | +** from the end of the pFrom buffer and *pnFrom is decremented. | |
| 68724 | 68726 | ** |
| 68725 | -** *pnByte is a counter of the number of bytes of space that have failed | |
| 68726 | -** to allocate. If there is insufficient space in *ppFrom to satisfy the | |
| 68727 | -** request, then increment *pnByte by the amount of the request. | |
| 68727 | +** *pnNeeded is a counter of the number of bytes of space that have failed | |
| 68728 | +** to allocate. If there is insufficient space in pFrom to satisfy the | |
| 68729 | +** request, then increment *pnNeeded by the amount of the request. | |
| 68728 | 68730 | */ |
| 68729 | 68731 | static void *allocSpace( |
| 68730 | 68732 | void *pBuf, /* Where return pointer will be stored */ |
| 68731 | 68733 | int nByte, /* Number of bytes to allocate */ |
| 68732 | - u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */ | |
| 68733 | - u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ | |
| 68734 | - int *pnByte /* If allocation cannot be made, increment *pnByte */ | |
| 68734 | + u8 *pFrom, /* Memory available for allocation */ | |
| 68735 | + int *pnFrom, /* IN/OUT: Space available at pFrom */ | |
| 68736 | + int *pnNeeded /* If allocation cannot be made, increment *pnByte */ | |
| 68735 | 68737 | ){ |
| 68736 | - assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) ); | |
| 68737 | - if( pBuf ) return pBuf; | |
| 68738 | - nByte = ROUND8(nByte); | |
| 68739 | - if( &(*ppFrom)[nByte] <= pEnd ){ | |
| 68740 | - pBuf = (void*)*ppFrom; | |
| 68741 | - *ppFrom += nByte; | |
| 68742 | - }else{ | |
| 68743 | - *pnByte += nByte; | |
| 68744 | - } | |
| 68738 | + assert( EIGHT_BYTE_ALIGNMENT(pFrom) ); | |
| 68739 | + if( pBuf==0 ){ | |
| 68740 | + nByte = ROUND8(nByte); | |
| 68741 | + if( nByte <= *pnFrom ){ | |
| 68742 | + *pnFrom -= nByte; | |
| 68743 | + pBuf = &pFrom[*pnFrom]; | |
| 68744 | + }else{ | |
| 68745 | + *pnNeeded += nByte; | |
| 68746 | + } | |
| 68747 | + } | |
| 68748 | + assert( EIGHT_BYTE_ALIGNMENT(pBuf) ); | |
| 68745 | 68749 | return pBuf; |
| 68746 | 68750 | } |
| 68747 | 68751 | |
| 68748 | 68752 | /* |
| 68749 | 68753 | ** Rewind the VDBE back to the beginning in preparation for |
| @@ -68812,12 +68816,12 @@ | ||
| 68812 | 68816 | int nMem; /* Number of VM memory registers */ |
| 68813 | 68817 | int nCursor; /* Number of cursors required */ |
| 68814 | 68818 | int nArg; /* Number of arguments in subprograms */ |
| 68815 | 68819 | int nOnce; /* Number of OP_Once instructions */ |
| 68816 | 68820 | int n; /* Loop counter */ |
| 68821 | + int nFree; /* Available free space */ | |
| 68817 | 68822 | u8 *zCsr; /* Memory available for allocation */ |
| 68818 | - u8 *zEnd; /* First byte past allocated memory */ | |
| 68819 | 68823 | int nByte; /* How much extra memory is needed */ |
| 68820 | 68824 | |
| 68821 | 68825 | assert( p!=0 ); |
| 68822 | 68826 | assert( p->nOp>0 ); |
| 68823 | 68827 | assert( pParse!=0 ); |
| @@ -68845,18 +68849,19 @@ | ||
| 68845 | 68849 | |
| 68846 | 68850 | /* Allocate space for memory registers, SQL variables, VDBE cursors and |
| 68847 | 68851 | ** an array to marshal SQL function arguments in. |
| 68848 | 68852 | */ |
| 68849 | 68853 | zCsr = (u8*)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ |
| 68850 | - zEnd = (u8*)&p->aOp[pParse->nOpAlloc]; /* First byte past end of zCsr[] */ | |
| 68854 | + assert( pParse->nOpAlloc*sizeof(Op) <= 0x7fffff00 ); | |
| 68855 | + nFree = (pParse->nOpAlloc - p->nOp)*sizeof(p->aOp[0]); /* Available space */ | |
| 68851 | 68856 | |
| 68852 | 68857 | resolveP2Values(p, &nArg); |
| 68853 | 68858 | p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); |
| 68854 | 68859 | if( pParse->explain && nMem<10 ){ |
| 68855 | 68860 | nMem = 10; |
| 68856 | 68861 | } |
| 68857 | - memset(zCsr, 0, zEnd-zCsr); | |
| 68862 | + memset(zCsr, 0, nFree); | |
| 68858 | 68863 | zCsr += (zCsr - (u8*)0)&7; |
| 68859 | 68864 | assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); |
| 68860 | 68865 | p->expired = 0; |
| 68861 | 68866 | |
| 68862 | 68867 | /* Memory for registers, parameters, cursor, etc, is allocated in two |
| @@ -68869,25 +68874,25 @@ | ||
| 68869 | 68874 | ** the leftover space at the end of the opcode array can significantly |
| 68870 | 68875 | ** reduce the amount of memory held by a prepared statement. |
| 68871 | 68876 | */ |
| 68872 | 68877 | do { |
| 68873 | 68878 | nByte = 0; |
| 68874 | - p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte); | |
| 68875 | - p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte); | |
| 68876 | - p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte); | |
| 68877 | - p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte); | |
| 68879 | + p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), zCsr, &nFree, &nByte); | |
| 68880 | + p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), zCsr, &nFree, &nByte); | |
| 68881 | + p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), zCsr, &nFree, &nByte); | |
| 68882 | + p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), zCsr, &nFree, &nByte); | |
| 68878 | 68883 | p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*), |
| 68879 | - &zCsr, zEnd, &nByte); | |
| 68880 | - p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, &zCsr, zEnd, &nByte); | |
| 68884 | + zCsr, &nFree, &nByte); | |
| 68885 | + p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, zCsr, &nFree, &nByte); | |
| 68881 | 68886 | #ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 68882 | - p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), &zCsr, zEnd, &nByte); | |
| 68887 | + p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), zCsr, &nFree, &nByte); | |
| 68883 | 68888 | #endif |
| 68884 | 68889 | if( nByte ){ |
| 68885 | 68890 | p->pFree = sqlite3DbMallocZero(db, nByte); |
| 68886 | 68891 | } |
| 68887 | 68892 | zCsr = p->pFree; |
| 68888 | - zEnd = &zCsr[nByte]; | |
| 68893 | + nFree = nByte; | |
| 68889 | 68894 | }while( nByte && !db->mallocFailed ); |
| 68890 | 68895 | |
| 68891 | 68896 | p->nCursor = nCursor; |
| 68892 | 68897 | p->nOnceFlag = nOnce; |
| 68893 | 68898 | if( p->aVar ){ |
| 68894 | 68899 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -325,11 +325,11 @@ | |
| 325 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 326 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 327 | */ |
| 328 | #define SQLITE_VERSION "3.10.0" |
| 329 | #define SQLITE_VERSION_NUMBER 3010000 |
| 330 | #define SQLITE_SOURCE_ID "2015-12-03 22:33:55 8534a46c06601ad35b97caee442371f24c718d0f" |
| 331 | |
| 332 | /* |
| 333 | ** CAPI3REF: Run-Time Library Version Numbers |
| 334 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 335 | ** |
| @@ -23130,11 +23130,11 @@ | |
| 23130 | }else{ |
| 23131 | zNew = sqlite3_realloc64(zOld, p->nAlloc); |
| 23132 | } |
| 23133 | if( zNew ){ |
| 23134 | assert( p->zText!=0 || p->nChar==0 ); |
| 23135 | if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); |
| 23136 | p->zText = zNew; |
| 23137 | p->nAlloc = sqlite3DbMallocSize(p->db, zNew); |
| 23138 | }else{ |
| 23139 | sqlite3StrAccumReset(p); |
| 23140 | setStrAccumError(p, STRACCUM_NOMEM); |
| @@ -30379,17 +30379,20 @@ | |
| 30379 | int ii; |
| 30380 | int fd = -1; |
| 30381 | char zDirname[MAX_PATHNAME+1]; |
| 30382 | |
| 30383 | sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename); |
| 30384 | for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--); |
| 30385 | if( ii>1 ){ |
| 30386 | zDirname[ii] = '\0'; |
| 30387 | fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); |
| 30388 | if( fd>=0 ){ |
| 30389 | OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); |
| 30390 | } |
| 30391 | } |
| 30392 | *pFd = fd; |
| 30393 | if( fd>=0 ) return SQLITE_OK; |
| 30394 | return unixLogError(SQLITE_CANTOPEN_BKPT, "openDirectory", zDirname); |
| 30395 | } |
| @@ -68716,34 +68719,35 @@ | |
| 68716 | ** NULL simply return pBuf. Only allocate new memory space when pBuf |
| 68717 | ** is NULL. |
| 68718 | ** |
| 68719 | ** nByte is the number of bytes of space needed. |
| 68720 | ** |
| 68721 | ** *ppFrom points to available space and pEnd points to the end of the |
| 68722 | ** available space. When space is allocated, *ppFrom is advanced past |
| 68723 | ** the end of the allocated space. |
| 68724 | ** |
| 68725 | ** *pnByte is a counter of the number of bytes of space that have failed |
| 68726 | ** to allocate. If there is insufficient space in *ppFrom to satisfy the |
| 68727 | ** request, then increment *pnByte by the amount of the request. |
| 68728 | */ |
| 68729 | static void *allocSpace( |
| 68730 | void *pBuf, /* Where return pointer will be stored */ |
| 68731 | int nByte, /* Number of bytes to allocate */ |
| 68732 | u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */ |
| 68733 | u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ |
| 68734 | int *pnByte /* If allocation cannot be made, increment *pnByte */ |
| 68735 | ){ |
| 68736 | assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) ); |
| 68737 | if( pBuf ) return pBuf; |
| 68738 | nByte = ROUND8(nByte); |
| 68739 | if( &(*ppFrom)[nByte] <= pEnd ){ |
| 68740 | pBuf = (void*)*ppFrom; |
| 68741 | *ppFrom += nByte; |
| 68742 | }else{ |
| 68743 | *pnByte += nByte; |
| 68744 | } |
| 68745 | return pBuf; |
| 68746 | } |
| 68747 | |
| 68748 | /* |
| 68749 | ** Rewind the VDBE back to the beginning in preparation for |
| @@ -68812,12 +68816,12 @@ | |
| 68812 | int nMem; /* Number of VM memory registers */ |
| 68813 | int nCursor; /* Number of cursors required */ |
| 68814 | int nArg; /* Number of arguments in subprograms */ |
| 68815 | int nOnce; /* Number of OP_Once instructions */ |
| 68816 | int n; /* Loop counter */ |
| 68817 | u8 *zCsr; /* Memory available for allocation */ |
| 68818 | u8 *zEnd; /* First byte past allocated memory */ |
| 68819 | int nByte; /* How much extra memory is needed */ |
| 68820 | |
| 68821 | assert( p!=0 ); |
| 68822 | assert( p->nOp>0 ); |
| 68823 | assert( pParse!=0 ); |
| @@ -68845,18 +68849,19 @@ | |
| 68845 | |
| 68846 | /* Allocate space for memory registers, SQL variables, VDBE cursors and |
| 68847 | ** an array to marshal SQL function arguments in. |
| 68848 | */ |
| 68849 | zCsr = (u8*)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ |
| 68850 | zEnd = (u8*)&p->aOp[pParse->nOpAlloc]; /* First byte past end of zCsr[] */ |
| 68851 | |
| 68852 | resolveP2Values(p, &nArg); |
| 68853 | p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); |
| 68854 | if( pParse->explain && nMem<10 ){ |
| 68855 | nMem = 10; |
| 68856 | } |
| 68857 | memset(zCsr, 0, zEnd-zCsr); |
| 68858 | zCsr += (zCsr - (u8*)0)&7; |
| 68859 | assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); |
| 68860 | p->expired = 0; |
| 68861 | |
| 68862 | /* Memory for registers, parameters, cursor, etc, is allocated in two |
| @@ -68869,25 +68874,25 @@ | |
| 68869 | ** the leftover space at the end of the opcode array can significantly |
| 68870 | ** reduce the amount of memory held by a prepared statement. |
| 68871 | */ |
| 68872 | do { |
| 68873 | nByte = 0; |
| 68874 | p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte); |
| 68875 | p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte); |
| 68876 | p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte); |
| 68877 | p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte); |
| 68878 | p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*), |
| 68879 | &zCsr, zEnd, &nByte); |
| 68880 | p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, &zCsr, zEnd, &nByte); |
| 68881 | #ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 68882 | p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), &zCsr, zEnd, &nByte); |
| 68883 | #endif |
| 68884 | if( nByte ){ |
| 68885 | p->pFree = sqlite3DbMallocZero(db, nByte); |
| 68886 | } |
| 68887 | zCsr = p->pFree; |
| 68888 | zEnd = &zCsr[nByte]; |
| 68889 | }while( nByte && !db->mallocFailed ); |
| 68890 | |
| 68891 | p->nCursor = nCursor; |
| 68892 | p->nOnceFlag = nOnce; |
| 68893 | if( p->aVar ){ |
| 68894 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -325,11 +325,11 @@ | |
| 325 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 326 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 327 | */ |
| 328 | #define SQLITE_VERSION "3.10.0" |
| 329 | #define SQLITE_VERSION_NUMBER 3010000 |
| 330 | #define SQLITE_SOURCE_ID "2015-12-07 18:18:33 e7ae120d04cffafd9bc2b4ecd68571c17e05ed72" |
| 331 | |
| 332 | /* |
| 333 | ** CAPI3REF: Run-Time Library Version Numbers |
| 334 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 335 | ** |
| @@ -23130,11 +23130,11 @@ | |
| 23130 | }else{ |
| 23131 | zNew = sqlite3_realloc64(zOld, p->nAlloc); |
| 23132 | } |
| 23133 | if( zNew ){ |
| 23134 | assert( p->zText!=0 || p->nChar==0 ); |
| 23135 | if( p->zText==p->zBase && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); |
| 23136 | p->zText = zNew; |
| 23137 | p->nAlloc = sqlite3DbMallocSize(p->db, zNew); |
| 23138 | }else{ |
| 23139 | sqlite3StrAccumReset(p); |
| 23140 | setStrAccumError(p, STRACCUM_NOMEM); |
| @@ -30379,17 +30379,20 @@ | |
| 30379 | int ii; |
| 30380 | int fd = -1; |
| 30381 | char zDirname[MAX_PATHNAME+1]; |
| 30382 | |
| 30383 | sqlite3_snprintf(MAX_PATHNAME, zDirname, "%s", zFilename); |
| 30384 | for(ii=(int)strlen(zDirname); ii>0 && zDirname[ii]!='/'; ii--); |
| 30385 | if( ii>0 ){ |
| 30386 | zDirname[ii] = '\0'; |
| 30387 | }else{ |
| 30388 | if( zDirname[0]!='/' ) zDirname[0] = '.'; |
| 30389 | zDirname[1] = 0; |
| 30390 | } |
| 30391 | fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); |
| 30392 | if( fd>=0 ){ |
| 30393 | OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); |
| 30394 | } |
| 30395 | *pFd = fd; |
| 30396 | if( fd>=0 ) return SQLITE_OK; |
| 30397 | return unixLogError(SQLITE_CANTOPEN_BKPT, "openDirectory", zDirname); |
| 30398 | } |
| @@ -68716,34 +68719,35 @@ | |
| 68719 | ** NULL simply return pBuf. Only allocate new memory space when pBuf |
| 68720 | ** is NULL. |
| 68721 | ** |
| 68722 | ** nByte is the number of bytes of space needed. |
| 68723 | ** |
| 68724 | ** pFrom points to *pnFrom bytes of available space. New space is allocated |
| 68725 | ** from the end of the pFrom buffer and *pnFrom is decremented. |
| 68726 | ** |
| 68727 | ** *pnNeeded is a counter of the number of bytes of space that have failed |
| 68728 | ** to allocate. If there is insufficient space in pFrom to satisfy the |
| 68729 | ** request, then increment *pnNeeded by the amount of the request. |
| 68730 | */ |
| 68731 | static void *allocSpace( |
| 68732 | void *pBuf, /* Where return pointer will be stored */ |
| 68733 | int nByte, /* Number of bytes to allocate */ |
| 68734 | u8 *pFrom, /* Memory available for allocation */ |
| 68735 | int *pnFrom, /* IN/OUT: Space available at pFrom */ |
| 68736 | int *pnNeeded /* If allocation cannot be made, increment *pnByte */ |
| 68737 | ){ |
| 68738 | assert( EIGHT_BYTE_ALIGNMENT(pFrom) ); |
| 68739 | if( pBuf==0 ){ |
| 68740 | nByte = ROUND8(nByte); |
| 68741 | if( nByte <= *pnFrom ){ |
| 68742 | *pnFrom -= nByte; |
| 68743 | pBuf = &pFrom[*pnFrom]; |
| 68744 | }else{ |
| 68745 | *pnNeeded += nByte; |
| 68746 | } |
| 68747 | } |
| 68748 | assert( EIGHT_BYTE_ALIGNMENT(pBuf) ); |
| 68749 | return pBuf; |
| 68750 | } |
| 68751 | |
| 68752 | /* |
| 68753 | ** Rewind the VDBE back to the beginning in preparation for |
| @@ -68812,12 +68816,12 @@ | |
| 68816 | int nMem; /* Number of VM memory registers */ |
| 68817 | int nCursor; /* Number of cursors required */ |
| 68818 | int nArg; /* Number of arguments in subprograms */ |
| 68819 | int nOnce; /* Number of OP_Once instructions */ |
| 68820 | int n; /* Loop counter */ |
| 68821 | int nFree; /* Available free space */ |
| 68822 | u8 *zCsr; /* Memory available for allocation */ |
| 68823 | int nByte; /* How much extra memory is needed */ |
| 68824 | |
| 68825 | assert( p!=0 ); |
| 68826 | assert( p->nOp>0 ); |
| 68827 | assert( pParse!=0 ); |
| @@ -68845,18 +68849,19 @@ | |
| 68849 | |
| 68850 | /* Allocate space for memory registers, SQL variables, VDBE cursors and |
| 68851 | ** an array to marshal SQL function arguments in. |
| 68852 | */ |
| 68853 | zCsr = (u8*)&p->aOp[p->nOp]; /* Memory avaliable for allocation */ |
| 68854 | assert( pParse->nOpAlloc*sizeof(Op) <= 0x7fffff00 ); |
| 68855 | nFree = (pParse->nOpAlloc - p->nOp)*sizeof(p->aOp[0]); /* Available space */ |
| 68856 | |
| 68857 | resolveP2Values(p, &nArg); |
| 68858 | p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); |
| 68859 | if( pParse->explain && nMem<10 ){ |
| 68860 | nMem = 10; |
| 68861 | } |
| 68862 | memset(zCsr, 0, nFree); |
| 68863 | zCsr += (zCsr - (u8*)0)&7; |
| 68864 | assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); |
| 68865 | p->expired = 0; |
| 68866 | |
| 68867 | /* Memory for registers, parameters, cursor, etc, is allocated in two |
| @@ -68869,25 +68874,25 @@ | |
| 68874 | ** the leftover space at the end of the opcode array can significantly |
| 68875 | ** reduce the amount of memory held by a prepared statement. |
| 68876 | */ |
| 68877 | do { |
| 68878 | nByte = 0; |
| 68879 | p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), zCsr, &nFree, &nByte); |
| 68880 | p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), zCsr, &nFree, &nByte); |
| 68881 | p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), zCsr, &nFree, &nByte); |
| 68882 | p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), zCsr, &nFree, &nByte); |
| 68883 | p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*), |
| 68884 | zCsr, &nFree, &nByte); |
| 68885 | p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, zCsr, &nFree, &nByte); |
| 68886 | #ifdef SQLITE_ENABLE_STMT_SCANSTATUS |
| 68887 | p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), zCsr, &nFree, &nByte); |
| 68888 | #endif |
| 68889 | if( nByte ){ |
| 68890 | p->pFree = sqlite3DbMallocZero(db, nByte); |
| 68891 | } |
| 68892 | zCsr = p->pFree; |
| 68893 | nFree = nByte; |
| 68894 | }while( nByte && !db->mallocFailed ); |
| 68895 | |
| 68896 | p->nCursor = nCursor; |
| 68897 | p->nOnceFlag = nOnce; |
| 68898 | if( p->aVar ){ |
| 68899 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -111,11 +111,11 @@ | ||
| 111 | 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | 113 | */ |
| 114 | 114 | #define SQLITE_VERSION "3.10.0" |
| 115 | 115 | #define SQLITE_VERSION_NUMBER 3010000 |
| 116 | -#define SQLITE_SOURCE_ID "2015-12-03 22:33:55 8534a46c06601ad35b97caee442371f24c718d0f" | |
| 116 | +#define SQLITE_SOURCE_ID "2015-12-07 18:18:33 e7ae120d04cffafd9bc2b4ecd68571c17e05ed72" | |
| 117 | 117 | |
| 118 | 118 | /* |
| 119 | 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | 121 | ** |
| 122 | 122 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -111,11 +111,11 @@ | |
| 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | */ |
| 114 | #define SQLITE_VERSION "3.10.0" |
| 115 | #define SQLITE_VERSION_NUMBER 3010000 |
| 116 | #define SQLITE_SOURCE_ID "2015-12-03 22:33:55 8534a46c06601ad35b97caee442371f24c718d0f" |
| 117 | |
| 118 | /* |
| 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | ** |
| 122 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -111,11 +111,11 @@ | |
| 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | */ |
| 114 | #define SQLITE_VERSION "3.10.0" |
| 115 | #define SQLITE_VERSION_NUMBER 3010000 |
| 116 | #define SQLITE_SOURCE_ID "2015-12-07 18:18:33 e7ae120d04cffafd9bc2b4ecd68571c17e05ed72" |
| 117 | |
| 118 | /* |
| 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | ** |
| 122 |