Update all built-in VFSes to return SQLITE_OK for the
SQLITE_FCNTL_SYNC_OMITTED file-control operation. Also change the
xFileControl methods to return SQLITE_NOTFOUND for unrecognized
operation codes.
FossilOrigin-Name: 6f2c72a0f6579db3f40c079436ca40e3e52bd6d9
diff --git a/src/main.c b/src/main.c
index 4b93a2b..88dfcf0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -816,7 +816,7 @@
/* SQLITE_INTERRUPT */ "interrupted",
/* SQLITE_IOERR */ "disk I/O error",
/* SQLITE_CORRUPT */ "database disk image is malformed",
- /* SQLITE_NOTFOUND */ 0,
+ /* SQLITE_NOTFOUND */ "unknown operation",
/* SQLITE_FULL */ "database or disk is full",
/* SQLITE_CANTOPEN */ "unable to open database file",
/* SQLITE_PROTOCOL */ "locking protocol",
@@ -2364,6 +2364,8 @@
rc = SQLITE_OK;
}else if( fd->pMethods ){
rc = sqlite3OsFileControl(fd, op, pArg);
+ }else{
+ rc = SQLITE_NOTFOUND;
}
sqlite3BtreeLeave(pBtree);
}
diff --git a/src/os_os2.c b/src/os_os2.c
index 7ac0cc7..df5ad10 100644
--- a/src/os_os2.c
+++ b/src/os_os2.c
@@ -533,7 +533,7 @@
return SQLITE_OK;
}
}
- return SQLITE_ERROR;
+ return SQLITE_NOTFOUND;
}
/*
diff --git a/src/os_unix.c b/src/os_unix.c
index edc716c..fa200ae 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -3135,8 +3135,11 @@
return proxyFileControl(id,op,pArg);
}
#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */
+ case SQLITE_FCNTL_SYNC_OMITTED: {
+ return SQLITE_OK; /* A no-op */
+ }
}
- return SQLITE_ERROR;
+ return SQLITE_NOTFOUND;
}
/*
diff --git a/src/os_win.c b/src/os_win.c
index 1be5149..7042517 100644
--- a/src/os_win.c
+++ b/src/os_win.c
@@ -1183,8 +1183,11 @@
SimulateIOErrorBenign(0);
return SQLITE_OK;
}
+ case SQLITE_FCNTL_SYNC_OMITTED: {
+ return SQLITE_OK;
+ }
}
- return SQLITE_ERROR;
+ return SQLITE_NOTFOUND;
}
/*
diff --git a/src/sqlite.h.in b/src/sqlite.h.in
index f3d7092..eb97746 100644
--- a/src/sqlite.h.in
+++ b/src/sqlite.h.in
@@ -385,7 +385,7 @@
#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/
#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */
#define SQLITE_CORRUPT 11 /* The database disk image is malformed */
-#define SQLITE_NOTFOUND 12 /* NOT USED. Table or record not found */
+#define SQLITE_NOTFOUND 12 /* Unknown opcode in sqlite3_file_control() */
#define SQLITE_FULL 13 /* Insertion failed because database is full */
#define SQLITE_CANTOPEN 14 /* Unable to open the database file */
#define SQLITE_PROTOCOL 15 /* Database lock protocol error */
@@ -617,7 +617,9 @@
** core reserves all opcodes less than 100 for its own use.
** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available.
** Applications that define a custom xFileControl method should use opcodes
-** greater than 100 to avoid conflicts.
+** greater than 100 to avoid conflicts. VFS implementations should
+** return [SQLITE_NOTFOUND] for file control opcodes that they do not
+** recognize.
**
** The xSectorSize() method returns the sector size of the
** device that underlies the file. The sector size is the
diff --git a/src/test1.c b/src/test1.c
index bab7845..cf7e06b 100644
--- a/src/test1.c
+++ b/src/test1.c
@@ -4801,13 +4801,13 @@
}
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
rc = sqlite3_file_control(db, 0, 0, &iArg);
- assert( rc==SQLITE_ERROR );
+ assert( rc==SQLITE_NOTFOUND );
rc = sqlite3_file_control(db, "notadatabase", SQLITE_FCNTL_LOCKSTATE, &iArg);
assert( rc==SQLITE_ERROR );
rc = sqlite3_file_control(db, "main", -1, &iArg);
- assert( rc==SQLITE_ERROR );
+ assert( rc==SQLITE_NOTFOUND );
rc = sqlite3_file_control(db, "temp", -1, &iArg);
- assert( rc==SQLITE_ERROR );
+ assert( rc==SQLITE_NOTFOUND || rc==SQLITE_ERROR );
return TCL_OK;
}