10bet网址
MySQL Internals手册


23.9打开一张桌子

在表上执行任何读取或写入操作之前,MySQL Server将调用[自定义-naument.html#自定义-igen-api-referent-open hander :: soped()]方法以打开表数据和索引文件(如果它们存在)。

int打开(const char * name,int模式,int test_if_locked);

第一个参数是要打开的表的名称。第二个参数确定要打开的文件或采取什么操作。值定义为handler.h.并在此处复制为您的方便:

O_rdonly  - 打开只读o_rdwr  - 打开读/写

最后一个选项指示处理程序在打开表之前是否应该检查该表上的锁。有以下选项:

#define ha_open_abort_if_locked 0 / *默认* / #define ha_open_wait_if_locked 1 #define ha_open_ignore_if_locked 2 #define ha_open_tmp_table 4 / *表是一个temp表* / #define ha_open_delay_key_write 8 / * not更新index * / #define ha_open_abort_if_crashed 16 #define ha_open_for_repair即使崩溃* /

通常,您的存储引擎需要实现某种形式的共享访问控制,以防止文件损坏是多线程环境。有关如何实现文件锁定的示例,请参阅get_share()Free_share()方法SQL / examples / ha_tina.cc