summaryrefslogtreecommitdiff
path: root/src/test_vfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test_vfs.c')
-rw-r--r--src/test_vfs.c64
1 files changed, 46 insertions, 18 deletions
diff --git a/src/test_vfs.c b/src/test_vfs.c
index 546cb7c..d1c34a3 100644
--- a/src/test_vfs.c
+++ b/src/test_vfs.c
@@ -480,6 +480,27 @@ static int tvfsCheckReservedLock(sqlite3_file *pFile, int *pResOut){
*/
static int tvfsFileControl(sqlite3_file *pFile, int op, void *pArg){
TestvfsFd *p = tvfsGetFd(pFile);
+ if( op==SQLITE_FCNTL_PRAGMA ){
+ char **argv = (char**)pArg;
+ if( sqlite3_stricmp(argv[1],"error")==0 ){
+ int rc = SQLITE_ERROR;
+ if( argv[2] ){
+ const char *z = argv[2];
+ int x = atoi(z);
+ if( x ){
+ rc = x;
+ while( sqlite3Isdigit(z[0]) ){ z++; }
+ while( sqlite3Isspace(z[0]) ){ z++; }
+ }
+ if( z[0] ) argv[0] = sqlite3_mprintf("%s", z);
+ }
+ return rc;
+ }
+ if( sqlite3_stricmp(argv[1], "filename")==0 ){
+ argv[0] = sqlite3_mprintf("%s", p->zFilename);
+ return SQLITE_OK;
+ }
+ }
return sqlite3OsFileControl(p->pReal, op, pArg);
}
@@ -763,7 +784,7 @@ static int tvfsShmOpen(sqlite3_file *pFile){
if( 0==strcmp(pFd->zFilename, pBuffer->zFile) ) break;
}
if( !pBuffer ){
- int nByte = sizeof(TestvfsBuffer) + strlen(pFd->zFilename) + 1;
+ int nByte = sizeof(TestvfsBuffer) + (int)strlen(pFd->zFilename) + 1;
pBuffer = (TestvfsBuffer *)ckalloc(nByte);
memset(pBuffer, 0, nByte);
pBuffer->zFile = (char *)&pBuffer[1];
@@ -845,13 +866,13 @@ static int tvfsShmLock(
if( p->pScript && p->mask&TESTVFS_SHMLOCK_MASK ){
sqlite3_snprintf(sizeof(zLock), zLock, "%d %d", ofst, n);
- nLock = strlen(zLock);
+ nLock = (int)strlen(zLock);
if( flags & SQLITE_SHM_LOCK ){
strcpy(&zLock[nLock], " lock");
}else{
strcpy(&zLock[nLock], " unlock");
}
- nLock += strlen(&zLock[nLock]);
+ nLock += (int)strlen(&zLock[nLock]);
if( flags & SQLITE_SHM_SHARED ){
strcpy(&zLock[nLock], " shared");
}else{
@@ -988,7 +1009,7 @@ static int testvfs_obj_cmd(
switch( aSubcmd[i].eCmd ){
case CMD_SHM: {
Tcl_Obj *pObj;
- int i;
+ int i, rc;
TestvfsBuffer *pBuffer;
char *zName;
if( objc!=3 && objc!=4 ){
@@ -996,10 +1017,16 @@ static int testvfs_obj_cmd(
return TCL_ERROR;
}
zName = ckalloc(p->pParent->mxPathname);
- p->pParent->xFullPathname(
+ rc = p->pParent->xFullPathname(
p->pParent, Tcl_GetString(objv[2]),
p->pParent->mxPathname, zName
);
+ if( rc!=SQLITE_OK ){
+ Tcl_AppendResult(interp, "failed to get full path: ",
+ Tcl_GetString(objv[2]), 0);
+ ckfree(zName);
+ return TCL_ERROR;
+ }
for(pBuffer=p->pBuffer; pBuffer; pBuffer=pBuffer->pNext){
if( 0==strcmp(pBuffer->zFile, zName) ) break;
}
@@ -1156,18 +1183,19 @@ static int testvfs_obj_cmd(
int iValue;
} aFlag[] = {
{ "default", -1 },
- { "atomic", SQLITE_IOCAP_ATOMIC },
- { "atomic512", SQLITE_IOCAP_ATOMIC512 },
- { "atomic1k", SQLITE_IOCAP_ATOMIC1K },
- { "atomic2k", SQLITE_IOCAP_ATOMIC2K },
- { "atomic4k", SQLITE_IOCAP_ATOMIC4K },
- { "atomic8k", SQLITE_IOCAP_ATOMIC8K },
- { "atomic16k", SQLITE_IOCAP_ATOMIC16K },
- { "atomic32k", SQLITE_IOCAP_ATOMIC32K },
- { "atomic64k", SQLITE_IOCAP_ATOMIC64K },
- { "sequential", SQLITE_IOCAP_SEQUENTIAL },
- { "safe_append", SQLITE_IOCAP_SAFE_APPEND },
+ { "atomic", SQLITE_IOCAP_ATOMIC },
+ { "atomic512", SQLITE_IOCAP_ATOMIC512 },
+ { "atomic1k", SQLITE_IOCAP_ATOMIC1K },
+ { "atomic2k", SQLITE_IOCAP_ATOMIC2K },
+ { "atomic4k", SQLITE_IOCAP_ATOMIC4K },
+ { "atomic8k", SQLITE_IOCAP_ATOMIC8K },
+ { "atomic16k", SQLITE_IOCAP_ATOMIC16K },
+ { "atomic32k", SQLITE_IOCAP_ATOMIC32K },
+ { "atomic64k", SQLITE_IOCAP_ATOMIC64K },
+ { "sequential", SQLITE_IOCAP_SEQUENTIAL },
+ { "safe_append", SQLITE_IOCAP_SAFE_APPEND },
{ "undeletable_when_open", SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN },
+ { "powersafe_overwrite", SQLITE_IOCAP_POWERSAFE_OVERWRITE },
{ 0, 0 }
};
Tcl_Obj *pRet;
@@ -1201,7 +1229,7 @@ static int testvfs_obj_cmd(
iNew |= aFlag[idx].iValue;
}
- p->iDevchar = iNew;
+ p->iDevchar = iNew| 0x10000000;
}
pRet = Tcl_NewObj();
@@ -1368,7 +1396,7 @@ static int testvfs_cmd(
}
zVfs = Tcl_GetString(objv[1]);
- nByte = sizeof(Testvfs) + strlen(zVfs)+1;
+ nByte = sizeof(Testvfs) + (int)strlen(zVfs)+1;
p = (Testvfs *)ckalloc(nByte);
memset(p, 0, nByte);
p->iDevchar = -1;