MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
innodb_api.h File Reference
#include "api0api.h"
#include "innodb_engine.h"
#include "assert.h"
#include "handler_api.h"
Include dependency graph for innodb_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mci_column
struct  mci_item

Macros

#define LOCK_CONN_IF_NOT_LOCKED(has_lock, engine)
#define UNLOCK_CONN_IF_NOT_LOCKED(has_lock, engine)
#define LOCK_CURRENT_CONN_IF_NOT_LOCKED(has_lock, conn)
#define UNLOCK_CURRENT_CONN_IF_NOT_LOCKED(has_lock, conn)
#define MCI_COL_TO_GET   5

Typedefs

typedef enum mci_col mci_col_t
typedef struct mci_column mci_column_t
typedef struct mci_item mci_item_t
typedef enum conn_op_type conn_op_type_t

Enumerations

enum  mci_col {
  MCI_COL_KEY, MCI_COL_VALUE, MCI_COL_FLAG, MCI_COL_CAS,
  MCI_COL_EXP
}
enum  conn_op_type { CONN_OP_READ, CONN_OP_WRITE, CONN_OP_DELETE, CONN_OP_FLUSH }

Functions

void register_innodb_cb (void *p)
ib_err_t innodb_api_begin (innodb_engine_t *engine, const char *dbname, const char *name, innodb_conn_data_t *conn_data, ib_trx_t ib_trx, ib_crsr_t *crsr, ib_crsr_t *idx_crsr, ib_lck_mode_t lock_mode)
ib_err_t innodb_api_search (innodb_conn_data_t *cursor_data, ib_crsr_t *crsr, const char *key, int len, mci_item_t *item, ib_tpl_t *r_tpl, bool sel_only)
ib_err_t innodb_api_insert (innodb_engine_t *engine, innodb_conn_data_t *cursor_data, const char *key, int len, uint32_t val_len, uint64_t exp, uint64_t *cas, uint64_t flags)
ENGINE_ERROR_CODE innodb_api_delete (innodb_engine_t *engine, innodb_conn_data_t *cursor_data, const char *key, int len)
ENGINE_ERROR_CODE innodb_api_arithmetic (innodb_engine_t *engine, innodb_conn_data_t *cursor_data, const char *key, int len, int delta, bool increment, uint64_t *cas, rel_time_t exp_time, bool create, uint64_t initial, uint64_t *result)
ENGINE_ERROR_CODE innodb_api_store (innodb_engine_t *engine, innodb_conn_data_t *cursor_data, const char *key, int len, uint32_t val_len, uint64_t exp, uint64_t *cas, uint64_t input_cas, uint64_t flags, ENGINE_STORE_OPERATION op)
ENGINE_ERROR_CODE innodb_api_flush (innodb_engine_t *engine, innodb_conn_data_t *conn_data, const char *dbname, const char *name)
uint64_t mci_get_time (void)
void innodb_api_cursor_reset (innodb_engine_t *engine, innodb_conn_data_t *conn_data, conn_op_type_t op_type, bool commit)
bool innodb_reset_conn (innodb_conn_data_t *conn_data, bool has_lock, bool commit, bool has_binlog)
ib_err_t innodb_verify_low (meta_cfg_info_t *info, ib_crsr_t crsr, bool runtime)
ib_err_t innodb_cb_cursor_close (ib_crsr_t ib_crsr)
ib_trx_t innodb_cb_trx_begin (ib_trx_level_t ib_trx_level)
ib_err_t innodb_cb_trx_commit (ib_trx_t ib_trx)
ib_err_t innodb_cb_close_thd (void *thd)
ib_err_t innodb_cb_cursor_new_trx (ib_crsr_t ib_crsr, ib_trx_t ib_trx)
ib_err_t innodb_cb_cursor_lock (innodb_engine_t *eng, ib_crsr_t ib_crsr, ib_lck_mode_t ib_lck_mode)
ib_tpl_t innodb_cb_read_tuple_create (ib_crsr_t ib_crsr)
ib_err_t innodb_cb_cursor_first (ib_crsr_t ib_crsr)
ib_err_t innodb_cb_read_row (ib_crsr_t ib_crsr, ib_tpl_t ib_tpl)
ib_ulint_t innodb_cb_col_get_meta (ib_tpl_t ib_tpl, ib_ulint_t i, ib_col_meta_t *ib_col_meta)
void innodb_cb_tuple_delete (ib_tpl_t ib_tpl)
ib_ulint_t innodb_cb_tuple_get_n_cols (const ib_tpl_t ib_tpl)
const void * innodb_cb_col_get_value (ib_tpl_t ib_tpl, ib_ulint_t i)
ib_err_t innodb_cb_open_table (const char *name, ib_trx_t ib_trx, ib_crsr_t *ib_crsr)
char * innodb_cb_col_get_name (ib_crsr_t ib_crsr, ib_ulint_t i)
ib_err_t innodb_cb_cursor_open_index_using_name (ib_crsr_t ib_open_crsr, const char *index_name, ib_crsr_t *ib_crsr, int *idx_type, ib_id_u64_t *idx_id)
int innodb_cb_get_cfg ()

