Рейтинг@Mail.ru

Модуль box

Замечание

Документация находится в процессе перевода и может отставать от английской версии.

Модуль box

box_function_ctx_t

Opaque structure passed to the stored C procedure

int box_return_tuple(box_function_ctx_t *ctx, box_tuple_t *tuple)

Return a tuple from stored C procedure.

Returned tuple is automatically reference counted by Tarantool.

Параметры:
  • ctx (box_funtion_ctx_t*) – an opaque structure passed to the stored C procedure by Tarantool
  • tuple (box_tuple_t*) – a tuple to return
Результат:

-1 on error (perhaps, out of memory; check box_error_last())

Результат:

0 otherwise

uint32_t box_space_id_by_name(const char *name, uint32_t len)

Find space id by name.

This function performs SELECT request to _vspace system space.

Параметры:
  • char* name (const) – space name
  • len (uint32_t) – length of name
Результат:

BOX_ID_NIL on error or if not found (check box_error_last())

Результат:

space_id otherwise

See also: box_index_id_by_name

uint32_t box_index_id_by_name(uint32_t space_id, const char *name, uint32_t len)

Find index id by name.

Параметры:
  • space_id (uint32_t) – space identifier
  • char* name (const) – index name
  • len (uint32_t) – length of name
Результат:

BOX_ID_NIL on error or if not found (check box_error_last())

Результат:

space_id otherwise

This function performs SELECT request to _vindex system space.

See also: box_space_id_by_name

int box_insert(uint32_t space_id, const char *tuple, const char *tuple_end, box_tuple_t **result)

Execute an INSERT/REPLACE request.

Параметры:
  • space_id (uint32_t) – space identifier
  • char* tuple (const) – encoded tuple in MsgPack Array format ([ field1, field2, ...])
  • char* tuple_end (const) – end of a tuple
  • result (box_tuple_t**) – output argument. Resulted tuple. Can be set to NULL to discard result
Результат:

-1 on error (check box_error_last())

Результат:

0 otherwise

See also space_object.insert()

int box_replace(uint32_t space_id, const char *tuple, const char *tuple_end, box_tuple_t **result)

Execute an REPLACE request.

Параметры:
  • space_id (uint32_t) – space identifier
  • char* tuple (const) – encoded tuple in MsgPack Array format ([ field1, field2, ...])
  • char* tuple_end (const) – end of a tuple
  • result (box_tuple_t**) – output argument. Resulted tuple. Can be set to NULL to discard result
Результат:

-1 on error (check box_error_last())

Результат:

0 otherwise

See also space_object.replace()

int box_delete(uint32_t space_id, uint32_t index_id, const char *key, const char *key_end, box_tuple_t **result)

Execute an DELETE request.

Параметры:
  • space_id (uint32_t) – space identifier
  • index_id (uint32_t) – index identifier
  • char* key (const) – encoded key in MsgPack Array format ([ field1, field2, ...])
  • char* key_end (const) – end of a key
  • result (box_tuple_t**) – output argument. Result an old tuple. Can be set to NULL to discard result
Результат:

-1 on error (check box_error_last())

Результат:

0 otherwise

See also space_object.delete()

int box_update(uint32_t space_id, uint32_t index_id, const char *key, const char *key_end, const char *ops, const char *ops_end, int index_base, box_tuple_t **result)

Execute an UPDATE request.

Параметры:
  • space_id (uint32_t) – space identifier
  • index_id (uint32_t) – index identifier
  • char* key (const) – encoded key in MsgPack Array format ([ field1, field2, ...])
  • char* key_end (const) – end of a key
  • char* ops (const) – encoded operations in MsgPack Arrat format, e.g. [[ '=', field_id,  value ], ['!', 2, 'xxx']]
  • char* ops_end (const) – end of a ops
  • index_base (int) – 0 if field_ids in update operation are zero-based indexed (like C) or 1 if for one-based indexed field ids (like Lua).
  • result (box_tuple_t**) – output argument. Result an old tuple. Can be set to NULL to discard result
Результат:

-1 on error (check box_error_last())

Результат:

0 otherwise

See also space_object.update()

int box_upsert(uint32_t space_id, uint32_t index_id, const char *tuple, const char *tuple_end, const char *ops, const char *ops_end, int index_base, box_tuple_t **result)

Execute an UPSERT request.

Параметры:
  • space_id (uint32_t) – space identifier
  • index_id (uint32_t) – index identifier
  • char* tuple (const) – encoded tuple in MsgPack Array format ([ field1, field2, ...])
  • char* tuple_end (const) – end of a tuple
  • char* ops (const) – encoded operations in MsgPack Arrat format, e.g. [[ '=', field_id,  value ], ['!', 2, 'xxx']]
  • char* ops_end (const) – end of a ops
  • index_base (int) – 0 if field_ids in update operation are zero-based indexed (like C) or 1 if for one-based indexed field ids (like Lua).
  • result (box_tuple_t**) – output argument. Result an old tuple. Can be set to NULL to discard result
Результат:

-1 on error (check :box_error_last())

Результат:

0 otherwise

See also space_object.upsert()