MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
innodb_api.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include "innodb_api.h"
#include "memcached/util.h"
#include <innodb_cb_api.h>
#include <innodb_config.h>
Include dependency graph for innodb_api.c:

Go to the source code of this file.

Macros

#define UPDATE_ALL_VAL_COL   -1
#define SET_EXP_TIME(exp)

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)
uint64_t mci_get_time (void)
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 __attribute__((unused)), bool create, uint64_t initial, uint64_t *out_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)
bool innodb_reset_conn (innodb_conn_data_t *conn_data, bool has_lock, bool commit, bool has_binlog)
void innodb_api_cursor_reset (innodb_engine_t *engine, innodb_conn_data_t *conn_data, conn_op_type_t op_type, bool commit)
ib_err_t innodb_cb_cursor_close (ib_crsr_t ib_crsr)
ib_err_t innodb_cb_trx_commit (ib_trx_t ib_trx)
ib_err_t innodb_cb_close_thd (void *thd)
ib_trx_t innodb_cb_trx_begin (ib_trx_level_t ib_trx_level)
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 ()

Variables

option_t config_option_names []

Detailed Description

InnoDB APIs to support memcached commands

Created 04/12/2011 Jimmy Yang

Definition in file innodb_api.c.

Macro Definition Documentation

#define SET_EXP_TIME (   exp)
Value:
if (exp) { \
if (exp < 60*60*24*30) { \
exp += mci_get_time(); \
} \
}
Set expiration time. If the exp sent by client is larger than

60*60*24*30 (number of seconds in 30 days), it will be considered to be real Unix time value rather than an offset from current time

Definition at line 108 of file innodb_api.c.

#define UPDATE_ALL_VAL_COL   -1

Whether to update all columns' value or a specific column value

Definition at line 38 of file innodb_api.c.

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   __attribute__(unused),
bool  create,
uint64_t  initial,
uint64_t *  out_result 
)

Update a row with arithmetic operations

Returns
ENGINE_SUCCESS if successful otherwise ENGINE_NOT_STORED
Parameters
enginein: InnoDB Memcached engine
cursor_datain/out: cursor info
keyin: key value
lenin: key length
deltain: value to add or subtract
incrementin: increment or decrement
casout: cas
__attribute__in: expire time
createin: whether to create new entry if not found
initialin: initialize value
out_resultin: arithmetic result

Definition at line 1533 of file innodb_api.c.

Here is the call graph for this function:

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 
)

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.

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, 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 
)

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
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 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 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
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
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
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
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 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
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 
)

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 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
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
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
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
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
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
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.

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
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.

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:

uint64_t mci_get_time ( void  )

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

Parameters
pin: Pointer to callback function array

Definition at line 118 of file innodb_api.c.

Variable Documentation

option_t config_option_names[]

Configure options enum IDs, their "names" and their default value

Definition at line 38 of file innodb_config.c.