Detailed Description

Created 03/15/2011 Jimmy Yang

Definition in file innodb_api.h.

Macro Definition Documentation

#define LOCK_CONN_IF_NOT_LOCKED (   has_lock,
  engine 
)
Value:
if (!(has_lock)) { \
pthread_mutex_lock(&(engine)->conn_mutex); \
}

Macros to lock/unlock the engine connection mutex

Definition at line 34 of file innodb_api.h.

#define LOCK_CURRENT_CONN_IF_NOT_LOCKED (   has_lock,
  conn 
)
Value:
if (!(has_lock)) { \
pthread_mutex_lock(&(conn)->curr_conn_mutex); \
}
Macros to lock/unlock the connection mutex, used for any

connection specific operations

Definition at line 46 of file innodb_api.h.

#define MCI_COL_TO_GET   5
We would need to fetch 5 column values from each key value rows if they

are available. They are the "key", "value", "cas", "exp" and "flag"

Definition at line 58 of file innodb_api.h.

#define UNLOCK_CONN_IF_NOT_LOCKED (   has_lock,
  engine 
)
Value:
if (!(has_lock)) { \
pthread_mutex_unlock(&(engine)->conn_mutex); \
}

Definition at line 39 of file innodb_api.h.

#define UNLOCK_CURRENT_CONN_IF_NOT_LOCKED (   has_lock,
  conn 
)
Value:
if (!(has_lock)) { \
pthread_mutex_unlock(&(conn)->curr_conn_mutex); \
}

Definition at line 51 of file innodb_api.h.

Typedef Documentation

types of operations performed

typedef struct mci_column mci_column_t
mci_column is the structure that stores and describes a column info

in InnoDB Memcached. The supported column types are either character type or integer type (see above "enum mci_col" for columns supporting memcached)

typedef struct mci_item mci_item_t
"mci_item_t" represents values we read from a table row, and enough

to assemble to an memcached response. As described in above mci_col, we must have "MCI_COL_TO_GET" (5) column values to read. In addition, the user table could have multiple "value" columns, and it is possible to map such multiple "value" columns to a single memcached key, such value is separated by "separator" as defined in the "config_option" table. And we will assemble and disassemble the memcached value from these column values. And "extra_col_value" and "n_extra_col" is used to support multiple value columns

Enumeration Type Documentation

types of operations performed

Enumerator:
CONN_OP_READ 

read operation

CONN_OP_WRITE 

write operation

CONN_OP_DELETE 

delete operation

CONN_OP_FLUSH 

flush operation

Definition at line 227 of file innodb_api.h.

enum mci_col
Enumerator:
MCI_COL_KEY 

key

MCI_COL_VALUE 

value

MCI_COL_FLAG 

flag

MCI_COL_CAS 

check and set value

MCI_COL_EXP 

expiration

Definition at line 60 of file innodb_api.h.

Function Documentation

ENGINE_ERROR_CODE innodb_api_arithmetic ( innodb_engine_t engine,
innodb_conn_data_t cursor_data,
const char *  key,
int  len,
int  delta,
bool  increment,
uint64_t *  cas,
rel_time_t  exp_time,
bool  create,
uint64_t  initial,
uint64_t *  result 
)

Update a row with arithmetic operation

Returns
DB_SUCCESS if successful otherwise ENGINE_NOT_STORED out: result value
Parameters
enginein: InnoDB Memcached engine
cursor_datain/out: cursor info
keyin: key values
lenin: key length
deltain: value to add or subtract
incrementin: increment or decrement
casout: cas
exp_timein: expire time
createin: whether to create new entry if not found
initialin: initialize value
ib_err_t innodb_api_begin ( innodb_engine_t engine,
const char *  dbname,
const char *  name,
innodb_conn_data_t conn_data,
ib_trx_t  ib_trx,
ib_crsr_t crsr,
ib_crsr_t idx_crsr,
ib_lck_mode_t  lock_mode 
)

in: lock mode

