mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Add new extended error codes for I/O errors on seek and shared-memory map.
Add sqlite3_log() calls in the windows backend to record details of errors. FossilOrigin-Name: fe603217fce8e3a696bd108d5ae7f7a291b7e215
This commit is contained in:
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\sa\susage\scomment\stypo\sin\sthe\sshowdb\sutility.
|
C Add\snew\sextended\serror\scodes\sfor\sI/O\serrors\son\sseek\sand\sshared-memory\smap.\nAdd\ssqlite3_log()\scalls\sin\sthe\swindows\sbackend\sto\srecord\sdetails\sof\serrors.
|
||||||
D 2011-04-13T16:52:41.916
|
D 2011-04-13T20:26:13.392
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2
|
F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -162,8 +162,8 @@ F src/os.c 22ac61d06e72a0dac900400147333b07b13d8e1d
|
|||||||
F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
|
F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
|
||||||
F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
|
F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
|
||||||
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
|
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
|
||||||
F src/os_unix.c b2d4cd9976bbcc798f33746d3fab12b3ea57ffa9
|
F src/os_unix.c 6c9db4728681138141f0bfc6f931303ac4c67a36
|
||||||
F src/os_win.c 24d72407a90551969744cf9bcbb1b4c72c5fa845
|
F src/os_win.c bcd4fbe3edb6e6bcad3426feb674856d0d677a66
|
||||||
F src/pager.c 055239dcdfe12b3f5d97f6f01f85da01e2d6d912
|
F src/pager.c 055239dcdfe12b3f5d97f6f01f85da01e2d6d912
|
||||||
F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1
|
F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1
|
||||||
F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
|
F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
|
||||||
@@ -178,7 +178,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706
|
|||||||
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
|
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
|
||||||
F src/select.c 649a6f10f7eb7b52a5a28847773cb9968a828ae8
|
F src/select.c 649a6f10f7eb7b52a5a28847773cb9968a828ae8
|
||||||
F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79
|
F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79
|
||||||
F src/sqlite.h.in 4d28db70c37a1b17942820308eb59f211140da43
|
F src/sqlite.h.in fe9a777d43276b4778e92b16a8b89ea6c38bb32b
|
||||||
F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754
|
F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754
|
||||||
F src/sqliteInt.h ac8f3f5846275c634f6649969304a9e97f6f9854
|
F src/sqliteInt.h ac8f3f5846275c634f6649969304a9e97f6f9854
|
||||||
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
||||||
@@ -929,7 +929,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
|||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c
|
F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
P a35e83eac7b185f4d363d7fa51677f2fdfa27695
|
P 8744ced4ec495852b7aa2de573001cb4993e6328
|
||||||
R f5f7247c7feeae44d4f2f556cf926eb4
|
R a6242b7bfc19e91e66c655c801889c0d
|
||||||
U drh
|
U drh
|
||||||
Z da92f7ef9fc7e97867d6f6d083c9ff23
|
Z fad7310c621c7362baadef9a16659a99
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
8744ced4ec495852b7aa2de573001cb4993e6328
|
fe603217fce8e3a696bd108d5ae7f7a291b7e215
|
||||||
@@ -3915,7 +3915,7 @@ static int unixShmMap(
|
|||||||
MAP_SHARED, pShmNode->h, pShmNode->nRegion*szRegion
|
MAP_SHARED, pShmNode->h, pShmNode->nRegion*szRegion
|
||||||
);
|
);
|
||||||
if( pMem==MAP_FAILED ){
|
if( pMem==MAP_FAILED ){
|
||||||
rc = SQLITE_IOERR;
|
rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
|
||||||
goto shmpage_out;
|
goto shmpage_out;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
198
src/os_win.c
198
src/os_win.c
@@ -118,6 +118,7 @@ struct winFile {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Forward prototypes.
|
** Forward prototypes.
|
||||||
*/
|
*/
|
||||||
@@ -298,6 +299,106 @@ static char *utf8ToMbcs(const char *zFilename){
|
|||||||
return zFilenameMbcs;
|
return zFilenameMbcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The return value of getLastErrorMsg
|
||||||
|
** is zero if the error message fits in the buffer, or non-zero
|
||||||
|
** otherwise (if the message was truncated).
|
||||||
|
*/
|
||||||
|
static int getLastErrorMsg(int nBuf, char *zBuf){
|
||||||
|
/* FormatMessage returns 0 on failure. Otherwise it
|
||||||
|
** returns the number of TCHARs written to the output
|
||||||
|
** buffer, excluding the terminating null char.
|
||||||
|
*/
|
||||||
|
DWORD error = GetLastError();
|
||||||
|
DWORD dwLen = 0;
|
||||||
|
char *zOut = 0;
|
||||||
|
|
||||||
|
if( isNT() ){
|
||||||
|
WCHAR *zTempWide = NULL;
|
||||||
|
dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
NULL,
|
||||||
|
error,
|
||||||
|
0,
|
||||||
|
(LPWSTR) &zTempWide,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
if( dwLen > 0 ){
|
||||||
|
/* allocate a buffer and convert to UTF8 */
|
||||||
|
zOut = unicodeToUtf8(zTempWide);
|
||||||
|
/* free the system buffer allocated by FormatMessage */
|
||||||
|
LocalFree(zTempWide);
|
||||||
|
}
|
||||||
|
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
|
||||||
|
** Since the ASCII version of these Windows API do not exist for WINCE,
|
||||||
|
** it's important to not reference them for WINCE builds.
|
||||||
|
*/
|
||||||
|
#if SQLITE_OS_WINCE==0
|
||||||
|
}else{
|
||||||
|
char *zTemp = NULL;
|
||||||
|
dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
NULL,
|
||||||
|
error,
|
||||||
|
0,
|
||||||
|
(LPSTR) &zTemp,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
if( dwLen > 0 ){
|
||||||
|
/* allocate a buffer and convert to UTF8 */
|
||||||
|
zOut = sqlite3_win32_mbcs_to_utf8(zTemp);
|
||||||
|
/* free the system buffer allocated by FormatMessage */
|
||||||
|
LocalFree(zTemp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if( 0 == dwLen ){
|
||||||
|
sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error);
|
||||||
|
}else{
|
||||||
|
/* copy a maximum of nBuf chars to output buffer */
|
||||||
|
sqlite3_snprintf(nBuf, zBuf, "%s", zOut);
|
||||||
|
/* free the UTF8 buffer */
|
||||||
|
free(zOut);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
**
|
||||||
|
** This function - winLogErrorAtLine() - is only ever called via the macro
|
||||||
|
** winLogError().
|
||||||
|
**
|
||||||
|
** This routine is invoked after an error occurs in an OS function.
|
||||||
|
** It logs a message using sqlite3_log() containing the current value of
|
||||||
|
** error code and, if possible, the human-readable equivalent from
|
||||||
|
** FormatMessage.
|
||||||
|
**
|
||||||
|
** The first argument passed to the macro should be the error code that
|
||||||
|
** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN).
|
||||||
|
** The two subsequent arguments should be the name of the OS function that
|
||||||
|
** failed and the the associated file-system path, if any.
|
||||||
|
*/
|
||||||
|
#define winLogError(a,b,c) winLogErrorAtLine(a,b,c,__LINE__)
|
||||||
|
static int winLogErrorAtLine(
|
||||||
|
int errcode, /* SQLite error code */
|
||||||
|
const char *zFunc, /* Name of OS function that failed */
|
||||||
|
const char *zPath, /* File path associated with error */
|
||||||
|
int iLine /* Source line number where error occurred */
|
||||||
|
){
|
||||||
|
char zMsg[500]; /* Human readable error text */
|
||||||
|
DWORD iErrno = GetLastError(); /* Error code */
|
||||||
|
|
||||||
|
zMsg[0] = 0;
|
||||||
|
getLastErrorMsg(sizeof(zMsg), zMsg);
|
||||||
|
assert( errcode!=SQLITE_OK );
|
||||||
|
if( zPath==0 ) zPath = "";
|
||||||
|
sqlite3_log(errcode,
|
||||||
|
"os_win.c:%d: (%d) %s(%s) - %s",
|
||||||
|
iLine, iErrno, zFunc, zPath, zMsg
|
||||||
|
);
|
||||||
|
|
||||||
|
return errcode;
|
||||||
|
}
|
||||||
|
|
||||||
#if SQLITE_OS_WINCE
|
#if SQLITE_OS_WINCE
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
** This section contains code for WinCE only.
|
** This section contains code for WinCE only.
|
||||||
@@ -375,6 +476,7 @@ static BOOL winceCreateLock(const char *zFilename, winFile *pFile){
|
|||||||
pFile->hMutex = CreateMutexW(NULL, FALSE, zName);
|
pFile->hMutex = CreateMutexW(NULL, FALSE, zName);
|
||||||
if (!pFile->hMutex){
|
if (!pFile->hMutex){
|
||||||
pFile->lastErrno = GetLastError();
|
pFile->lastErrno = GetLastError();
|
||||||
|
winLogError(SQLITE_ERROR, "winceCreateLock1", zFilename);
|
||||||
free(zName);
|
free(zName);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -406,6 +508,7 @@ static BOOL winceCreateLock(const char *zFilename, winFile *pFile){
|
|||||||
/* If mapping failed, close the shared memory handle and erase it */
|
/* If mapping failed, close the shared memory handle and erase it */
|
||||||
if (!pFile->shared){
|
if (!pFile->shared){
|
||||||
pFile->lastErrno = GetLastError();
|
pFile->lastErrno = GetLastError();
|
||||||
|
winLogError(SQLITE_ERROR, "winceCreateLock2", zFilename);
|
||||||
CloseHandle(pFile->hShared);
|
CloseHandle(pFile->hShared);
|
||||||
pFile->hShared = NULL;
|
pFile->hShared = NULL;
|
||||||
}
|
}
|
||||||
@@ -651,6 +754,7 @@ static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){
|
|||||||
dwRet = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
|
dwRet = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
|
||||||
if( (dwRet==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR) ){
|
if( (dwRet==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR) ){
|
||||||
pFile->lastErrno = GetLastError();
|
pFile->lastErrno = GetLastError();
|
||||||
|
winLogError(SQLITE_IOERR_SEEK, "seekWinFile", pFile->zPath);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,7 +800,8 @@ static int winClose(sqlite3_file *id){
|
|||||||
#endif
|
#endif
|
||||||
OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
|
OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
|
||||||
OpenCounter(-1);
|
OpenCounter(-1);
|
||||||
return rc ? SQLITE_OK : SQLITE_IOERR;
|
return rc ? SQLITE_OK
|
||||||
|
: winLogError(SQLITE_IOERR_CLOSE, "winClose", pFile->zPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -722,7 +827,7 @@ static int winRead(
|
|||||||
}
|
}
|
||||||
if( !ReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
|
if( !ReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
|
||||||
pFile->lastErrno = GetLastError();
|
pFile->lastErrno = GetLastError();
|
||||||
return SQLITE_IOERR_READ;
|
return winLogError(SQLITE_IOERR_READ, "winRead", pFile->zPath);
|
||||||
}
|
}
|
||||||
if( nRead<(DWORD)amt ){
|
if( nRead<(DWORD)amt ){
|
||||||
/* Unread parts of the buffer must be zero-filled */
|
/* Unread parts of the buffer must be zero-filled */
|
||||||
@@ -773,7 +878,7 @@ static int winWrite(
|
|||||||
if( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ){
|
if( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ){
|
||||||
return SQLITE_FULL;
|
return SQLITE_FULL;
|
||||||
}
|
}
|
||||||
return SQLITE_IOERR_WRITE;
|
return winLogError(SQLITE_IOERR_WRITE, "winWrite", pFile->zPath);
|
||||||
}
|
}
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
@@ -801,10 +906,10 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
|
|||||||
|
|
||||||
/* SetEndOfFile() returns non-zero when successful, or zero when it fails. */
|
/* SetEndOfFile() returns non-zero when successful, or zero when it fails. */
|
||||||
if( seekWinFile(pFile, nByte) ){
|
if( seekWinFile(pFile, nByte) ){
|
||||||
rc = SQLITE_IOERR_TRUNCATE;
|
rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate1", pFile->zPath);
|
||||||
}else if( 0==SetEndOfFile(pFile->h) ){
|
}else if( 0==SetEndOfFile(pFile->h) ){
|
||||||
pFile->lastErrno = GetLastError();
|
pFile->lastErrno = GetLastError();
|
||||||
rc = SQLITE_IOERR_TRUNCATE;
|
rc = winLogError(SQLITE_IOERR_TRUNCATE, "winTruncate2", pFile->zPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
OSTRACE(("TRUNCATE %d %lld %s\n", pFile->h, nByte, rc ? "failed" : "ok"));
|
OSTRACE(("TRUNCATE %d %lld %s\n", pFile->h, nByte, rc ? "failed" : "ok"));
|
||||||
@@ -863,7 +968,7 @@ static int winSync(sqlite3_file *id, int flags){
|
|||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}else{
|
}else{
|
||||||
pFile->lastErrno = GetLastError();
|
pFile->lastErrno = GetLastError();
|
||||||
return SQLITE_IOERR;
|
return winLogError(SQLITE_IOERR_FSYNC, "winSync", pFile->zPath);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -884,7 +989,7 @@ static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){
|
|||||||
&& ((error = GetLastError()) != NO_ERROR) )
|
&& ((error = GetLastError()) != NO_ERROR) )
|
||||||
{
|
{
|
||||||
pFile->lastErrno = error;
|
pFile->lastErrno = error;
|
||||||
return SQLITE_IOERR_FSTAT;
|
return winLogError(SQLITE_IOERR_FSTAT, "winFileSize", pFile->zPath);
|
||||||
}
|
}
|
||||||
*pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;
|
*pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
@@ -923,6 +1028,7 @@ static int getReadLock(winFile *pFile){
|
|||||||
}
|
}
|
||||||
if( res == 0 ){
|
if( res == 0 ){
|
||||||
pFile->lastErrno = GetLastError();
|
pFile->lastErrno = GetLastError();
|
||||||
|
/* No need to log a failure to lock */
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -943,6 +1049,7 @@ static int unlockReadLock(winFile *pFile){
|
|||||||
}
|
}
|
||||||
if( res == 0 ){
|
if( res == 0 ){
|
||||||
pFile->lastErrno = GetLastError();
|
pFile->lastErrno = GetLastError();
|
||||||
|
winLogError(SQLITE_IOERR_UNLOCK, "unlockReadLock", pFile->zPath);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -1143,7 +1250,7 @@ static int winUnlock(sqlite3_file *id, int locktype){
|
|||||||
if( locktype==SHARED_LOCK && !getReadLock(pFile) ){
|
if( locktype==SHARED_LOCK && !getReadLock(pFile) ){
|
||||||
/* This should never happen. We should always be able to
|
/* This should never happen. We should always be able to
|
||||||
** reacquire the read lock */
|
** reacquire the read lock */
|
||||||
rc = SQLITE_IOERR_UNLOCK;
|
rc = winLogError(SQLITE_IOERR_UNLOCK, "winUnlock", pFile->zPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( type>=RESERVED_LOCK ){
|
if( type>=RESERVED_LOCK ){
|
||||||
@@ -1500,7 +1607,7 @@ static int winOpenSharedMemory(winFile *pDbFd){
|
|||||||
if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
|
if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
|
||||||
rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
|
rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
rc = SQLITE_IOERR_SHMOPEN;
|
rc = winLogError(SQLITE_IOERR_SHMOPEN, "winOpenShm", pDbFd->zPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
@@ -1759,7 +1866,7 @@ static int winShmMap(
|
|||||||
*/
|
*/
|
||||||
rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);
|
rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
rc = SQLITE_IOERR_SHMSIZE;
|
rc = winLogError(SQLITE_IOERR_SHMSIZE, "winShmMap1", pDbFd->zPath);
|
||||||
goto shmpage_out;
|
goto shmpage_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1773,7 +1880,7 @@ static int winShmMap(
|
|||||||
if( !isWrite ) goto shmpage_out;
|
if( !isWrite ) goto shmpage_out;
|
||||||
rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);
|
rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
rc = SQLITE_IOERR_SHMSIZE;
|
rc = winLogError(SQLITE_IOERR_SHMSIZE, "winShmMap2", pDbFd->zPath);
|
||||||
goto shmpage_out;
|
goto shmpage_out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1810,7 +1917,7 @@ static int winShmMap(
|
|||||||
}
|
}
|
||||||
if( !pMap ){
|
if( !pMap ){
|
||||||
pShmNode->lastErrno = GetLastError();
|
pShmNode->lastErrno = GetLastError();
|
||||||
rc = SQLITE_IOERR;
|
rc = winLogError(SQLITE_IOERR_SHMMAP, "winShmMap3", pDbFd->zPath);
|
||||||
if( hMap ) CloseHandle(hMap);
|
if( hMap ) CloseHandle(hMap);
|
||||||
goto shmpage_out;
|
goto shmpage_out;
|
||||||
}
|
}
|
||||||
@@ -1972,68 +2079,6 @@ static int getTempname(int nBuf, char *zBuf){
|
|||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** The return value of getLastErrorMsg
|
|
||||||
** is zero if the error message fits in the buffer, or non-zero
|
|
||||||
** otherwise (if the message was truncated).
|
|
||||||
*/
|
|
||||||
static int getLastErrorMsg(int nBuf, char *zBuf){
|
|
||||||
/* FormatMessage returns 0 on failure. Otherwise it
|
|
||||||
** returns the number of TCHARs written to the output
|
|
||||||
** buffer, excluding the terminating null char.
|
|
||||||
*/
|
|
||||||
DWORD error = GetLastError();
|
|
||||||
DWORD dwLen = 0;
|
|
||||||
char *zOut = 0;
|
|
||||||
|
|
||||||
if( isNT() ){
|
|
||||||
WCHAR *zTempWide = NULL;
|
|
||||||
dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
NULL,
|
|
||||||
error,
|
|
||||||
0,
|
|
||||||
(LPWSTR) &zTempWide,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
if( dwLen > 0 ){
|
|
||||||
/* allocate a buffer and convert to UTF8 */
|
|
||||||
zOut = unicodeToUtf8(zTempWide);
|
|
||||||
/* free the system buffer allocated by FormatMessage */
|
|
||||||
LocalFree(zTempWide);
|
|
||||||
}
|
|
||||||
/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed.
|
|
||||||
** Since the ASCII version of these Windows API do not exist for WINCE,
|
|
||||||
** it's important to not reference them for WINCE builds.
|
|
||||||
*/
|
|
||||||
#if SQLITE_OS_WINCE==0
|
|
||||||
}else{
|
|
||||||
char *zTemp = NULL;
|
|
||||||
dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
NULL,
|
|
||||||
error,
|
|
||||||
0,
|
|
||||||
(LPSTR) &zTemp,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
if( dwLen > 0 ){
|
|
||||||
/* allocate a buffer and convert to UTF8 */
|
|
||||||
zOut = sqlite3_win32_mbcs_to_utf8(zTemp);
|
|
||||||
/* free the system buffer allocated by FormatMessage */
|
|
||||||
LocalFree(zTemp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if( 0 == dwLen ){
|
|
||||||
sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error);
|
|
||||||
}else{
|
|
||||||
/* copy a maximum of nBuf chars to output buffer */
|
|
||||||
sqlite3_snprintf(nBuf, zBuf, "%s", zOut);
|
|
||||||
/* free the UTF8 buffer */
|
|
||||||
free(zOut);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Open a file.
|
** Open a file.
|
||||||
*/
|
*/
|
||||||
@@ -2205,6 +2250,7 @@ static int winOpen(
|
|||||||
|
|
||||||
if( h==INVALID_HANDLE_VALUE ){
|
if( h==INVALID_HANDLE_VALUE ){
|
||||||
pFile->lastErrno = GetLastError();
|
pFile->lastErrno = GetLastError();
|
||||||
|
winLogError(SQLITE_CANTOPEN, "winOpen", zUtf8Name);
|
||||||
free(zConverted);
|
free(zConverted);
|
||||||
if( isReadWrite ){
|
if( isReadWrite ){
|
||||||
return winOpen(pVfs, zName, id,
|
return winOpen(pVfs, zName, id,
|
||||||
@@ -2308,7 +2354,8 @@ static int winDelete(
|
|||||||
"ok" : "failed" ));
|
"ok" : "failed" ));
|
||||||
|
|
||||||
return ( (rc == INVALID_FILE_ATTRIBUTES)
|
return ( (rc == INVALID_FILE_ATTRIBUTES)
|
||||||
&& (error == ERROR_FILE_NOT_FOUND)) ? SQLITE_OK : SQLITE_IOERR_DELETE;
|
&& (error == ERROR_FILE_NOT_FOUND)) ? SQLITE_OK :
|
||||||
|
winLogError(SQLITE_IOERR_DELETE, "winDelete", zFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2348,6 +2395,7 @@ static int winAccess(
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if( GetLastError()!=ERROR_FILE_NOT_FOUND ){
|
if( GetLastError()!=ERROR_FILE_NOT_FOUND ){
|
||||||
|
winLogError(SQLITE_IOERR_ACCESS, "winAccess", zFilename);
|
||||||
free(zConverted);
|
free(zConverted);
|
||||||
return SQLITE_IOERR_ACCESS;
|
return SQLITE_IOERR_ACCESS;
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -447,6 +447,8 @@ int sqlite3_exec(
|
|||||||
#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8))
|
#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8))
|
||||||
#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8))
|
#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8))
|
||||||
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
|
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
|
||||||
|
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
|
||||||
|
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
|
||||||
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
|
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
|
||||||
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
|
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
|
||||||
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
|
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
|
||||||
|
|||||||
Reference in New Issue
Block a user