设为首页 收藏本站
查看: 1124|回复: 0

[经验分享] sqlite源码剖析(18)

[复制链接]

尚未签到

发表于 2016-11-29 08:36:33 | 显示全部楼层 |阅读模式
  声明:本SQLite源码剖析系列为刘兴(http://deepfuture.iyunv.com/)原创,未经笔者授权,任何人和机构不能转载
  ** CAPI3REF: OS Interface Open File Handle
  **sqlite3_file对象代表一个在sqlite3_vfs | OS interface layer打开的文件,独立的OS接口实现将通过这个对象的子类增加自己的字段
  ** An [sqlite3_file] object represents an open file in the 
  ** [sqlite3_vfs | OS interface layer].  Individual OS interface
  ** implementations will
  ** want to subclass this object by appending additional fields
  ** for their own use.  The pMethods entry is a pointer to an
  ** [sqlite3_io_methods] object that defines methods for performing
  ** I/O operations on the open file.
  *pMethods入口是指向sqlite3_io_methods对象的指针,该对象定义了在打开文件执行I/O操作的方法
  */
  typedef struct sqlite3_file sqlite3_file;
  struct sqlite3_file {
  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */
  };
  /*
  ** CAPI3REF: OS Interface File Virtual Methods Object
  **OS接口文件的虚拟方法对象
  *被sqlite3_vfs对象的xOpen方法打开的每个文件组成了sqlite3_file对象或该对象的子类,这些文件以指向这些对象的实例的指针形式存在
  ** Every file opened by the [sqlite3_vfs] xOpen method populates an
  ** [sqlite3_file] object (or, more commonly, a subclass of the
  ** [sqlite3_file] object) with a pointer to an instance of this object.
  **该对象定义了多种对代表sqlite3_file对象的打开文件的操作
  ** This object defines the methods used to perform various operations
  ** against the open file represented by the [sqlite3_file] object.
  **如果xopen方法设置sqlite3_file.pMethods元素为非NULL指针,则sqlite3_io_methods.xClose会被调用,即使在xOpen失败时也是如此。如果要防止xClose在xopen失败后调用,只能将sqlite3_file.pMethods设置为空
  ** If the xOpen method sets the sqlite3_file.pMethods element 
  ** to a non-NULL pointer, then the sqlite3_io_methods.xClose method
  ** may be invoked even if the xOpen reported that it failed.  The
  ** only way to prevent a call to xClose following a failed xOpen
  ** is for the xOpen to set the sqlite3_file.pMethods element to NULL.
  **SQLITE_SYNC_NORMAL和SQLITE_SYNC_FULL是xSync的标志参数,首选是使用标准的fsync(),其次是使用Mac OS X 形式的fullsync。与SQLITE_SYNC_DATAONLY标志进行或运算(即|SQLITE_SYNC_DATAONLY)表明文件数据和它的非索引节点需要被同步
  ** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
  ** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().
  ** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]
  ** flag may be ORed in to indicate that only the data of the file
  ** and not its inode needs to be synced.
  ** The integer values to xLock() and xUnlock() are one of
  ** <ul>xLock()和 xUnlock()的整数值是下列之一:
  ** <li> [SQLITE_LOCK_NONE],
  ** <li> [SQLITE_LOCK_SHARED],
  ** <li> [SQLITE_LOCK_RESERVED],
  ** <li> [SQLITE_LOCK_PENDING], or
  ** <li> [SQLITE_LOCK_EXCLUSIVE].
  ** </ul>
  ** xLock() increases the lock. xUnlock() decreases the lock.
  xLock增加锁,xUnlock()解锁,xCheckReservedLock()检测是否存在数据库连接,本进程或其它进程是否在文件中施加RESERVED、PENDING或EXCLUSIVE锁,如果锁存在返回true,否则返回false
  ** The xCheckReservedLock() method checks whether any database connection,
  ** either in this process or in some other process, is holding a RESERVED,
  ** PENDING, or EXCLUSIVE lock on the file.  It returns true
  ** if such a lock exists and false otherwise.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-306914-1-1.html 上篇帖子: SQLite剖析(1):功能特性 下篇帖子: Android 学习之 SQLite操作
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表