Open a table and return a cursor for the table.

Returns
DB_SUCCESS if table successfully opened
Parameters
enginein: InnoDB Memcached engine
dbnamein: NUL terminated database name
namein: NUL terminated table name
conn_datain/out: connnection specific data
ib_trxin: transaction
crsrout: innodb cursor
idx_crsrout: innodb index cursor
lock_modein: lock mode

Definition at line 139 of file innodb_api.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void innodb_api_cursor_reset ( innodb_engine_t engine,
innodb_conn_data_t conn_data,
conn_op_type_t  op_type,
bool  commit 
)

Increment read and write counters, if they exceed the batch size, commit the transaction. in: commit or abort trx

Increment read and write counters, if they exceed the batch size, commit the transaction.

Parameters
enginein: InnoDB Memcached engine
conn_datain/out: cursor affiliated with a connection
op_typein: type of DML performed
commitin: commit or abort trx

Definition at line 1984 of file innodb_api.c.

Here is the call graph for this function:

ENGINE_ERROR_CODE innodb_api_delete ( innodb_engine_t engine,
innodb_conn_data_t cursor_data,
const char *  key,
int  len 
)

Delete a row, implements the "remove" command

Returns
ENGINE_SUCCESS if successful otherwise, error code in: value length

Delete a row, support the memcached "remove" command

Returns
ENGINE_SUCCESS if successful otherwise, error code
Parameters
enginein: InnoDB Memcached engine
cursor_datain/out: cursor info
keyin: value to insert
lenin: value length

Definition at line 1367 of file innodb_api.c.

Here is the call graph for this function:

ENGINE_ERROR_CODE innodb_api_flush ( innodb_engine_t engine,
innodb_conn_data_t conn_data,
const char *  dbname,
const char *  name 
)

in: table name

Implement the "flush_all" command, map to InnoDB's "trunk table" operation return ENGINE_SUCCESS is all successful

Parameters
enginein: InnoDB Memcached engine
conn_datain/out: cursor affiliated with a connection
dbnamein: database name
namein: table name

Definition at line 1842 of file innodb_api.c.

Here is the call graph for this function:

ib_err_t innodb_api_insert ( innodb_engine_t engine,
innodb_conn_data_t cursor_data,
const char *  key,
int  len,
uint32_t  val_len,
uint64_t  exp,
uint64_t *  cas,
uint64_t  flags 
)

Insert a row

Returns
DB_SUCCESS if successful otherwise, error code in: flags

Insert a row

Returns
DB_SUCCESS if successful, otherwise, error code
Parameters
enginein: InnoDB Memcached engine
cursor_datain/out: cursor info
keyin: key and value to insert
lenin: key length
val_lenin: value length
expin: expiration time
casin/out: cas value
flagsin: flags

Definition at line 1234 of file innodb_api.c.

Here is the call graph for this function:

Here is the caller graph for this function:

ib_err_t innodb_api_search ( innodb_conn_data_t cursor_data,
ib_crsr_t crsr,
const char *  key,
int  len,
mci_item_t item,
ib_tpl_t r_tpl,
bool  sel_only 
)

Position a row accord to key, and fetch value if needed

Returns
DB_SUCCESS if successful otherwise, error code in: for select only

Position a row according to the search key, and fetch value if needed

Returns
DB_SUCCESS if successful otherwise, error code
Parameters
cursor_datain/out: cursor info
crsrin/out: cursor used to search
keyin: key to search
lenin: key length
itemin: result
r_tplin: tpl for other DML operations
sel_onlyin: for select only

Definition at line 748 of file innodb_api.c.

Here is the caller graph for this function:

ENGINE_ERROR_CODE innodb_api_store ( innodb_engine_t engine,
innodb_conn_data_t cursor_data,
const char *  key,
int  len,
uint32_t  val_len,
uint64_t  exp,
uint64_t *  cas,
uint64_t  input_cas,
uint64_t  flags,
ENGINE_STORE_OPERATION  op 
)

This is the interface to following commands: 1) add 2) replace 3) append 4) prepend 5) set 6) cas

Returns
ENGINE_SUCCESS if successful otherwise, error code in: Operations

This is the main interface to following memcached commands: 1) add 2) replace 3) append 4) prepend 5) set 6) cas

Returns
ENGINE_SUCCESS if successful, otherwise, error code
Parameters
enginein: InnoDB Memcached engine
cursor_datain/out: cursor info
keyin: key value
lenin: key length
val_lenin: value length
expin: expire time
casout: cas value
input_casin: cas value supplied by user
flagsin: flags
opin: Operations

