- Apr 20, 2020
-
-
Vladislav Shpilevoy authored
C struct error objects can be created directly only in C. C-side increments their reference counter when pushes to the Lua stack. It is not going to be so convenient soon. error_unpack() function will be used in netbox to decode error object via Lua FFI. Such error object will have 0 refs and no Lua GC callback established. Because it won't be pushed on Lua stack natually, from Lua C. To make such errors alive their reference counter will be incremented and error_unref() will be set as GC callback. Follow up for #4398
-
Leonid Vasiliev authored
Co-authored-by:
Vladislav <Shpilevoy<v.shpilevoy@tarantool.org> Part of #4398 @TarantoolBot document Title: Custom error types for Lua errors Errors can be created in 2 ways: `box.error.new()` and `box.error()`. Both used to take either `code, reason, <reason string args>` or `{code = code, reason = reason, ...}` arguments. Now in the first option instead of code a user can specify a string as its own error type. In the second option a user can specify both code and type. For example: ```Lua box.error('MyErrorType', 'Message') box.error({type = 'MyErrorType', code = 1024, reason = 'Message'}) ``` Or no-throw version: ```Lua box.error.new('MyErrorType', 'Message') box.error.new({type = 'MyErrorType', code = 1024, reason = 'Message'}) ``` When a custom type is specified, it is shown in `err.type` attribute. When it is not specified, `err.type` shows one of built-in errors such as 'ClientError', 'OurOfMemory', etc. Name length limit on the custom type is 63 bytes. All what is longer is truncated. Original error type can be checked using `err.base_type` member, although normally it should not be used. For user-defined types base type is 'CustomError'. For example: ``` tarantool> e = box.error.new({type = 'MyErrorType', code = 1024, reason = 'Message'}) --- ... tarantool> e:unpack() --- - code: 1024 trace: - file: '[string "e = box.error.new({type = ''MyErrorType'', code..."]' line: 1 type: MyErrorType custom_type: MyErrorType message: Message base_type: CustomError ... ```
-
- Apr 14, 2020
-
-
Vladislav Shpilevoy authored
API is different from box.session.push() - sync argument was removed. It will disappear from Lua API as well, because it just is not needed here. Session is omitted as well. Indeed, a user can't push to a foreign session, and the current session can be obtained inside box_session_push(). And anyway session is not in the public C API. Internally dump into iproto is done using obuf_dup(), just like tuple_to_obuf() does. obuf_alloc() would be a bad call here, because it wouldn't be able to split the pushed data into several obuf chunks, and would cause obuf fragmentation. Dump into plain text behaves just like a Lua push - it produces a YAML formatted text or Lua text depending on output format. But to turn MessagePack into YAML or Lua text an intermediate Lua representation is used, because there are no a MessagePack -> YAML and MessagePack -> Lua text translators yet. Closes #4734 @TarantoolBot document Title: box_session_push() C API There is a new function in the public C API: ```C int box_session_push(const char *data, const char *data_end); ``` It takes raw MessagePack, and behaves just like Lua `box.session.push()`.
-
- Apr 13, 2020
-
-
Chris Sosnin authored
box.session.storage is a general-purpose table, which can be used by user. Therefore, we shouldn't store any internal details in it. Needed for #4686
-
Serge Petrenko authored
A special format for encoding UUIDs to MsgPack is introduced. It is supported by both lua and C encoders/decoders, and it is now possible to insert UUIDs into spaces, but only into unindexed fields without format for now. Prerequisite #4268 @TarantoolBot document Title: Internals: msgpack format for UUID UUID values share the MessagePack type with decimals: both use MP_EXT. A new subtype is introduced for UUIDs, MP_UUID = `0x02` UUID is encoded as follows: ``` +--------+---------+-----------+ | MP_EXT | MP_UUID | UuidValue | +--------+---------+-----------+ ``` Since UUID is 16 bytes in size, the header, MP_EXT, is always the same: `0xd8`. MP_UUID = `0x02` follows. The header is followed by the 16 bytes of the UuidValue. UuidValue consists of 11 fields, which are encoded as big endian unsigned integers in the following order: `time_low` (4 bytes), `time_mid` (2 bytes), `time_hi_and_version` (2 bytes), `clock_seq_hi_and_reserved` (1 byte), `clock_seq_low` (1 byte), `node[0], ..., node[5]` (1 byte each). The total size of such a representation is 18 bytes, whereas storing uuids as strings requires from 34 (when '-'s are ommitted) to 38 bytes per UUID, giving a 2x space usage improvement.
-
- Apr 07, 2020
-
-
Nikita Pettik authored
In terms of implementation, now struct error objects can be organized into double-linked lists. To achieve this pointers to the next and previous elements (cause and effect correspondingly) have been added to struct error. It is worth mentioning that already existing rlist and stailq list implementations are not suitable: rlist is cycled list, as a result it is impossible to start iteration over the list from random list entry and finish it at the logical end of the list; stailq is single-linked list leaving no possibility to remove elements from the middle of the list. As a part of C interface, box_error_add() has been introduced. In contrast to box_error_set() it does not replace last raised error, but instead it adds error to the list of diagnostic errors having already been set. If error is to be deleted (its reference counter hits 0 value) it is unlinked from the list it belongs to and destroyed. Meanwhile, error destruction leads to decrement of reference counter of its previous error and so on. To organize errors into lists in Lua, table representing error object in Lua now has .prev field (corresponding to 'previous' error) and method :set_prev(e). The latter accepts error object (i.e. created via box.error.new() or box.error.last()) and nil value. Both field .prev and :set_prev() method are implemented as ffi functions. Also note that cycles are not allowed while organizing errors into lists: e1 -> e2 -> e3; e3:set_prev(e1) -- would lead to error. Part of #1148
-
- Mar 18, 2020
-
-
Oleg Babin authored
This patch introduces "current" function for sequences. It returns the last retrieved value of specified sequence or throws an error if no value has been generated yet. This patch partially reverts 3ff1f1e3 (box: remove sequence_get) here similar function "get" was removed to avoid possible misleading with "currval" function of PosgreSQL that returns the last obtained value of the sequence in the scope of current session. In contrast "current" returns the last globally retrieved value of the sequence. Closes #4752 Reviewed-by:
Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Reviewed-by:
Nikita Pettik <korablev@tarantool.org> @TarantoolBot document Title: sequence:current() This patch introduces "current" function for sequences. It returns the last retrieved value of specified sequence or throws an error if no value has been generated yet ("next" has not been called yet or right after "reset" is called). Lua: Example: ```lua sq = box.schema.sequence.create('test') --- ... sq:current() --- - error: Sequence 'test' is not started ... sq:next() --- - 1 ... sq:current() --- - 1 ... sq:set(42) --- ... sq:current() --- - 42 ... sq:reset() --- ... sq:current() -- error --- - error: Sequence 'test' is not started ... ``` C API: ```C int box_sequence_current(uint32_t seq_id, int64_t *result); ``` Where: * seq_id - sequence identifier; * result - pointer to a variable where the current sequence value will be stored on success. Returns 0 on success and -1 otherwise. In case of an error user could get it via `box_error_last()`.
-
- Mar 05, 2020
-
-
Chris Sosnin authored
All lua types feature check, push and is functions. We expose lua_checktuple for full consistency. Closes #2553
-
- Aug 22, 2019
-
-
Serge Petrenko authored
This patch adds the methods necessary to encode and decode decimals to MsgPack. MsgPack EXT type (MP_EXT) together with a new extension type MP_DECIMAL is used as a record header. The decimal MsgPack representation looks like this: +--------+-------------------+------------+===============+ | MP_EXT | length (optional) | MP_DECIMAL | PackedDecimal | +--------+-------------------+------------+===============+ The whole record may be encoded and decoded with mp_encode_decimal() and mp_decode_decimal(). This is equivalent to performing mp_encode_extl()/mp_decode_extl() on the first 3 fields and decimal_pack/unpack() on the PackedDecimal field. It is also possible to decode and encode decimals to msgpack from lua, which means you can insert decimals into spaces, but only into unindexed fields for now. Follow up #692 Part of #4333
-
- Jun 09, 2019
-
-
Vladislav Shpilevoy authored
These function are going to yield in scope of #4250, because swim:new() will start a fiber, while swim:delete() cancels and gives it a control. Needed for #4250
-
- May 21, 2019
-
-
Vladislav Shpilevoy authored
Encryption with an arbitrary algorithm and any mode with a configurable private key. Closes #3234
-
Vladislav Shpilevoy authored
Users of Lua SWIM module likely will use Lua objects as a payload. Lua objects are serialized into MessagePack automatically, and deserialized back on other instances. But deserialization of 1.2Kb payload on each member:payload() invocation is quite heavy operation. This commit caches decoded payloads to return them again until change. A microbenchmark showed, that cached payload is returned ~100 times faster, than it is decoded each time. Even though a tested payload was quite small and simple: s:set_payload({a = 100, b = 200}) Even this payload is returned 100 times faster, and does not affect GC. Part of #3234
-
Vladislav Shpilevoy authored
SWIM as a library can be useful not only for server internals, but for users as well. This commit exposes Lua bindings to SWIM C API. Here only basic bindings are introduced to create, delete, quit, check a SWIM instance. With sanity tests. Part of #3234
-
Vladislav Shpilevoy authored
Static allocator gives memory blocks from cyclic BSS memory block of 3 pages 4096 bytes each. It is much faster than malloc, when a temporary buffer is needed. Moreover, it does not complicate GC job. Despite being faster than malloc, it is still slower, than ffi.new() of size <= 128 known in advance (according to microbenchmarks). ffi.new(size<=128) works either much faster or with the same speed as static_alloc, because internally FFI allocator library caches small blocks and can return them without malloc(). A simple micro benchmark showed, that ffi.new() vs buffer.static_alloc() is ~100 times slower on allocations of > 128 size, on <= 128 when size is not inlined. To better understand what is meant as 'inlined': this ffi.new('char[?]', < <=128 >) works ~100 times faster than this: local size = <= 128 ffi.new('char[?]', size) ffi.new() with inlined size <= 128 works faster than light, and even static allocator can't beat it.
-
- May 15, 2019
-
-
Vladislav Shpilevoy authored
crypto.lua is a public module using OpenSSL directly. But now lib/crypto encapsulates OpenSSL with additional checks and similar but more conforming API. It allows to replace OpenSSL cipher in crypto.lua with lib/crypto methods.
-
Vladislav Shpilevoy authored
Tarantool has a strict rule for naming methods of libraries - use the library name as a prefix. For crypto lib methods it should be 'crypto_', not 'tnt_'.
-
- Apr 30, 2019
-
-
Alexander Turenko authored
Needed for #3276.
-
- Mar 26, 2019
-
-
Roman Khabibov authored
It's OK to use json format with the boot logger. As for syslog, let's add a check to Lua's log_format() so that it fails gracefully rather than raising an assertion. Closes #3946
-
- Feb 21, 2019
-
-
Michał Durak authored
Add optional 'chars' parameter to string.strip, string.lstrip and string.rstrip for specifying the unwanted characters. Behavior modeled after the equivalent Python built-ins. Closes: #2977 @TarantoolBot document Title: string.strip(inp, chars) Update the documentation for string.strip, string.lstrip and string.rstrip to reflect the addition of the optional param.
-
- Jan 30, 2019
-
-
Serge Petrenko authored
Make os.exit() call tarantool_exit(), just like the signal handler does. Now on_shutdown triggers are not run only when a fatal signal is received. Closes #1607 @TarantoolBot document Title: Document box.ctl.on_shutdown triggers on_shutdown triggers may be set similar to space:on_replace triggers: ``` box.ctl.on_shutdown(new_trigger, old_trigger) ``` The triggers will be run when tarantool exits due to receiving one of the signals: `SIGTERM`, `SIGINT`, `SIGHUP` or when user executes `os.exit()`. Note that the triggers will not be run if tarantool receives a fatal signal: `SIGSEGV`, `SIGABORT` or any signal causing immediate program termination.
-
- Sep 22, 2018
-
-
Vladimir Davydov authored
Closes #3311
-
- Aug 21, 2018
-
-
Konstantin Belyavskiy authored
Fixing build under FreeBSD: Undefined symbol "iconv_open" Add compile time build check with FindICONV.cmake and a wrapper to import relevant symbol names with include file. Closes #3441
-
- Aug 15, 2018
-
-
Eugine Blikh authored
`lua_tostring`/`lua_tolstring` ignores metatable/boolean/nil and return NULL, but sometimes it's needed to have similar behaviour, like lua functions tostring. Lua 5.1 and LuaJIT ignores it by default, Lua 5.2 introduced auxilary function luaL_to(l)string with supporting of __tostring. This function is backport of Lua 5.1 "lauxlib.h"s luaL_tostring in the luaT namespace.
-
- Aug 14, 2018
-
-
Kirill Shcherbatov authored
Resolves #3284.
-
- Jul 13, 2018
-
-
Ivan Kosenko authored
-
- Jun 29, 2018
-
-
AKhatskevich authored
`sql_current_time` is exported only in debug mode and used to check builtin datetime sql functions behavior in specific time moments. Extra changes: * table-14.1 test is deleted, as it does not test anything. It was testing ddl inside of a transaction. This case is checked by 14.2 by now. Closes #2646
-
- Apr 04, 2018
-
-
Alexander Turenko authored
Filed gh-3311 to remove this export soon. Fixes #3310.
-
- Jan 18, 2018
-
-
Vladimir Davydov authored
So that it can be used not only for serializing a list of tuples, but also for serializing a Lua stack that stores output of CALL/EVAL. Needed for #946
-
- Dec 21, 2017
-
-
Ilya authored
* Add struct log * Add possibility to add logger configuration to global scope * Refactor functions in say to use them with specified config, not only global variable This patch was inspired by need of additional logger in audit log Relates #2912
-
- Oct 12, 2017
-
-
Ilya authored
* Add log_format option to box.cfg{} * Add json format in logging * Add table converting to json in lua logging Closes #2795
-
- Oct 09, 2017
-
-
Tony Freeman authored
-
- Sep 06, 2017
-
-
Bulat Niatshin authored
- Remove sqlite3BitvecBuiltinTest from export.
-
- Sep 05, 2017
-
-
Vladislav Shpilevoy authored
Savepoint allows to partialy rollback a transaction. After savepoint creation a transaction owner can rollback all changes applied after the savepoint without rolling back the entire transaction. Multiple savepoints can be created in each transaction. Rollback to a savepoint cancels changes made after the savepoint, and deletes all newer savepoints. It is impossible to rollback to a savepoint from a substatements level, different from the savepoint's one. For example, a transaction can not rollback to a savepoint, created outside of a trigger, from a trigger body. Closes #2025
-
- Aug 22, 2017
-
-
Vladimir Davydov authored
fiber_time() reports real time, which shouldn't be used for calculating timeouts as it is affected by system time changes. Add fiber_clock() based on ev_monotonic_now(), export it to Lua, and use it instead. Needed for #2527
-
- Aug 01, 2017
-
-
Vladislav Shpilevoy authored
-
- Jul 14, 2017
-
-
Roman Tsisyk authored
A part of #1451
-
- Jul 11, 2017
-
-
Vladislav Shpilevoy authored
Add `sqlite3BitvecBuiltinTest` to exported symbols to expose it to ffi. Bug #2590 submitted to remove it from exports.
-
- May 25, 2017
-
-
Georgy Kirichenko authored
Fiber attributes are a way to specify parameters that is different from the default. When a fiber is created using fiber_new_ex(), an attribute object can be specified to configure custom values for some options. Attributes are specified only at fiber creation time; they cannot be altered while the fiber is being used. Currently only stack_size attribute is supported. Fibers with non-default stack size won't be recycled via fiber pool. API overview: * fiber_new_ex() creates a fiber with custom attributes. * fiber_attr_new()/fiber_attr_delete() creates/destroys attributes. * fiber_attr_setstacksize()/fiber_attr_getstacksize() sets/gets the fiber stack size. * fiber_self() returns current running fiber. All new functions are available from public C API for modules. See #2438
-
- May 16, 2017
-
-
Kirill Yukhin authored
`sql_schema_put` is a static function and should not be exported. This routine was exported on early stages of SQL development when DDL was non-functional at all and came to the top due to patches re-mix.
-
- May 12, 2017
-
-
Kirill Yukhin authored
SQL tests works just fine on current stack sizes, so revert commit `sql: Run SQL compiler on large stack` and run SQL compiler (entry is `sqlite3LockAndPrepare(...)`) on top of caller's stack.
-