Tarantool
Get your data in RAM. Get compute close to data. Enjoy the performance.
 
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
module.h File Reference
#include <stddef.h>
#include <stdarg.h>
#include <errno.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/types.h>
#include "lua.h"

Go to the source code of this file.

Data Structures

union  PACKED
 Public representation of a key part definition. More...
 
struct  box_decimal
 public More...
 

Macros

#define PACKAGE_VERSION_MAJOR   3
 Package major version - 1 for 1.6.7.
 
#define PACKAGE_VERSION_MINOR   3
 Package minor version - 6 for 1.6.7.
 
#define PACKAGE_VERSION_PATCH   0
 Package patch version - 7 for 1.6.7.
 
#define PACKAGE_VERSION   "3.3.0-entrypoint-125-g4a866f64d"
 A string with major-minor-patch-commit-id identifier of the release, e.g.
 
#define TZDATA_VERSION   "2022a"
 A string with tag identifier of the tzdata release, e.g.
 
#define SYSCONF_DIR   "etc"
 public
 
#define INSTALL_PREFIX   "/usr/local"
 Install prefix (e.g.
 
#define BUILD_TYPE   "Debug"
 Build type, e.g.
 
#define BUILD_INFO   "Linux-x86_64-Debug"
 CMake build type signature, e.g.
 
#define BUILD_OPTIONS   "cmake . -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BACKTRACE=TRUE"
 Command line used to run CMake.
 
#define COMPILER_INFO   "GNU-13.2.0"
 Compiler ID and version, assuming the C and C++ compiler IDs are equal.
 
#define TARANTOOL_C_FLAGS   " -fexceptions -funwind-tables -fasynchronous-unwind-tables -fno-common -msse2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -fPIC -fmacro-prefix-map=/home/runner/work/tarantool/tarantool=. -std=c11 -Wall -Wextra -Wno-gnu-alignof-expression -fno-gnu89-inline -Wno-cast-function-type -Werror -g -ggdb -O0 "
 C compile flags used to build Tarantool.
 
#define TARANTOOL_CXX_FLAGS   " -fexceptions -funwind-tables -fasynchronous-unwind-tables -fno-common -msse2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -fPIC -fmacro-prefix-map=/home/runner/work/tarantool/tarantool=. -std=c++11 -Wall -Wextra -Wno-invalid-offsetof -Wno-gnu-alignof-expression -Wno-cast-function-type -Werror -g -ggdb -O0 "
 CXX compile flags used to build Tarantool.
 
#define MODULE_LIBDIR   "/usr/local/lib/tarantool"
 A path to install *.lua module files.
 
#define MODULE_LUADIR   "/usr/local/share/tarantool"
 A path to install *.so / *.dylib module files.
 
#define MODULE_INCLUDEDIR   "/usr/local/include/tarantool"
 A path to Lua includes (the same directory where this file is contained)
 
#define MODULE_LUAPATH   "/usr/local/share/tarantool/?.lua;/usr/local/share/tarantool/?/init.lua;/usr/share/tarantool/?.lua;/usr/share/tarantool/?/init.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua"
 A constant added to package.path in Lua to find *.lua module files.
 
#define MODULE_LIBPATH   "/usr/local/lib/x86_64-linux-gnu/tarantool/?.so;/usr/local/lib/tarantool/?.so;/usr/lib/x86_64-linux-gnu/lua/luarocks/lib/tarantool/?.so;/usr/lib/x86_64-linux-gnu/tarantool/?.so;/usr/local/lib/x86_64-linux-gnu/lua/5.1/?.so;/usr/local/lib/lua/5.1/?.so;/usr/lib/x86_64-linux-gnu/lua/luarocks/lib/lua/5.1/?.so;/usr/lib/x86_64-linux-gnu/lua/5.1/?.so"
 A constant added to package.cpath in Lua to find *.so module files.
 
#define MODULE_LIBSUFFIX   ".so"
 Shared library suffix - ".so" on Linux, ".dylib" on Mac.
 
#define __has_feature(x)   0
 public
 
#define __has_builtin(x)   0
 The special operator __has_builtin (operand) may be used in constant integer contexts and in preprocessor "#if" and "#elif" expressions to test whether the symbol named by its operand is recognized as a built-in function by GCC in the current language and conformance mode.
 
#define __has_attribute(x)   0
 The special operator __has_attribute (operand) may be used in "#if" and "#elif" expressions to test whether the attribute referenced by its operand is recognized by GCC.
 
#define __has_cpp_attribute(x)   0
 The special operator __has_cpp_attribute (operand) may be used in "#if" and "#elif" expressions in C++ code to test whether the attribute referenced by it operand is recognized by GCC.
 
#define likely(x)   (x)
 Compiler-independent built-ins.
 
#define unlikely(x)   (x)
 You may use likely()/unlikely() to provide the compiler with branch prediction information.
 
#define prefetch(addr, ...)   ((void) addr)
 This macro is used to minimize cache-miss latency by moving data into a cache before it is accessed.
 
#define unreachable()   (assert(0))
 If control flow reaches the point of the unreachable(), the program is undefined.
 
#define offsetof(type, member)   ((size_t)&((type *)0)->member)
 The macro offsetof expands to an integral constant expression of type size_t, the value of which is the offset, in bytes, from the beginning of an object of specified type to its specified member, including padding if any.
 
#define container_of(ptr, type, member)
 This macro is used to retrieve an enclosing structure from a pointer to a nested element.
 
#define alignas(_n)
 C11/C++11 keyword.
 
#define alignof(_T)   offsetof(struct { char c; _T member; }, member)
 C11/C++11 operator.
 
#define MAYBE_UNUSED
 Built-ins }}}.
 
#define NODISCARD
 A diagnostic is generated when a function is marked with NODISCARD and the function call appears as a potentially-evaluated discarded-value expression that is not explicitly cast to void.
 
#define NOINLINE
 This function attribute prevents a function from being considered for inlining.
 
#define ALWAYS_INLINE   inline
 Adds the 'always_inline' attribute to the function if it's supported.
 
#define NORETURN
 A function declared as NORETURN shall not return to its caller.
 
#define DEPRECATED(_msg)
 The DEPRECATED attribute can be applied to a function, a variable, or a type.
 
#define API_EXPORT   extern
 The API_EXPORT attribute declares public C API function.
 
#define CFORMAT(archetype, stringindex, firsttocheck)
 The CFORMAT attribute specifies that a function takes printf, scanf, strftime or strfmon style arguments that should be type-checked against a format string.
 
#define PACKED
 The PACKED qualifier is useful to map a structure to an external data structure, or for accessing unaligned data, but it is generally not useful to save data size because of the relatively high cost of unaligned access on some architectures.
 
#define NO_SANITIZE_ADDRESS
 NO_SANITIZE_ADDRESS attribute disables AddressSanitizer for a given function.
 
#define FALLTHROUGH
 Function Attributes }}}.
 
#define say_file_line(level, file, line, error, format, ...)
 Format and print a message to Tarantool log file.
 
#define say(level, error, format, ...)
 Format and print a message to Tarantool log file.
 
#define say_error(format, ...)   say(S_ERROR, NULL, format, ##__VA_ARGS__)
 Format and print a message to Tarantool log file.
 
#define say_crit(format, ...)   say(S_CRIT, NULL, format, ##__VA_ARGS__)
 Format and print a message to Tarantool log file.
 
#define say_warn(format, ...)   say(S_WARN, NULL, format, ##__VA_ARGS__)
 Format and print a message to Tarantool log file.
 
#define say_info(format, ...)   say(S_INFO, NULL, format, ##__VA_ARGS__)
 Format and print a message to Tarantool log file.
 
#define say_verbose(format, ...)   say(S_VERBOSE, NULL, format, ##__VA_ARGS__)
 Format and print a message to Tarantool log file.
 
#define say_debug(format, ...)   say(S_DEBUG, NULL, format, ##__VA_ARGS__)
 Format and print a message to Tarantool log file.
 
#define say_syserror(format, ...)
 Format and print a message to Tarantool log file.
 
#define SYSTEM_SPACES(_)
 public
 
#define SYSTEM_SPACE_MEMBER(name, id, ...)   BOX_ ## name ## _ID = id,
 System space identifier definition.
 
#define box_error_raise(code, format, ...)    box_error_set(__FILE__, __LINE__, code, format, ##__VA_ARGS__)
 A backward-compatible API define.
 
#define BOX_DECIMAL_STRING_BUFFER_SIZE   128
 Buffer of this size is enough to hold any box_decimal_to_string() result.
 

Typedefs

typedef void(* sayfunc_t) (int, const char *, int, const char *, const char *,...)
 public
 
typedef int(* fiber_func) (va_list)
 Fiber - contains information about fiber.
 
typedef struct ibuf box_ibuf_t
 public
 
typedef struct tuple_format box_tuple_format_t
 public
 
typedef struct tuple box_tuple_t
 Tuple.
 
typedef struct tuple_iterator box_tuple_iterator_t
 Tuple iterator.
 
typedef struct key_def box_key_def_t
 public
 
typedef union PACKED box_key_part_def_t
 Public representation of a key part definition.
 
typedef struct box_function_ctx box_function_ctx_t
 public
 
typedef enum iproto_handler_status(* iproto_handler_t) (const char *header, const char *header_end, const char *body, const char *body_end, void *ctx)
 IPROTO request handler signature: receives MsgPack encoded header and body, a context provided by box_iproto_override(), and must return one of the status codes from iproto_handler_status.
 
typedef void(* iproto_handler_destroy_t) (void *ctx)
 IPROTO request handler destructor called when the corresponding handler is removed.
 
typedef struct iterator box_iterator_t
 public
 
typedef struct error box_error_t
 Error - contains information about error.
 
typedef struct box_latch box_latch_t
 public
 
typedef struct box_decimal box_decimal_t
 Storage for a decimal number.
 

Enumerations

enum  say_level {
  S_FATAL ,
  S_SYSERROR ,
  S_ERROR ,
  S_CRIT ,
  S_WARN ,
  S_INFO ,
  S_VERBOSE ,
  S_DEBUG ,
  say_level_MAX
}
 public More...
 
enum  say_format {
  SF_PLAIN ,
  SF_JSON ,
  say_format_MAX
}
 Log formats.
 
enum  {
  COIO_READ = 0x1 ,
  COIO_WRITE = 0x2
}
 public More...
 
enum  txn_isolation_level {
  TXN_ISOLATION_DEFAULT ,
  TXN_ISOLATION_READ_COMMITTED ,
  TXN_ISOLATION_READ_CONFIRMED ,
  TXN_ISOLATION_BEST_EFFORT ,
  TXN_ISOLATION_LINEARIZABLE ,
  txn_isolation_level_MAX
}
 public More...
 
enum  {
  BOX_KEY_PART_DEF_IS_NULLABLE = 1 << 0 ,
  BOX_KEY_PART_DEF_EXCLUDE_NULL = 1 << 1 ,
  BOX_KEY_PART_DEF_SORT_ORDER_DESC = 1 << 2
}
 Key part definition flags.
 
enum  { BOX_KEY_PART_DEF_T_SIZE = 64 }
 It is recommended to verify size of box_key_part_def_t against this constant on the module side at build time. More...
 
enum  field_type {
  FIELD_TYPE_ANY = 0 ,
  FIELD_TYPE_UNSIGNED ,
  FIELD_TYPE_STRING ,
  FIELD_TYPE_NUMBER ,
  FIELD_TYPE_DOUBLE ,
  FIELD_TYPE_INTEGER ,
  FIELD_TYPE_BOOLEAN ,
  FIELD_TYPE_VARBINARY ,
  FIELD_TYPE_SCALAR ,
  FIELD_TYPE_DECIMAL ,
  FIELD_TYPE_UUID ,
  FIELD_TYPE_DATETIME ,
  FIELD_TYPE_INTERVAL ,
  FIELD_TYPE_ARRAY ,
  FIELD_TYPE_MAP ,
  FIELD_TYPE_INT8 ,
  FIELD_TYPE_UINT8 ,
  FIELD_TYPE_INT16 ,
  FIELD_TYPE_UINT16 ,
  FIELD_TYPE_INT32 ,
  FIELD_TYPE_UINT32 ,
  FIELD_TYPE_INT64 ,
  FIELD_TYPE_UINT64 ,
  FIELD_TYPE_FLOAT32 ,
  FIELD_TYPE_FLOAT64 ,
  field_type_MAX
}
 public
 
enum  on_conflict_action {
  ON_CONFLICT_ACTION_NONE = 0 ,
  ON_CONFLICT_ACTION_ROLLBACK ,
  ON_CONFLICT_ACTION_ABORT ,
  ON_CONFLICT_ACTION_FAIL ,
  ON_CONFLICT_ACTION_IGNORE ,
  ON_CONFLICT_ACTION_REPLACE ,
  ON_CONFLICT_ACTION_DEFAULT ,
  on_conflict_action_MAX
}
 Possible actions on conflict.
 
enum  {
  BOX_SYSTEM_ID_MIN = 256 ,
  BOX_SYSTEM_ID_MAX = 511 ,
  BOX_ID_NIL = 2147483647
}
 
enum  iproto_handler_status {
  IPROTO_HANDLER_OK ,
  IPROTO_HANDLER_ERROR ,
  IPROTO_HANDLER_FALLBACK
}
 Return codes for IPROTO request handlers. More...
 
enum  box_slab_info_type {
  BOX_SLAB_INFO_ITEMS_SIZE = 0 ,
  BOX_SLAB_INFO_ITEMS_USED = 1 ,
  BOX_SLAB_INFO_ARENA_SIZE = 2 ,
  BOX_SLAB_INFO_ARENA_USED = 3 ,
  BOX_SLAB_INFO_QUOTA_SIZE = 4 ,
  BOX_SLAB_INFO_QUOTA_USED = 5
}
 
enum  iterator_type {
  ITER_EQ = 0 ,
  ITER_REQ = 1 ,
  ITER_ALL = 2 ,
  ITER_LT = 3 ,
  ITER_LE = 4 ,
  ITER_GE = 5 ,
  ITER_GT = 6 ,
  ITER_BITS_ALL_SET = 7 ,
  ITER_BITS_ANY_SET = 8 ,
  ITER_BITS_ALL_NOT_SET = 9 ,
  ITER_OVERLAPS = 10 ,
  ITER_NEIGHBOR = 11 ,
  ITER_NP = 12 ,
  ITER_PP = 13 ,
  iterator_type_MAX
}
 public More...
 
