- Aug 01, 2019
-
-
Nikita Pettik authored
According to ANSI specification, if TRIM function accepts binary string and trim octet is not specified, then it is implicitly set to X'00'. Before this patch trim octet was set to ' ' both for string and binary string arguments. In turn, ' ' is equal to X'20' in hex representation. Hence, TRIM function cut wrong characters: TRIM(X'004420') -> X‘0044' This patch sets default trim octet to X'00' for binary string arguments. Part of #4206
-
Nikita Pettik authored
Since values of type 'varbinary' can't be cast to any other type, let's patch built-in functions which are not assumed to accept arguments of this type to raise an error in case argument turn out to be of type varbinary. Part of #4206
-
Nikita Pettik authored
We are going to introduce new column type 'VARBINARY', which allows to store values with MP_BIN msgpack format. On the other hand, now it is also possible to meet this type: all literals in form of x'...' are supposed to be inserted into SCALAR column type exactly with MP_BIN encoding. Prior to this moment type of such values (encoded as MP_BIN) was called 'blob'. Thus, let's fix all visible to user messages using 'varbinary' name of type instead of 'blob'.
-
Nikita Pettik authored
Before this patch, resulting type for CASE-WHEN statement was assumed to be the same as type of argument of first THEN clause. Obviously, it is wrong and could lead to sad consequence (e.g. creating ephemeral table with inconsistent format). To deal with this, we check all THEN arguments: if all of them have the same type, then such type will be resulting of the whole statement; if at least two types are different, we can't determine actual resulting type during compilation stage and assign SCALAR as a most general type in SQL now. Need for #4206
-
Nikita Pettik authored
Function which converts values to string representation (sqlVdbeMemStringify()) erase MEM_Int/MEM_Real/MEM_Bool flags only when it is specified by 'force' parameter. Hence, when 'force' argument is false, memory cell after conversion will contain string value, but flag indicating its type will be equal to combination of MEM_Str and one of mentioned flags. It seems to be remains of affinity routines, since in current state memory cell must have only one type. What is more, it can lead to unpredicted consequences, for instance assertion fault (sql_value_type() assumes that value has one specific type). Let's fix it removing 'force' argument from sqlVdbeMemStringify() and always clean up type flag.
-
- Jul 31, 2019
-
-
Vladislav Shpilevoy authored
Box recently added support of transactional DDL allowing to do any number of non-yielding DDL operations atomically. This is really a big relief of one of the biggest pains of SQL. Before this patch each multirow SQL DDL statement needed to prepare its own rollback procedure for a case if something would go wrong. Now with box support SQL wraps each DDL statement into a transaction, and doesn't need own escape-routes in a form of 'struct save_record' and others. Closes #4086 @TarantoolBot document Title: SQL DDL is transactional SQL DDL operations are atomic now. For example, if a CREATE TABLE request fails somewhere in the middle, it won't leave any garbage. Like a space without indexes, or unused sequences. Even if the instance is powered off during the request. Also, SQL DDL can be manually included into transactions, with certain limitations - such a transaction can't yield. For example, this is legal: START TRANSACTION; CREATE TABLE test(a INTEGER PRIMARY KEY, b INTEGER); CREATE INDEX test_a ON test(a); COMMIT; If you want to test it in the console, then wrap it into a function to do not get a rollback by yield, because the console yields after each command: function create() box.execute('START TRANSACTION;') box.execute('CREATE TABLE test(a INTEGER PRIMARY KEY, b INTEGER);') box.execute('CREATE INDEX test_a ON test(a);') box.execute('COMMIT;') end create() But the following example is illegal and you will get an error: box.execute('CREATE TABLE test(a INTEGER PRIMARY KEY, b INTEGER, c INTEGER);') box.execute('INSERT INTO test VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3);') function index() box.execute('START TRANSACTION;') box.execute('CREATE INDEX test_b ON test(b);') box.execute('CREATE INDEX test_c ON test(c);') box.execute('COMMIT;') end tarantool> index() --- - error: Can not perform index build in a multi-statement transaction ... The error is because an attempt to build an index on a non-empty space leads to immediate yield.
-
Vladislav Shpilevoy authored
When transactional DDL is introduced, 'DROP TABLE' will remove a space and its cks in one transaction. At the moment of that transaction commit the space is already removed from _space and from space cache, and can't be accessed from other triggers. This patch makes all space-related actions in on_replace. Part of #4086
-
Vladimir Davydov authored
Vinyl writes a signature of each statement that created or dropped or modified an LSM tree to vylog. This is needed to match xlog rows to vylog records on recovery. So alter_space_commit() passes txn->signature to index_commit_create(), index_commit_drop(), and index_commit_modify() methods. If a transaction has multiple DDL statements, all of them will have the same signature. Per se this is fine. The problem is that on recovery we apply statements one-by-one, not transactionally, and so we pass signatures assigned to individual statements, not to transactions. As a result, while recovering a multi-statement DDL transaction vinyl gets different signatures for them instead of those that were used when those statements were committed, which apparently breaks its assumptions and leads to a crash or even a data loss. To fix this issue, let's, rather than using txn->signature, make alter_space_commit() pass the signature of the actual statement that committed a DDL operation, which is pretty easy to compute given the number of statements in a transaction at the time when the statement was committed. Fixes commit f266559b ("ddl: allow to execute non-yielding DDL statements in transactions"). Closes #4350 Follow-up #4083
-
Roman Khabibov authored
There are two reasons to disable support of tables with __tostring metamethods as opts.headers values: * It seems this feature is not much needed: a type convertion can be easily done on a user's end with explicit tostring() call if needed. * It never did work since introduction in 2.1.1-311-g85e1d78bc ('httpc: add checking of headers in httpc:request'): __tostring presence was verified, but a function in the field was not invoked. Now http client accepts only a Lua string as a header key or a value. Closes #3679 (again).
-
Vladimir Davydov authored
A txn_stmt keeps a reference to the space it modifies. Memtx uses this space reference to revert the statement on error or voluntary rollback so the space must stay valid throughout the whole transaction. The problem is a DML statement may be followed by a DDL statement that modifies the target space in the same transaction. If we try to roll it back before running the rollback triggers installed by the DDL statement, it will access an invalid space object (e.g. missing an index), which will result in a crash. To fix this problem, let's run triggers installed by a statement right after rolling back the statement. Closes #4368
-
Vladimir Davydov authored
We must un-account index.stat.txw.rows not only when a whole transaction is rolled back, but also when we undo statements using a savepoint.
-
Alexander Turenko authored
After 2.2.0-390-ga7c855e5b ("net.box: fetch '_vcollation' sysview into the module") net.box fetches _vcollation view unconditionally, while the view was added in 2.2.0-389-g3e3ef182f and, say, tarantool-1.10 and tarantool-2.1 do not have it. This leads to a runtime error "Space '277' does not exist" on a newer client that connects to an older server. Now the view is fetched conditionally depending of a version of a server: if it is above 2.2.1, then net.box will fetch it. Note: at the time there are no release with a number above 2.2.1. When _vcollation view is available, a collation in an index part will be shown by its name (with 'collation' field), otherwise it will be shown by its ID (in 'collation_id' field). For example: Connect to tarantool 1.10: | tarantool> connection = require('net.box').connect('localhost:3301') | --- | ... | | tarantool> connection.space.s.index.sk.parts | --- | - - type: string | is_nullable: false | collation_id: 2 | fieldno: 2 | ... Connect to tarantool 2.2.1 (when it will be released): | tarantool> connection = require('net.box').connect('localhost:3301') | --- | ... | | tarantool> connection.space.s.index.sk.parts | --- | - - type: string | is_nullable: false | collation: unicode_ci | fieldno: 2 | ... Fixes #4307.
-
- 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.
-
Vladimir Davydov authored
When reverting to a savepoint inside a DDL transaction, apart from undoing changes done by the DDL statements to the system spaces, we also have to - Run rollback triggers installed after the savepoint was set, because otherwise changes done to the schema by DDL won't be undone. - Remove commit triggers installed after the savepoint, because they are not relevant anymore, apparently. To achieve that let's append DDL triggers right to txn statements. This allows us to easily discard commit triggers and run rollback triggers when a statement is rolled back. Note, txn commit/rollback triggers are not removed, because they are still used by applier and Lua box.on_commit/on_rollback functions. Closes #4364 Closes #4365
-
Vladimir Davydov authored
It's not used anywhere anymore.
-
Vladimir Davydov authored
txn_stmt_new is supposed to simply allocate an initialize a new txn_stmt struct. Adding the new statement to the txn's statement list and setting up a savepoint for rollback looks confusing. Move it to txn_begin_stmt.
-
Vladimir Davydov authored
-
- Jul 29, 2019
-
-
Kirill Yukhin authored
-
Roman Khabibov authored
Added the following checks: * opts.headers is a table. * opts.headers keys are strings. Clarified an error message re Lua type of opts.headers values. Found and fixed a memory leak that appears in http client when invalid opts.headers is passed. Closes #4281
-
Vladimir Davydov authored
Commit triggers must be run in the same order they are added, see commit 01343264 ("txn: fix execution order of commit triggers"). To achieve that we added a new trigger method, trigger_add_tail(), which adds new triggers to the trigger list tail rather than to the head, and now we use this new method for adding commit triggers. Come to think of it now, that solution was rather confusing. First, commit triggers are still added to the head of the list from Lua. Second, to revert triggers on rollback-to-savepoint it would be really more convenient to have both commit and rollback trigger lists have the same order. So this patch reverts the above-mentioned commit and instead simply uses a reverse iterator to run commit triggers.
-
Vladimir Davydov authored
To bring new rlist methods - rlist_foreach_entry_safe_reverse and rlist_cut_before. Also, remove unit/rlist test as it is now a part of the small suite.
-
- Jul 28, 2019
-
-
Konstantin Osipov authored
-
Konstantin Osipov authored
Update test output.
-
- Jul 26, 2019
-
-
Alexander V. Tikhonov authored
The uninitialized variable found that caused the fail on build, due to LTO builds with flag to check warnings as errors. Set the variable to 0 initial value. The found issue was: [100%] Built target xrow.test src/box/sql/vdbe.c: In function ‘sqlVdbeExec’: src/box/sql/vdbe.c:3691:11: error: ‘id’ may be used uninitialized in this function [-Werror=maybe-uninitialized] uint64_t id; ^ lto1: all warnings being treated as errors lto-wrapper: fatal error: /usr/bin/c++ returned 1 exit status compilation terminated. /usr/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status Closes #4378
-
Alexander V. Tikhonov authored
Increased the maximum number of open file descriptors on macOS. Travis-ci: needed the "ulimit -n <value>" call, because found that the tests fail without it even with launchctl limit tool set. Gitlab-ci: needed the "launchctl limit maxfiles <value>" call, because under gitlib-ci it is needed the password to change the limits and we call the sudo tool which separates the local set of the environment. Closes #4373
-
Kirill Shcherbatov authored
Closes #1260 @TarantoolBot document Title: introduce func indexes in memtx Now you can define a func_index using a registered persistent function. There are restrictions for function and key definition for a functional index: - the referenced function must be persistent, deterministic and must return a scalar type or an array. - you must define key parts which describe the function return value - the function must return data which types match the defined key parts - the function may return multiple keys; this would be a multikey functional index; each key entry is indexed separately; - for multikey functional indexes, the key definition should start with part 1 and cover all returned key parts - key parts can't use JSON paths. - the function used for the functional index can not access tuple fields by name, only by index. Functional index can't be primary. It is not possible to change the used function after a functional index is defined on it. The index must be dropped first. Each key returned by functional index function (even when it is a single scalar) must be returned as a table i.e. {1} and must match the key definition. To define a multikey functional index, create a function with opts = {is_multikey = true} and return a table of keys. Example: s = box.schema.space.create('withdata') s:format({{name = 'name', type = 'string'}, {name = 'address', type = 'string'}}) pk = s:create_index('name', {parts = {1, 'string'}}) lua_code = [[function(tuple) local address = string.split(tuple[2]) local ret = {} for _, v in pairs(address) do table.insert(ret, {utf8.upper(v)}) end return ret end]] box.schema.func.create('address', {body = lua_code, is_deterministic = true, is_sandboxed = true, opts = {is_multikey = true}}) idx = s:create_index('addr', {unique = false, func = 'address', parts = {{1, 'string', collation = 'unicode_ci'}}}) s:insert({"James", "SIS Building Lambeth London UK"}) s:insert({"Sherlock", "221B Baker St Marylebone London NW1 6XE UK"}) idx:select('Uk') --- - - ['James', 'SIS Building Lambeth London UK'] - ['Sherlock', '221B Baker St Marylebone London NW1 6XE UK'] ...
-
Kirill Shcherbatov authored
Introduced a new object tuple_chunk: a memory allocation is associated with given tuple. tuple_format's vtab is extended with few new methods to manage tuple_chunks lifecycle. Implemented corresponding methid for memtx engine: a memory chunks are allocated with memtx's smalloc allocator. Needed for #1260
-
Kirill Shcherbatov authored
Needed for #1260 @TarantoolBot document Title: A new option is_multikey for function definition A new option is_multikey allows to specify wether new function returns multiple values packed in a table object. This is a native way to define multikey func_index.
-
Alexander Turenko authored
The problem was that a tagged revision is not deployed, so after a release we did an empty commit to trigger deployment. Now it is worked around by adding extra deployment rules that deploys tagged revisions. The workaround was suggested by Hiro Asari in [1]. [1]: https://github.com/travis-ci/travis-ci/issues/7780#issuecomment-302389370 Fixes #3745.
-
Alexander V. Tikhonov authored
Due to the new 7.65.3 curl version released on 2019-07-19, removed temporary workaround that downgraded the curl to 7.65.0. This reverts commit 2e880af0. Follows up #4288
-
- Jul 25, 2019
-
-
Vladimir Davydov authored
Update the signature of space_build_index wrapper instead.
-
Vladimir Davydov authored
If any sub-set of fields indexed by a unique index is indexed by another unique index, we can skip the uniqueness check for it. We use this to optimize out unnecessary uniqueness checks in vinyl, where they may be pretty costly, especially if the bloom filter doesn't reflect them. Currently, whether to check if an index is unique or not is determined in vinyl space constructor, which sets vy_lsm::check_is_unique flag for the space indexes. This looks ugly, because this means that no other engine can make use of this optimization without duplicating the code setting up the flags. True, no other engine needs it now, but still it doesn't feel right. Besides, the check_is_unique flag isn't actually an index property - it's rather a property of a space so storing it in vy_lsm looks wrong. Because of that we have to update the flag when an index is reassigned to another space by MoveIndex DDL operation, see vinyl_space_swap_index(). So let's store the flags indicating whether a uniqueness check is required for a particular index in a bitmap in the space struct and set it up in the generic space constructor, space_create().
-
Vladimir Davydov authored
When an index definition is modified by DDL in such a way that doesn't require index rebuild (e.g. a key part type is changed from unsigned to integer), we move the index from the old space container to the new one, see ModifyIndex. In case of Vinyl we also need to update key definitions and options stored in vy_lsm. We do that in swap_index space method, but this isn't entirely correct, as this method is also called when an index is moved without any modifications, see MoveIndex. Let's do this from update_def index method instead, which seems to be more suitable. The only reason this code lives in swap_index space method now is that we didn't have update_def index method when this functionality was introduced in the first place.
-
Vladimir Davydov authored
We may write to txn->sub_stmt_begin[TXN_SUB_STMT_MAX] so the array size must be TXN_SUB_STMT_MAX+1 (see txn_begin_stmt). This didn't lead to any problems, because we would only overwrite txn::signature, which wouldn't break anything. However, should we change the txn struct, we could get an unexpected error or even a crash.
-
Cyrill Gorcunov authored
-
- Jul 24, 2019
-
-
Kirill Shcherbatov authored
Function memtx_tree_index_build_array_deduplicate worked incorrectly: when build_array is empty it changed it size to 1. Follow up #1257 Needed for #1260
-
Konstantin Osipov authored
It is convential to prefix boolean predicates with _is_.
-
Kirill Shcherbatov authored
Renamed memtx_tree_delete_identical to memtx_tree_delete_value because it is a more descriptive name. Changed its signature to return a deleted item, because this item may require an own destruction. This refactoring is required in scope of functional indexes. Needed for #1260
-
Konstantin Osipov authored
-