Skip to content
Snippets Groups Projects
  1. Oct 14, 2020
  2. Sep 18, 2020
    • Sergey Bronnikov's avatar
      extra: add Terraform config files · 0b59bc93
      Sergey Bronnikov authored
      For testing Tarantool with Jepsen we use virtual machines as they provides
      better resource isolation in comparison to containers. Jepsen tests may need a
      single instance or a set of instances for testing cluster.  To setup virtual
      machines we use Terraform [1]. Patch adds a set of configuration files for
      Terraform that can create required number of virtual machines in MCS and output
      IP addresses to stdout.
      
      Terraform needs some parameters before run. They are:
      
      - id, identificator of a test stand that should be specific for this run, id
      also is a part of virtual machine name
      - keypair_name, name of keypair used in a cloud, public SSH key of that key pair
      will be placed to virtual machine
      - instance_count, number of virtual machines in a test stand
      - ssh_key, SSH private key, used to access to a virtual machine
      - user_name
      - password
      - tenant_id
      - user_domain_id
      
      These parameters can be passed via enviroment variables with TF_VAR_ prefix
      (like TF_VAR_id) or via command-line parameters.
      
      To demonstrate full lifecycle of a test stand with Terraform one needs to
      perform these commands:
      
      terraform init extra/tf
      terraform apply extra/tf
      terraform output instance_names
      terraform output instance_ips
      terraform destroy extra/tf
      
      1. https://www.terraform.io/
      
      Part of #5277
      0b59bc93
  3. Jul 15, 2020
  4. Jun 10, 2020
  5. May 18, 2020
    • Vladislav Shpilevoy's avatar
      cmake: remove dynamic-list linker option · 03790ac5
      Vladislav Shpilevoy authored
      dynamic-list (exported_symbols_list on Mac) was used to forbid
      export of all symbols of the tarantool executable except a given
      list. Motivation of that was to avoid hacking the linker with
      false usage of symbols needed to be exported. As a consequence,
      symbols not listed in these options became invisible.
      
      Before these options, when a symbol was defined, but not used in
      the final executable, the linker could throw it away, even though
      many symbols were used by Lua FFI, or should be visible for user's
      dynamic modules. Where the linker, obviously, can't see if they
      are needed.
      
      To make the linker believe the symbols are actually needed there
      was a hack with getting pointers at these functions and doing
      something with them.
      
      For example, assume we have 'test()' function in 'box' static
      library:
      
          int
          test(void);
      
      It is not used anywhere in the final executable. So to trick the
      linker there is a function 'export_syms()' declared, which takes a
      pointer at 'test()' and seemingly does something with it (or
      actually does - it does not matter):
      
          void
          export_syms()
          {
              void *syms[] = {test};
              if (time(NULL) == 0) {
                  syms[0]();
                  syms[1]();
                  ...
              }
          }
      
      Some users want to use not documented but visible symbols, so the
      patch removes the dynamic-list option, and returns the linker
      hack back. But with 0 dependencies in the export file.
      
      Closes #2971
      03790ac5
  6. Apr 28, 2020
    • Vladislav Shpilevoy's avatar
      box: introduce box_return_mp() public C function · dd36c610
      Vladislav Shpilevoy authored
      Closes #4641
      
      @TarantoolBot document
      Title: box_return_mp() public C function
      
      Stored C functions could return a result only via
      `box_return_tuple()` function. That made users create a tuple
      every time they wanted to return something from a C function.
      
      Now public C API offers another way to return - `box_return_mp()`.
      It allows to return arbitrary MessagePack, not wrapped into a
      tuple object. This is simpler to use for small results like a
      number, boolean, or a short string. Besides, `box_return_mp()` is
      much faster than `box_return_tuple()`, especially for small
      MessagePack.
      
      Note, that it is faster only if an alternative is to create a
      tuple by yourself. If an already existing tuple was obtained from
      an iterator, and you want to return it, then of course it is
      faster to return via `box_return_tuple()`, than via extraction of
      tuple data, and calling `box_return_mp()`.
      
      Here is the function declaration from module.h:
      ```C
      /**
       * Return MessagePack from a stored C procedure. The MessagePack
       * is copied, so it is safe to free/reuse the passed arguments
       * after the call.
       * MessagePack is not validated, for the sake of speed. It is
       * expected to be a single encoded object. An attempt to encode
       * and return multiple objects without wrapping them into an
       * MP_ARRAY or MP_MAP is undefined behaviour.
       *
       * \param ctx An opaque structure passed to the stored C procedure
       *        by Tarantool.
       * \param mp Begin of MessagePack.
       * \param mp_end End of MessagePack.
       * \retval -1 Error.
       * \retval 0 Success.
       */
      API_EXPORT int
      box_return_mp(box_function_ctx_t *ctx, const char *mp, const char *mp_end);
      ```
      dd36c610
  7. Apr 20, 2020
    • Vladislav Shpilevoy's avatar
      error: make iproto errors reuse mp_error module · 712af455
      Vladislav Shpilevoy authored
      After error objects marshaling was implemented in #4398, there
      were essentially 2 versions of the marshaling - when an error is
      sent inside response body, and when it is thrown and is encoded
      in iproto fields IPROTO_ERROR and IPROTO_ERROR_STACK. That is not
      really useful to have 2 implementation of the same feature. This
      commit drops the old iproto error encoding (its IPROTO_ERROR_STACK
      part), and makes it reuse the common error encoder.
      
      Note, the encoder skips MP_EXT header. This is because
      
      * The header is not needed - error is encoded as a value of
        IPROTO_ERROR_STACK key, so it is known this is an error. MP_EXT
        is needed only when type is unknown on decoding side in advance;
      
      * Old clients may not expect MP_EXT in iproto fields. That is the
        case of netbox connector, at least.
      
      Follow up #4398
      
      @TarantoolBot document
      Title: Stacked diagnostics binary protocol
      Stacked diagnostics is described in details in
      https://github.com/tarantool/doc/issues/1224. This commit
      changes nothing except binary protocol. The old protocol should
      not be documented anywhere.
      
      `IPROTO_ERROR_STACK` is still 0x52, but format of its value is
      different now. It looks exactly like `MP_ERROR` object, without
      `MP_EXT` header.
      
      ```
      IPROTO_ERROR_STACK: <MP_MAP> {
          MP_ERROR_STACK: <MP_ARRAY> [
              <MP_MAP> {
                  ... <all the other fields of MP_ERROR> ...
              },
              ...
          ]
      }
      ```
      
      It is easy to see, that key `IPROTO_ERROR_STACK` is called
      'stack', and `MP_ERROR_STACK` is also 'stack'. So it may be good
      to rename the former key in the documentation. For example, the
      old `IPROTO_ERROR` can be renamed to `IPROTO_ERROR_24` and
      `IPROTO_ERROR_STACK` can be renamed to just `IPROTO_ERROR`.
      712af455
    • Vladislav Shpilevoy's avatar
      error: export error_unref() function · ed217292
      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
      ed217292
    • Leonid Vasiliev's avatar
      error: add custom error type · b728e7af
      Leonid Vasiliev authored
      
      Co-authored-by: default avatarVladislav <Shpilevoy&lt;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
      ...
      ```
      b728e7af
  8. Apr 14, 2020
    • Vladislav Shpilevoy's avatar
      box: export box_session_push to the public C API · 5d795527
      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()`.
      5d795527
    • Leonid's avatar
      rocks: forward options to luarocks · ce8c6ef1
      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
      ce8c6ef1
  9. Apr 13, 2020
    • Chris Sosnin's avatar
      session: store output format in struct session · 9c0e40f9
      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
      9c0e40f9
    • Chris Sosnin's avatar
      sql: provide a user friendly frontend for accessing session settings · 6706f659
      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
      ...
      
      ```
      6706f659
    • Serge Petrenko's avatar
      box: add MsgPack encoding/decoding for UUID · d68fc292
      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.
      d68fc292
  10. Apr 07, 2020
    • Nikita Pettik's avatar
      box: introduce stacked diagnostic area · 3b887d04
      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
      3b887d04
  11. Apr 02, 2020
  12. Mar 18, 2020
    • Oleg Babin's avatar
      box: allow to retrieve the last generated value of sequence · 64c69fe0
      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: default avatarVladislav Shpilevoy <v.shpilevoy@tarantool.org>
      Reviewed-by: default avatarNikita 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()`.
      64c69fe0
  13. Mar 05, 2020
  14. Dec 28, 2019
    • Nikita Pettik's avatar
      sql: display line and position in syntax errors · ea958f41
      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
      ea958f41
  15. Dec 27, 2019
    • Mergen Imeev's avatar
      sql: introduce DOUBLE type · 64745b10
      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;')
      64745b10
  16. Oct 16, 2019
    • Kirill Shcherbatov's avatar
      sql: add an ability to disable CK constraints · c4781f93
      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'
      c4781f93
  17. Sep 16, 2019
    • Nikita Pettik's avatar
      sql: remove ENGINE from list of reserved keywords · 07618dad
      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.
      07618dad
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. Jun 16, 2019
  25. 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
  26. Jun 09, 2019
  27. 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
Loading