Definition at line 1727 of file innodb_api.c.

Here is the call graph for this function:

ib_err_t innodb_cb_close_thd ( void *  thd)

Close table associated to the connection

Returns
DB_SUCCESS if successful or error code in: THD

Close table associated to the connection

Returns
DB_SUCCESS if successful or error code
Parameters
thdin: THD

Definition at line 2059 of file innodb_api.c.

ib_ulint_t innodb_cb_col_get_meta ( ib_tpl_t  ib_tpl,
ib_ulint_t  i,
ib_col_meta_t ib_col_meta 
)

Get a column type, length and attributes from the tuple.

Returns
len of column data out: column meta data

Get a column type, length and attributes from the tuple.

Returns
len of column data
Parameters
ib_tplin: tuple instance
iin: column index in tuple
ib_col_metaout: column meta data

Definition at line 2156 of file innodb_api.c.

Here is the caller graph for this function:

char* innodb_cb_col_get_name ( ib_crsr_t  ib_crsr,
ib_ulint_t  i 
)

Get a column name from the tuple.

Returns
name of the column in: column index in tuple

Get a column name from the tuple.

Returns
name of the column
Parameters
ib_crsrin: InnoDB cursor instance
iin: column index in tuple

Definition at line 2216 of file innodb_api.c.

Here is the caller graph for this function:

const void* innodb_cb_col_get_value ( ib_tpl_t  ib_tpl,
ib_ulint_t  i 
)

Get a column value pointer from the tuple.

Returns
NULL or pointer to buffer in: column index in tuple

Get a column value pointer from the tuple.

Returns
NULL or pointer to buffer
Parameters
ib_tplin: tuple instance
iin: column index in tuple

Definition at line 2191 of file innodb_api.c.

ib_err_t innodb_cb_cursor_close ( ib_crsr_t  ib_crsr)

Following are a set of InnoDB callback function wrappers for functions that will be used outside innodb_api.c

Returns
DB_SUCCESS if successful or error code in: cursor to close
Following are a set of InnoDB callback function wrappers for functions

that will be used outside innodb_api.c Close a cursor

Returns
DB_SUCCESS if successful or error code
Parameters
ib_crsrin/out: cursor to close

Definition at line 2037 of file innodb_api.c.

Here is the caller graph for this function:

ib_err_t innodb_cb_cursor_first ( ib_crsr_t  ib_crsr)

Move cursor to the first record in the table.

Returns
DB_SUCCESS or err code in: InnoDB cursor instance

Move cursor to the first record in the table.

Returns
DB_SUCCESS or err code
Parameters
ib_crsrin: InnoDB cursor instance

Definition at line 2133 of file innodb_api.c.

Here is the caller graph for this function:

ib_err_t innodb_cb_cursor_lock ( innodb_engine_t eng,
ib_crsr_t  ib_crsr,
ib_lck_mode_t  ib_lck_mode 
)

Lock the table with specified lock mode

Returns
DB_SUCCESS or error code in: lock mode

Set the Lock an InnoDB cursor/table.

Returns
DB_SUCCESS or error code
Parameters
engin: InnoDB Memcached engine
ib_crsrin/out: InnoDB cursor
ib_lck_modein: InnoDB lock mode

Definition at line 2093 of file innodb_api.c.

Here is the caller graph for this function:

ib_err_t innodb_cb_cursor_new_trx ( ib_crsr_t  ib_crsr,
ib_trx_t  ib_trx 
)

update the cursor with new transactions and also reset the cursor

Returns
DB_SUCCESS or error code in: transaction

update the cursor with new transactions and also reset the cursor

Returns
DB_SUCCESS or err code
Parameters
ib_crsrin/out: InnoDB cursor
ib_trxin: transaction

Definition at line 2081 of file innodb_api.c.

ib_err_t innodb_cb_cursor_open_index_using_name ( ib_crsr_t  ib_open_crsr,
const char *  index_name,
ib_crsr_t ib_crsr,
int *  idx_type,
ib_id_u64_t *  idx_id 
)

Open an InnoDB secondary index cursor and return a cursor handle to it.

Returns
DB_SUCCESS or err code out: index id

Open an InnoDB secondary index cursor and return a cursor handle to it.

Returns
DB_SUCCESS or err code
Parameters
ib_open_crsrin: open/active cursor
index_namein: secondary index name
ib_crsrout,own: InnoDB index cursor
idx_typeout: index is cluster index
idx_idout: index id

Definition at line 2228 of file innodb_api.c.

