声明:本SQLite源码剖析系列为刘兴(http://deepfuture.iteye.com/)原创,未经笔者授权,任何人和机构不能转载
** CAPI3REF: File Locking Levels
**文件锁,SQLITE使用这些整数值中的一个做为第2个参数调用sqlite3_io_methods对象的xlock()和xUunlock()方法
** SQLite uses one of these integer values as the second
** argument to calls it makes to the xLock() and xUnlock() methods
** of an [sqlite3_io_methods] object.
*/
#define SQLITE_LOCK_NONE 0
#define SQLITE_LOCK_SHARED 1
#define SQLITE_LOCK_RESERVED 2
#define SQLITE_LOCK_PENDING 3
#define SQLITE_LOCK_EXCLUSIVE 4
/*
** CAPI3REF: Synchronization Type Flags
**同步标志
** When SQLite invokes the xSync() method of an
** [sqlite3_io_methods] object it uses a combination of
** these integer values as the second argument.
**sqlite3_io_methods对象的xSync()方法使用这些整数值做为第2个参数
** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
** sync operation only needs to flush data to mass storage. Inode
** information need not be flushed. If the lower four bits of the flag
**SQLITE_SYNC_DATAONLY标志表示同步操作仅需要用于更新数据在主存区,索引信息不需要更新,如果flag的最低4位为SQLITE_SYNC_NORMAL,则使用fsync()。如果低4位为SQLITE_SYNC_FULL,则使用Mac OS X的fullsync替代fsync()
** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
** If the lower four bits equal SQLITE_SYNC_FULL, that means
** to use Mac OS X style fullsync instead of fsync().
*/
#define SQLITE_SYNC_NORMAL 0x00002
#define SQLITE_SYNC_FULL 0x00003
#define SQLITE_SYNC_DATAONLY 0x00010
本文解析了SQLite中使用的文件锁定级别及同步类型标志。详细介绍了不同锁级别的含义及其在xLock()和xUnlock()方法中的应用,并解释了同步标志在xSync()方法中的作用,包括SQLITE_SYNC_DATAONLY、SQLITE_SYNC_NORMAL和SQLITE_SYNC_FULL的区别。
547

被折叠的 条评论
为什么被折叠?