enum  box_error_code {
  ER_UNKNOWN = 0 ,
  ER_ILLEGAL_PARAMS = 1 ,
  ER_MEMORY_ISSUE = 2 ,
  ER_TUPLE_FOUND = 3 ,
  ER_UNSUPPORTED = 5 ,
  ER_READONLY = 7 ,
  ER_INJECTION = 8 ,
  ER_CREATE_SPACE = 9 ,
  ER_SPACE_EXISTS = 10 ,
  ER_DROP_SPACE = 11 ,
  ER_ALTER_SPACE = 12 ,
  ER_INDEX_TYPE = 13 ,
  ER_MODIFY_INDEX = 14 ,
  ER_LAST_DROP = 15 ,
  ER_TUPLE_FORMAT_LIMIT = 16 ,
  ER_DROP_PRIMARY_KEY = 17 ,
  ER_KEY_PART_TYPE = 18 ,
  ER_EXACT_MATCH = 19 ,
  ER_INVALID_MSGPACK = 20 ,
  ER_TUPLE_NOT_ARRAY = 22 ,
  ER_FIELD_TYPE = 23 ,
  ER_INDEX_PART_TYPE_MISMATCH = 24 ,
  ER_UPDATE_SPLICE = 25 ,
  ER_UPDATE_ARG_TYPE = 26 ,
  ER_FORMAT_MISMATCH_INDEX_PART = 27 ,
  ER_UNKNOWN_UPDATE_OP = 28 ,
  ER_UPDATE_FIELD = 29 ,
  ER_FUNCTION_TX_ACTIVE = 30 ,
  ER_KEY_PART_COUNT = 31 ,
  ER_PROC_LUA = 32 ,
  ER_NO_SUCH_PROC = 33 ,
  ER_NO_SUCH_TRIGGER = 34 ,
  ER_NO_SUCH_INDEX_ID = 35 ,
  ER_NO_SUCH_SPACE = 36 ,
  ER_NO_SUCH_FIELD_NO = 37 ,
  ER_EXACT_FIELD_COUNT = 38 ,
  ER_FIELD_MISSING = 39 ,
  ER_WAL_IO = 40 ,
  ER_MORE_THAN_ONE_TUPLE = 41 ,
  ER_ACCESS_DENIED = 42 ,
  ER_CREATE_USER = 43 ,
  ER_DROP_USER = 44 ,
  ER_NO_SUCH_USER = 45 ,
  ER_USER_EXISTS = 46 ,
  ER_CREDS_MISMATCH = 47 ,
  ER_UNKNOWN_REQUEST_TYPE = 48 ,
  ER_UNKNOWN_SCHEMA_OBJECT = 49 ,
  ER_CREATE_FUNCTION = 50 ,
  ER_NO_SUCH_FUNCTION = 51 ,
  ER_FUNCTION_EXISTS = 52 ,
  ER_BEFORE_REPLACE_RET = 53 ,
  ER_MULTISTATEMENT_TRANSACTION = 54 ,
  ER_TRIGGER_EXISTS = 55 ,
  ER_USER_MAX = 56 ,
  ER_NO_SUCH_ENGINE = 57 ,
  ER_RELOAD_CFG = 58 ,
  ER_CFG = 59 ,
  ER_SAVEPOINT_EMPTY_TX = 60 ,
  ER_NO_SUCH_SAVEPOINT = 61 ,
  ER_UNKNOWN_REPLICA = 62 ,
  ER_REPLICASET_UUID_MISMATCH = 63 ,
  ER_INVALID_UUID = 64 ,
  ER_REPLICASET_UUID_IS_RO = 65 ,
  ER_INSTANCE_UUID_MISMATCH = 66 ,
  ER_REPLICA_ID_IS_RESERVED = 67 ,
  ER_MISSING_REQUEST_FIELD = 69 ,
  ER_IDENTIFIER = 70 ,
  ER_DROP_FUNCTION = 71 ,
  ER_ITERATOR_TYPE = 72 ,
  ER_REPLICA_MAX = 73 ,
  ER_NO_CONNECTION = 77 ,
  ER_TIMEOUT = 78 ,
  ER_ACTIVE_TRANSACTION = 79 ,
  ER_CURSOR_NO_TRANSACTION = 80 ,
  ER_CROSS_ENGINE_TRANSACTION = 81 ,
  ER_NO_SUCH_ROLE = 82 ,
  ER_ROLE_EXISTS = 83 ,
  ER_CREATE_ROLE = 84 ,
  ER_INDEX_EXISTS = 85 ,
  ER_SESSION_CLOSED = 86 ,
  ER_ROLE_LOOP = 87 ,
  ER_GRANT = 88 ,
  ER_PRIV_GRANTED = 89 ,
  ER_ROLE_GRANTED = 90 ,
  ER_PRIV_NOT_GRANTED = 91 ,
  ER_ROLE_NOT_GRANTED = 92 ,
  ER_MISSING_SNAPSHOT = 93 ,
  ER_CANT_UPDATE_PRIMARY_KEY = 94 ,
  ER_UPDATE_INTEGER_OVERFLOW = 95 ,
  ER_GUEST_USER_PASSWORD = 96 ,
  ER_TRANSACTION_CONFLICT = 97 ,
  ER_UNSUPPORTED_PRIV = 98 ,
  ER_LOAD_FUNCTION = 99 ,
  ER_FUNCTION_LANGUAGE = 100 ,
  ER_RTREE_RECT = 101 ,
  ER_PROC_C = 102 ,
  ER_PROTOCOL = 104 ,
  ER_WRONG_INDEX_RECORD = 106 ,
  ER_WRONG_INDEX_PARTS = 107 ,
  ER_WRONG_INDEX_OPTIONS = 108 ,
  ER_WRONG_SCHEMA_VERSION = 109 ,
  ER_MEMTX_MAX_TUPLE_SIZE = 110 ,
  ER_WRONG_SPACE_OPTIONS = 111 ,
  ER_UNSUPPORTED_INDEX_FEATURE = 112 ,
  ER_VIEW_IS_RO = 113 ,
  ER_NO_TRANSACTION = 114 ,
  ER_SYSTEM = 115 ,
  ER_LOADING = 116 ,
  ER_CONNECTION_TO_SELF = 117 ,
  ER_COMPRESSION = 119 ,
  ER_CHECKPOINT_IN_PROGRESS = 120 ,
  ER_SUB_STMT_MAX = 121 ,
  ER_COMMIT_IN_SUB_STMT = 122 ,
  ER_ROLLBACK_IN_SUB_STMT = 123 ,
  ER_DECOMPRESSION = 124 ,
  ER_INVALID_XLOG_TYPE = 125 ,
  ER_ALREADY_RUNNING = 126 ,
  ER_INDEX_FIELD_COUNT_LIMIT = 127 ,
  ER_LOCAL_INSTANCE_ID_IS_READ_ONLY = 128 ,
  ER_BACKUP_IN_PROGRESS = 129 ,
  ER_READ_VIEW_ABORTED = 130 ,
  ER_INVALID_INDEX_FILE = 131 ,
  ER_INVALID_RUN_FILE = 132 ,
  ER_INVALID_VYLOG_FILE = 133 ,
  ER_CASCADE_ROLLBACK = 134 ,
  ER_VY_QUOTA_TIMEOUT = 135 ,
  ER_PARTIAL_KEY = 136 ,
  ER_TRUNCATE_SYSTEM_SPACE = 137 ,
  ER_LOAD_MODULE = 138 ,
  ER_VINYL_MAX_TUPLE_SIZE = 139 ,
  ER_WRONG_DD_VERSION = 140 ,
  ER_WRONG_SPACE_FORMAT = 141 ,
  ER_CREATE_SEQUENCE = 142 ,
  ER_ALTER_SEQUENCE = 143 ,
  ER_DROP_SEQUENCE = 144 ,
  ER_NO_SUCH_SEQUENCE = 145 ,
  ER_SEQUENCE_EXISTS = 146 ,
  ER_SEQUENCE_OVERFLOW = 147 ,
  ER_NO_SUCH_INDEX_NAME = 148 ,
  ER_SPACE_FIELD_IS_DUPLICATE = 149 ,
  ER_CANT_CREATE_COLLATION = 150 ,
  ER_WRONG_COLLATION_OPTIONS = 151 ,
  ER_NULLABLE_PRIMARY = 152 ,
  ER_NO_SUCH_FIELD_NAME_IN_SPACE = 153 ,
  ER_TRANSACTION_YIELD = 154 ,
  ER_NO_SUCH_GROUP = 155 ,
  ER_SQL_BIND_TYPE = 157 ,
  ER_SQL_BIND_PARAMETER_MAX = 158 ,
  ER_SQL_EXECUTE = 159 ,
  ER_UPDATE_DECIMAL_OVERFLOW = 160 ,
  ER_SQL_BIND_NOT_FOUND = 161 ,
  ER_ACTION_MISMATCH = 162 ,
  ER_VIEW_MISSING_SQL = 163 ,
  ER_FOREIGN_KEY_CONSTRAINT = 164 ,
  ER_NO_SUCH_MODULE = 165 ,
  ER_NO_SUCH_COLLATION = 166 ,
  ER_CREATE_FK_CONSTRAINT = 167 ,
  ER_NO_SUCH_CONSTRAINT = 169 ,
  ER_CONSTRAINT_EXISTS = 170 ,
  ER_SQL_TYPE_MISMATCH = 171 ,
  ER_ROWID_OVERFLOW = 172 ,
  ER_DROP_COLLATION = 173 ,
  ER_ILLEGAL_COLLATION_MIX = 174 ,
  ER_SQL_NO_SUCH_PRAGMA = 175 ,
  ER_SQL_CANT_RESOLVE_FIELD = 176 ,
  ER_INDEX_EXISTS_IN_SPACE = 177 ,
  ER_INCONSISTENT_TYPES = 178 ,
  ER_SQL_SYNTAX_WITH_POS = 179 ,
  ER_SQL_STACK_OVERFLOW = 180 ,
  ER_SQL_SELECT_WILDCARD = 181 ,
  ER_SQL_STATEMENT_EMPTY = 182 ,
  ER_SQL_KEYWORD_IS_RESERVED = 183 ,
  ER_SQL_SYNTAX_NEAR_TOKEN = 184 ,
  ER_SQL_UNKNOWN_TOKEN = 185 ,
  ER_SQL_PARSER_GENERIC = 186 ,
  ER_SQL_COLUMN_COUNT_MAX = 188 ,
  ER_HEX_LITERAL_MAX = 189 ,
  ER_INT_LITERAL_MAX = 190 ,
  ER_SQL_PARSER_LIMIT = 191 ,
  ER_INDEX_DEF_UNSUPPORTED = 192 ,
  ER_MULTIKEY_INDEX_MISMATCH = 194 ,
  ER_CREATE_CK_CONSTRAINT = 195 ,
  ER_SQL_COLUMN_COUNT = 197 ,
  ER_FUNC_INDEX_FUNC = 198 ,
  ER_FUNC_INDEX_FORMAT = 199 ,
  ER_FUNC_INDEX_PARTS = 200 ,
  ER_NO_SUCH_FIELD_NAME = 201 ,
  ER_FUNC_WRONG_ARG_COUNT = 202 ,
  ER_BOOTSTRAP_READONLY = 203 ,
  ER_SQL_FUNC_WRONG_RET_COUNT = 204 ,
  ER_FUNC_INVALID_RETURN_TYPE = 205 ,
  ER_SQL_PARSER_GENERIC_WITH_POS = 206 ,
  ER_REPLICA_NOT_ANON = 207 ,
  ER_CANNOT_REGISTER = 208 ,
  ER_SESSION_SETTING_INVALID_VALUE = 209 ,
  ER_SQL_PREPARE = 210 ,
  ER_WRONG_QUERY_ID = 211 ,
  ER_SEQUENCE_NOT_STARTED = 212 ,
  ER_NO_SUCH_SESSION_SETTING = 213 ,
  ER_UNCOMMITTED_FOREIGN_SYNC_TXNS = 214 ,
  ER_SYNC_QUORUM_TIMEOUT = 216 ,
  ER_SYNC_ROLLBACK = 217 ,
  ER_TUPLE_METADATA_IS_TOO_BIG = 218 ,
  ER_XLOG_GAP = 219 ,
  ER_TOO_EARLY_SUBSCRIBE = 220 ,
  ER_SQL_CANT_ADD_AUTOINC = 221 ,
  ER_QUORUM_WAIT = 222 ,
  ER_INTERFERING_PROMOTE = 223 ,
  ER_ELECTION_DISABLED = 224 ,
  ER_TXN_ROLLBACK = 225 ,
  ER_NOT_LEADER = 226 ,
  ER_SYNC_QUEUE_UNCLAIMED = 227 ,
  ER_SYNC_QUEUE_FOREIGN = 228 ,
  ER_UNABLE_TO_PROCESS_IN_STREAM = 229 ,
  ER_UNABLE_TO_PROCESS_OUT_OF_STREAM = 230 ,
  ER_TRANSACTION_TIMEOUT = 231 ,
  ER_ACTIVE_TIMER = 232 ,
  ER_TUPLE_FIELD_COUNT_LIMIT = 233 ,
  ER_CREATE_CONSTRAINT = 234 ,
  ER_FIELD_CONSTRAINT_FAILED = 235 ,
  ER_TUPLE_CONSTRAINT_FAILED = 236 ,
  ER_CREATE_FOREIGN_KEY = 237 ,
  ER_FOREIGN_KEY_INTEGRITY = 238 ,
  ER_FIELD_FOREIGN_KEY_FAILED = 239 ,
  ER_COMPLEX_FOREIGN_KEY_FAILED = 240 ,
  ER_WRONG_SPACE_UPGRADE_OPTIONS = 241 ,
  ER_NO_ELECTION_QUORUM = 242 ,
  ER_SSL = 243 ,
  ER_SPLIT_BRAIN = 244 ,
  ER_OLD_TERM = 245 ,
  ER_INTERFERING_ELECTIONS = 246 ,
  ER_ITERATOR_POSITION = 247 ,
  ER_DEFAULT_VALUE_TYPE = 248 ,
  ER_UNKNOWN_AUTH_METHOD = 249 ,
  ER_INVALID_AUTH_DATA = 250 ,
  ER_INVALID_AUTH_REQUEST = 251 ,
  ER_WEAK_PASSWORD = 252 ,
  ER_OLD_PASSWORD = 253 ,
  ER_NO_SUCH_SESSION = 254 ,
  ER_WRONG_SESSION_TYPE = 255 ,
  ER_PASSWORD_EXPIRED = 256 ,
  ER_AUTH_DELAY = 257 ,
  ER_AUTH_REQUIRED = 258 ,
  ER_SQL_SEQ_SCAN = 259 ,
  ER_NO_SUCH_EVENT = 260 ,
  ER_BOOTSTRAP_NOT_UNANIMOUS = 261 ,
  ER_CANT_CHECK_BOOTSTRAP_LEADER = 262 ,
  ER_BOOTSTRAP_CONNECTION_NOT_TO_ALL = 263 ,
  ER_NIL_UUID = 264 ,
  ER_WRONG_FUNCTION_OPTIONS = 265 ,
  ER_MISSING_SYSTEM_SPACES = 266 ,
  ER_CLUSTER_NAME_MISMATCH = 267 ,
  ER_REPLICASET_NAME_MISMATCH = 268 ,
  ER_INSTANCE_NAME_DUPLICATE = 269 ,
  ER_INSTANCE_NAME_MISMATCH = 270 ,
  ER_SCHEMA_NEEDS_UPGRADE = 271 ,
  ER_SCHEMA_UPGRADE_IN_PROGRESS = 272 ,
  ER_DEPRECATED = 273 ,
  ER_UNCONFIGURED = 274 ,
  ER_CREATE_DEFAULT_FUNC = 275 ,
  ER_DEFAULT_FUNC_FAILED = 276 ,
  ER_INVALID_DEC = 277 ,
  ER_IN_ANOTHER_PROMOTE = 278 ,
  ER_SHUTDOWN = 279 ,
  ER_FIELD_VALUE_OUT_OF_RANGE = 280 ,
  ER_REPLICASET_NOT_FOUND = 281 ,
  ER_REPLICASET_NO_WRITABLE = 282 ,
  ER_REPLICASET_MORE_THAN_ONE_WRITABLE = 283 ,
  ER_TXN_COMMIT = 284 ,
  ER_READ_VIEW_BUSY = 285 ,
  ER_READ_VIEW_CLOSED = 286 ,
  ER_WAL_QUEUE_FULL = 287 ,
  ER_INVALID_VCLOCK = 288 ,
  ER_ARROW_IPC_ENCODE = 289 ,
  ER_ARROW_IPC_DECODE = 290 ,
  ER_SYNC_QUEUE_FULL = 291 ,
  box_error_code_MAX
}
 public
 

Functions

int box_on_shutdown (void *arg, int(*new_handler)(void *), int(*old_handler)(void *))
 Statement Attributes }}}.
 
static bool say_log_level_is_enabled (int level)
 Function checks whether passed log level is enabled.
 
 CFORMAT (printf, 5, 6) extern sayfunc_t _say
 Internal function used to implement say() macros.
 
const char * _say_strerror (int errnum)
 Internal function that implements MT-Safe strerror().
 
struct fiber_attr * fiber_attr_new (void)
 Create a new fiber attribute container and initialize it with default parameters.
 
void fiber_attr_delete (struct fiber_attr *fiber_attr)
 Delete the fiber_attr and free all allocated resources.
 
int fiber_attr_setstacksize (struct fiber_attr *fiber_attr, size_t stack_size)
 Set stack size for the fiber attribute.
 
size_t fiber_attr_getstacksize (struct fiber_attr *fiber_attr)
 Get stack size from the fiber attribute.
 
struct fiber * fiber_self (void)
 Return the current fiber.
 
struct fiber * fiber_new (const char *name, fiber_func f)
 Create a new fiber.
 
struct fiber * fiber_new_ex (const char *name, const struct fiber_attr *fiber_attr, fiber_func f)
 Create a new fiber with defined attributes.
 
void fiber_yield (void)
 Return control to another fiber and wait until it'll be woken.
 
void fiber_start (struct fiber *callee,...)
 Start execution of created fiber.
 
void fiber_set_ctx (struct fiber *f, void *f_arg)
 Set a pointer to context for the fiber.
 
void * fiber_get_ctx (struct fiber *f)
 Get the context for the fiber which was set via the fiber_set_ctx function.
 
void fiber_wakeup (struct fiber *f)
 Interrupt a synchronous wait of a fiber.
 
void fiber_cancel (struct fiber *f)
 Cancel the subject fiber.
 
bool fiber_set_cancellable (bool yesno)
 Deprecated.
 
void fiber_set_joinable (struct fiber *fiber, bool yesno)
 Set fiber to be joinable (false by default).
 
int fiber_join (struct fiber *f)
 Wait until the fiber is dead and then move its execution status to the caller.
 
int fiber_join_timeout (struct fiber *f, double timeout)
 Wait until the fiber is dead or timeout exceeded.
 
void fiber_sleep (double s)
 Put the current fiber to sleep for at least 's' seconds.
 
bool fiber_is_cancelled (void)
 Check current fiber for cancellation (it must be checked manually).
 
double fiber_time (void)
 Report loop begin time as double (cheap).
 
int64_t fiber_time64 (void)
 Report loop begin time as 64-bit int.
 
double fiber_clock (void)
 Report loop begin time as double (cheap).
 
int64_t fiber_clock64 (void)
 Report loop begin time as 64-bit int.
 
void fiber_reschedule (void)
 Reschedule fiber to end of event loop cycle.
 
void fiber_set_name_n (struct fiber *fiber, const char *name, uint32_t len)
 Set fiber name.
 
const char * fiber_name (const struct fiber *fiber)
 Get fiber name.
 
uint64_t fiber_id (const struct fiber *fiber)
 Get fiber id.
 
uint64_t fiber_csw (const struct fiber *fiber)
 Get number of context switches of the given fiber.
 
struct fiber * fiber_find (uint64_t fid)
 Get a pointer to a live fiber in the current cord by the given fiber id, which may be used for getting other info about the fiber (name, csw, etc.).
 
size_t box_region_used (void)
 box region allocator
 
void * box_region_alloc (size_t size)
 Allocate size bytes from the box region.
 
void * box_region_aligned_alloc (size_t size, size_t alignment)
 Allocate size bytes from the box region with given alignment.
 
void box_region_truncate (size_t size)
 Truncate the box region to the given size.
 
struct fiber_cond * fiber_cond_new (void)
 public
 
void fiber_cond_delete (struct fiber_cond *cond)
 Delete the fiber cond object.
 
void fiber_cond_signal (struct fiber_cond *cond)
 Wake one fiber waiting for the cond.
 
void fiber_cond_broadcast (struct fiber_cond *cond)
 Wake up all fibers waiting for the cond.
 
int fiber_cond_wait_timeout (struct fiber_cond *cond, double timeout)
 Suspend the execution of the current fiber (i.e.
 
int fiber_cond_wait (struct fiber_cond *cond)
 Shortcut for fiber_cond_wait_timeout().
 
int coio_wait (int fd, int event, double timeout)
 Wait until READ or WRITE event on socket (fd).
 
int coio_close (int fd)
 Close the fd and wake any fiber blocked in coio_wait() call on this fd.
 
ssize_t coio_call (ssize_t(*func)(va_list),...)
 public
 
int coio_getaddrinfo (const char *host, const char *port, const struct addrinfo *hints, struct addrinfo **res, double timeout)
 Fiber-friendly version of getaddrinfo(3).
 
void * box_ibuf_reserve (box_ibuf_t *ibuf, size_t size)
 Reserve requested amount of bytes in ibuf buffer.
 
void box_ibuf_read_range (box_ibuf_t *ibuf, char ***rpos, char ***wpos)
 Return pointers to read range pointers used [rpos..wpos)
 
void box_ibuf_write_range (box_ibuf_t *ibuf, char ***wpos, char ***end)
 Return pointers to write range pointers used [wpos..end)
 
int luaL_iscdata (struct lua_State *L, int idx)
 public
 
void * luaL_pushcdata (struct lua_State *L, uint32_t ctypeid)
 Push cdata of given ctypeid onto the stack.
 
void * luaL_checkcdata (struct lua_State *L, int idx, uint32_t *ctypeid)
 Checks whether the function argument idx is a cdata.
 
void luaL_setcdatagc (struct lua_State *L, int idx)
 Sets finalizer function on a cdata object.
 
size_t luaL_getgctotal (struct lua_State *L)
 Return size of currently allocated memory.
 
uint32_t luaL_ctypeid (struct lua_State *L, const char *ctypename)
 Return CTypeID (FFI) of given СDATA type.
 
int luaL_cdef (struct lua_State *L, const char *ctypename)
 Declare symbols for FFI.
 
void luaL_pushuint64 (struct lua_State *L, uint64_t val)
 public
 
void luaL_pushint64 (struct lua_State *L, int64_t val)
 Push int64_t onto the stack.
 
uint64_t luaL_checkuint64 (struct lua_State *L, int idx)
 Checks whether the argument idx is a uint64 or a convertible string and returns this number.
 
int64_t luaL_checkint64 (struct lua_State *L, int idx)
 Checks whether the argument idx is a int64 or a convertible string and returns this number.
 
uint64_t luaL_touint64 (struct lua_State *L, int idx)
 Checks whether the argument idx is a uint64 or a convertible string and returns this number.
 
int64_t luaL_toint64 (struct lua_State *L, int idx)
 Checks whether the argument idx is a int64 or a convertible string and returns this number.
 
int luaT_call (lua_State *L, int nargs, int nreturns)
 Like lua_call(), but with the proper support of Tarantool errors.
 
int luaT_dostring (struct lua_State *L, const char *str)
 Like luaL_dostring(), but in case of error sets fiber diag instead of putting error on stack.
 
int luaT_cpcall (lua_State *L, lua_CFunction func, void *ud)
 Like lua_cpcall(), but with the proper support of Tarantool errors.
 
lua_State * luaT_state (void)
 Get global Lua state used by Tarantool.
 
const char * luaT_tolstring (lua_State *L, int idx, size_t *ssize)
 Like lua_tolstring, but supports metatables, booleans and nil properly.
 
int luaL_iscallable (lua_State *L, int idx)
 Check whether a Lua object is a function or has metatable/metatype with a __call field.
 
box_ibuf_tluaT_toibuf (struct lua_State *L, int idx)
 Check if a value on L stack by index idx is an ibuf object.
 
void luaL_pushnull (struct lua_State *L)
 Push ffi's NULL (cdata<void *>: NULL) onto the stack.
 
bool luaL_isnull (struct lua_State *L, int idx)
 Return true if the value at Lua stack is ffi's NULL (cdata<void *>: NULL).
 
int luaT_error (lua_State *L)
 Re-throws the last Tarantool error as a Lua object.
 
int luaT_error_at (lua_State *L, int level)
 Same as luaT_error but set error trace frame according to given level.
 
int luaT_push_nil_and_error (lua_State *L)
 Return nil as the first return value and an error as the second.
 
void luaT_pusherror (struct lua_State *L, struct error *e)
 Push error to a Lua stack.
 
int64_t box_txn_id (void)
 public
 
int box_txn_isolation (void)
 Get isolation level of current transaction, one of enum txn_isolation_level values (but cannot be TXN_ISOLATION_DEFAULT (which is zero) by design).
 
bool box_txn (void)
 Return true if there is an active transaction.
 
int box_txn_begin (void)
 Begin a transaction in the current fiber.
 
int box_txn_commit (void)
 Commit the current transaction.
 
int box_txn_rollback (void)
 Rollback the current transaction.
 
void * box_txn_alloc (size_t size)
 Allocate memory on txn memory pool.
 
int box_txn_set_timeout (double timeout)
 Set timeout for transaction, when it expires, transaction will be rolled back.
 
int box_txn_set_isolation (uint32_t level)
 Set an isolation level for a transaction.
 
void box_txn_make_sync (void)
 Make the transaction synchronous.
 
box_tuple_format_tbox_tuple_format_default (void)
 Tuple Format.
 
int box_tuple_ref (box_tuple_t *tuple)
 Increase the reference counter of tuple.
 
void box_tuple_unref (box_tuple_t *tuple)
 Decrease the reference counter of tuple.
 
uint32_t box_tuple_field_count (box_tuple_t *tuple)
 Return the number of fields in tuple (the size of MsgPack Array).
 
size_t box_tuple_bsize (box_tuple_t *tuple)
 Return the number of bytes used to store internal tuple data (MsgPack Array).
 
ssize_t box_tuple_to_buf (box_tuple_t *tuple, char *buf, size_t size)
 Dump raw MsgPack data to the memory buffer buf of size size.
 
box_tuple_format_tbox_tuple_format (box_tuple_t *tuple)
 Return the associated format.
 
const char * box_tuple_field (box_tuple_t *tuple, uint32_t fieldno)
 Return the raw tuple field in MsgPack format.
 
const char * box_tuple_field_by_path (box_tuple_t *tuple, const char *path, uint32_t path_len, int index_base)
 Return a raw tuple field in the MsgPack format pointed by a JSON path.
 
box_tuple_iterator_tbox_tuple_iterator (box_tuple_t *tuple)
 Allocate and initialize a new tuple iterator.
 
void box_tuple_iterator_free (box_tuple_iterator_t *it)
 Destroy and free tuple iterator.
 
uint32_t box_tuple_position (box_tuple_iterator_t *it)
 Return zero-based next position in iterator.
 
void box_tuple_rewind (box_tuple_iterator_t *it)
 Rewind iterator to the initial position.
 
const char * box_tuple_seek (box_tuple_iterator_t *it, uint32_t fieldno)
 Seek the tuple iterator.
 
const char * box_tuple_next (box_tuple_iterator_t *it)
 Return the next tuple field from tuple iterator.
 
box_tuple_tbox_tuple_new (box_tuple_format_t *format, const char *data, const char *end)
 Allocate and initialize a new tuple from a raw MsgPack Array data.
 
box_tuple_tbox_tuple_update (box_tuple_t *tuple, const char *expr, const char *expr_end)
 Update a tuple.
 
box_tuple_tbox_tuple_upsert (box_tuple_t *tuple, const char *expr, const char *expr_end)
 Update a tuple.
 
int box_tuple_validate (box_tuple_t *tuple, box_tuple_format_t *format)
 Check tuple data correspondence to the space format.
 
box_key_def_tbox_key_def_new (uint32_t *fields, uint32_t *types, uint32_t part_count)
 Create key definition with given field numbers and field types.
 
void box_key_part_def_create (box_key_part_def_t *part)
 Initialize a key part with default values.
 
box_key_def_tbox_key_def_new_v2 (box_key_part_def_t *parts, uint32_t part_count)
 Create a key_def from given key parts.
 
box_key_def_tbox_key_def_dup (const box_key_def_t *key_def)
 Duplicate key_def.
 
void box_key_def_delete (box_key_def_t *key_def)
 Delete key definition.
 
box_key_part_def_tbox_key_def_dump_parts (const box_key_def_t *key_def, uint32_t *part_count_ptr)
 Dump key part definitions of given key_def.
 
int box_key_def_validate_tuple (box_key_def_t *key_def, box_tuple_t *tuple)
 Check that tuple fields match with given key definition.
 
int box_tuple_compare (box_tuple_t *tuple_a, box_tuple_t *tuple_b, box_key_def_t *key_def)
 Compare tuples using the key definition.
 
int box_tuple_compare_with_key (box_tuple_t *tuple_a, const char *key_b, box_key_def_t *key_def)
 Compare tuple with key using the key definition.
 
box_key_def_tbox_key_def_merge (const box_key_def_t *first, const box_key_def_t *second)
 Allocate a new key_def with a set union of key parts from first and second key defs.
 
char * box_key_def_extract_key (box_key_def_t *key_def, box_tuple_t *tuple, int multikey_idx, uint32_t *key_size_ptr)
 Extract key from tuple by given key definition and return buffer allocated on the box region with this key.
 
int box_key_def_validate_key (const box_key_def_t *key_def, const char *key, uint32_t *key_size_ptr)
 Check a key against given key definition.
 
int box_key_def_validate_full_key (const box_key_def_t *key_def, const char *key, uint32_t *key_size_ptr)
 Check a full key against given key definition.
 
box_tuple_format_tbox_tuple_format_new (struct key_def **keys, uint16_t key_count)
 public
 
void box_tuple_format_ref (box_tuple_format_t *format)
 Increment tuple format ref count.
 
void box_tuple_format_unref (box_tuple_format_t *format)
 Decrement tuple format ref count.
 
uint64_t box_schema_version (void)
 public
 
bool box_is_ro (void)
 public
 
int box_wait_ro (bool ro, double timeout)
 public
 
const char * box_ro_reason (void)
 public
 
int box_return_tuple (box_function_ctx_t *ctx, box_tuple_t *tuple)
 Return a tuple from stored C procedure.
 
int box_return_mp (box_function_ctx_t *ctx, const char *mp, const char *mp_end)
 Return MessagePack from a stored C procedure.
 
uint32_t box_space_id_by_name (const char *name, uint32_t len)
 Find space 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.
 
int box_insert (uint32_t space_id, const char *tuple, const char *tuple_end, box_tuple_t **result)
 Execute an INSERT request.
 
int box_replace (uint32_t space_id, const char *tuple, const char *tuple_end, box_tuple_t **result)
 Execute an REPLACE request.
 
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.
 
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.
 
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.
 
int box_insert_arrow (uint32_t space_id, struct ArrowArray *array, struct ArrowSchema *schema)
 Executes a batch insert request.
 
int box_truncate (uint32_t space_id)
 Truncate space.
 
int box_sequence_next (uint32_t seq_id, int64_t *result)
 Advance a sequence.
 
int box_sequence_current (uint32_t seq_id, int64_t *result)
 Get the last value returned by a sequence.
 
int box_sequence_set (uint32_t seq_id, int64_t value)
 Set a sequence value.
 
int box_sequence_reset (uint32_t seq_id)
 Reset a sequence.
 
int box_session_push (const char *data, const char *data_end)
 Push MessagePack data into a session data channel - socket, console or whatever is behind the session.
 
uint64_t box_session_id (void)
 
int box_iproto_send (uint64_t sid, const char *header, const char *header_end, const char *body, const char *body_end)
 Sends a packet with the given header and body over the IPROTO session's socket.
 
int box_iproto_override (uint32_t req_type, iproto_handler_t handler, iproto_handler_destroy_t destroy, void *ctx)
 Sets an IPROTO request handler with the provided context for the given request type.
 
int64_t box_info_lsn (void)
 Get self LSN component of box vclock, -1 if no one or bootstrap haven't succeeded.
 
uint64_t box_slab_info (enum box_slab_info_type type)
 Get memtx status information for box.slab.info.
 
box_iterator_tbox_index_iterator (uint32_t space_id, uint32_t index_id, int type, const char *key, const char *key_end)
 Allocate and initialize iterator for space_id, index_id.
 
int box_iterator_next (box_iterator_t *iterator, box_tuple_t **result)
 Retrieve the next item from the iterator.
 
void box_iterator_free (box_iterator_t *iterator)
 Destroy and deallocate iterator.
 
ssize_t box_index_len (uint32_t space_id, uint32_t index_id)
 Return the number of element in the index.
 
ssize_t box_index_bsize (uint32_t space_id, uint32_t index_id)
 Return the number of bytes used in memory by the index.
 
int box_index_random (uint32_t space_id, uint32_t index_id, uint32_t rnd, box_tuple_t **result)
 Return a random tuple from the index (useful for statistical analysis).
 
int box_index_get (uint32_t space_id, uint32_t index_id, const char *key, const char *key_end, box_tuple_t **result)
 Get a tuple from index by the key.
 
int box_index_min (uint32_t space_id, uint32_t index_id, const char *key, const char *key_end, box_tuple_t **result)
 Return a first (minimal) tuple matched the provided key.
 
int box_index_max (uint32_t space_id, uint32_t index_id, const char *key, const char *key_end, box_tuple_t **result)
 Return a last (maximal) tuple matched the provided key.
 
ssize_t box_index_count (uint32_t space_id, uint32_t index_id, int type, const char *key, const char *key_end)
 Count the number of tuple matched the provided key.
 
char * box_tuple_extract_key (box_tuple_t *tuple, uint32_t space_id, uint32_t index_id, uint32_t *key_size)
 Extract key from tuple according to key definition of given index.
 
const char * box_error_type (const box_error_t *error)
 Return the error type, e.g.
 
uint32_t box_error_code (const box_error_t *error)
 Return IPROTO error code.
 
const char * box_error_message (const box_error_t *error)
 Return the error message.
 
box_error_tbox_error_last (void)
 Get the information about the last API call error.
 
void box_error_clear (void)
 Clear the last error.
 
int box_error_set (const char *file, unsigned line, uint32_t code, const char *format,...)
 Set the last error.
 
box_tuple_tluaT_checktuple (struct lua_State *L, int idx)
 public
 
void luaT_pushtuple (struct lua_State *L, box_tuple_t *tuple)
 Push a tuple onto the stack.
 
box_tuple_tluaT_istuple (struct lua_State *L, int idx)
 Checks whether argument idx is a tuple.
 
char * luaT_tuple_encode (struct lua_State *L, int idx, size_t *tuple_len_ptr)
 Encode a table or a tuple on the Lua stack as an MsgPack array.
 
box_tuple_tluaT_tuple_new (struct lua_State *L, int idx, box_tuple_format_t *format)
 Create a new tuple with specific format from a Lua table or a tuple.
 
box_latch_tbox_latch_new (void)
 Allocate and initialize the new latch.
 
void box_latch_delete (box_latch_t *latch)
 Destroy and free the latch.
 
void box_latch_lock (box_latch_t *latch)
 Lock a latch.
 
int box_latch_trylock (box_latch_t *latch)
 Try to lock a latch.
 
void box_latch_unlock (box_latch_t *latch)
 Unlock a latch.
 
double clock_realtime (void)
 public
 
double clock_monotonic (void)
 A nonsettable system-wide clock that represents monotonic time.
 
double clock_process (void)
 A clock that measures CPU time consumed by this process (by all threads in the process).
 
double clock_thread (void)
 A clock that measures CPU time consumed by this thread.
 
int64_t clock_realtime64 (void)
 Same as clock_realtime(), but returns the time as 64 bit signed integer.
 
int64_t clock_monotonic64 (void)
 Same as clock_monotonic(), but returns the time as 64 bit signed integer.
 
int64_t clock_process64 (void)
 Same as clock_process(), but returns the time as 64 bit signed integer.
 
int64_t clock_thread64 (void)
 Same as clock_thread(), but returns the time as 64 bit signed integer.
 
int box_decimal_precision (const box_decimal_t *dec)
 Decimal precision.
 
int box_decimal_scale (const box_decimal_t *dec)
 Decimal scale.
 
bool box_decimal_is_int (const box_decimal_t *dec)
 Whether the fractional part of a decimal number is 0.
 
bool box_decimal_is_neg (const box_decimal_t *dec)
 Whether a decimal number is negative.
 
box_decimal_tbox_decimal_zero (box_decimal_t *dec)
 Initialize a zero decimal number.
 
box_decimal_tbox_decimal_from_string (box_decimal_t *dec, const char *str)
 Initialize a decimal with a value from a string.
 
box_decimal_tbox_decimal_from_double (box_decimal_t *dec, double d)
 Initialize a decimal from double.
 
box_decimal_tbox_decimal_from_int64 (box_decimal_t *dec, int64_t num)
 Initialize a decimal with a signed integer value.
 
box_decimal_tbox_decimal_from_uint64 (box_decimal_t *dec, uint64_t num)
 Initialize a decimal with a unsigned integer value.
 
box_decimal_tbox_decimal_copy (box_decimal_t *dest, const box_decimal_t *src)
 Copy decimal value from one storage to another.
 
void box_decimal_to_string (const box_decimal_t *dec, char *buf)
 Write the decimal as a string into the passed buffer.
 
const box_decimal_tbox_decimal_to_int64 (const box_decimal_t *dec, int64_t *num)
 Convert a given decimal to int64_t.
 
const box_decimal_tbox_decimal_to_uint64 (const box_decimal_t *dec, uint64_t *num)
 Convert a given decimal to uint64_t.
 
box_decimal_tbox_decimal_round (box_decimal_t *dec, int scale)
 Round to nearest decimal at given scale, half goes away from zero.
 
box_decimal_tbox_decimal_floor (box_decimal_t *dec, int scale)
 Apply a floor function to a decimal, i.e.
 
box_decimal_tbox_decimal_trim (box_decimal_t *dec)
 Remove trailing zeros from the fractional part of a number.
 
box_decimal_tbox_decimal_rescale (box_decimal_t *dec, int scale)
 Set scale of dec to scale.
 
int box_decimal_compare (const box_decimal_t *lhs, const box_decimal_t *rhs)
 Compare two decimal values.
 
box_decimal_tbox_decimal_abs (box_decimal_t *res, const box_decimal_t *dec)
 Get the absolute value of a decimal.
 
box_decimal_tbox_decimal_minus (box_decimal_t *res, const box_decimal_t *dec)
 Perform unary minus operation.
 
box_decimal_tbox_decimal_add (box_decimal_t *res, const box_decimal_t *lhs, const box_decimal_t *rhs)
 Calculate a sum of two decimal numbers.
 
box_decimal_tbox_decimal_sub (box_decimal_t *res, const box_decimal_t *lhs, const box_decimal_t *rhs)
 Subtract one decimal number from another.
 
box_decimal_tbox_decimal_mul (box_decimal_t *res, const box_decimal_t *lhs, const box_decimal_t *rhs)
 Multiply two decimal numbers.
 
box_decimal_tbox_decimal_div (box_decimal_t *res, const box_decimal_t *lhs, const box_decimal_t *rhs)
 Divide one decimal number on another.
 
box_decimal_tbox_decimal_remainder (box_decimal_t *res, const box_decimal_t *lhs, const box_decimal_t *rhs)
 Get the remainder of diviging two decimals.
 
box_decimal_tbox_decimal_log10 (box_decimal_t *res, const box_decimal_t *dec)
 Calculate a common logarithm (base 10).
 
box_decimal_tbox_decimal_ln (box_decimal_t *res, const box_decimal_t *dec)
 Calculate a natural logarithm (base e).
 
box_decimal_tbox_decimal_pow (box_decimal_t *res, const box_decimal_t *lhs, const box_decimal_t *rhs)
 Calculate lhs raised to the power of rhs.
 
box_decimal_tbox_decimal_exp (box_decimal_t *res, const box_decimal_t *dec)
 Calculate exp(dec), i.e.
 
box_decimal_tbox_decimal_sqrt (box_decimal_t *res, const box_decimal_t *dec)
 Calculate a square root.
 
uint32_t box_decimal_mp_sizeof (const box_decimal_t *dec)
 Calculate exact buffer size needed to store msgpack representation of a decimal.
 
char * box_decimal_mp_encode (const box_decimal_t *dec, char *data)
 Encode a decimal as msgpack.
 
box_decimal_tbox_decimal_mp_decode (box_decimal_t *dec, const char **data)
 Decode a decimal from msgpack data.
 
box_decimal_tbox_decimal_mp_decode_data (box_decimal_t *dec, const char **data, uint32_t size)
 Decode a decimal from msgpack data without the msgpack extension header.
 
box_decimal_tluaT_newdecimal (struct lua_State *L)
 public
 
box_decimal_tluaT_pushdecimal (struct lua_State *L, const box_decimal_t *dec)
 Allocate a new decimal on the Lua stack with copy of given decimal and return a pointer to it.
 
box_decimal_tluaT_isdecimal (struct lua_State *L, int index)
 Check whether a value on the Lua stack is a decimal.
 

Variables

int log_level
 Logging level.
 
void(* log_write_flightrec )(int level, const char *filename, int line, const char *error, const char *format, va_list ap)
 This function is called for every log which log level is not less than log_level_flightrec.
 

Macro Definition Documentation

◆ __has_feature

#define __has_feature (   x)    0

public

Feature test macros for -std=c11 / -std=c++11

Sic: clang aims to be gcc-compatible and thus defines GNUC

◆ alignas

#define alignas (   _n)

C11/C++11 keyword.

Appears in the declaration syntax as one of the type specifiers to modify the alignment requirement of the object being declared.

Sic: alignas() doesn't work on anonymous structs on gcc < 4.9

Example:

struct obuf { int a; int b; alignas(16) int c; };

◆ alignof

#define alignof (   _T)    offsetof(struct { char c; _T member; }, member)

C11/C++11 operator.

Returns the alignment, in bytes, required for any instance of the type indicated by type-id, which is either complete type, an array type, or a reference type.

◆ ALWAYS_INLINE

#define ALWAYS_INLINE   inline

Adds the 'always_inline' attribute to the function if it's supported.

This attribute forces the function to be inlined if it's possible. If it's not, this results in a diagnostic.

Example:

ALWAYS_INLINE int function() { return 0; }
#define ALWAYS_INLINE
Adds the 'always_inline' attribute to the function if it's supported.
Definition module.h:363

◆ BUILD_INFO

#define BUILD_INFO   "Linux-x86_64-Debug"

CMake build type signature, e.g.

Linux-x86_64-Debug

◆ BUILD_TYPE

#define BUILD_TYPE   "Debug"

Build type, e.g.

Debug or Release

◆ CFORMAT

#define CFORMAT (   archetype,
  stringindex,
  firsttocheck 
)