Here is the caller graph for this function:

int innodb_cb_get_cfg ( )

Get InnoDB API configure option

Returns
configure status

Definition at line 2243 of file innodb_api.c.

ib_err_t innodb_cb_open_table ( const char *  name,
ib_trx_t  ib_trx,
ib_crsr_t ib_crsr 
)

Open a table using the table name.

Returns
table instance if found in: cursor to be used

Open a table using the table name.

Returns
table instance if found
Parameters
namein: table name to lookup
ib_trxin: transaction
ib_crsrin: cursor to be used

Definition at line 2203 of file innodb_api.c.

Here is the caller graph for this function:

ib_err_t innodb_cb_read_row ( ib_crsr_t  ib_crsr,
ib_tpl_t  ib_tpl 
)

Read current row.

Returns
DB_SUCCESS or err code out: read cols into this tuple

Read current row.

Returns
DB_SUCCESS or err code
Parameters
ib_crsrin: InnoDB cursor instance
ib_tplout: read cols into this tuple

Definition at line 2144 of file innodb_api.c.

Here is the caller graph for this function:

ib_tpl_t innodb_cb_read_tuple_create ( ib_crsr_t  ib_crsr)

Create an InnoDB tuple used for index/table search.

Returns
own: Tuple for current index in: Cursor instance

Create an InnoDB tuple used for index/table search.

Returns
own: Tuple for current index
Parameters
ib_crsrin: Cursor instance

Definition at line 2122 of file innodb_api.c.

Here is the caller graph for this function:

ib_trx_t innodb_cb_trx_begin ( ib_trx_level_t  ib_trx_level)

Start a transaction

Returns
DB_SUCCESS if successful or error code in: trx isolation level

Start a transaction

Returns
DB_SUCCESS if successful or error code
Parameters
ib_trx_levelin: trx isolation level

Definition at line 2070 of file innodb_api.c.

Here is the caller graph for this function:

ib_err_t innodb_cb_trx_commit ( ib_trx_t  ib_trx)

Commit the transaction

Returns
DB_SUCCESS if successful or error code in: transaction to commit

Commit the transaction

Returns
DB_SUCCESS if successful or error code
Parameters
ib_trxin/out: transaction to commit

Definition at line 2048 of file innodb_api.c.

Here is the caller graph for this function:

void innodb_cb_tuple_delete ( ib_tpl_t  ib_tpl)

Destroy an InnoDB tuple. in,own: Tuple instance to delete

Destroy an InnoDB tuple.

Parameters
ib_tplin,own: Tuple instance to delete

Definition at line 2168 of file innodb_api.c.

Here is the caller graph for this function:

ib_ulint_t innodb_cb_tuple_get_n_cols ( const ib_tpl_t  ib_tpl)

Return the number of columns in the tuple definition.

Returns
number of columns in: Tuple for table/index

Return the number of columns in the tuple definition.

Returns
number of columns
Parameters
ib_tplin: Tuple for table/index

Definition at line 2180 of file innodb_api.c.

Here is the caller graph for this function:

bool innodb_reset_conn ( innodb_conn_data_t conn_data,
bool  has_lock,
bool  commit,
bool  has_binlog 
)

Increment read and write counters, if they exceed the batch size, commit the transaction. in: binlog enabled

Increment read and write counters, if they exceed the batch size, commit the transaction.

Parameters
conn_datain/out: cursor affiliated with a connection
has_lockin: has lock on connection
commitin: commit or abort trx
has_binlogin: binlog enabled

Definition at line 1878 of file innodb_api.c.

Here is the call graph for this function:

Here is the caller graph for this function:

ib_err_t innodb_verify_low ( meta_cfg_info_t info,
ib_crsr_t  crsr,
bool  runtime 
)

This function verifies the table configuration information on an opened table, and fills in columns used for memcached functionalities (cas, exp etc.)

Returns
true if everything works out fine in: verify at the runtime

This function verifies the table configuration information on an opened table, and fills in columns used for memcached functionalities (cas, exp etc.)

Returns
true if everything works out fine
Parameters
infoin/out: meta info structure
crsrin: crsr
runtimein: verify at the runtime

Definition at line 877 of file innodb_config.c.

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t mci_get_time ( void  )

Get current time

Get current time

Returns
time in seconds

Definition at line 997 of file innodb_api.c.

void register_innodb_cb ( void *  p)

Register InnoDB Callback functions in: Pointer to callback function arrary

Register InnoDB Callback functions

Parameters
pin: Pointer to callback function array

Definition at line 118 of file innodb_api.c.