首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Data Change Notification Callbacks

代码语言:javascript
复制
void *sqlite3_update_hook(
  sqlite3*, 
  void(*)(void *,int ,char const *,char const *,sqlite3_int64),
  void*
);

每当在 rowid 表中更新,插入或删除行时, sqlite3_update_hook() 接口将注册一个回调函数,该函数的第一个参数标识的数据库连接将被调用。通过先前调用此函数为同一数据库连接设置的任何回调都将被覆盖。

第二个参数是指向在 rowid 表中更新,插入或删除行时要调用的函数的指针。回调函数的第一个参数是 sqlite3_update_hook() 的第三个参数的副本。第二个回调参数是 SQLITE_INSERT , SQLITE_DELETE 或 SQLITE_UPDATE 之一,具体取决于导致回调被调用的操作。回调的第三个和第四个参数包含指向包含受影响行的数据库和表名称的指针。最后的回调参数是行的 rowid 。在更新的情况下,这是更新发生后的 rowid 。

当内部系统表被修改时(例如,sqlite_master 和 sqlite_sequence ),不会调用更新挂钩。当 WITHOUT ROWID 表被修改时,不会调用更新挂钩。

在当前实现中,当冲突行由于 ON CONFLICT REPLACE 子句而被删除时,不会调用更新挂钩。当使用截断优化删除行时,更新钩子也不会被调用。本段中定义的异常可能会在未来的 SQLite 版本中发生变化。

The update hook implementation must not do anything that will modify the database connection that invoked the update hook. Any actions to modify the database connection must be deferred until after the completion of the sqlite3_step() call that triggered the update hook. Note that sqlite3_prepare_v2() and sqlite3_step() both modify their database connections for the meaning of "modify" in this paragraph.

sqlite3_update_hook(D,C,P) 函数返回前一个调用的 P 参数在同一个数据库连接 D 上,或者在 D 上第一次调用时返回 NULL 。

另请参阅 sqlite3_commit_hook() ,sqlite3_rollback_hook() 和 sqlite3_preupdate_hook() 接口。

另请参见对象,常量和函数的列表。

代码语言:txt
复制
 SQLite is in the Public Domain.

扫码关注腾讯云开发者

领取腾讯云代金券