mirror of
https://github.com/php/php-src.git
synced 2025-08-20 09:24:05 +02:00
Upgrade libsqlite 3 inside PDO sqlite to version 3.3.15
This commit is contained in:
parent
857f992cd3
commit
eb8d30f912
51 changed files with 5351 additions and 3624 deletions
|
@ -596,6 +596,7 @@ int sqlite3WinDelete(const char *zFilename){
|
|||
if( zConverted==0 ){
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
SimulateIOError(return SQLITE_IOERR_DELETE);
|
||||
if( isNT() ){
|
||||
do{
|
||||
rc = DeleteFileW(zConverted);
|
||||
|
@ -612,7 +613,7 @@ int sqlite3WinDelete(const char *zFilename){
|
|||
#endif
|
||||
}
|
||||
sqliteFree(zConverted);
|
||||
TRACE2("DELETE \"%s\"\n", zFilename);
|
||||
OSTRACE2("DELETE \"%s\"\n", zFilename);
|
||||
return rc!=0 ? SQLITE_OK : SQLITE_IOERR;
|
||||
}
|
||||
|
||||
|
@ -738,7 +739,7 @@ int sqlite3WinOpenReadWrite(
|
|||
#if OS_WINCE
|
||||
f.zDeleteOnClose = 0;
|
||||
#endif
|
||||
TRACE3("OPEN R/W %d \"%s\"\n", h, zFilename);
|
||||
OSTRACE3("OPEN R/W %d \"%s\"\n", h, zFilename);
|
||||
return allocateWinFile(&f, pId);
|
||||
}
|
||||
|
||||
|
@ -819,7 +820,7 @@ int sqlite3WinOpenExclusive(const char *zFilename, OsFile **pId, int delFlag){
|
|||
return SQLITE_CANTOPEN;
|
||||
}
|
||||
f.h = h;
|
||||
TRACE3("OPEN EX %d \"%s\"\n", h, zFilename);
|
||||
OSTRACE3("OPEN EX %d \"%s\"\n", h, zFilename);
|
||||
return allocateWinFile(&f, pId);
|
||||
}
|
||||
|
||||
|
@ -870,7 +871,7 @@ int sqlite3WinOpenReadOnly(const char *zFilename, OsFile **pId){
|
|||
f.zDeleteOnClose = 0;
|
||||
f.hMutex = NULL;
|
||||
#endif
|
||||
TRACE3("OPEN RO %d \"%s\"\n", h, zFilename);
|
||||
OSTRACE3("OPEN RO %d \"%s\"\n", h, zFilename);
|
||||
return allocateWinFile(&f, pId);
|
||||
}
|
||||
|
||||
|
@ -897,13 +898,6 @@ static int winOpenDirectory(
|
|||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** If the following global variable points to a string which is the
|
||||
** name of a directory, then that directory will be used to store
|
||||
** temporary files.
|
||||
*/
|
||||
char *sqlite3_temp_directory = 0;
|
||||
|
||||
/*
|
||||
** Create a temporary file name in zBuf. zBuf must be big enough to
|
||||
** hold at least SQLITE_TEMPNAME_SIZE characters.
|
||||
|
@ -955,7 +949,7 @@ int sqlite3WinTempFileName(char *zBuf){
|
|||
zBuf[j] = 0;
|
||||
if( !sqlite3OsFileExists(zBuf) ) break;
|
||||
}
|
||||
TRACE2("TEMP FILENAME: %s\n", zBuf);
|
||||
OSTRACE2("TEMP FILENAME: %s\n", zBuf);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
|
@ -975,7 +969,7 @@ static int winClose(OsFile **pId){
|
|||
int rc = 1;
|
||||
if( pId && (pFile = (winFile*)*pId)!=0 ){
|
||||
int rc, cnt = 0;
|
||||
TRACE2("CLOSE %d\n", pFile->h);
|
||||
OSTRACE2("CLOSE %d\n", pFile->h);
|
||||
do{
|
||||
rc = CloseHandle(pFile->h);
|
||||
}while( rc==0 && cnt++ < MX_CLOSE_ATTEMPT && (Sleep(100), 1) );
|
||||
|
@ -1002,7 +996,7 @@ static int winRead(OsFile *id, void *pBuf, int amt){
|
|||
DWORD got;
|
||||
assert( id!=0 );
|
||||
SimulateIOError(return SQLITE_IOERR_READ);
|
||||
TRACE3("READ %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
|
||||
OSTRACE3("READ %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
|
||||
if( !ReadFile(((winFile*)id)->h, pBuf, amt, &got, 0) ){
|
||||
return SQLITE_IOERR_READ;
|
||||
}
|
||||
|
@ -1024,7 +1018,7 @@ static int winWrite(OsFile *id, const void *pBuf, int amt){
|
|||
assert( id!=0 );
|
||||
SimulateIOError(return SQLITE_IOERR_READ);
|
||||
SimulateDiskfullError(return SQLITE_FULL);
|
||||
TRACE3("WRITE %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
|
||||
OSTRACE3("WRITE %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
|
||||
assert( amt>0 );
|
||||
while( amt>0 && (rc = WriteFile(((winFile*)id)->h, pBuf, amt, &wrote, 0))!=0
|
||||
&& wrote>0 ){
|
||||
|
@ -1055,9 +1049,8 @@ static int winSeek(OsFile *id, i64 offset){
|
|||
#ifdef SQLITE_TEST
|
||||
if( offset ) SimulateDiskfullError(return SQLITE_FULL);
|
||||
#endif
|
||||
SEEK(offset/1024 + 1);
|
||||
rc = SetFilePointer(((winFile*)id)->h, lowerBits, &upperBits, FILE_BEGIN);
|
||||
TRACE3("SEEK %d %lld\n", ((winFile*)id)->h, offset);
|
||||
OSTRACE3("SEEK %d %lld\n", ((winFile*)id)->h, offset);
|
||||
if( rc==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR ){
|
||||
return SQLITE_FULL;
|
||||
}
|
||||
|
@ -1069,7 +1062,7 @@ static int winSeek(OsFile *id, i64 offset){
|
|||
*/
|
||||
static int winSync(OsFile *id, int dataOnly){
|
||||
assert( id!=0 );
|
||||
TRACE3("SYNC %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
|
||||
OSTRACE3("SYNC %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
|
||||
if( FlushFileBuffers(((winFile*)id)->h) ){
|
||||
return SQLITE_OK;
|
||||
}else{
|
||||
|
@ -1092,7 +1085,7 @@ int sqlite3WinSyncDirectory(const char *zDirname){
|
|||
static int winTruncate(OsFile *id, i64 nByte){
|
||||
LONG upperBits = nByte>>32;
|
||||
assert( id!=0 );
|
||||
TRACE3("TRUNCATE %d %lld\n", ((winFile*)id)->h, nByte);
|
||||
OSTRACE3("TRUNCATE %d %lld\n", ((winFile*)id)->h, nByte);
|
||||
SimulateIOError(return SQLITE_IOERR_TRUNCATE);
|
||||
SetFilePointer(((winFile*)id)->h, nByte, &upperBits, FILE_BEGIN);
|
||||
SetEndOfFile(((winFile*)id)->h);
|
||||
|
@ -1220,7 +1213,7 @@ static int winLock(OsFile *id, int locktype){
|
|||
winFile *pFile = (winFile*)id;
|
||||
|
||||
assert( pFile!=0 );
|
||||
TRACE5("LOCK %d %d was %d(%d)\n",
|
||||
OSTRACE5("LOCK %d %d was %d(%d)\n",
|
||||
pFile->h, locktype, pFile->locktype, pFile->sharedLockByte);
|
||||
|
||||
/* If there is already a lock of this type or more restrictive on the
|
||||
|
@ -1250,7 +1243,7 @@ static int winLock(OsFile *id, int locktype){
|
|||
/* Try 3 times to get the pending lock. The pending lock might be
|
||||
** held by another reader process who will release it momentarily.
|
||||
*/
|
||||
TRACE2("could not get a PENDING lock. cnt=%d\n", cnt);
|
||||
OSTRACE2("could not get a PENDING lock. cnt=%d\n", cnt);
|
||||
Sleep(1);
|
||||
}
|
||||
gotPendingLock = res;
|
||||
|
@ -1288,12 +1281,12 @@ static int winLock(OsFile *id, int locktype){
|
|||
if( locktype==EXCLUSIVE_LOCK && res ){
|
||||
assert( pFile->locktype>=SHARED_LOCK );
|
||||
res = unlockReadLock(pFile);
|
||||
TRACE2("unreadlock = %d\n", res);
|
||||
OSTRACE2("unreadlock = %d\n", res);
|
||||
res = LockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
|
||||
if( res ){
|
||||
newLocktype = EXCLUSIVE_LOCK;
|
||||
}else{
|
||||
TRACE2("error-code = %d\n", GetLastError());
|
||||
OSTRACE2("error-code = %d\n", GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1310,7 +1303,7 @@ static int winLock(OsFile *id, int locktype){
|
|||
if( res ){
|
||||
rc = SQLITE_OK;
|
||||
}else{
|
||||
TRACE4("LOCK FAILED %d trying for %d but got %d\n", pFile->h,
|
||||
OSTRACE4("LOCK FAILED %d trying for %d but got %d\n", pFile->h,
|
||||
locktype, newLocktype);
|
||||
rc = SQLITE_BUSY;
|
||||
}
|
||||
|
@ -1329,14 +1322,14 @@ static int winCheckReservedLock(OsFile *id){
|
|||
assert( pFile!=0 );
|
||||
if( pFile->locktype>=RESERVED_LOCK ){
|
||||
rc = 1;
|
||||
TRACE3("TEST WR-LOCK %d %d (local)\n", pFile->h, rc);
|
||||
OSTRACE3("TEST WR-LOCK %d %d (local)\n", pFile->h, rc);
|
||||
}else{
|
||||
rc = LockFile(pFile->h, RESERVED_BYTE, 0, 1, 0);
|
||||
if( rc ){
|
||||
UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0);
|
||||
}
|
||||
rc = !rc;
|
||||
TRACE3("TEST WR-LOCK %d %d (remote)\n", pFile->h, rc);
|
||||
OSTRACE3("TEST WR-LOCK %d %d (remote)\n", pFile->h, rc);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
@ -1358,7 +1351,7 @@ static int winUnlock(OsFile *id, int locktype){
|
|||
winFile *pFile = (winFile*)id;
|
||||
assert( pFile!=0 );
|
||||
assert( locktype<=SHARED_LOCK );
|
||||
TRACE5("UNLOCK %d to %d was %d(%d)\n", pFile->h, locktype,
|
||||
OSTRACE5("UNLOCK %d to %d was %d(%d)\n", pFile->h, locktype,
|
||||
pFile->locktype, pFile->sharedLockByte);
|
||||
type = pFile->locktype;
|
||||
if( type>=EXCLUSIVE_LOCK ){
|
||||
|
@ -1454,6 +1447,20 @@ static int winLockState(OsFile *id){
|
|||
return ((winFile*)id)->locktype;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the sector size in bytes of the underlying block device for
|
||||
** the specified file. This is almost always 512 bytes, but may be
|
||||
** larger for some devices.
|
||||
**
|
||||
** SQLite code assumes this function cannot fail. It also assumes that
|
||||
** if two files are created in the same file-system directory (i.e.
|
||||
** a database and it's journal file) that the sector size will be the
|
||||
** same for both.
|
||||
*/
|
||||
static int winSectorSize(OsFile *id){
|
||||
return SQLITE_DEFAULT_SECTOR_SIZE;
|
||||
}
|
||||
|
||||
/*
|
||||
** This vector defines all the methods that can operate on an OsFile
|
||||
** for win32.
|
||||
|
@ -1473,6 +1480,7 @@ static const IoMethod sqlite3WinIoMethod = {
|
|||
winUnlock,
|
||||
winLockState,
|
||||
winCheckReservedLock,
|
||||
winSectorSize,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue