⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ha_example.cc

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 CC
📖 第 1 页 / 共 2 页
字号:
*/int ha_example::index_read_idx(byte * buf, uint index, const byte * key,                               uint key_len __attribute__((unused)),                               enum ha_rkey_function find_flag                               __attribute__((unused))){  DBUG_ENTER("ha_example::index_read_idx");  DBUG_RETURN(HA_ERR_WRONG_COMMAND);}/*  Used to read forward through the index.*/int ha_example::index_next(byte * buf){  DBUG_ENTER("ha_example::index_next");  DBUG_RETURN(HA_ERR_WRONG_COMMAND);}/*  Used to read backwards through the index.*/int ha_example::index_prev(byte * buf){  DBUG_ENTER("ha_example::index_prev");  DBUG_RETURN(HA_ERR_WRONG_COMMAND);}/*  index_first() asks for the first key in the index.  Called from opt_range.cc, opt_sum.cc, sql_handler.cc,  and sql_select.cc.*/int ha_example::index_first(byte * buf){  DBUG_ENTER("ha_example::index_first");  DBUG_RETURN(HA_ERR_WRONG_COMMAND);}/*  index_last() asks for the last key in the index.  Called from opt_range.cc, opt_sum.cc, sql_handler.cc,  and sql_select.cc.*/int ha_example::index_last(byte * buf){  DBUG_ENTER("ha_example::index_last");  DBUG_RETURN(HA_ERR_WRONG_COMMAND);}/*  rnd_init() is called when the system wants the storage engine to do a table  scan.  See the example in the introduction at the top of this file to see when  rnd_init() is called.  Called from filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc,  and sql_update.cc.*/int ha_example::rnd_init(bool scan){  DBUG_ENTER("ha_example::rnd_init");  DBUG_RETURN(HA_ERR_WRONG_COMMAND);}int ha_example::rnd_end(){  DBUG_ENTER("ha_example::rnd_end");  DBUG_RETURN(0);}/*  This is called for each row of the table scan. When you run out of records  you should return HA_ERR_END_OF_FILE. Fill buff up with the row information.  The Field structure for the table is the key to getting data into buf  in a manner that will allow the server to understand it.  Called from filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc,  and sql_update.cc.*/int ha_example::rnd_next(byte *buf){  DBUG_ENTER("ha_example::rnd_next");  DBUG_RETURN(HA_ERR_END_OF_FILE);}/*  position() is called after each call to rnd_next() if the data needs  to be ordered. You can do something like the following to store  the position:  my_store_ptr(ref, ref_length, current_position);  The server uses ref to store data. ref_length in the above case is  the size needed to store current_position. ref is just a byte array  that the server will maintain. If you are using offsets to mark rows, then  current_position should be the offset. If it is a primary key like in  BDB, then it needs to be a primary key.  Called from filesort.cc, sql_select.cc, sql_delete.cc and sql_update.cc.*/void ha_example::position(const byte *record){  DBUG_ENTER("ha_example::position");  DBUG_VOID_RETURN;}/*  This is like rnd_next, but you are given a position to use  to determine the row. The position will be of the type that you stored in  ref. You can use ha_get_ptr(pos,ref_length) to retrieve whatever key  or position you saved when position() was called.  Called from filesort.cc records.cc sql_insert.cc sql_select.cc sql_update.cc.*/int ha_example::rnd_pos(byte * buf, byte *pos){  DBUG_ENTER("ha_example::rnd_pos");  DBUG_RETURN(HA_ERR_WRONG_COMMAND);}/*  ::info() is used to return information to the optimizer.  see my_base.h for the complete description  Currently this table handler doesn't implement most of the fields  really needed. SHOW also makes use of this data  Another note, you will probably want to have the following in your  code:  if (records < 2)    records = 2;  The reason is that the server will optimize for cases of only a single  record. If in a table scan you don't know the number of records  it will probably be better to set records to two so you can return  as many records as you need.  Along with records a few more variables you may wish to set are:    records    deleted    data_file_length    index_file_length    delete_length    check_time  Take a look at the public variables in handler.h for more information.  Called in:    filesort.cc    ha_heap.cc    item_sum.cc    opt_sum.cc    sql_delete.cc    sql_delete.cc    sql_derived.cc    sql_select.cc    sql_select.cc    sql_select.cc    sql_select.cc    sql_select.cc    sql_show.cc    sql_show.cc    sql_show.cc    sql_show.cc    sql_table.cc    sql_union.cc    sql_update.cc*/void ha_example::info(uint flag){  DBUG_ENTER("ha_example::info");  DBUG_VOID_RETURN;}/*  extra() is called whenever the server wishes to send a hint to  the storage engine. The myisam engine implements the most hints.  ha_innodb.cc has the most exhaustive list of these hints.*/int ha_example::extra(enum ha_extra_function operation){  DBUG_ENTER("ha_example::extra");  DBUG_RETURN(0);}/*  Deprecated and likely to be removed in the future. Storage engines normally  just make a call like:  ha_example::extra(HA_EXTRA_RESET);  to handle it.*/int ha_example::reset(void){  DBUG_ENTER("ha_example::reset");  DBUG_RETURN(0);}/*  Used to delete all rows in a table. Both for cases of truncate and  for cases where the optimizer realizes that all rows will be  removed as a result of a SQL statement.  Called from item_sum.cc by Item_func_group_concat::clear(),  Item_sum_count_distinct::clear(), and Item_func_group_concat::clear().  Called from sql_delete.cc by mysql_delete().  Called from sql_select.cc by JOIN::reinit().  Called from sql_union.cc by st_select_lex_unit::exec().*/int ha_example::delete_all_rows(){  DBUG_ENTER("ha_example::delete_all_rows");  DBUG_RETURN(HA_ERR_WRONG_COMMAND);}/*  First you should go read the section "locking functions for mysql" in  lock.cc to understand this.  This create a lock on the table. If you are implementing a storage engine  that can handle transacations look at ha_berkely.cc to see how you will  want to goo about doing this. Otherwise you should consider calling flock()  here.  Called from lock.cc by lock_external() and unlock_external(). Also called  from sql_table.cc by copy_data_between_tables().*/int ha_example::external_lock(THD *thd, int lock_type){  DBUG_ENTER("ha_example::external_lock");  DBUG_RETURN(0);}/*  The idea with handler::store_lock() is the following:  The statement decided which locks we should need for the table  for updates/deletes/inserts we get WRITE locks, for SELECT... we get  read locks.  Before adding the lock into the table lock handler (see thr_lock.c)  mysqld calls store lock with the requested locks.  Store lock can now  modify a write lock to a read lock (or some other lock), ignore the  lock (if we don't want to use MySQL table locks at all) or add locks  for many tables (like we do when we are using a MERGE handler).  Berkeley DB for example  changes all WRITE locks to TL_WRITE_ALLOW_WRITE  (which signals that we are doing WRITES, but we are still allowing other  reader's and writer's.  When releasing locks, store_lock() are also called. In this case one  usually doesn't have to do anything.  In some exceptional cases MySQL may send a request for a TL_IGNORE;  This means that we are requesting the same lock as last time and this  should also be ignored. (This may happen when someone does a flush  table when we have opened a part of the tables, in which case mysqld  closes and reopens the tables and tries to get the same locks at last  time).  In the future we will probably try to remove this.  Called from lock.cc by get_lock_data().*/THR_LOCK_DATA **ha_example::store_lock(THD *thd,                                       THR_LOCK_DATA **to,                                       enum thr_lock_type lock_type){  if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)    lock.type=lock_type;  *to++= &lock;  return to;}/*  Used to delete a table. By the time delete_table() has been called all  opened references to this table will have been closed (and your globally  shared references released. The variable name will just be the name of  the table. You will need to remove any files you have created at this point.  If you do not implement this, the default delete_table() is called from  handler.cc and it will delete all files with the file extentions returned  by bas_ext().  Called from handler.cc by delete_table and  ha_create_table(). Only used  during create if the table_flag HA_DROP_BEFORE_CREATE was specified for  the storage engine.*/int ha_example::delete_table(const char *name){  DBUG_ENTER("ha_example::delete_table");  /* This is not implemented but we want someone to be able that it works. */  DBUG_RETURN(0);}/*  Renames a table from one name to another from alter table call.  If you do not implement this, the default rename_table() is called from  handler.cc and it will delete all files with the file extentions returned  by bas_ext().  Called from sql_table.cc by mysql_rename_table().*/int ha_example::rename_table(const char * from, const char * to){  DBUG_ENTER("ha_example::rename_table ");  DBUG_RETURN(HA_ERR_WRONG_COMMAND);}/*  Given a starting key, and an ending key estimate the number of rows that  will exist between the two. end_key may be empty which in case determine  if start_key matches any rows.  Called from opt_range.cc by check_quick_keys().*/ha_rows ha_example::records_in_range(uint inx, key_range *min_key,                                     key_range *max_key){  DBUG_ENTER("ha_example::records_in_range");  DBUG_RETURN(10);                         // low number to force index usage}/*  create() is called to create a database. The variable name will have the name  of the table. When create() is called you do not need to worry about opening  the table. Also, the FRM file will have already been created so adjusting  create_info will not do you any good. You can overwrite the frm file at this  point if you wish to change the table definition, but there are no methods  currently provided for doing that.  Called from handle.cc by ha_create_table().*/int ha_example::create(const char *name, TABLE *table_arg,                       HA_CREATE_INFO *create_info){  DBUG_ENTER("ha_example::create");  /* This is not implemented but we want someone to be able that it works. */  DBUG_RETURN(0);}#endif /* HAVE_EXAMPLE_DB */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -