API Reference MySQL

bas_ext

Purpose
Defines the file extensions used by the storage engine.

Synopsis


Description

This is the bas_ext method. It is called to provide the MySQL server with a list of file extensions used by the storage engine. The list returned is a null-terminated string array.

By providing a list of extensions, storage engines can in many cases omit the delete_table() method as the MySQL server will close all references to the table and delete all files with the specified extension.

Parameters

There are no parameters for this method.

Return Values

Return value is a null-terminated string array of storage engine extensions. The following is an example from the CSV engine:

Usage

Default Implementation

close

Purpose

Closes an open table.

Synopsis

Description

This is the close method.

Closes a table. A good time to free any resources that we have allocated.Called from sql_base.cc, sql_select.cc, and table.cc. In sql_select.cc it is only used to close up temporary tables or during the process where a temporary table is converted over to being a MyISAM table.

For sql_base.cc look at close_data_tables().

Parameters

void

Return Values

There are no return values.

Usage

createPurpose

Creates a new table.

Synopsis

Description

This is the create method.

create() is called to create a table. The variable name will have the name of the table. When create() is called you do not need to open the table. Also, the .frm file will have already been created so adjusting create_info is not recommended.

Called from handler.cc by ha_create_table().

Parameters

  • name
  • form
  • info

Return Values

There are no return values.

Usage

Example from the CSV storage engine:

Example from the CSV storage engine

delete_rowPurpose

Deletes a row.

Synopsis

Description

This is the delete_row method. buf will contain a copy of the row to be deleted. The server will call this right after the current row has been called (from either a previous rnd_next() or index call). If you keep a pointer to the last row or can access a primary key it will make doing the deletion quite a bit easier. Keep in mind that the server does not guarantee consecutive deletions. ORDER BY clauses can be used.

Called in sql_acl.cc and sql_udf.cc to manage internal table information. Called in sql_delete.cc, sql_insert.cc, and sql_select.cc. In sql_select it is used for removing duplicates, while in insert it is used for REPLACE calls.

Parameters

  • buf

Return Values

There are no return values.

Default Implementation

delete_tablePurpose

Delete all files with extension from bas_ext().
Synopsis

Description

This is the delete_table method.

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 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 extensions returned by bas_ext(). We assume that the handler may return more extensions than were actually used for the file.

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.

Parameters

  • name: Base name of table

Return Values

  • 0 if we successfully deleted at least one file from base_ext and didn't get any other errors than ENOENT
  • #: Error

Usage

Most storage engines can omit implementing this method.

external_lock

Purpose

Handles table locking for transactions.

Synopsis

Description

This is the external_lock method.

The “locking methods for mysql” section in lock.cc has additional comments on this topic that may be useful to read.

This creates a lock on the table. If you are implementing a storage engine that can handle transactions,look at ha_innodb.cc to see how you will want to go 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().

Parameters

  • thd
  • lock_type

Return Values

There are no return values.

Default Implementation

{ return 0; }


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

MySQL Topics