- 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()`.
-
Leonid authored
The policy for check of luarocks flags has been changed (moved from tarantoolctl to luarocks). Chdir has been moved to luarocks. Closes #4629 @TarantoolBot document Title: Update tarantoolctl rocks tarantoolctl rocks commands has been added: build config download init lint new_version purge which write_rockspec https://github.com/luarocks/luarocks/wiki/luarocks
-
- 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
-
Chris Sosnin authored
Currently if a user wants to change session setting with SQL, one has to execute UPDATE query like: [[UPDATE "_session_settings" SET "value" = true WHERE "name" = 'name']] However, direct access to system spaces isn't considered to be a good practice. To avoid that and a bit simplify user's life, we introduce SQL shortcut command SET SESSION. Closes #4711 @TarantoolBot document Title: API for accessing _session_settings space. There are two ways of updating values of session settings: via Lua and SQL. Lua: box.session.settings is a table, which is always accessible to user. The syntax is the following: `box.session.settings.<setting_name> = <new_value>`. Example of usage: ``` tarantool> box.session.settings.sql_default_engine --- - memtx ... tarantool> box.session.settings.sql_default_engine = 'vinyl' --- ... ``` The table itself represents the (unordered) result of select from _session_settings space. SQL: Instead of typing long UPDATE query one can use the SET SESSION command: `box.execute([[SET SESSION "<setting_name>" = <new_value>]])`. Note, that this query is case sensitive so the name must be quoted. Also, SET SESSION doesn't provide any implicit casts, so <new_value> must be of the type corresponding to the setting being updated. Example: ``` tarantool> box.execute([[set session "sql_default_engine" = 'memtx']]) --- - row_count: 1 ... tarantool> box.execute([[set session "sql_defer_foreign_keys" = true]]) --- - row_count: 1 ... ```
-
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
-
- Apr 02, 2020
-
-
Leonid authored
@Changelog Fixed the tarantoolctl rocks remove flag --force Forwarding of the --force flag to tarantoolctl rocks module was added. (Command: tarantoolctl rocks remove --force) Fixes: #3632
-
Leonid authored
@Changelog Fixed the tarantoolctl rocks search flag --all Forwarding of the --all flag to tarantoolctl rocks module was added. (Command: tarantoolctl rocks search --all) Fixes: #4529
-
- 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
-
- Dec 28, 2019
-
-
Nikita Pettik authored
When it comes for huge queries, it may turn out to be useful to see exact position of occurred error. Hence, let's now display line and position within line near which syntax error takes place. Note that it can be done only during parsing process (since AST can be analysed only after its construction is completed), so most of semantic errors still don't contain position. A few errors have been reworked to match new formatting patterns. First iteration of this patch is implemented by @romanhabibov Closes #2611
-
- Dec 27, 2019
-
-
Mergen Imeev authored
This patch introduces type DOUBLE in SQL. Closes #3812 Needed for #4233 @TarantoolBot document Title: Tarantool DOUBLE field type and DOUBLE type in SQL The DOUBLE field type was added to Tarantool mainly for adding the DOUBLE type to SQL. Values of this type are stored as MP_DOUBLE in msgpack. The size of the encoded value is always 9 bytes. In Lua, only non-integer numbers and CDATA of type DOUBLE can be inserted in this field. You cannot insert integers of type Lua NUMBER or CDATA of type int64 or uint64 in this field. The same rules apply to key in get(), select(), update() and upsert() methods. It was done this way to avoid unwanted implicit casts that could affect performance. It is important to note that you can use the ffi.cast() function to cast numbers to CDATA of type DOUBLE. An example of this can be seen below. Another very important point is that CDATA of type DOUBLE in lua can be used in arithmetic, but arithmetic for them does not work correctly. This comes from LuaJIT and most likely will not be fixed. Example of usage in Lua: s = box.schema.space.create('s', {format = {{'d', 'double'}}}) _ = s:create_index('ii') s:insert({1.1}) ffi = require('ffi') s:insert({ffi.cast('double', 1)}) s:insert({ffi.cast('double', tonumber('123'))}) s:select(1.1) s:select({ffi.cast('double', 1)}) In SQL, DOUBLE type behavior is different due to implicit casting. In a column of type DOUBLE, the number of any supported type can be inserted. However, it is possible that the number that will be inserted will be different from that which is inserted due to the rules for casting to DOUBLE. In addition, after this patch, all floating point literals will be recognized as DOUBLE. Prior to that, they were considered as NUMBER. Example of usage in SQL: box.execute('CREATE TABLE t (d DOUBLE PRIMARY KEY);') box.execute('INSERT INTO t VALUES (10), (-2.0), (3.3);') box.execute('SELECT * FROM t;') box.execute('SELECT d / 100 FROM t;') box.execute('SELECT * from t WHERE d < 15;') box.execute('SELECT * from t WHERE d = 3.3;')
-
- Oct 16, 2019
-
-
Kirill Shcherbatov authored
Closes #4244 @TarantoolBot document Title: an ability to disable CK constraints Now it is possible to disable and enable ck constraints. All ck constraints are enabled by default when Tarantool is configured. Ck constraints checks are not performed during standard recovery, but performed during force_recovery - all conflicting tuples are skipped in case of ck_constraint conflict. To change CK constraint "is_enabled" state, call -- in LUA ck_obj:enable(new_state in {true, false}) -- in SQL ALTER TABLE {TABLE_NAME} {EN, DIS}ABLE CHECK CONSTRAINT {CK_NAME}; Example: box.space.T6.ck_constraint.ck_unnamed_T6_1:enable(false) box.space.T6.ck_constraint.ck_unnamed_T6_1 - space_id: 512 is_enabled: false name: ck_unnamed_T6_1 expr: a < 10 box.space.T6:insert({11}) -- passed box.execute("ALTER TABLE t6 ENABLE CHECK CONSTRAINT \"ck_unnamed_T6_1\"") box.space.T6:insert({12}) - error: 'Check constraint failed ''ck_unnamed_T6_1'': a < 10'
-
- Sep 16, 2019
-
-
Nikita Pettik authored
ENGINE became reserved keyword in 1013a744. There's no any actual reason why ENGINE should be reserved keyword. What is more, we are going to use this word as a name of some fields for tables forming informational schema. Hence, until it is too late (it is not documented yet), let's remove ENGINE from the list of reserved keywords and allow identifiers be that word.
-
- Aug 22, 2019
-
-
Max Melentiev authored
`tarantoolctl start` patches box.cfg two times: 1) before the init script to set default values and enforce some others, 2) after the init script to prevent changing a pid_file in runtime. The second patching fails if an init file does not call box.cfg{} before it's finished. This can take a place in apps with managed instances which receive configuration from external server. This patch moves the second patching into the box.cfg wrapper created during the first patching. So the second patching is performed only after box.cfg{} was invoked, so it does not fail anymore. However there is relatively minor flaw for applications that invoke box.cfg{} after init script is finished: `tarantoolctl start` goes to background only when box.cfg{} is called. Though this is not the case for daemon management systems like systemd, as they handle backgrounding on their side Fixes #4435 @TarantoolBot document Title: tarantoolctl allows to start instances without a box.cfg{} tarantoolctl now works for instances without box.cfg{} or with delayed box.cfg{} call. This can be managed instances which receive configuration from external server. For such instances `tarantoolctl start` goes to background when box.cfg{} is called, so it will wait until options for box.cfg are received. However this is not the case for daemon management systems like systemd, as they handle backgrounding on their side.
-
Nikita Pettik authored
Closes #4422 @TarantoolBot document Title: Introduce <WITH ENGINE> clause for CREATE TABLE statement To allow user to specify engine as per table option, CREATE TABLE statement has been extended with optional <WITH ENGINE = engine_name> clause. This clause comes at the end of CREATE TABLE statement. For instance: CREATE TABLE t_vinyl (id INT PRIMARY KEY) WITH ENGINE = 'vinyl'; Name of engine is considered to be string literal ergo should be enclosed in single quotation marks and be lower-cased. Note that engine specified in WITH ENGINE clause overwrites default engine, which is set via 'pragma sql_default_engine'.
-
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
-
- Aug 16, 2019
-
-
Roman Khabibov authored
Originally, mask in struct Keyword served to reduce set of reserved keywords for build-dependent features. For instance, it was allowed to disable triggers as a compilation option, and in this case TRIGGER wouldn't be reserved word. Nowadays, our build always comprises all features, so there's no need in this option anymore. Hence, we can remove mask alongside with related to it macros. Closes #4155
-
- Aug 01, 2019
-
-
Nikita Pettik authored
Current patch introduces new type available in SQL: - VARBINARY now is reserved keyword; - Allow to specify VARBINARY column and CAST type; - All literals which start from 'x' are assumed to be of this type; - There's no available implicit or explicit conversions between VARBINARY and other types; - Under the hood all values of VARBINARY type are stored as MP_BIN msgpack format type. Closes #4206
-
- Jul 30, 2019
-
-
Nikita Pettik authored
Before this patch it was allowed to specify REAL/FLOAT/DOUBLE types which matched with NUMBER NoSQL type in space format. However, NUMBER is different from standard floating point types, since it is able to hold integers in range [-2^63; 2^64-1] alongside with double precision floating point values. Hence, to not confuse users it has been decided to remove support of REAL/FLOAT/DOUBLE types from SQL grammar and use instead original NUMBER type naming.
-
Nikita Pettik authored
TEXT type is called "string" in the original Tarantool NoSQL, so it would be rational to allow using the same type name in SQL.
-
- Jul 24, 2019
-
-
Nikita Pettik authored
Since all preparations concerning internal handling of unsigned values have been done, now nothing prevents us from using UNSIGNED type in SQL. This patch allows to specify UNSIGNED as a column type and adds CAST rules, which are the same as for casual INTEGER, but with additional check - result must be positive. Otherwise, error is raised. Closes #4015
-
- Jun 18, 2019
-
-
Alexander Turenko authored
Built-in modules are bundled into tarantool in the following way. A lua file from src/lua or src/box/lua is stored as a string literal in a C file, then built and linked into tarantool. During startup tarantool calls luaL_loadbuffer() on this string. When a Lua source is converted to a C literal, proper escaping is performed. However there is one case, which was not covered: trigraphs. The patch adds escaping of question mark symbols to avoid matching ??X sequences as trigraphs by C preprocessor. The most simple way to check that it works is to apply the following patch: | diff --git a/src/lua/string.lua b/src/lua/string.lua | index 6e12c59ae..2da2dbf4d 100644 | --- a/src/lua/string.lua | +++ b/src/lua/string.lua | @@ -425,3 +425,6 @@ string.fromhex = string_fromhex | string.strip = string_strip | string.lstrip = string_lstrip | string.rstrip = string_rstrip | +string.foo = function() | + return '??(' | +end And call the function like so: | ./src/tarantool -e 'print(string.foo()) os.exit()' If it printfs `??(`, then everything is okay. If it prints `[`, then `??(` was preprocessed as the trigraph. We hit this problem when tried to bundle luarocks-3: it contains "^(.-)(%??)$" regexp, where `??)` was interpreted as `]`. Debug build or a build with -DENABLE_WERROR reports an error in the case, but usual RelWithDebInfo build passes (with -Wtrigraphs warnings) and can show this unexpected behaviour. Fixes #4291.
-
- Jun 16, 2019
-
-
Daniil Kotelnikov authored
* Added a new command `test` that is new feature of luarocks 3.x. * Added a new command `make_manifest` that is command from luarocks-admin. * Added a new command `help` for getting help of internal luarocks commands.
-
Daniil Kotelnikov authored
Also refined arguments descriptions of existing tarantoolctl rocks commands.
-
Daniil Kotelnikov authored
Made tarantoolctl compatible with luarocks-3.x. Fixes #4052.
-
- Jun 13, 2019
-
-
Stanislav Zudin authored
Removes the following unused macros: SQL_OMIT_AUTOINCREMENT SQL_OMIT_CONFLICT_CLAUSE SQL_OMIT_PRAGMA SQL_PRINTF_PRECISION_LIMIT SQL_OMIT_COMPOUND_SELECT SQL_POWERSAFE_OVERWRITE SQL_OMIT_PROGRESS_CALLBACK SQL_OMIT_AUTORESET SQL_OMIT_DECLTYPE SQL_ENABLE_COLUMN_METADATA SQL_TRACE_SIZE_LIMIT SQL_OMIT_LIKE_OPTIMIZATION SQL_OMIT_OR_OPTIMIZATION SQL_OMIT_BETWEEN_OPTIMIZATION SQL_EXPLAIN_ESTIMATED_ROWS SQL_ENABLE_COLUMN_USED_MASK SQL_DISABLE_DIRSYNC SQL_DEBUG_SORTER_THREADS SQL_DEFAULT_WORKER_THREADS SQL_LIMIT_WORKER_THREADS SQL_MAX_WORKER_THREADS SQL_ENABLE_MEMORY_MANAGEMENT SQL_ENABLE_UNKNOWN_SQL_FUNCTION SQL_SUBSTR_COMPATIBILITY SQL_ENABLE_STMT_SCANSTATUS Removed the remains of multithreading in the VDBE sorting tools. Updates tests. Closes #3978
-
- 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 17, 2019
-
-
Mergen Imeev authored
This patch stops the parser if any error occurs. Prior to this patch, it was possible to replace the error with another one, since the parser may continue to work, even if an error occurred. For example: box.execute("insert into not_exist values(1) a") The first error is "Space 'NOT_EXIST' does not exist", but "Syntax error near 'a'" is displayed. After this patch, the first error will be displayed. Closes #3964 Closes #4195
-
- 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.
-
- Apr 25, 2019
-
-
Nikita Pettik authored
This patch introduces basic facilities to operate on boolean type: boolean literals "true" and "false" where true > false; alias to null - unknown; column type "BOOLEAN" and shortcut "BOOL"; opportunity to insert and select boolean values from table; OR and AND predicates accept boolean arguments; CAST operation involving boolean type; comparison between boolean values (including VDBE sorter routines). Part of #3648
-
- Apr 23, 2019
-
-
Roman Khabibov authored
According to the ANSI standard, ltrim, rtrim and trim should be merged into one unified TRIM() function. The specialization of trimming (left, right or both and trimming characters) determined in arguments of this function. Closes #3879 @TarantoolBot document Title: TRIM() function Modify signature of SQL function TRIM(). This function removes characters included in <trim character> (binary) string from <trim source> (binary) string until encounter a character that doesn't belong to <trim character>. Removal occurs on the side, specified by <trim specification>. Now, syntax is following: TRIM([ [ <trim specification> ] [ <trim character> ] FROM ] <trim source>). <trim specification> can be one of the following keywords: LEADING, TRAILING and BOTH. <trim character> is the set of trimming characters. <trim source> is the string, that will be trimmed. If FROM is specified, then: 1) Either <trim specification> or <trim character> or both shall be specified. 2) If <trim specification> is not specified, then BOTH is implicit. 3) If <trim character> is not specified, then ' ' is implicit.
-
- Apr 17, 2019
-
-
Konstantin Osipov authored
There can be a lot of small files with vinyl.
-
- Apr 16, 2019
-
-
Roman Khabibov authored
Added a check whether box.cfg() is called within an instance file. If box.cfg() is missed, point a user the reason of a fail explicitly. Before this commit the error was look so: /usr/bin/tarantoolctl:541: attempt to index a nil value Closes #3953
-