- Dec 30, 2019
-
-
Nikita Pettik authored
Let's follow unified naming rules for SQL high level API which manipulates on statements objects. To be more precise, let's use 'sql_stmt_' prefix for interface functions operating on statement handles.
-
Nikita Pettik authored
sql_prepare() is going not only to compile statement, but also to save it to the prepared statement cache. So we'd better rename sqlPrepare() which is static wrapper around sql_prepare() and make it non-static. Where it is possible let's use sql_stmt_compile() instead of sql_prepare(). Needed for #2592
-
Nikita Pettik authored
We are going to split sql_prepare_and_execute() into several explicit and logically separated steps: 1. sql_prepare() -- compile VDBE byte-code 2. sql_bind() -- bind variables (if there are any) 3. sql_execute() -- query (byte-code) execution in virtual machine For instance, for dry-run we are interested only in query preparation. Contrary, if we had prepared statement cache, we could skip query preparation and handle only bind and execute steps. To avoid inclusion of sql/sqlInt.h header (which gathers almost all SQL specific functions and constants) let's move sql_prepare() to box/execute.h header (which already holds sql_prepare_and_execute()). Needed for #3292
-
Nikita Pettik authored
- Removed saveSqlFlag as argument from sqlPrepare(). It was used to indicate that its caller is sql_prepare_v2() not sql_prepare(). Since in previous commit we've left only one version of this function let's remove this flag at all. - Removed struct db from list of sql_prepare() arguments. There's one global database handler and it can be obtained by sql_get() call. Hence, it makes no sense to pass around this argument. Needed for #3292
-
Nikita Pettik authored
There are two versions of the same function (sql_prepare()) which are almost identical. Let's keep more relevant version sql_prepare_v2() but rename it to sql_prepare() in order to avoid any mess. Needed for #3292
-
- Dec 29, 2019
-
-
Nikita Pettik authored
Each column of result set features its name span (in full metadata mode). For instance: SELECT x + 1 AS add FROM ...; In this case real name (span) of resulting set column is "x + 1" meanwhile "add" is its alias. This patch extends metadata with member which corresponds to column's original expression. It is worth mentioning that in most cases span coincides with name, so to avoid overhead and sending the same string twice, we follow the rule that if span is encoded as MP_NIL then its value is the same as name. Also note that span is always presented in full metadata mode. Closes #4407 @TarantoolBot document Title: extended SQL metadata Before this patch metadata for SQL DQL contained only two fields: name and type of each column of result set. Now it may contain following properties: - collation (in case type of resulting set column is string and collation is different from default "none"); is encoded with IPROTO_FIELD_COLL (0x2) key in IPROTO_METADATA map; in msgpack is encoded as string and held with MP_STR type; - is_nullable (in case column of result set corresponds to space's field; for expressions like x+1 for the sake of simplicity nullability is omitted); is encoded with IPROTO_FIELD_IS_NULLABLE key (0x3) in IPROTO_METADATA; in msgpack is encoded as boolean and held with MP_BOOL type; note that absence of this field implies that nullability is unknown; - is_autoincrement (is set only for autoincrement column in result set); is encoded with IPROTO_FIELD_IS_AUNTOINCREMENT (0x4) key in IPROTO_METADATA; in msgpack is encoded as boolean and held with MP_BOOL type; - span (is always set in full metadata mode; it is an original expression forming result set column. For instance: SELECT a + 1 AS x; -- x is a name, meanwhile a + 1 is a span); is encoded with IPROTO_FIELD_SPAN (0x5) key in IPROTO_METADATA map; in msgpack is encoded as string and held with MP_STR type OR as NIL with MP_NIL type. The latter case indicates that span coincides with name. This simple optimization allows to avoid sending the same string twice. This extended metadata is send only when PRAGMA full_metadata is enabled. Otherwise, only basic (name and type) metadata is processed.
-
- 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;')
-
Mergen Imeev authored
This patch creates DOUBLE field type in Tarantool. The main purpose of this field type is to add DOUBLE type to SQL. Part of #3812
-
Nikita Pettik authored
Accidentally, number of indexes to be considered during query planning in presence of INDEXED BY is calculated wrong. Instead of one (INDEXED BY is not a hint but requirement) index to be used (which is indicated in INDEXED BY clause), all space indexes take part in query planning. There are not so many tests checking this feature, so unfortunately this bug was hidden. Let's fix it and force only one index to be used in QP in case of INDEXED BY clause.
-
- Dec 25, 2019
-
-
Nikita Pettik authored
If result set contains column which features attached sequence (AUTOINCREMENT in terms of SQL) then meta-information will contain corresponding field ('is_autoicrement' : boolean) in response. Part of #4407
-
Nikita Pettik authored
If member of result set is (solely) column identifier, then metadata will contain its corresponding field nullability as boolean property. Note that indicating nullability for other expressions (like x + 1) may make sense but it requires derived nullability calculation which in turn seems to be overkill (at least in scope of current patch). Part of #4407
-
Nikita Pettik authored
If resulting set column is of STRING type and features collation (no matter explicit or implicit) different from "none", then metadata will contain its name. This patch also introduces new pragma: full_metadata. By default it is not set. If it is turned on, then optional metadata (like collation) is pushed to Lua stack. Note that via IProto protocol always full metadata is send, but its decoding depends on session SQL settings. Part of #4407
-
Nikita Pettik authored
Move names and types of resulting set to a separate structure. Simplify their storage by introducing separate members for name and type (previously names and types were stored in one char * array). It will allow us to add new metadata properties with ease. Needed for #4407
-
- Dec 24, 2019
-
-
Nikita Pettik authored
Any user defined function features assumed type of returned value (if it is not set explicitly during UDF creation, then it is ANY). After function's invocation in SQL, type of returned value is checked to be compatible with mentioned type of returned value specified in function's definition. It is done by means of field_mp_plain_type_is_compatible(). This functions accepts 'is_nullable' arguments which indicates whether value can be nullable or not. For some reason 'is_nullable' is set to 'false' in our particular case. Hence, nils can't be returned from UDF for SCALAR types. Since there's no reason why nils can't be returned from UDFs, let's fix this unfortunate bug.
-
Chris Sosnin authored
It is possible to create a sequence manually, and give it to a newly created index as a source of unique identifiers. Such sequences are not owned by a space, and therefore shouldn't be deleted when the space is dropped. They are not dropped when space:drop() in Lua is called, but were dropped in SQL 'DROP TABLE' before this patch. Now Lua and SQL are consistent in that case.
-
Nikita Pettik authored
GCC features warning diagnostics which allows to detect wrong ; right after 'if' operator: if (X == Y); { ... } In this case despite evaluation of 'if' argument expression, statements after it will be always executed. According to our codestyle, we neglect bracers around 'if' body in case it consists of single statement and fits into one line. On the other hand, in SQL debug macros like VdbeComment() are defined as empty, so statements like: if (X) VdbeComment(); turn into if (X) ; in release builds. As a result, we get 'false' warning (which is compilation error in -Werror mode). To fix it let's make VdbeComment() macros be non-empty in release mode and expand them into (void) 0.
-
Chris Sosnin authored
Dropping table with sql removes everything associated with it but grants, which is inconsistent. Generating code for it fixes this bug. Closes #4546
-
- Dec 23, 2019
-
-
Ilya Kosarev authored
libcurl-7.66.0 and older returns CURLE_WRITE_ERROR when a server responds with unknown or unsupported Content-Encoding (see [1] and [2]). This was fixed in future libcurl-7.67.0 and proper CURLE_BAD_CONTENT_ENCODING code will be returned in this case. We should process the code in the same way as we do for CURLE_WRITE_ERROR. [1]: curl/curl#4310 [2]: curl/curl#4449 Closes #4579 Reviewed-by:
Alexander Turenko <alexander.turenko@tarantool.org>
-
Ilya Kosarev authored
CURLOPT_ACCEPT_ENCODING libcurl option is now supported. This option enables automatic decompression of HTTP responses. See https://curl.haxx.se/libcurl/c/CURLOPT_ACCEPT_ENCODING.html Closes #4232 Reviewed-by:
Alexander Turenko <alexander.turenko@tarantool.org> @TarantoolBot document Title: httpc: add curl accept_encoding option Update the documentation for client_object:request() parameters to reflect new accept_encoding option. It enables automatic decompression of HTTP responses by setting the contents of the Accept-Encoding header sent in a HTTP request and enabling decoding of a response when a Content-Encoding header is received. This is a request, not an order; the server may or may not do it. Servers might respond with Content-Encoding even without getting an Accept-Encoding in the request. Servers might respond with a different Content-Encoding than what was asked for in the request. @param accept_encoding specifies what encoding you'd like. This param can be an empty string which means Accept-Encoding header will contain all built-in supported encodings. This param can be comma-separated list of accepted encodings, like: "br, gzip, deflate". Bundled libcurl supports "identity", meaning non-compressed, "deflate" which requests the server to compress its response using the zlib algorithm and "gzip" which requests the gzip algorithm. System libcurl also possibly supports "br" which is brotli. See https://curl.haxx.se/libcurl/c/CURLOPT_ACCEPT_ENCODING.html
-
Ilya Kosarev authored
After executing curl request we need to process curl_request code. It might be CURLE_WRITE_ERROR. We had special case for it, which assumed diagnostic message being set and contained corresponding assert, though it is incorrect. Better way is to handle it as any other non-standard event. It was discovered while adding accept_encoding option. In case of unknown encoding curl_request code is currently set to CURLE_WRITE_ERROR and therefore we come to an assert assuming we have some diagnostics set. However, it is not being set and it is totally fine. This means we are failing on assert and it is not correct behavior. Prerequisites: #4232 Reviewed-by:
Alexander Turenko <alexander.turenko@tarantool.org>
-
- Dec 19, 2019
-
-
Mergen Imeev authored
This patch fixes a bug that appeared after commit 3a13be1d ('lua: fix lua_tofield() for 2**64 value') . Due to this bug, -2^63 was serialized as double, although it should be serialized as integer. Closes #4672
-
Vladislav Shpilevoy authored
Isolated tuple update is an update by JSON path, which hasn't a common prefix with any other JSON update operation in the same set. For example, these JSON update operations are isolated: {'=', '[1][2][3]', 100}, {'+', '[2].b.c', 200} Their JSON paths has no a common prefix. But these operations are not isolated: {'=', '[1][2][3]', 100}, {'+', '[1].b.c', 200} They have a common prefix '[1]'. Isolated updates are a first part of fully functional JSON updates. Their feature is that their implementation is relatively simple and lightweight - an isolated JSON update does not store each part of the JSON path as a separate object. Isolated update stores just string with JSON and pointer to the MessagePack object to update. Such isolated updates are called 'bar update'. They are a basic brick of more complex JSON updates. Part of #1261
-
Oleg Babin authored
Before this patch if user passed {verbose = false} to http client it was considered as "true" This patch fixes such behaviour and takes into account user's value
-
- Dec 17, 2019
-
-
Nikita Pettik authored
Some built-in functions can accept different number of arguments. Check of argument count for such functions takes place right before its execution. So it is possible that expression-list representing arguments for built-in function is NULL. On the other hand, in sql_expr_coll() (which returns collation of expression) it is assumed that if function features SQL_FUNC_DERIVEDCOLL flag (it implies that resulting collation depends on collation of arguments) then it has at least one argument. The last assumption is wrong considering for example SUBSTR() function: it may have 1 or 2 arguments, so check of argument count doesn't occur during compilation. Hence, if it is required to calculate collation for SUBSTR() function and there's no arguments, Tarantool crashes due to null-dereference. This patch fixes this bug with one additional check in sql_expr_coll().
-
- Dec 16, 2019
-
-
Chris Sosnin authored
As long as we are sure, that strlen(sd_unix_path) < sizeof(sa.sun_path) we can assume that there is always enough space and the path will be null-terminated. Thus, copy 1 byte less to get rid of the warning. Closes #4515
-
- Dec 11, 2019
-
-
Mergen Imeev authored
This patch fixes a bug that prevented the conversion of real values that are greater than INT64_MAX and less than UINT64_MAX to INTEGER and UNSIGNED. Closes #4526
-
Mergen Imeev authored
The sqlVdbeMemIntegerify() function accepts the is_forced flag as one of the arguments. But this flag is actually useless, because regardless of whether it is TRUE or FALSE, the function will do the same. This patch removes the is_forced argument from the function. There will be no test, since the result of the function has not changed. Part of #4526
-
- Dec 10, 2019
-
-
Olga Arkhangelskaia authored
According to code coio_call does not take a timeout as an argument, however it was mentioned in the comment and usage example. This lead to error in documentation. The patch fixes it. Closes #4663
-
Vladislav Shpilevoy authored
C functions are loaded from .so/.dylib dynamic libraries. A library is loaded when any function from there is called first time. And was supposed to be unloaded, when all its functions are dropped from the schema (box.schema.func.drop()), and none of them is still in a call. But the unloading part was broken. In fact, box.schema.func.drop() never unloaded anything. Moreover, when functions from the module were added again without a restart, it led to a second mmap of the same module. And so on, the same library could be loaded any number of times. The problem was in a useless flag in struct module preventing its unloading even when it is totally unused. It is dropped. Closes #4648
-
Vladislav Shpilevoy authored
Error injections are used to simulate an error. They are represented as a flag, or a number, and are used in Lua tests. But they don't have any feedback. That makes impossible to use the injections to check that something has happened. Something very needed to be checked, and impossible to check in a different way. More certainly, the patch is motivated by a necessity to count loaded dynamic libraries to ensure, that they are loaded and unloaded when expected. This is impossible to do in a platform independent way. But an error injection as a debug-only counter would solve the problem. Needed for #4648
-
Vladislav Shpilevoy authored
There is a bug in XCode 11 which makes some standard C headers not self sufficient when compile with gcc. At least <stdlib.h> and <algorithm> are affected. When they are included first, compilation fails with creepy errors like this: In file included from /Applications/Xcode.app/Contents/Developer/ Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ sys/wait.h:110, from /Applications/Xcode.app/Contents/Developer/ Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ stdlib.h:66, from tarantool/third_party/zstd/lib/common/zstd_common.c:16: /Applications/Xcode.app/Content/Developer/ Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ sys/resource.h: In function 'getiopolicy_np': /Applications/Xcode.app/Contents/Developer/ Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ sys/resource.h:447:34: error: expected declaration specifiers before '__OSX_AVAILABLE_STARTING' 447 | int getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); The patch workarounds the bug by deleting the buggy header includes where possible, and by changing include order in other cases. Also there was a second compilation problem. This was about different definitions of the same standard functions: via extern "C" and without. It looked like this: In file included from tarantool/src/trivia/util.h:36, from tarantool/src/tt_pthread.h:35, from tarantool/src/lib/core/fiber.h:38, from tarantool/src/lib/core/coio.h:33, from tarantool/src/lib/core/coio.cc:31: /usr/local/Cellar/gcc/9.2.0_1/lib/gcc/9/gcc/x86_64-apple-darwin18/9.2.0 include-fixed/stdio.h:222:7: error: conflicting declaration of 'char* ctermid(char*)' with 'C' linkage 222 | char *ctermid(char *); | ^~~~~~~ In file included from /Applications/Xcode.app/Contents/Developer/Platforms/ MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:525, from tarantool/src/lib/core/fiber.h:37, from tarantool/src/lib/core/coio.h:33, from tarantool/src/lib/core/coio.cc:31: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/ Developer/SDKs/MacOSX.sdk/usr/include/_ctermid.h:26:10: note: previous declaration with 'C++' linkage 26 | char *ctermid(char *); | ^~~~~~~ This bug is workarounded by deletion of the conflicting includes, because anyway they appeared to be not needed. Closes #4580 Conflicts: third_party/decNumber
-
Serge Petrenko authored
snrpintf always null-terminates the passed string, and it also returns the number of bytes that "would have been written if there was enough space", so not only we don't have to null-terminate the string, but even more so we shouldn't do it erroneously. The only case when a string should be null-terminated manually is when the print cycle doesn't run at all, so move the termination before the cycle. Closes #4636
-
Serge Petrenko authored
The tarantool_free() call in the end of main() works all the time except when we exit due to a panic. We need to clear terminal state in this case also, so return to using atexit() to clear readline state. Closes #4466
-
Chris Sosnin authored
Unicode_ci collation breaks the general rule for objects naming, so we remove it in version 2.3.1 Closes #4561
-
- Dec 06, 2019
-
-
Alexander V. Tikhonov authored
After the commit 77fa45bd ('lua: add fiber.top() listing fiber cpu consumption') the unit tests builds failed like: /opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/ld: ../../src/lib/core/libcore.a(fiber.c.o): undefined reference to symbol 'clock_gettime@@GLIBC_2.2.5' //lib64/librt.so.1: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status test/unit/CMakeFiles/cbus.test.dir/build.make:108: recipe for target 'test/unit/cbus.test' failed make[2]: *** [test/unit/cbus.test] Error 1 Found that fiber.cc is using now clock_gettime(), which requires -lrt with glibc. To fix it added librt dependency for core library for glibc. Due to glibc requires for -lrt for clock_gettime() only for some versions, check 'man clock_gettime.2': 'Link with -lrt (only for glibc versions before 2.17).' the check whether is able to use clock_gettime() w/o librt library is added. Close #4639 (cherry picked from commit 99b0ef771135eab66ef3758371b1b5431e21cbff)
-
Chris Sosnin authored
It was requested to be raised from 32 to 128 Closes #4670
-
- Dec 02, 2019
-
-
Ilya Kosarev authored
In replicaset_follow we iterate anon replicas list: list of replicas that haven't received an UUID. In case of successful connect replica link is being removed from anon list. If it happens immediately, without yield in applier, iteration breaks. Now it is fixed by rlist_foreach_entry_safe instead of common rlist_foreach_entry. Relevant test case is added. Part of #4586 Closes #4576 Closes #4440
-
Ilya Kosarev authored
During pruning of appliers some anon replicas might connect from replicaset_follow called in another fiber. Therefore we need to prune appliers of anon replicas first and, moreover, prune them one by one instead of iterating them, as far as any of them might connect while we are stopping the other one and it will break iteration. Part of #4586 Closes #4643
-
- Nov 27, 2019
-
-
Ilya Kosarev authored
Triggers don't throw exceptions any more. Now they have return codes to report errors. Closes #4247
-