The CFORMAT attribute specifies that a function takes printf, scanf, strftime or strfmon style arguments that should be type-checked against a format string.

See also
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

◆ container_of

#define container_of (   ptr,
  type,
  member 
)
Value:
({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#define offsetof(type, member)
The macro offsetof expands to an integral constant expression of type size_t, the value of which is t...
Definition module.h:220

This macro is used to retrieve an enclosing structure from a pointer to a nested element.

◆ DEPRECATED

#define DEPRECATED (   _msg)

The DEPRECATED attribute can be applied to a function, a variable, or a type.

This is useful when identifying functions, variables, or types that are expected to be removed in a future version of a program.

◆ FALLTHROUGH

#define FALLTHROUGH

Function Attributes }}}.

{{{ Statement Attributes The fallthrough attribute with a null statement serves as a fallthrough statement. It hints to the compiler that a statement that falls through to another case label, or user-defined label in a switch statement is intentional and thus the -Wimplicit-fallthrough warning must not trigger. The fallthrough attribute may appear at most once in each attribute list, and may not be mixed with other attributes. It can only be used in a switch statement (the compiler will issue an error otherwise), after a preceding statement and before a logically succeeding case label, or user-defined label.

◆ INSTALL_PREFIX

#define INSTALL_PREFIX   "/usr/local"

Install prefix (e.g.

/usr)

◆ likely

#define likely (   x)    (x)

Compiler-independent built-ins.

See also
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

{{{ Built-ins You may use likely()/unlikely() to provide the compiler with branch prediction information.

◆ MAYBE_UNUSED

#define MAYBE_UNUSED

Built-ins }}}.

Compiler-independent function attributes.

See also
https://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html
http://clang.llvm.org/docs/AttributeReference.html#function-attributes
http://en.cppreference.com/w/cpp/language/attributes

{{{ Function Attributes The MAYBE_UNUSED function attribute can be used to silence -Wunused diagnostics when the entity cannot be removed. For instance, a local variable may exist solely for use in an assert() statement, which makes the local variable unused when NDEBUG is defined.

Example:

int fun(MAYBE_UNUSED int unused_arg);
#define MAYBE_UNUSED
Built-ins }}}.
Definition module.h:311

◆ NO_SANITIZE_ADDRESS

#define NO_SANITIZE_ADDRESS

NO_SANITIZE_ADDRESS attribute disables AddressSanitizer for a given function.

The attribute may not be supported by old compilers, but they do not support ASAN as well, so it's safe to define the attribute only if ASAN is enabled.

◆ NODISCARD

#define NODISCARD

A diagnostic is generated when a function is marked with NODISCARD and the function call appears as a potentially-evaluated discarded-value expression that is not explicitly cast to void.

Example:

NODISCARD int function() { return -1 };
#define NODISCARD
A diagnostic is generated when a function is marked with NODISCARD and the function call appears as a...
Definition module.h:330

◆ NOINLINE

#define NOINLINE

This function attribute prevents a function from being considered for inlining.

Example:

NOINLINE int function() { return 0; };
#define NOINLINE
This function attribute prevents a function from being considered for inlining.
Definition module.h:346

◆ NORETURN

#define NORETURN

A function declared as NORETURN shall not return to its caller.

The compiler will generate a diagnostic for a function declared as NORETURN that appears to be capable of returning to its caller.

Example:

NORETURN void abort();
#define NORETURN
A function declared as NORETURN shall not return to its caller.
Definition module.h:382

◆ PACKAGE_VERSION

#define PACKAGE_VERSION   "3.3.0-entrypoint-125-g4a866f64d"

A string with major-minor-patch-commit-id identifier of the release, e.g.

1.6.6-113-g8399d0e.

◆ PACKED

#define PACKED

The PACKED qualifier is useful to map a structure to an external data structure, or for accessing unaligned data, but it is generally not useful to save data size because of the relatively high cost of unaligned access on some architectures.

Example:

struct PACKED name { char a; int b; };
Public representation of a key part definition.
Definition module.h:1919

◆ prefetch

#define prefetch (   addr,
  ... 
)    ((void) addr)

This macro is used to minimize cache-miss latency by moving data into a cache before it is accessed.

You can insert calls to prefetch() into code for which you know addresses of data in memory that is likely to be accessed soon. If the target supports them, data prefetch instructions will be generated. If the prefetch is done early enough before the access then the data will be in the cache by the time it is accessed.

The value of addr is the address of the memory to prefetch. There are two optional arguments, rw and locality. The value of rw is a compile-time constant one or zero; one means that the prefetch is preparing for a write to the memory address and zero, the default, means that the prefetch is preparing for a read. The value locality must be a compile-time constant integer between zero and three. A value of zero means that the data has no temporal locality, so it need not be left in the cache after the access. A value of three means that the data has a high degree of temporal locality and should be left in all levels of cache possible. Values of one and two mean, respectively, a low or moderate degree of temporal locality. The default is three.

◆ say

#define say (   level,
  error,
  format,
  ... 
)
Value:
({ \
say_file_line(level, __FILE__, __LINE__, error, format, ##__VA_ARGS__); })

Format and print a message to Tarantool log file.

Parameters
level(int) - log level (see enum say_level)
error(const char * ) - error description, may be NULL
format(const char * ) - printf()-like format string
...- format arguments
See also
printf()
enum say_level

◆ say_crit

#define say_crit (   format,
  ... 
)    say(S_CRIT, NULL, format, ##__VA_ARGS__)

Format and print a message to Tarantool log file.

Parameters
format(const char * ) - printf()-like format string
...- format arguments
See also
printf()
enum say_level Example:
say_info("Some useful information: %s", status);
#define say_info(format,...)
Format and print a message to Tarantool log file.
Definition module.h:612

◆ say_debug

#define say_debug (   format,
  ... 
)    say(S_DEBUG, NULL, format, ##__VA_ARGS__)

Format and print a message to Tarantool log file.

Parameters
format(const char * ) - printf()-like format string
...- format arguments
See also
printf()
enum say_level Example:
say_info("Some useful information: %s", status);

◆ say_error

#define say_error (   format,
  ... 
)    say(S_ERROR, NULL, format, ##__VA_ARGS__)

Format and print a message to Tarantool log file.

Parameters
format(const char * ) - printf()-like format string
...- format arguments
See also
printf()
enum say_level Example:
say_info("Some useful information: %s", status);

◆ say_file_line

#define say_file_line (   level,
  file,
  line,
  error,
  format,
  ... 
)
Value:
({ \
_say(level, file, line, error, format, ##__VA_ARGS__); })
static bool say_log_level_is_enabled(int level)
Function checks whether passed log level is enabled.
Definition module.h:545

Format and print a message to Tarantool log file.

Parameters
level(int) - log level (see enum say_level)
file(const char * ) - file name to print
line(int) - line number to print
error(const char * ) - error description, may be NULL
format(const char * ) - printf()-like format string
...- format arguments
See also
printf()
enum say_level

◆ say_info

#define say_info (   format,
  ... 
)    say(S_INFO, NULL, format, ##__VA_ARGS__)

Format and print a message to Tarantool log file.

Parameters
format(const char * ) - printf()-like format string
...- format arguments
See also
printf()
enum say_level Example:
say_info("Some useful information: %s", status);

◆ say_syserror

#define say_syserror (   format,
  ... 
)
Value:
say(S_SYSERROR, _say_strerror(errno), \
format, ##__VA_ARGS__)
#define say(level, error, format,...)
Format and print a message to Tarantool log file.
Definition module.h:591
const char * _say_strerror(int errnum)
Internal function that implements MT-Safe strerror().

Format and print a message to Tarantool log file.

Parameters
format(const char * ) - printf()-like format string
...- format arguments
See also
printf()
enum say_level Example:
say_info("Some useful information: %s", status);

◆ say_verbose

#define say_verbose (   format,
  ... 
)    say(S_VERBOSE, NULL, format, ##__VA_ARGS__)

Format and print a message to Tarantool log file.

Parameters
format(const char * ) - printf()-like format string
...- format arguments
See also
printf()
enum say_level Example:
say_info("Some useful information: %s", status);

◆ say_warn

#define say_warn (   format,
  ... 
)    say(S_WARN, NULL, format, ##__VA_ARGS__)

Format and print a message to Tarantool log file.

Parameters
format(const char * ) - printf()-like format string
...- format arguments
See also
printf()
enum say_level Example:
say_info("Some useful information: %s", status);

◆ SYSCONF_DIR

#define SYSCONF_DIR   "etc"

public

System configuration dir (e.g /etc)

◆ SYSTEM_SPACES

#define SYSTEM_SPACES (   _)

public

List of system space definitions in the following format: (name, identifier, is_sync), where is_sync determines whether synchronous replication is enabled for this system space when the synchronous queue is claimed. If is_sync is false, a reason must be supplied after the space definition comment.

◆ TZDATA_VERSION

#define TZDATA_VERSION   "2022a"

A string with tag identifier of the tzdata release, e.g.

2024a.

◆ unlikely

#define unlikely (   x)    (x)

You may use likely()/unlikely() to provide the compiler with branch prediction information.

See also
https://en.cppreference.com/w/cpp/language/attributes/likely

◆ unreachable

#define unreachable ( )    (assert(0))

If control flow reaches the point of the unreachable(), the program is undefined.

It is useful in situations where the compiler cannot deduce the unreachability of the code.

Typedef Documentation

◆ box_decimal_t

typedef struct box_decimal box_decimal_t

Storage for a decimal number.

This type is large enough to hold a decimal value. The primary usage is to allocate a decimal on the stack and pass it to a box_decimal_*() function.

Take it as opacue structure with ability to allocate a value on the stack.

Use box_decimal_copy() to copy the value, don't use memcpy(). The real data can be smaller than this type. Moreover, tarantool may allocate less bytes for box_decimal_t value, so direct read/write of the structure may lead to access to an unallocated memory.

The alignment of the structure is not less than alignment of decimal values allocated by tarantool. It can be larger and it is another reason to don't access the structure content directly.

Last, but not least: the data format is unspecified and can be changed. Modules and applications that aims to be compatible with future tarantool versions must not lean on particular data representation within the structure.

◆ box_key_part_def_t

typedef union PACKED box_key_part_def_t

Public representation of a key part definition.

Usage: Allocate an array of such key parts, initialize each key part (call box_key_part_def_create() and set necessary fields), pass the array into box_key_def_new_v2() function.

Important: A module should call box_key_part_def_create() to initialize the structure with default values. There is no guarantee that all future default values for fields and flags will be remain the same.

The idea of separation from internal "struct key_part_def" is to provide stable API and ABI for modules.

New fields may be added into the end of the structure in later tarantool versions. Also new flags may be introduced within flags field. collation cannot be changed to a union (to reuse for some other value), because it is verified even for a non-string key part by box_key_def_new_v2().

Fields that are unknown at given tarantool version are ignored in general, but filled with zeros when initialized.

◆ box_latch_t

typedef struct box_latch box_latch_t

public

A lock for cooperative multitasking environment

◆ iproto_handler_destroy_t

typedef void(* iproto_handler_destroy_t) (void *ctx)

IPROTO request handler destructor called when the corresponding handler is removed.

Parameters
ctxcontext provided by box_iproto_override()

◆ iproto_handler_t

typedef enum iproto_handler_status(* iproto_handler_t) (const char *header, const char *header_end, const char *body, const char *body_end, void *ctx)

IPROTO request handler signature: receives MsgPack encoded header and body, a context provided by box_iproto_override(), and must return one of the status codes from iproto_handler_status.

Parameters
headerMsgpack encoded header
header_endend of Msgpack encoded header
bodyMsgpack encoded body
body_endend of Msgpack encoded body
ctxcontext provided by box_iproto_override()
Returns
a status code

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

public

Enumerator
COIO_READ 

READ event.

COIO_WRITE 

WRITE event.

◆ anonymous enum

anonymous enum

It is recommended to verify size of box_key_part_def_t against this constant on the module side at build time.

Example:

#if !defined(__cplusplus) && !defined(static_assert)
#define static_assert _Static_assert
#endif
(slash)*
* Verify that box_key_part_def_t has the same size when
* compiled within tarantool and within the module.
*
* It is important, because the module allocates an array of key
* parts and passes it to box_key_def_new_v2() tarantool
* function.
*(slash)
"sizeof(box_key_part_def_t)");
box_key_def_t * box_key_def_new_v2(box_key_part_def_t *parts, uint32_t part_count)
Create a key_def from given key parts.
@ BOX_KEY_PART_DEF_T_SIZE
The constant.
Definition module.h:1892

This snippet is not part of module.h, because portability of static_assert() / _Static_assert() is dubious. It should be decision of a module author how portable its code should be.

Enumerator
BOX_KEY_PART_DEF_T_SIZE 

The constant.

◆ anonymous enum

anonymous enum
Enumerator
BOX_SYSTEM_ID_MIN 

Start of the reserved range of system spaces.

BOX_SYSTEM_ID_MAX 

End of the reserved range of system spaces.

◆ box_slab_info_type

Codes for request memtx status information for box.slab.info.

Enumerator
BOX_SLAB_INFO_ITEMS_SIZE 

Allocated only for tuples.

BOX_SLAB_INFO_ITEMS_USED 

Used only for tuples.

BOX_SLAB_INFO_ARENA_SIZE 

Allocated for tuples and indexes.

BOX_SLAB_INFO_ARENA_USED 

Used for both tuples and indexes.

BOX_SLAB_INFO_QUOTA_SIZE 

Memory limit for slab allocator.

BOX_SLAB_INFO_QUOTA_USED 

Used by slab allocator.

◆ iproto_handler_status

Return codes for IPROTO request handlers.

Enumerator
IPROTO_HANDLER_OK 

Success, no further actions needed.

IPROTO_HANDLER_ERROR 

Error, diagnostic must be set by handler via box_error_set().

IPROTO_HANDLER_FALLBACK 

Fallback to system handler.

◆ iterator_type

public

Controls how to iterate over tuples in an index. Different index types support different iterator types. For example, one can start iteration from a particular value (request key) and then retrieve all tuples where keys are greater or equal (= GE) to this key.

If iterator type is not supported by the selected index type, iterator constructor must fail with ER_UNSUPPORTED. To be selectable for primary key, an index must support at least ITER_EQ and ITER_GE types.

NULL value of request key corresponds to the first or last key in the index, depending on iteration direction. (first key for GE and GT types, and last key for LE and LT). Therefore, to iterate over all tuples in an index, one can use ITER_GE or ITER_LE iteration types with start key equal to NULL. For ITER_EQ, the key must not be NULL.

◆ say_level

enum say_level

public

Log levels

◆ txn_isolation_level

public

When a transaction calls commit, this action can last for some time until redo data is written to WAL. While such a commit call is in progress we call changes of such a transaction as 'committed', and when the process is finished - we call the changes as 'confirmed'. One of the main options of a transaction is to see or not to see 'committed' changes. Note that now there are different terminologies in different places. This enum uses new 'committed' and 'confirmed' states of transactions. Meanwhile in engined the first state is usually called as 'prepared', and the second as 'committed' or 'completed'. Warning: this enum is exposed in lua via ffi, and thus any change in items must be correspondingly modified on ffi.cdef(), see schema.lua.

Enumerator
TXN_ISOLATION_DEFAULT 

Take isolation level from global default_isolation_level.

TXN_ISOLATION_READ_COMMITTED 

Allow to read committed, but not confirmed changes.

TXN_ISOLATION_READ_CONFIRMED 

Allow to read only confirmed changes.

TXN_ISOLATION_BEST_EFFORT 

Determine isolation level automatically.

TXN_ISOLATION_LINEARIZABLE 

Allow to read only the changes confirmed on any cluster node.

txn_isolation_level_MAX 

Upper bound of valid values.

Function Documentation

◆ _say_strerror()

const char * _say_strerror ( int  errnum)

Internal function that implements MT-Safe strerror().

It is used by say_syserror() macro.

◆ box_decimal_abs()

box_decimal_t * box_decimal_abs ( box_decimal_t res,
const box_decimal_t dec 
)

Get the absolute value of a decimal.

res is set to the absolute value of dec.

box_decimal_abs(&a, &a) is allowed.

Parameters
reswhere to store the result
decdecimal operand
Returns
res

◆ box_decimal_add()

box_decimal_t * box_decimal_add ( box_decimal_t res,
const box_decimal_t lhs,
const box_decimal_t rhs 
)

Calculate a sum of two decimal numbers.

Parameters
reswhere to hold the result
lhsleft hand side operand
rhsright hand side operand
Returns
NULL on an error (an overflow for example)
decimal result (res)

◆ box_decimal_compare()

int box_decimal_compare ( const box_decimal_t lhs,
const box_decimal_t rhs 
)

Compare two decimal values.

Parameters
lhsleft hand side operand
rhsright hand side operand
Returns
-1 if lhs < rhs
0 if lhs = rhs
1 if lhs > rhs

◆ box_decimal_copy()

box_decimal_t * box_decimal_copy ( box_decimal_t dest,
const box_decimal_t src 
)

Copy decimal value from one storage to another.

Use this function where you would use memcpy() if the precise data size would be known.

The memory areas must not overlap.

Parameters
destwhere to store the copy
srcfrom where to copy
Returns
the copy (dest)

◆ box_decimal_div()

box_decimal_t * box_decimal_div ( box_decimal_t res,
const box_decimal_t lhs,
const box_decimal_t rhs 
)

Divide one decimal number on another.

Parameters
reswhere to hold the result
lhsleft hand side operand
rhsright hand side operand
Returns
NULL on an error
decimal result (res)

◆ box_decimal_exp()

box_decimal_t * box_decimal_exp ( box_decimal_t res,
const box_decimal_t dec 
)

Calculate exp(dec), i.e.

pow(e, dec).

Parameters
reswhere to hold the result
decdecimal operand
Returns
NULL on an error
decimal result (res)

◆ box_decimal_floor()

box_decimal_t * box_decimal_floor ( box_decimal_t dec,
int  scale 
)

Apply a floor function to a decimal, i.e.

round it towards zero to a decimal with given scale.

floor(-0.66, 1) -> -0.6 floor(-0.65, 1) -> -0.6 floor(-0.64, 1) -> -0.6

floor(0.64, 1) -> 0.6 floor(0.65, 1) -> 0.6 floor(0.66, 1) -> 0.6

See also
box_decimal_round
Parameters
decdecimal number
scaletarget scale
Returns
NULL if scale is out of supported range
dec (changed)

◆ box_decimal_from_double()

box_decimal_t * box_decimal_from_double ( box_decimal_t dec,
double  d 
)

Initialize a decimal from double.

Parameters
decwhere to store the decimal result
dsource double value
Returns
NULL if the double is NaN, Infinity or greater than a maximum precision for decimal values
decimal result

◆ box_decimal_from_int64()

box_decimal_t * box_decimal_from_int64 ( box_decimal_t dec,
int64_t  num 
)

Initialize a decimal with a signed integer value.

Parameters
decwhere to store the decimal result
numsource integer value (signed)
Returns
decimal result

◆ box_decimal_from_string()

box_decimal_t * box_decimal_from_string ( box_decimal_t dec,
const char *  str 
)

Initialize a decimal with a value from a string.

The fractional part may be rounded if a maximum precision is reached.

Parameters
decwhere to store the decimal result
strsource string value
Returns
NULL if the string is invalid or the number is too big
decimal result

◆ box_decimal_from_uint64()

box_decimal_t * box_decimal_from_uint64 ( box_decimal_t dec,
uint64_t  num 
)

Initialize a decimal with a unsigned integer value.

Parameters
decwhere to store the decimal result
numsource integer value (unsigned)
Returns
decimal result

◆ box_decimal_is_int()

bool box_decimal_is_int ( const box_decimal_t dec)

Whether the fractional part of a decimal number is 0.

Parameters
decdecimal number
Returns
true if the fractional part is zero
false otherwise

◆ box_decimal_is_neg()

bool box_decimal_is_neg ( const box_decimal_t dec)

Whether a decimal number is negative.

Parameters
decdecimal number
Returns
true if the decimal is less than zero
false otherwise

◆ box_decimal_ln()

box_decimal_t * box_decimal_ln ( box_decimal_t res,
const box_decimal_t dec 
)

Calculate a natural logarithm (base e).

Parameters
reswhere to hold the result
decdecimal operand
Returns
NULL on an error
decimal result (res)

◆ box_decimal_log10()

box_decimal_t * box_decimal_log10 ( box_decimal_t res,
const box_decimal_t dec 
)

Calculate a common logarithm (base 10).

Parameters
reswhere to hold the result
decdecimal operand
Returns
NULL on an error
decimal result (res)

◆ box_decimal_minus()

box_decimal_t * box_decimal_minus ( box_decimal_t res,
const box_decimal_t dec 
)

Perform unary minus operation.

res is set to -dec.

Parameters
reswhere to store the result
decdecimal operand
Returns
res

◆ box_decimal_mp_decode()

box_decimal_t * box_decimal_mp_decode ( box_decimal_t dec,
const char **  data 
)

Decode a decimal from msgpack data.

Parameters
decwhere to store the decoded decimal
datapointer to a buffer with the msgpack data
Returns
NULL if the msgpack data does not represent a valid decimal value
the decoded decimal
Postcondition
*data = *data + box_decimal_mp_sizeof(retval)

◆ box_decimal_mp_decode_data()

box_decimal_t * box_decimal_mp_decode_data ( box_decimal_t dec,
const char **  data,
uint32_t  size 
)

Decode a decimal from msgpack data without the msgpack extension header.

box_decimal_mp_decode_data() must be called for this position
|
v
<msgpack type> <size> <extension type> <data>
^
|
box_decimal_mp_decode() must be called for this position
box_decimal_t * box_decimal_mp_decode_data(box_decimal_t *dec, const char **data, uint32_t size)
Decode a decimal from msgpack data without the msgpack extension header.
box_decimal_t * box_decimal_mp_decode(box_decimal_t *dec, const char **data)
Decode a decimal from msgpack data.

This function is suitable to finish decoding after calling mp_decode_extl() (from the msgpuck library).

Parameters
decwhere to store the decoded decimal
datapointer to a buffer with the msgpack data
sizesize of the decimal data in the buffer; this value is returned by mp_decode_extl()
Returns
NULL if the msgpack data does not represent a valid decimal value
the decoded decimal
Postcondition
*data = *data + size

◆ box_decimal_mp_encode()

char * box_decimal_mp_encode ( const box_decimal_t dec,
char *  data 
)

Encode a decimal as msgpack.

Parameters
decdecimal number to encode
databuffer to write the result
Returns
data + box_decimal_mp_sizeof(dec)

◆ box_decimal_mp_sizeof()

uint32_t box_decimal_mp_sizeof ( const box_decimal_t dec)

Calculate exact buffer size needed to store msgpack representation of a decimal.

Parameters
decdecimal operand
Returns
the buffer size

◆ box_decimal_mul()

box_decimal_t * box_decimal_mul ( box_decimal_t res,
const box_decimal_t lhs,
const box_decimal_t rhs 
)

Multiply two decimal numbers.

Parameters
reswhere to hold the result
lhsleft hand side operand
rhsright hand side operand
Returns
NULL on an error (an overflow for example)
decimal result (res)

◆ box_decimal_pow()

box_decimal_t * box_decimal_pow ( box_decimal_t res,
const box_decimal_t lhs,
const box_decimal_t rhs 
)

Calculate lhs raised to the power of rhs.

Parameters
reswhere to hold the result
lhsleft hand side operand, base
rhsright hand side operand, power
Returns
NULL on an error
decimal result (res)

◆ box_decimal_precision()

int box_decimal_precision ( const box_decimal_t dec)

Decimal precision.

It is equivalent to amount of decimal digits in the string representation (not counting minus, decimal separator and the leading zero in 0.ddd...ddd number, but counting trailing zeros if any).

Parameters
decdecimal number
Returns
precision

◆ box_decimal_remainder()

box_decimal_t * box_decimal_remainder ( box_decimal_t res,
const box_decimal_t lhs,
const box_decimal_t rhs 
)

Get the remainder of diviging two decimals.

res is set to the remainder of dividing lhs by rhs.

Parameters
reswhere to hold the result
lhsleft hand side operand
rhsright hand side operand
Returns
NULL on an error
decimal result (res)

◆ box_decimal_rescale()

box_decimal_t * box_decimal_rescale ( box_decimal_t dec,
int  scale 
)

Set scale of dec to scale.

If scale is less than scale(dec), round the decimal. Otherwise append a sufficient amount of trailing fractional zeros.

See also
box_decimal_round
box_decimal_trim
Parameters
decdecimal number
scaletarget scale
Returns
NULL if scale is out of supported range (less than zero or too big)
dec (changed)

◆ box_decimal_round()

box_decimal_t * box_decimal_round ( box_decimal_t dec,
int  scale 
)

Round to nearest decimal at given scale, half goes away from zero.

round(-0.66, 1) -> -0.7 round(-0.65, 1) -> -0.7 round(-0.64, 1) -> -0.6

round(0.64, 1) -> 0.6 round(0.65, 1) -> 0.7 round(0.66, 1) -> 0.7

Resulting decimal number has not more than scale digits after the decimal point.

If scale if greater than current dec scale, do nothing.

Parameters
decdecimal number
scaletarget scale
Returns
NULL if scale is out of supported range
dec (changed)

◆ box_decimal_scale()

int box_decimal_scale ( const box_decimal_t dec)

Decimal scale.

It is equivalent to amount of digits after the decimal separator.

Parameters
decdecimal number
Returns
scale

◆ box_decimal_sqrt()

box_decimal_t * box_decimal_sqrt ( box_decimal_t res,
const box_decimal_t dec 
)

Calculate a square root.

Parameters
reswhere to hold the result
decdecimal operand
Returns
NULL on an error
decimal result (res)

◆ box_decimal_sub()

box_decimal_t * box_decimal_sub ( box_decimal_t res,
const box_decimal_t lhs,
const box_decimal_t rhs 
)

Subtract one decimal number from another.

Parameters
reswhere to hold the result
lhsleft hand side operand
rhsright hand side operand
Returns
NULL on an error (an overflow for example)
decimal result (res)

◆ box_decimal_to_int64()

const box_decimal_t * box_decimal_to_int64 ( const box_decimal_t dec,
int64_t *  num 
)

Convert a given decimal to int64_t.

Parameters
decsource decimal number
numwhere to store dec integer representation
Returns
NULL if the value does not fit into int64_t
dec

◆ box_decimal_to_string()

void box_decimal_to_string ( const box_decimal_t dec,
char *  buf 
)

Write the decimal as a string into the passed buffer.

The buffer must have at least BOX_DECIMAL_STRING_BUFFER_SIZE bytes.

Parameters
decsource decimal number
bufwhere to write dec string representation

◆ box_decimal_to_uint64()

const box_decimal_t * box_decimal_to_uint64 ( const box_decimal_t dec,
uint64_t *  num 
)

Convert a given decimal to uint64_t.

Parameters
decsource decimal number
numwhere to store dec integer representation
Returns
NULL if the value does not fit into uint64_t
dec

◆ box_decimal_trim()

box_decimal_t * box_decimal_trim ( box_decimal_t dec)

Remove trailing zeros from the fractional part of a number.

Parameters
decdecimal number
Returns
dec (changed)

◆ box_decimal_zero()

box_decimal_t * box_decimal_zero ( box_decimal_t dec)

Initialize a zero decimal number.

Parameters
decwhere to store the decimal result
Returns
the decimal result

◆ box_delete()

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.

Parameters
space_idspace identifier
index_idindex identifier
keyencoded key in MsgPack Array format ([part1, part2, ...]).
key_endthe end of encoded key.
[out]resultan old tuple. Can be set to NULL to discard result.
Return values
-1on error (check box_error_last())
0on success
See also
box.space[space_id].index[index_id]:delete(key)

◆ box_error_code()

uint32_t box_error_code ( const box_error_t error)

Return IPROTO error code.

Parameters
errorerror
Returns
enum box_error_code

◆ box_error_last()

box_error_t * box_error_last ( void  )

Get the information about the last API call error.

The Tarantool error handling works most like libc's errno. All API calls return -1 or NULL in the event of error. An internal pointer to box_error_t type is set by API functions to indicate what went wrong. This value is only significant if API call failed (returned -1 or NULL).

Successful function can also touch the last error in some cases. You don't have to clear the last error before calling API functions. The returned object is valid only until next call to any API function.

You must set the last error using box_error_set() in your stored C procedures if you want to return a custom error message. You can re-throw the last API error to IPROTO client by keeping the current value and returning -1 to Tarantool from your stored procedure.

Returns
last error.

◆ box_error_message()

const char * box_error_message ( const box_error_t error)

Return the error message.

Parameters
errorerror
Returns
not-null string

◆ box_error_set()

int box_error_set ( const char *  file,
unsigned  line,
uint32_t  code,
const char *  format,
  ... 
)

Set the last error.

Parameters
filefile name, usually FILE macro
lineline number in the file, usually LINE macro
codeIPROTO error code (enum box_error_code)
format(const char * ) - printf()-like format string
...- format arguments
Returns
-1 for convention use
See also
enum box_error_code

◆ box_error_type()

const char * box_error_type ( const box_error_t error)

Return the error type, e.g.

"ClientError", "SocketError", etc.

Parameters
error
Returns
not-null string

◆ box_ibuf_read_range()

void box_ibuf_read_range ( box_ibuf_t ibuf,
char ***  rpos,
char ***  wpos 
)

Return pointers to read range pointers used [rpos..wpos)

Parameters
ibufibuf structure
rposwhere to place ibuf.rpos address
wposwhere to place ibuf.wpos address

◆ box_ibuf_reserve()

void * box_ibuf_reserve ( box_ibuf_t ibuf,
size_t  size 
)

Reserve requested amount of bytes in ibuf buffer.

Parameters
ibufbuffer used for allocation
sizeallocated bytes
Return values
NULLon error, check diag.

◆ box_ibuf_write_range()

void box_ibuf_write_range ( box_ibuf_t ibuf,
char ***  wpos,
char ***  end 
)

Return pointers to write range pointers used [wpos..end)

Parameters
ibufibuf structure
wposwhere to place ibuf.rpos address
endwhere to place ibuf.wpos address

◆ box_index_bsize()

ssize_t box_index_bsize ( uint32_t  space_id,
uint32_t  index_id 
)

Return the number of bytes used in memory by the index.

Parameters
space_idspace identifier
index_idindex identifier
Return values
-1on error (check box_error_last())
>=0 otherwise

◆ box_index_count()

ssize_t box_index_count ( uint32_t  space_id,
uint32_t  index_id,
int  type,
const char *  key,
const char *  key_end 
)

Count the number of tuple matched the provided key.

Parameters
space_idspace identifier
index_idindex identifier
typeiterator type - enum iterator_type
keyencoded key in MsgPack Array format ([part1, part2, ...]).
key_endthe end of encoded key.
Return values
-1on error (check box_error_last())
>=0on success
See also
box.space[space_id].index[index_id]:count(key,
{ iterator = type })

◆ box_index_get()

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

Get a tuple from index by the key.

Please note that this function works much more faster than box_select() or box_index_iterator() + box_iterator_next().

Parameters
space_idspace identifier
index_idindex identifier
keyencoded key in MsgPack Array format ([part1, part2, ...]).
key_endthe end of encoded key
[out]resulta tuple or NULL if index is empty
Return values
-1on error (check box_error_last())
0on success
Precondition
key != NULL
See also
box.space[space_id].index[index_id]:get(key)

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

This function performs SELECT request to _vindex system space.

Parameters
space_idspace identifier
nameindex name
lenlength of name
Return values
BOX_ID_NILon error or if not found (check box_error_last())
index_idotherwise
See also
box_space_id_by_name

◆ box_index_iterator()

box_iterator_t * box_index_iterator ( uint32_t  space_id,
uint32_t  index_id,
int  type,
const char *  key,
const char *  key_end 
)

Allocate and initialize iterator for space_id, index_id.

A returned iterator must be destroyed by box_iterator_free().

Parameters
space_idspace identifier.
index_idindex identifier.
typeiterator type
keyencoded key in MsgPack Array format ([part1, part2, ...]).
key_endthe end of encoded key
Return values
NULLon error (check box_error_last())
iteratorotherwise
See also
box_iterator_next()
box_iterator_free()

◆ box_index_len()

ssize_t box_index_len ( uint32_t  space_id,
uint32_t  index_id 
)

Return the number of element in the index.

Parameters
space_idspace identifier
index_idindex identifier
Return values
-1on error (check box_error_last())
>=0 otherwise

◆ box_index_max()

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

Return a last (maximal) tuple matched the provided key.

Parameters
space_idspace identifier
index_idindex identifier
keyencoded key in MsgPack Array format ([part1, part2, ...]).
key_endthe end of encoded key.
[out]resulta tuple or NULL if index is empty
Return values
-1on error (check box_error_last())
0on success
See also
box.space[space_id].index[index_id]:max(key)

◆ box_index_min()

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

Return a first (minimal) tuple matched the provided key.

Parameters
space_idspace identifier
index_idindex identifier
keyencoded key in MsgPack Array format ([part1, part2, ...]).
key_endthe end of encoded key.
[out]resulta tuple or NULL if index is empty
Return values
-1on error (check box_error_last())
0on success
See also
box.space[space_id].index[index_id]:min(key)

◆ box_index_random()

int box_index_random ( uint32_t  space_id,
uint32_t  index_id,
uint32_t  rnd,
box_tuple_t **  result 
)

Return a random tuple from the index (useful for statistical analysis).

Parameters
space_idspace identifier
index_idindex identifier
rndrandom seed
[out]resulta tuple or NULL if index is empty
Return values
-1on error (check box_error_last())
0on success
See also
box.space[space_id].index[index_id]:random(rnd)

◆ box_insert()

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

Execute an INSERT request.

Parameters
space_idspace identifier
tupleencoded tuple in MsgPack Array format ([ field1, field2, ...])
tuple_endend of tuple
[out]resulta new tuple. Can be set to NULL to discard result.
Return values
-1on error (check box_error_last())
0on success
See also
box.space[space_id]:insert(tuple)

◆ box_insert_arrow()

int box_insert_arrow ( uint32_t  space_id,
struct ArrowArray *  array,
struct ArrowSchema *  schema 
)

Executes a batch insert request.

A record batch from the Arrow array is inserted into the space columns, whose names are provided by the Arrow schema. Column types in the schema must match the types of the corresponding fields in the space format.

If a column is nullable in space format, it can be omitted. All non-nullable columns (including primary key parts) must be present in the batch.

This function does not release neither array nor schema.

Parameters
space_idspace identifier
arrayinput data in ArrowArray format
schemadefinition of the input data in ArrowSchema format
Return values
0on success
-1on error (check box_error_last())

◆ box_iproto_override()

int box_iproto_override ( uint32_t  req_type,
iproto_handler_t  handler,
iproto_handler_destroy_t  destroy,
void *  ctx 
)

Sets an IPROTO request handler with the provided context for the given request type.

NB: yields.

Parameters
req_typerequest type code from iproto_type enumeration (src/box/iproto_constants.h); use IPROTO_UNKNOWN for overriding the handler of unknown request types;
handlerIPROTO request handler; passing NULL resets the corresponding handler
destroyIPROTO request handler destructor
ctxcontext passed to handler
Return values
-1on error (check box_error_last())
0on success

◆ box_iproto_send()

int box_iproto_send ( uint64_t  sid,
const char *  header,
const char *  header_end,
const char *  body,
const char *  body_end 
)

Sends a packet with the given header and body over the IPROTO session's socket.

NB: yields.

Parameters
sidIPROTO session identifier
headerMsgPack encoded header
header_endMsgPack encoded header end
bodyMsgPack encoded body
body_endMsgPack encoded body end
Return values
-1on error (check box_error_last())
0on success

◆ box_iterator_free()

void box_iterator_free ( box_iterator_t iterator)

Destroy and deallocate iterator.

Parameters
iteratoran iterator returned by box_index_iterator()

◆ box_iterator_next()

int box_iterator_next ( box_iterator_t iterator,
box_tuple_t **  result 
)

Retrieve the next item from the iterator.

Parameters
iteratoran iterator returned by box_index_iterator().
[out]resulta tuple or NULL if there is no more data.
Return values
-1on error (check box_error_last() for details)
0on success. The end of data is not an error.

◆ box_key_def_delete()

void box_key_def_delete ( box_key_def_t key_def)

Delete key definition.

Parameters
key_defkey definition to delete

◆ box_key_def_dump_parts()

box_key_part_def_t * box_key_def_dump_parts ( const box_key_def_t key_def,
uint32_t *  part_count_ptr 
)

Dump key part definitions of given key_def.

The function allocates key parts and storage for pointer fields (e.g. collation names) on the box region.

See also
box_region_truncate()

box_key_part_def_t fields that are unknown at given tarantool version are set to zero. The same for unknown flags bits.

In case of an error set a diag and return NULL.

See also
box_error_last()

◆ box_key_def_dup()

box_key_def_t * box_key_def_dup ( const box_key_def_t key_def)

Duplicate key_def.

Parameters
key_defOriginal key_def.
Return values
notNULL Duplicate of src.

◆ box_key_def_extract_key()

char * box_key_def_extract_key ( box_key_def_t key_def,
box_tuple_t tuple,
int  multikey_idx,
uint32_t *  key_size_ptr 
)

Extract key from tuple by given key definition and return buffer allocated on the box region with this key.

See also
box_region_truncate()

This function has O(n) complexity, where n is the number of key parts.

Parameters
key_defDefinition of key that need to extract.
tupleTuple from which need to extract key.
multikey_idxMultikey index hint or -1.
key_size_ptrHere will be size of extracted key.
Return values
notNULL Success.
NULLMemory allocation error.

In case of an error set a diag and return NULL.

See also
box_error_last()

◆ box_key_def_merge()

box_key_def_t * box_key_def_merge ( const box_key_def_t first,
const box_key_def_t second 
)

Allocate a new key_def with a set union of key parts from first and second key defs.

Parts of the new key_def consist of the first key_def's parts and those parts of the second key_def that were not among the first parts.

Return values
notNULL Ok.
NULLMemory error.

In case of an error set a diag and return NULL.

See also
box_error_last()

◆ box_key_def_new()

box_key_def_t * box_key_def_new ( uint32_t *  fields,
uint32_t *  types,
uint32_t  part_count 
)

Create key definition with given field numbers and field types.

May be used for tuple format creation and/or tuple comparison.

See also
box_key_def_new_v2()
Parameters
fieldsarray with key field identifiers
typesarray with key field types (see enum field_type)
part_countthe number of key fields
Returns
a new key definition object

◆ box_key_def_new_v2()

box_key_def_t * box_key_def_new_v2 ( box_key_part_def_t parts,
uint32_t  part_count 
)

Create a key_def from given key parts.

Unlike box_key_def_new() this function allows to define nullability, collation and other options for each key part.

box_key_part_def_t fields that are unknown at given tarantool version are ignored. The same for unknown flags bits.

In case of an error set a diag and return NULL.

See also
box_error_last()

◆ box_key_def_validate_full_key()

int box_key_def_validate_full_key ( const box_key_def_t key_def,
const char *  key,
uint32_t *  key_size_ptr 
)

Check a full key against given key definition.

Verifies key parts against given key_def's field types with respect to nullability.

Imposes the same parts count in key as in key_def. Absence of trailing key parts fails the check.

Note: nil is accepted for nullable fields, but only for them.

Parameters
key_defKey definition.
keyMessagePack'ed data for matching.
key_size_ptrHere will be size of the validated key.
Return values
0The key is valid.
-1The key is invalid.

In case of an invalid key set a diag and return -1.

See also
box_error_last()

◆ box_key_def_validate_key()

int box_key_def_validate_key ( const box_key_def_t key_def,
const char *  key,
uint32_t *  key_size_ptr 
)

Check a key against given key definition.

Verifies key parts against given key_def's field types with respect to nullability.

A partial key (with less part than defined in key_def) is verified by given key parts, the omitted tail is not verified anyhow.

Note: nil is accepted for nullable fields, but only for them.

Parameters
key_defKey definition.
keyMessagePack'ed data for matching.
key_size_ptrHere will be size of the validated key.
Return values
0The key is valid.
-1The key is invalid.

In case of an invalid key set a diag and return -1.

See also
box_error_last()

◆ box_key_def_validate_tuple()

int box_key_def_validate_tuple ( box_key_def_t key_def,
box_tuple_t tuple 
)

Check that tuple fields match with given key definition.

Parameters
key_defKey definition.
tupleTuple to validate.
Return values
0The tuple is valid.
-1The tuple is invalid.

In case of an invalid tuple set a diag and return -1.

See also
box_error_last()

◆ box_key_part_def_create()

void box_key_part_def_create ( box_key_part_def_t part)

Initialize a key part with default values.

Field Default value Details
fieldno 0
flags default flags
field_type NULL [^1]
collation NULL
path NULL

Default flag values are the following:

Flag Default value
BOX_KEY_PART_DEF_IS_NULLABLE 0 (unset)
BOX_KEY_PART_DEF_EXCLUDE_NULL 0 (unset)
BOX_KEY_PART_DEF_SORT_ORDER_DESC 0 (unset)

Default values of fields and flags are permitted to be changed in future tarantool versions. However we should be VERY conservative here and consider any meaningful usage scenarios, when doing so. At least new defaults should be consistent with how tarantool itself doing key_def related operations: validation, key extraction, comparisons and so on.

All trailing padding bytes are set to zero. The same for unknown flags bits.

[^1]: box_key_def_new_v2() does not accept NULL as a field_type, so it should be filled explicitly.

◆ box_latch_delete()

void box_latch_delete ( box_latch_t latch)

Destroy and free the latch.

Parameters
latchlatch

◆ box_latch_lock()

void box_latch_lock ( box_latch_t latch)

Lock a latch.

Waits indefinitely until the current fiber can gain access to the latch. Locks are acquired in the strict order as they were requested.

Parameters
latcha latch

◆ box_latch_new()

box_latch_t * box_latch_new ( void  )

Allocate and initialize the new latch.

Returns
latch

◆ box_latch_trylock()

int box_latch_trylock ( box_latch_t latch)

Try to lock a latch.

Return immediately if the latch is locked.

Parameters
latcha latch
Return values
0- success
1- the latch is locked.

◆ box_latch_unlock()

void box_latch_unlock ( box_latch_t latch)

Unlock a latch.

The fiber calling this function must own the latch.

Parameters
latcha latch

◆ box_on_shutdown()

int box_on_shutdown ( void *  arg,
int(*)(void *)  new_handler,
int(*)(void *)  old_handler 
)

Statement Attributes }}}.

public Function, which registers or deletes on_shutdown handler.

Parameters
[in]argon_shutdown function's argument.
[in]new_handlerNew on_shutdown handler, in case this argument is NULL, function finds and destroys old on_shutdown handler.
[in]old_handlerOld on_shutdown handler.
Return values
return0 if success otherwise return -1 and sets errno. There are three cases when function fails:
  • both old_handler and new_handler are equal to zero (sets errno to EINVAL).
  • old_handler != NULL, but there is no trigger with such function (sets errno to EINVAL).
  • malloc for some internal struct memory allocation return NULL (errno sets by malloc to ENOMEM).

◆ box_region_aligned_alloc()

void * box_region_aligned_alloc ( size_t  size,
size_t  alignment 
)

Allocate size bytes from the box region with given alignment.

Alignment must be a power of 2.

In case of a memory error set a diag and return NULL.

See also
box_error_last().

◆ box_region_alloc()

void * box_region_alloc ( size_t  size)

Allocate size bytes from the box region.

Don't use this function to allocate a memory block for a value or array of values of a type with alignment requirements. A violation of alignment requirements leads to undefined behaviour.

In case of a memory error set a diag and return NULL.

See also
box_error_last().

◆ box_region_used()

size_t box_region_used ( void  )

box region allocator

It is the region allocator from the small library. It is useful for allocating tons of small objects and free them at once.

Typical usage is illustrated in the sketch below.

size_t region_svp = box_region_used();
while (<...>) {
char *buf = box_region_alloc(<...>);
<...>
}
box_region_truncate(region_svp);
size_t box_region_used(void)
box region allocator
void * box_region_alloc(size_t size)
Allocate size bytes from the box region.
void box_region_truncate(size_t size)
Truncate the box region to the given size.

There are module API functions that return a result on this region. In this case a caller is responsible to free the result:

size_t region_svp = box_region_used();
char *buf = box_<...>(<...>);
<...>
box_region_truncate(region_svp);

This API provides better compatibility guarantees over using the small library directly in a module. A binary layout of internal structures may be changed in a future, but <box_region_*>() functions will remain API and ABI compatible.

Each fiber has its own box region. It means that a call of, say, box_region_used() will give its own value in different fibers. It also means that a yield does not invalidate data in the box region.

Prior to version 2.11, the box region was implicitly cleaned up on transaction commit (see box_txn_commit()) so that box_region_truncate() wasn't strictly necessary. Starting from version 2.11, it isn't true anymore, and the client code must free all its allocations explicitly. How much memory is used by the box region.

◆ box_replace()

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

Execute an REPLACE request.

Parameters
space_idspace identifier
tupleencoded tuple in MsgPack Array format ([ field1, field2, ...])
tuple_endend of tuple
[out]resulta new tuple. Can be set to NULL to discard result.
Return values
-1on error (check box_error_last())
0on success
See also
box.space[space_id]:replace(tuple)

◆ box_return_mp()

int box_return_mp ( box_function_ctx_t ctx,
const char *  mp,
const char *  mp_end 
)

Return MessagePack from a stored C procedure.

The MessagePack is copied, so it is safe to free/reuse the passed arguments after the call. MessagePack is not validated, for the sake of speed. It is expected to be a single encoded object. An attempt to encode and return multiple objects without wrapping them into an MP_ARRAY or MP_MAP is undefined behaviour.

Parameters
ctxAn opaque structure passed to the stored C procedure by Tarantool.
mpBegin of MessagePack.
mp_endEnd of MessagePack.
Return values
-1Error.
0Success.

◆ box_return_tuple()

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.

Parameters
ctxan opaque structure passed to the stored C procedure by Tarantool
tuplea tuple to return
Return values
-1on error (perhaps, out of memory; check box_error_last())
0otherwise

◆ box_ro_reason()

const char * box_ro_reason ( void  )

public

Get the reason why the instance is read only if it is. Can't be called on a writable instance.

◆ box_schema_version()

uint64_t box_schema_version ( void  )

public

Returns the current version of the database schema, an unsigned number that goes up when there is a major change in the schema, i.e., on DDL operations.

See also
IPROTO_SCHEMA_VERSION

◆ box_sequence_current()

int box_sequence_current ( uint32_t  seq_id,
int64_t *  result 
)

Get the last value returned by a sequence.

Parameters
seq_idsequence identifier
[out]resultpointer to a variable where the current sequence value will be stored on success
Return values
-1on error (check box_error_last())
0on success

◆ box_sequence_next()

int box_sequence_next ( uint32_t  seq_id,
int64_t *  result 
)

Advance a sequence.

Parameters
seq_idsequence identifier
[out]resultpointer to a variable where the next sequence value will be stored on success
Return values
-1on error (check box_error_last())
0on success

◆ box_sequence_reset()

int box_sequence_reset ( uint32_t  seq_id)

Reset a sequence.

Parameters
seq_idsequence identifier
Return values
-1on error (check box_error_last())
0on success

◆ box_sequence_set()

int box_sequence_set ( uint32_t  seq_id,
int64_t  value 
)

Set a sequence value.

Parameters
seq_idsequence identifier
valuenew sequence value; on success the next call to box_sequence_next() will return the value following value
Return values
-1on error (check box_error_last())
0on success

◆ box_session_id()

uint64_t box_session_id ( void  )
Returns
current session's unique monotonic identifier
See also
box.session.id

◆ box_session_push()

int box_session_push ( const char *  data,
const char *  data_end 
)

Push MessagePack data into a session data channel - socket, console or whatever is behind the session.

Note, that successful push does not guarantee delivery in case it was sent into the network. Just like with write()/send() system calls.

Parameters
databegin of MessagePack to push
data_endend of MessagePack to push
Return values
-1on error (check box_error_last())
0on success

◆ box_space_id_by_name()

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.

Parameters
namespace name
lenlength of name
Return values
BOX_ID_NILon error or if not found (check box_error_last())
space_idotherwise
See also
box_index_id_by_name

◆ box_truncate()

int box_truncate ( uint32_t  space_id)

Truncate space.

Parameters
space_idspace identifier

◆ box_tuple_bsize()

size_t box_tuple_bsize ( box_tuple_t tuple)

Return the number of bytes used to store internal tuple data (MsgPack Array).

Parameters
tuplea tuple

◆ box_tuple_compare()

int box_tuple_compare ( box_tuple_t tuple_a,
box_tuple_t tuple_b,
box_key_def_t key_def 
)

Compare tuples using the key definition.

Parameters
tuple_afirst tuple
tuple_bsecond tuple
key_defkey definition
Return values
0if key_fields(tuple_a) == key_fields(tuple_b)
<0if key_fields(tuple_a) < key_fields(tuple_b)
>0if key_fields(tuple_a) > key_fields(tuple_b)

◆ box_tuple_compare_with_key()

int box_tuple_compare_with_key ( box_tuple_t tuple_a,
const char *  key_b,
box_key_def_t key_def 
)

Compare tuple with key using the key definition.

Parameters
tuple_atuple
key_bkey with MessagePack array header
key_defkey definition
Return values
0if key_fields(tuple) == parts(key)
<0if key_fields(tuple) < parts(key)
>0if key_fields(tuple) > parts(key)

◆ box_tuple_extract_key()

char * box_tuple_extract_key ( box_tuple_t tuple,
uint32_t  space_id,
uint32_t  index_id,
uint32_t *  key_size 
)

Extract key from tuple according to key definition of given index.

Returned buffer is allocated on box_txn_alloc() with this key.

Parameters
tupleTuple from which need to extract key.
space_idSpace identifier.
index_idIndex identifier.
[out]key_sizewhere to store the size of the extracted key; pass NULL here if it is not needed
Return values
notNULL Success
NULLMemory Allocation error

◆ box_tuple_field()

const char * box_tuple_field ( box_tuple_t tuple,
uint32_t  fieldno 
)

Return the raw tuple field in MsgPack format.

The buffer is valid until next call to box_tuple_* functions.

Parameters
tuplea tuple
fieldnozero-based index in MsgPack array.
Return values
NULLif i >= box_tuple_field_count(tuple)
msgpackotherwise

◆ box_tuple_field_by_path()

const char * box_tuple_field_by_path ( box_tuple_t tuple,
const char *  path,
uint32_t  path_len,
int  index_base 
)

Return a raw tuple field in the MsgPack format pointed by a JSON path.

The JSON path includes the outmost field. For example, "c" in ["a", ["b", "c"], "d"] can be accessed using "[2][2]" path (if index_base is 1, as in Lua). If index_base is set to 0, the same field will be pointed by the "[1][1]" path.

The first JSON path token may be a field name if the tuple has associated format with named fields. A field of a nested map can be accessed in the same way: "foo.bar" or ".foo.bar".

The return value is valid until the tuple is destroyed, see box_tuple_ref().

Return NULL if the field does not exist or if the JSON path is malformed or invalid. Multikey JSON path token [*] is treated as invalid in this context.

Parameters
tuplea tuple
patha JSON path
path_lena length of path
index_base0 if array element indexes in path are zero-based (like in C) or 1 if they're one-based (like in Lua)
Return values
apointer to a field data if the field exists or NULL

◆ box_tuple_field_count()

uint32_t box_tuple_field_count ( box_tuple_t tuple)

Return the number of fields in tuple (the size of MsgPack Array).

Parameters
tuplea tuple

◆ box_tuple_format()

box_tuple_format_t * box_tuple_format ( box_tuple_t tuple)

Return the associated format.

Parameters
tupletuple
Returns
tuple_format

◆ box_tuple_format_default()

box_tuple_format_t * box_tuple_format_default ( void  )

Tuple Format.

Each Tuple has associated format (class). Default format is used to create tuples which are not attach to any particular space.

◆ box_tuple_format_new()

box_tuple_format_t * box_tuple_format_new ( struct key_def **  keys,
uint16_t  key_count 
)

public

Return new in-memory tuple format based on passed key definitions.

Parameters
keysarray of keys defined for the format
key_countcount of keys
Return values
newtuple format if success
NULLfor error

◆ box_tuple_format_ref()

void box_tuple_format_ref ( box_tuple_format_t format)

Increment tuple format ref count.

Parameters
formatthe tuple format to ref

◆ box_tuple_format_unref()

void box_tuple_format_unref ( box_tuple_format_t format)

Decrement tuple format ref count.

Parameters
formatthe tuple format to unref

◆ box_tuple_iterator()

box_tuple_iterator_t * box_tuple_iterator ( box_tuple_t tuple)

Allocate and initialize a new tuple iterator.

The tuple iterator allow to iterate over fields at root level of MsgPack array.

Example:

if (it == NULL) {
// error handling using box_error_last()
}
const char *field;
while (field = box_tuple_next(it)) {
// process raw MsgPack data
}
// rewind iterator to first position
assert(box_tuple_position(it) == 0);
// rewind iterator to first position
field = box_tuple_seek(it, 3);
assert(box_tuple_position(it) == 4);
void box_iterator_free(box_iterator_t *iterator)
Destroy and deallocate iterator.
void box_tuple_rewind(box_tuple_iterator_t *it)
Rewind iterator to the initial position.
uint32_t box_tuple_position(box_tuple_iterator_t *it)
Return zero-based next position in iterator.
const char * box_tuple_next(box_tuple_iterator_t *it)
Return the next tuple field from tuple iterator.
const char * box_tuple_seek(box_tuple_iterator_t *it, uint32_t fieldno)
Seek the tuple iterator.
box_tuple_iterator_t * box_tuple_iterator(box_tuple_t *tuple)
Allocate and initialize a new tuple iterator.
Postcondition
box_tuple_position(it) == 0

◆ box_tuple_new()

box_tuple_t * box_tuple_new ( box_tuple_format_t format,
const char *  data,
const char *  end 
)

Allocate and initialize a new tuple from a raw MsgPack Array data.

Parameters
formattuple format. Use box_tuple_format_default() to create space-independent tuple.
datatuple data in MsgPack Array format ([field1, field2, ...]).
endthe end of data
Return values
tuple
Precondition
data, end is valid MsgPack Array
See also
box.tuple.new(data)

◆ box_tuple_next()

const char * box_tuple_next ( box_tuple_iterator_t it)

Return the next tuple field from tuple iterator.

The returned buffer is valid until next call to box_tuple_* API.

Parameters
ittuple iterator.
Return values
NULLif there are no more fields.
MsgPackotherwise
Precondition
box_tuple_position(it) is zero-based id of returned field
Postcondition
box_tuple_position(it) == box_tuple_field_count(tuple) if returned value is NULL.

◆ box_tuple_position()

uint32_t box_tuple_position ( box_tuple_iterator_t it)

Return zero-based next position in iterator.

That is, this function return the field id of field that will be returned by the next call to box_tuple_next(). Returned value is zero after initialization or rewind and box_tuple_field_count() after the end of iteration.

Parameters
ittuple iterator
Returns
position.

◆ box_tuple_ref()

int box_tuple_ref ( box_tuple_t tuple)

Increase the reference counter of tuple.

Tuples are reference counted. All functions that return tuples guarantee that the last returned tuple is refcounted internally until the next call to API function that yields or returns another tuple.

You should increase the reference counter before taking tuples for long processing in your code. Such tuples will not be garbage collected even if another fiber remove they from space. After processing please decrement the reference counter using box_tuple_unref(), otherwise the tuple will leak.

Parameters
tuplea tuple
Return values
0always
See also
box_tuple_unref()

◆ box_tuple_rewind()

void box_tuple_rewind ( box_tuple_iterator_t it)

Rewind iterator to the initial position.

Parameters
ittuple iterator
Postcondition
box_tuple_position(it) == 0

◆ box_tuple_seek()

const char * box_tuple_seek ( box_tuple_iterator_t it,
uint32_t  fieldno 
)

Seek the tuple iterator.

The returned buffer is valid until next call to box_tuple_* API. Requested fieldno returned by next call to box_tuple_next().

Parameters
ittuple iterator
fieldno- zero-based position in MsgPack array.
Postcondition
box_tuple_position(it) == fieldno if returned value is not NULL
box_tuple_position(it) == box_tuple_field_count(tuple) if returned value is NULL.

◆ box_tuple_to_buf()

ssize_t box_tuple_to_buf ( box_tuple_t tuple,
char *  buf,
size_t  size 
)

Dump raw MsgPack data to the memory buffer buf of size size.

Store tuple fields in the memory buffer.

Return values
-1on error.
numberof bytes written on success. Upon successful return, the function returns the number of bytes written. If buffer size is not enough then the return value is the number of bytes which would have been written if enough space had been available.

◆ box_tuple_unref()

void box_tuple_unref ( box_tuple_t tuple)

Decrease the reference counter of tuple.

Parameters
tuplea tuple
See also
box_tuple_ref()

◆ box_tuple_update()

box_tuple_t * box_tuple_update ( box_tuple_t tuple,
const char *  expr,
const char *  expr_end 
)

Update a tuple.

Function returns a copy of tuple with updated fields. Pay attention that original tuple is left without changes.

Parameters
tupleTuple to update.
exprMessagePack array of operations.
expr_endEnd of the expr.
Return values
NULLThe tuple was not updated.
box_tuple_tA copy of original tuple with updated fields.
See also
box_update()

◆ box_tuple_upsert()

box_tuple_t * box_tuple_upsert ( box_tuple_t tuple,
const char *  expr,
const char *  expr_end 
)

Update a tuple.

The same as box_tuple_update(), but ignores errors. In case of an error the tuple is left intact, but an error message is printed. Only client errors are ignored, such as a bad field type, or wrong field index/name. System errors, such as OOM, are not ignored and raised just like with a normal box_tuple_update(). Note that only bad operations are ignored. All correct operations are applied.

Despite the function name (upsert, update and insert), the function does not insert any tuple.

Parameters
tupleTuple to update.
exprMessagePack array of operations.
expr_endEnd of the expr.
Return values
NULLThe tuple was not updated.
box_tuple_tA copy of original tuple with updated fields.
See also
box_upsert()

◆ box_tuple_validate()

int box_tuple_validate ( box_tuple_t tuple,
box_tuple_format_t format 
)

Check tuple data correspondence to the space format.

Parameters
tupleTuple to validate.
formatFormat to which the tuple must match.
Return values
0The tuple is valid.
-1The tuple is invalid.

◆ box_txn_alloc()

void * box_txn_alloc ( size_t  size)

Allocate memory on txn memory pool.

The memory is automatically deallocated when the transaction is committed or rolled back.

Return values
NULLout of memory

◆ box_txn_begin()

int box_txn_begin ( void  )

Begin a transaction in the current fiber.

A transaction is attached to caller fiber, therefore one fiber can have only one active transaction.

Return values
0- success
-1- failed, perhaps a transaction has already been started

◆ box_txn_commit()

int box_txn_commit ( void  )

Commit the current transaction.

Return values
0- success
-1- failed, perhaps a disk write failure. started

◆ box_txn_id()

int64_t box_txn_id ( void  )

public

Transaction id - a non-persistent unique identifier of the current transaction. -1 if there is no current transaction.

◆ box_txn_isolation()

int box_txn_isolation ( void  )

Get isolation level of current transaction, one of enum txn_isolation_level values (but cannot be TXN_ISOLATION_DEFAULT (which is zero) by design).

-1 if there is no current transaction.

◆ box_txn_rollback()

int box_txn_rollback ( void  )

Rollback the current transaction.

May fail if called from a nested statement.

◆ box_txn_set_isolation()

int box_txn_set_isolation ( uint32_t  level)

Set an isolation level for a transaction.

Must be called before the first DML. The level must be of enun txn_isolation_level values.

Return values
0if success
-1if failed, diag is set.

◆ box_txn_set_timeout()

int box_txn_set_timeout ( double  timeout)

Set timeout for transaction, when it expires, transaction will be rolled back.

Return values
0if success
-1if timeout is less than or equal to 0, there is no current transaction or rollback timer for current transaction is already started.

◆ box_update()

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.

Parameters
space_idspace identifier
index_idindex identifier
keyencoded key in MsgPack Array format ([part1, part2, ...]).
key_endthe end of encoded key.
opsencoded operations in MsgPack Array format, e.g. [ [ '=', fieldno, value ], ['!', 2, 'xxx'] ]
ops_endthe end of encoded ops
index_base0 if fieldnos in update operations are zero-based indexed (like C) or 1 if for one-based indexed field ids (like Lua).
[out]resulta new tuple. Can be set to NULL to discard result.
Return values
-1on error (check box_error_last())
0on success
See also
box.space[space_id].index[index_id]:update(key, ops)
box_upsert()

◆ box_upsert()

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.

Parameters
space_idspace identifier
index_idindex identifier
opsencoded operations in MsgPack Array format, e.g. [ [ '=', fieldno, value ], ['!', 2, 'xxx'] ]
ops_endthe end of encoded ops
tupleencoded tuple in MsgPack Array format ([ field1, field2, ...])
tuple_endend of tuple
index_base0 if fieldnos in update operations are zero-based indexed (like C) or 1 if for one-based indexed field ids (like Lua).
[out]resulta new tuple. Can be set to NULL to discard result.
Return values
-1on error (check box_error_last())
0on success
See also
box.space[space_id].index[index_id]:update(key, ops)
box_update()

◆ box_wait_ro()

int box_wait_ro ( bool  ro,
double  timeout 
)

public

Wait until the instance switches to a desired mode.

Parameters
rowait read-only if set or read-write if unset
timeoutmax time to wait
Return values
-1timeout or fiber is cancelled
0success

◆ clock_monotonic()

double clock_monotonic ( void  )

A nonsettable system-wide clock that represents monotonic time.

See also
clock_gettime(2), CLOCK_MONOTONIC.

◆ clock_process()

double clock_process ( void  )

A clock that measures CPU time consumed by this process (by all threads in the process).

See also
clock_gettime(2), CLOCK_PROCESS_CPUTIME_ID.

◆ clock_realtime()

double clock_realtime ( void  )

public

A settable system-wide clock that measures real (i.e., wall-clock) time.

See also
clock_gettime(2), CLOCK_REALTIME.

◆ clock_thread()

double clock_thread ( void  )

A clock that measures CPU time consumed by this thread.

See also
clock_gettime(2), CLOCK_THREAD_CPUTIME_ID.

◆ coio_call()

ssize_t coio_call ( ssize_t(*)(va_list)  func,
  ... 
)

public

Create new eio task with specified function and arguments. Yield and wait until the task is complete.

This function doesn't throw exceptions to avoid double error checking: in most cases it's also necessary to check the return value of the called function and perform necessary actions. If func sets errno, the errno is preserved across the call.

Return values
-1and errno = ENOMEM if failed to create a task
thefunction return (errno is preserved).
static ssize_t openfile_cb(va_list ap)
{
const char *filename = va_arg(ap);
int flags = va_arg(ap);
return open(filename, flags);
}
if (coio_call(openfile_cb, "/tmp/file", 0) == -1)
// handle errors.
...
ssize_t coio_call(ssize_t(*func)(va_list),...)
public

◆ coio_getaddrinfo()

int coio_getaddrinfo ( const char *  host,
const char *  port,
const struct addrinfo *  hints,
struct addrinfo **  res,
double  timeout 
)

Fiber-friendly version of getaddrinfo(3).

Parameters
hosthost name, i.e. "tarantool.org"
portservice name, i.e. "80" or "http"
hintshints, see getaddrinfo(3)
[out]resresult, see getaddrinfo(3)
timeouttimeout
Return values
0on success, please free res using freeaddrinfo(3).
-1on error, check diag. Please note that the return value is not compatible with getaddrinfo(3).
See also
getaddrinfo()

◆ coio_wait()

int coio_wait ( int  fd,
int  event,
double  timeout 
)

Wait until READ or WRITE event on socket (fd).

Yields.

Parameters
fdnon-blocking socket file description
eventrequested events to wait. Combination of TNT_IO_READ | TNT_IO_WRITE bit flags.
timeouttimeout in seconds.
Return values
0timeout
>0returned events. Combination of TNT_IO_READ | TNT_IO_WRITE bit flags.

◆ fiber_attr_delete()

void fiber_attr_delete ( struct fiber_attr *  fiber_attr)

Delete the fiber_attr and free all allocated resources.

This is safe when fibers created with this attribute still exist.

Parameters
fiber_attrfiber attribute

◆ fiber_attr_getstacksize()

size_t fiber_attr_getstacksize ( struct fiber_attr *  fiber_attr)

Get stack size from the fiber attribute.

Parameters
fiber_attrfiber attribute container or NULL for default
Return values
stacksize

◆ fiber_attr_new()

struct fiber_attr * fiber_attr_new ( void  )

Create a new fiber attribute container and initialize it with default parameters.

Can be used for many fibers creation, corresponding fibers will not take ownership.

◆ fiber_attr_setstacksize()

int fiber_attr_setstacksize ( struct fiber_attr *  fiber_attr,
size_t  stack_size 
)

Set stack size for the fiber attribute.

Parameters
fiber_attrfiber attribute container
stack_sizestack size for new fibers

◆ fiber_cancel()

void fiber_cancel ( struct fiber *  f)

Cancel the subject fiber.

Cancellation is asynchronous. Use fiber_join() to wait for the cancellation to complete.

After fiber_cancel() is called, the fiber may or may not check whether it was cancelled. If the fiber does not check it, it cannot ever be cancelled. However, as long as most of the cooperative code calls fiber_testcancel(), most of the fibers are cancellable.

Parameters
ffiber to be cancelled

◆ fiber_clock()

double fiber_clock ( void  )

Report loop begin time as double (cheap).

Uses monotonic clock.

◆ fiber_clock64()

int64_t fiber_clock64 ( void  )

Report loop begin time as 64-bit int.

Uses monotonic clock.

◆ fiber_cond_broadcast()

void fiber_cond_broadcast ( struct fiber_cond *  cond)

Wake up all fibers waiting for the cond.

Parameters
condcondition

◆ fiber_cond_delete()

void fiber_cond_delete ( struct fiber_cond *  cond)

Delete the fiber cond object.

Behaviour is undefined if there are fiber waiting for the cond.

◆ fiber_cond_new()

struct fiber_cond * fiber_cond_new ( void  )

public

Instantiate a new fiber cond object.

◆ fiber_cond_signal()

void fiber_cond_signal ( struct fiber_cond *  cond)

Wake one fiber waiting for the cond.

Does nothing if no one is waiting.

Parameters
condcondition

◆ fiber_cond_wait()

int fiber_cond_wait ( struct fiber_cond *  cond)

◆ fiber_cond_wait_timeout()

int fiber_cond_wait_timeout ( struct fiber_cond *  cond,
double  timeout 
)

Suspend the execution of the current fiber (i.e.

yield) until fiber_cond_signal() is called. Like pthread_cond, fiber_cond can issue spurious wake ups caused by explicit fiber_wakeup() or fiber_cancel() calls. It is highly recommended to wrap calls to this function into a loop and check an actual predicate and fiber_testcancel() on every iteration.

Parameters
condcondition
timeouttimeout in seconds
Return values
0on fiber_cond_signal() call or a spurious wake up
-1on timeout or fiber cancellation, diag is set

◆ fiber_csw()

uint64_t fiber_csw ( const struct fiber *  fiber)

Get number of context switches of the given fiber.

Parameters
fiberTarget fiber, if it's NULL the current fiber is used.

◆ fiber_find()

struct fiber * fiber_find ( uint64_t  fid)

Get a pointer to a live fiber in the current cord by the given fiber id, which may be used for getting other info about the fiber (name, csw, etc.).

Parameters
fidTarget fiber id.
Returns
fiber on success, NULL if fiber was not found.
See also
fiber_name, fiber_csw, fiber_id

◆ fiber_get_ctx()

void * fiber_get_ctx ( struct fiber *  f)

Get the context for the fiber which was set via the fiber_set_ctx function.

Can be used to avoid calling fiber_start which means no yields. If f is NULL, the current fiber is used.

Return values
contextfor the fiber function set by fiber_set_ctx function
See also
fiber_set_ctx

◆ fiber_id()

uint64_t fiber_id ( const struct fiber *  fiber)

Get fiber id.

Parameters
fiberTarget fiber, if it's NULL the current fiber is used.

◆ fiber_join()

int fiber_join ( struct fiber *  f)

Wait until the fiber is dead and then move its execution status to the caller.

The fiber must not be detached (

See also
fiber_set_joinable()).
Precondition
FIBER_IS_JOINABLE flag is set (panic if not).
the fiber is not joined yet (panic if not).
the fiber is different from current (panic if not).
Parameters
ffiber to be woken up
Returns
fiber function ret code

◆ fiber_join_timeout()

int fiber_join_timeout ( struct fiber *  f,
double  timeout 
)

Wait until the fiber is dead or timeout exceeded.

In case timeout == TIMEOUT_INFINITY, this function same as fiber_join function. Return fiber execution status to the caller or -1 if timeout exceeded and set diag. The fiber must not be detached

See also
fiber_set_joinable()
Precondition
FIBER_IS_JOINABLE flag is set.
the fiber is not joined yet (panic if not).
Parameters
ffiber to be woken up
timeouttime during which we wait for the fiber completion
Returns
fiber function ret code or -1 in case if timeout exceeded

◆ fiber_name()

const char * fiber_name ( const struct fiber *  fiber)

Get fiber name.

Parameters
fiberTarget fiber, if it's NULL the current fiber is used.
Returns
pointer to a nul-terminated string.

◆ fiber_new()

struct fiber * fiber_new ( const char *  name,
fiber_func  f 
)

Create a new fiber.

Takes a fiber from fiber cache, if it's not empty. Can fail only if there is not enough memory for the fiber structure or fiber stack.

The created fiber automatically returns itself to the fiber cache when its "main" function completes.

Parameters
namestring with fiber name
ffunc for run inside fiber
See also
fiber_start

◆ fiber_new_ex()

struct fiber * fiber_new_ex ( const char *  name,
const struct fiber_attr *  fiber_attr,
fiber_func  f 
)

Create a new fiber with defined attributes.

Can fail only if there is not enough memory for the fiber structure or fiber stack.

The created fiber automatically returns itself to the fiber cache if has default stack size when its "main" function completes.

Parameters
namestring with fiber name
fiber_attrfiber attributes
ffunc for run inside fiber
See also
fiber_start

◆ fiber_set_cancellable()

bool fiber_set_cancellable ( bool  yesno)

Deprecated.

Returns
true

◆ fiber_set_ctx()

void fiber_set_ctx ( struct fiber *  f,
void *  f_arg 
)

Set a pointer to context for the fiber.

Can be used to avoid calling fiber_start which means no yields.

Parameters
ffiber to set the context for if NULL, the current fiber is used
f_argcontext for the fiber function

◆ fiber_set_joinable()

void fiber_set_joinable ( struct fiber *  fiber,
bool  yesno 
)

Set fiber to be joinable (false by default).

The fiber must not be joined already nor dead.

Precondition
the fiber is not dead (panic if not).
the fiber is not joined yet (panic if not).
Parameters
fiberto (un)set the joinable property. If set to NULL, the current fiber is used.
yesnostatus to set

◆ fiber_set_name_n()

void fiber_set_name_n ( struct fiber *  fiber,
const char *  name,
uint32_t  len 
)

Set fiber name.

Parameters
fiberTarget fiber, if it's NULL the current fiber is used.
nameA new name of fiber.
lenLength of the string pointed to by name.

◆ fiber_sleep()

void fiber_sleep ( double  s)

Put the current fiber to sleep for at least 's' seconds.

Parameters
stime to sleep
Note
this is a cancellation point
See also
fiber_is_cancelled

◆ fiber_start()

void fiber_start ( struct fiber *  callee,
  ... 
)

Start execution of created fiber.

Parameters
calleefiber to start
...arguments to start the fiber with
See also
fiber_new

◆ fiber_time()

double fiber_time ( void  )

Report loop begin time as double (cheap).

Uses real time clock.

◆ fiber_time64()

int64_t fiber_time64 ( void  )

Report loop begin time as 64-bit int.

Uses real time clock.

◆ fiber_wakeup()

void fiber_wakeup ( struct fiber *  f)

Interrupt a synchronous wait of a fiber.

Nop for the currently running fiber.

Parameters
ffiber to be woken up

◆ fiber_yield()

void fiber_yield ( void  )

Return control to another fiber and wait until it'll be woken.

Note
this is not a cancellation point (
See also
fiber_testcancel()), but it is considered a good practice to call fiber_testcancel() after each yield.
fiber_wakeup

◆ luaL_cdef()

int luaL_cdef ( struct lua_State *  L,
const char *  ctypename 
)

Declare symbols for FFI.

Parameters
LLua State
ctypenameC definitions, e.g "struct stat"
See also
ffi.cdef(def)
Return values
0on success
LUA_ERRRUN,LUA_ERRMEM,LUA_ERRERRotherwise

◆ luaL_checkcdata()

void * luaL_checkcdata ( struct lua_State *  L,
int  idx,
uint32_t *  ctypeid 
)

Checks whether the function argument idx is a cdata.

Parameters
LLua State
idxstack index
ctypeidFFI's CTypeID of this cdata
See also
luaL_pushcdata
Returns
memory associated with this cdata

◆ luaL_checkint64()

int64_t luaL_checkint64 ( struct lua_State *  L,
int  idx 
)

Checks whether the argument idx is a int64 or a convertible string and returns this number.

Exceptions
errorif the argument can't be converted.

◆ luaL_checkuint64()

uint64_t luaL_checkuint64 ( struct lua_State *  L,
int  idx 
)

Checks whether the argument idx is a uint64 or a convertible string and returns this number.

Exceptions
errorif the argument can't be converted.

◆ luaL_ctypeid()

uint32_t luaL_ctypeid ( struct lua_State *  L,
const char *  ctypename 
)

Return CTypeID (FFI) of given СDATA type.

Parameters
LLua State
ctypenameС type name as string (e.g. "struct request" or "uint32_t")
See also
luaL_pushcdata
luaL_checkcdata
Returns
CTypeID

◆ luaL_getgctotal()

size_t luaL_getgctotal ( struct lua_State *  L)

Return size of currently allocated memory.

Parameters
LLua State

◆ luaL_iscallable()

int luaL_iscallable ( lua_State *  L,
int  idx 
)

Check whether a Lua object is a function or has metatable/metatype with a __call field.

Note: It does not check type of __call metatable/metatype field.

◆ luaL_iscdata()

int luaL_iscdata ( struct lua_State *  L,
int  idx 
)

public

Checks whether a value on the Lua stack is a cdata.

Unlike luaL_checkcdata() this function does not raise an error. It is useful to raise a domain specific error.

Lua API and module API don't expose LUA_TCDATA constant. We have no guarantee that this constant will remain the same in future LuaJIT versions. So this function should be used in modules instead of lua_type(L, idx) == LUA_TCDATA.

Parameters
LLua state.
idxAcceptable index on the Lua stack.
Return values
1If the value at the given index is a cdata.
0Otherwise.

◆ luaL_isnull()

bool luaL_isnull ( struct lua_State *  L,
int  idx 
)

Return true if the value at Lua stack is ffi's NULL (cdata<void *>: NULL).

Parameters
Lstack
idxstack index

◆ luaL_pushcdata()

void * luaL_pushcdata ( struct lua_State *  L,
uint32_t  ctypeid 
)

Push cdata of given ctypeid onto the stack.

CTypeID must be used from FFI at least once. Allocated memory returned uninitialized. Only numbers and pointers are supported.

Parameters
LLua State
ctypeidFFI's CTypeID of this cdata
See also
luaL_checkcdata
Returns
memory associated with this cdata

◆ luaL_pushint64()

void luaL_pushint64 ( struct lua_State *  L,
int64_t  val 
)

Push int64_t onto the stack.

Parameters
Lis a Lua State
valis a value to push

◆ luaL_pushnull()

void luaL_pushnull ( struct lua_State *  L)

Push ffi's NULL (cdata<void *>: NULL) onto the stack.

Can be used as replacement of nil in Lua tables.

Parameters
Lstack

◆ luaL_pushuint64()

void luaL_pushuint64 ( struct lua_State *  L,
uint64_t  val 
)

public

Push uint64_t onto the stack.

Parameters
Lis a Lua State
valis a value to push

◆ luaL_setcdatagc()

void luaL_setcdatagc ( struct lua_State *  L,
int  idx 
)

Sets finalizer function on a cdata object.

Equivalent to call ffi.gc(obj, function). Finalizer function must be on the top of the stack.

Parameters
LLua State
idxobject

◆ luaL_toint64()

int64_t luaL_toint64 ( struct lua_State *  L,
int  idx 
)

Checks whether the argument idx is a int64 or a convertible string and returns this number.

Returns
the converted number or 0 of argument can't be converted.

◆ luaL_touint64()

uint64_t luaL_touint64 ( struct lua_State *  L,
int  idx 
)

Checks whether the argument idx is a uint64 or a convertible string and returns this number.

Returns
the converted number or 0 of argument can't be converted.

◆ luaT_call()

int luaT_call ( lua_State *  L,
int  nargs,
int  nreturns 
)

Like lua_call(), but with the proper support of Tarantool errors.

See also
lua_call()

◆ luaT_checktuple()

box_tuple_t * luaT_checktuple ( struct lua_State *  L,
int  idx 
)

public

Checks whether the argument idx is a tuple and returns it.

Parameters
LLua State
idxthe stack index
Return values
non-NULLargument is tuple
Exceptions
errorif the argument is not a tuple.

◆ luaT_cpcall()

int luaT_cpcall ( lua_State *  L,
lua_CFunction  func,
void *  ud 
)

Like lua_cpcall(), but with the proper support of Tarantool errors.

See also
lua_cpcall()

◆ luaT_dostring()

int luaT_dostring ( struct lua_State *  L,
const char *  str 
)

Like luaL_dostring(), but in case of error sets fiber diag instead of putting error on stack.

Parameters
LLua state
strstring with Lua code to load and run

◆ luaT_error()

int luaT_error ( lua_State *  L)

Re-throws the last Tarantool error as a Lua object.

Set trace frame of to the caller of Lua C API.

See also
lua_error()
box_error_last()

◆ luaT_error_at()

int luaT_error_at ( lua_State *  L,
int  level 
)

Same as luaT_error but set error trace frame according to given level.

luaT_error same as this function with level equal to 1. If level is 0 then error trace is unchanged.

◆ luaT_isdecimal()

box_decimal_t * luaT_isdecimal ( struct lua_State *  L,
int  index 
)

Check whether a value on the Lua stack is a decimal.

Returns a pointer to the decimal on a successful check, NULL otherwise.

◆ luaT_istuple()

box_tuple_t * luaT_istuple ( struct lua_State *  L,
int  idx 
)

Checks whether argument idx is a tuple.

Parameters
LLua State
idxthe stack index
Return values
non-NULLargument is tuple
NULLargument is not tuple

◆ luaT_newdecimal()

box_decimal_t * luaT_newdecimal ( struct lua_State *  L)

public

Allocate a new decimal on the Lua stack and return a pointer to it.

◆ luaT_push_nil_and_error()

int luaT_push_nil_and_error ( lua_State *  L)

Return nil as the first return value and an error as the second.

The error is received using box_error_last().

Parameters
LLua stack.

◆ luaT_pusherror()

void luaT_pusherror ( struct lua_State *  L,
struct error *  e 
)

Push error to a Lua stack.

Parameters
LLua stack.
eerror.

◆ luaT_pushtuple()

void luaT_pushtuple ( struct lua_State *  L,
box_tuple_t tuple 
)

Push a tuple onto the stack.

Parameters
LLua State
tuple
See also
luaT_istuple
Exceptions
onOOM

◆ luaT_toibuf()

box_ibuf_t * luaT_toibuf ( struct lua_State *  L,
int  idx 
)

Check if a value on L stack by index idx is an ibuf object.

Both 'struct ibuf' and 'struct ibuf *' are accepted. Returns NULL, if can't convert - not an ibuf object.

◆ luaT_tuple_encode()

char * luaT_tuple_encode ( struct lua_State *  L,
int  idx,
size_t *  tuple_len_ptr 
)

Encode a table or a tuple on the Lua stack as an MsgPack array.

Parameters
LLua state.
idxAcceptable index on the Lua stack.
tuple_len_ptrWhere to store tuple data size in bytes (or NULL).

The storage for data is allocated on the box region. A caller should call box_region_truncate() to release the data.

In case of an error set a diag and return NULL.

See also
luaT_tuple_new()

◆ luaT_tuple_new()

box_tuple_t * luaT_tuple_new ( struct lua_State *  L,
int  idx,
box_tuple_format_t format 
)

Create a new tuple with specific format from a Lua table or a tuple.

The new tuple is referenced in the same way as one created by box_tuple_new(). There are two possible usage scenarios:

  1. A short living tuple may not be referenced explicitly and will be collected automatically at the next module API call that yields or returns a tuple.
  2. A long living tuple must be referenced using box_tuple_ref() and unreferenced then with box_tuple_unref().
See also
box_tuple_ref()

In case of an error set a diag and return NULL.