Skip to content
Snippets Groups Projects
  1. Aug 22, 2019
    • Max Melentiev's avatar
      tarantoolctl: allow to start instances with delayed box.cfg{} · 17df9edf
      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.
      17df9edf
    • Nikita Pettik's avatar
      sql: allow to specify engine in CREATE TABLE stmt · 1013a744
      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'.
      1013a744
    • Serge Petrenko's avatar
      decimal: allow to encode/decode decimals as MsgPack · 485439e3
      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
      485439e3
  2. Aug 16, 2019
    • Roman Khabibov's avatar
      sql: remove mask from struct Keyword · 13ed1126
      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
      13ed1126
  3. Aug 01, 2019
    • Nikita Pettik's avatar
      sql: introduce VARBINARY column type · b4e61e1b
      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
      b4e61e1b
  4. Jul 30, 2019
    • Nikita Pettik's avatar
      sql: rename REAL/FLOAT/DOUBLE types to NUMBER · 36bdfbb2
      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.
      36bdfbb2
    • Nikita Pettik's avatar
      sql: add STRING alias to TEXT type · 36fc5fe1
      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.
      36fc5fe1
  5. Jul 24, 2019
    • Nikita Pettik's avatar
      sql: allow to specify UNSIGNED column type · a4386277
      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
      a4386277
  6. Jun 18, 2019
    • Alexander Turenko's avatar
      lua: escape trigraphs in bundled lua sources · 177a1713
      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.
      177a1713
  7. Jun 16, 2019
  8. Jun 13, 2019
    • Stanislav Zudin's avatar
      sql: cleanup code from obsolete macros · 6d7ca0e6
      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
      6d7ca0e6
  9. Jun 09, 2019
  10. May 21, 2019
    • Vladislav Shpilevoy's avatar
      swim: swim:set_codec() Lua API · 2dc1af75
      Vladislav Shpilevoy authored
      Encryption with an arbitrary algorithm and any mode with a
      configurable private key.
      
      Closes #3234
      2dc1af75
    • Vladislav Shpilevoy's avatar
      swim: cache decoded payload in the Lua module · 8ae88a3f
      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
      8ae88a3f
    • Vladislav Shpilevoy's avatar
      swim: introduce Lua interface · 407adf40
      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
      407adf40
    • Vladislav Shpilevoy's avatar
      buffer: port static allocator to Lua · 7fd6c809
      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.
      7fd6c809
  11. May 17, 2019
    • Mergen Imeev's avatar
      sql: stop parser on error · d039fc05
      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
      d039fc05
  12. May 15, 2019
  13. Apr 30, 2019
  14. Apr 25, 2019
    • Nikita Pettik's avatar
      sql: introduce type boolean · 0a8b1791
      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
      0a8b1791
  15. Apr 23, 2019
    • Roman Khabibov's avatar
      sql: modify TRIM() function signature · f95a34da
      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.
      f95a34da
  16. Apr 17, 2019
  17. Apr 16, 2019
    • Roman Khabibov's avatar
      tarantoolctl: raise error when box.cfg isn't called · 2b387d1c
      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
      2b387d1c
  18. Mar 26, 2019
  19. Mar 07, 2019
    • Nikita Pettik's avatar
      sql: replace BLOB as column type with SCALAR · 0d0f53aa
      Nikita Pettik authored
      BLOB column type is represented by SCALAR field type in terms of NoSQL.
      We attempted at emulating BLOB behaviour, but such efforts turn out to
      be not decent enough. For this reason, we've decided to abandon these
      attempts and fairly replace it with SCALAR column type.  SCALAR column
      type acts in the same way as it does in NoSQL: it is aggregator-type for
      INTEGER, NUMBER and STRING types. So, column declared with this type can
      contain values of these three (available in SQL) types. It is worth
      mentioning that CAST operator in this case does nothing.
      
      Still, we consider BLOB values as entries encoded in msgpack with MP_BIN
      format. To make this happen, values to be operated should be represented
      in BLOB form x'...' (e.g. x'000000'). What is more, there are two
      built-in functions returning BLOBs: randomblob() and zeroblob().  On the
      other hand, columns with STRING NoSQL type don't accept BLOB values.
      
      Closes #4019
      Closes #4023
      
      @TarantoolBot document
      Title: SQL types changes
      There are couple of recently introduced changes connected with SQL
      types.
      
      Firstly, we've removed support of DATE/TIME types from parser due to
      confusing behaviour of these types: they were mapped to NUMBER NoSQL
      type and have nothing in common with generally accepted DATE/TIME types
      (like in other DBs). In addition, all built-in functions related to
      these types (julianday(), date(), time(), datetime(), current_time(),
      current_date() etc) are disabled until we reimplement TIME-like types as
      a native NoSQL ones (see #3694 issue).
      
      Secondly, we've removed CHAR type (i.e. alias to VARCHAR and TEXT). The
      reason is that according to ANSI SQL CHAR(len) must accept only strings
      featuring length exactly equal to given in type definition. Obviously,
      now we don't provide such checks. Types VARCHAR and TEXT are still
      legal.
      
      For the same reason, we've removed NUMERIC and DECIMAL types, which were
      aliases to NUMBER NoSQL type. REAL, FLOAT and DOUBLE are still exist as
      aliases.
      
      Finally, we've renamed BLOB column type to SCALAR. We've decided that
      all our attempts to emulate BLOB behaviour using SCALAR NoSQL type don't
      seem decent enough, i.e. without native NoSQL type BLOB there always
      will be inconsistency, especially taking into account possible NoSQL-SQL
      interactions. In SQL SCALAR type works exactly in the same way as in
      NoSQL: it can store values of INTEGER, FLOAT and TEXT SQL types at the
      same time. Also, with this change behaviour of CAST operator has been
      slightly corrected: now cast to SCALAR doesn't affect type of value at
      all. Couple of examples:
      
      CREATE TABLE t1 (a SCALAR PRIMARY KEY);
      INSERT INTO t1 VALUES ('1');
      SELECT * FROM t1 WHERE a = 1;
      -- []
      Result is empty set since column "a" contains string literal value '1',
      not integer value 1.
      
      CAST(123 AS SCALAR); -- Returns 123 (integer)
      CAST('abc' AS SCALAR); -- Returns 'abc' (string)
      
      Note that in NoSQL values of BLOB type defined as ones decoded in
      msgpack with MP_BIN format. In SQL there are still a few ways to force
      this format: declaring literal in "BLOB" format (x'...') or using one of
      two built-in functions (randomblob() and zeroblob()). TEXT and VARCHAR
      SQL types don't accept BLOB values:
      
      CREATE TABLE t (a TEXT PRIMARAY KEY);
      INSERT INTO t VALUES (randomblob(5));
      ---
      - error: 'Tuple field 1 type does not match one required: expected string'
      ...
      
      BLOB itself is going to be reimplemented in scope of #3650.
      0d0f53aa
    • Nikita Pettik's avatar
      sql: remove support of NUMERIC type from parser · 696db264
      Nikita Pettik authored
      NMERIC and DECIMAL were allowed to be specified as column types. But in
      fact, they were just synonyms for FLOAT type and mapped to NUMERIC
      Tarantool NoSQL type. So, we've decided to remove this type from parser
      and return back when NUMERIC will be implemented as a native type.
      
      Part of #4019
      696db264
    • Nikita Pettik's avatar
      sql: remove support of DATE/TIME from parser · 3caeb33c
      Nikita Pettik authored
      Currently, there is no native (in Tarantool terms) types to represent
      time-like types. So, until we add implementation of those types, it
      makes no sense to allow to specify those types in table definition.
      Note that previously they were mapped to NUMBER type. For the same
      reason all built-in functions connected with DATE/TIME are disabled as
      well.
      
      Part of #4019
      3caeb33c
  20. Feb 27, 2019
  21. Feb 21, 2019
    • Michał Durak's avatar
      lua: add 'chars' param to string.strip functions · 16f58830
      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.
      16f58830
  22. Feb 13, 2019
  23. Feb 11, 2019
  24. Jan 30, 2019
    • Serge Petrenko's avatar
      lua: patch os.exit() to execute on_shutdown triggers. · 6dc4c8d7
      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.
      6dc4c8d7
    • Stanislav Zudin's avatar
      sql: prohibit type_def keywords in the VALUES statement · a10b1549
      Stanislav Zudin authored
      The "box.sql.execute('values(blob)')" causes an accert in the
      expression processing, because the parser doesn't distinguish the
      keyword "BLOB" from the binary value (in the form X'hex').
      
      This fix adds an additional checks in the SQL grammar.
      Thus the expressions such as "VALUES(BLOB)", "SELECT FLOAT"
      and so on are treated as a syntax errors.
      
      Closes #3888
      a10b1549
  25. Jan 05, 2019
Loading