Skip to content
Snippets Groups Projects
  1. Mar 07, 2023
  2. Feb 02, 2023
  3. Jan 30, 2023
    • Andrey Saranchin's avatar
      box: make ffi select work on M1 · 1b4a81fa
      Andrey Saranchin authored
      Recently, ffi select was broken on M1 in commit ec1a71ff
      ("box: introduce pagination to memtx_tree and tuple position methods").
      It turned out that ffi on M1 poorly supports a big quantity of arguments.
      Fortunately, there is a workaround - we can pass only 64-bit integer
      arguments beyond the 8th argument. Let's do it.
      
      Closes #7946
      
      NO_TEST=reflected in existing tests
      NO_CHANGELOG=bugfix for unreleased feature
      NO_DOC=bugfix
      1b4a81fa
  4. Jan 13, 2023
    • Aleksandr Lyapunov's avatar
      box: introduce options in box.atomic · 9d1cbda5
      Aleksandr Lyapunov authored
      If the first argument of box.atomic is a non-callable table then
      consider it as options table for box.begin{}.
      
      For test and debug purposes introduce internal getter of current
      transaction isolation level as box.internal.txn_isolation().
      
      Closes #7202
      
      @TarantoolBot document
      Title: Options in box.atomic
      
      Now it's allowed to pass transaction options in the first argument
      of box.atomic(..) call. The options must be a table, exactly as
      in box.begin(..). If options are passed as the first arguments,
      the second and the rest arguments are expected to be a functions
      and its arguments, like in usual box.atomic.
      9d1cbda5
  5. Jan 12, 2023
    • Alexander Turenko's avatar
      build: fix build fail on clang 15 · 1c6b6f85
      Alexander Turenko authored
      Fixed pthread-related CMake checks. The checks code is built with
      `-pedantic-errors` and it leads to errors of the following kind on
      clang 15:
      
      ```
      <...>/CMakeFiles/CMakeScratch/TryCompile-78KaOK/src.c:4:17: error: a
          function declaration without a prototype is deprecated in all
          versions of C [-Werror,-Wstrict-prototypes]
              int main() { pthread_setname_np(pthread_self(), ""); }
                      ^
                       void
      ```
      
      Fixed a warning in the SQL code (it's an error in Debug build):
      
      ```
      <...>/src/box/sql/vdbeaux.c:170:13: error: variable 'n' set but not used
          [-Werror,-Wunused-but-set-variable]
              static int n = 0;
      ```
      
      Fixed several warnings from lemon.c of the following kind:
      
      ```
      <...>/extra/lemon.c:173:6: warning: a function declaration without a
          prototype is deprecated in all versions of C and is treated as a
          zero-parameter prototype in C2x, conflicting with a subsequent
          definition [-Wdeprecated-non-prototype]
      void FindRulePrecedences();
           ^
      <...>/extra/lemon.c:766:6: note: conflicting prototype is here
      void FindRulePrecedences(struct lemon *xp)
      ```
      
      See also https://github.com/tarantool/small/issues/57
      
      Fixes #8110
      
      NO_DOC=build fix
      NO_TEST=build fix
      1c6b6f85
  6. Jan 11, 2023
    • Georgiy Lebedev's avatar
      box: overriding IPROTO request handlers · 998964c8
      Georgiy Lebedev authored
      Add `IPROTO_UNKNOWN` command code for overriding the unknown request
      handler.
      
      Change request type variable types related to IPROTO to `uint32_t`.
      
      Add request handler hash table to transaction thread and request handler
      set to IPROTO threads for storing overridden request handlers: TX thread
      notifies IPROTO threads about overridden request handlers using IPROTO
      configuration message.
      
      If a given request handler is overridden, the IPROTO thread does not
      preprocess it and sends the package immediately over a dedicated route. If
      later it is necessary to fallback to the system handler, the message
      decoding and dispatching is done in the TX thread.
      
      Add new `box.iproto.override` method to Lua and `box_iproto_override` to C
      API, which allow setting IPROTO request handler callbacks.
      
      Closes #7901
      
      @TarantoolBot document
      Title: Document overriding IPROTO request handlers feature
      For the API description and usage examples, see:
      * [design document](https://www.notion.so/tarantool/box-iproto-override-44935a6ac7e04fb5a2c81ca713ed1bce#0f84694523214c0e9bf2f3d75cccace4);
      * tarantool/tarantool#7901.
      998964c8
  7. Dec 27, 2022
    • Mergen Imeev's avatar
      sql: introduce SEQSCAN to SELECT · 77648827
      Mergen Imeev authored
      This patch introduces new keyword SEQSCAN and new restrictions on
      SELECTs. These restrictions are disabled by default.
      
      Closes #7747
      
      @TarantoolBot document
      Title: SEQSCAN
      
      Now scanning SELECT will not run and will throw an error if the new
      SEQSCAN keyword is not used for scanned spaces. This change only affects
      SELECT and does not affect UPDATE and DELETE. A SELECT is recognized as
      a scanning SELECT if `EXPLAIN QUERY PLAN SELECT ...` indicates that the
      SELECT `scans` rather than `searches`.
      
      For example, if we have spaces created with these queries:
      ```
      CREATE TABLE t(i INT PRIMARY KEY, a INT);
      CREATE TABLE s(i INT PRIMARY KEY, a INT);
      ```
      
      Then these queries will throw an error:
      ```
      SELECT * FROM t;
      SELECT * FROM t WHERE a > 1;
      SELECT * FROM t WHERE i + 1 = 5;
      SELECT * FROM t, s;
      SELECT * FROM t JOIN s;
      ```
      
      And these will not:
      ```
      SELECT * FROM t WHERE i > 1;
      SELECT * FROM SEQSCAN t;
      SELECT * FROM SEQSCAN t WHERE i + 1 = 5;
      SELECT * FROM SEQSCAN t, SEQSCAN s;
      SELECT * FROM SEQSCAN t JOIN SEQSCAN s;
      ```
      
      Scanning can be allowed or disallowed by default. To do this, a new
      session setting is introduced: `sql_seq_scan`. The default value for
      setting is `true`, i.e. scanning is allowed. When set to `false`, the
      scanning SELECTs will throw a `scanning is not allowed` error.
      77648827
    • Sergey Bronnikov's avatar
      uri: speedup encode and decode functions · dcd46244
      Sergey Bronnikov authored
      
      Patch replaces encoding and decoding functions written in Lua with
      functions implemented in C.
      
      Performance of Lua implementation (before the patch):
      
      ```
      uri.escape   152.37  runs/sec
      uri.unescape 263.44  runs/sec
      ```
      
      Performance of C implementation (after the patch):
      
      ```
      uri.escape   4983.03  runs/sec
      uri.unescape 4197.19  runs/sec
      ```
      
      Follows up #3682
      
      NO_CHANGELOG=see previous commit
      NO_DOC=see previous commit
      
      Co-authored-by: default avatarAlexander Turenko <alexander.turenko@tarantool.org>
      dcd46244
    • Georgiy Lebedev's avatar
      box: sending arbitrary IPROTO packets · b9892247
      Georgiy Lebedev authored
      Add translation table for `box.iproto.key` constants encoding to simplify
      packet assembly.
      
      Add new `box.iproto.send` method to Lua and `box_iproto_send` function to C
      API, which allow sending arbitrary IPROTO packets, using active IPROTO
      sessions. Packets are sent asynchronously using Kharon.
      
      Add `xregion_join` to the `xalloc` API.
      
      Change gh-7894 test: instead of simply comparing `box.iproto` table to the
      reference table, iterate over `box.iproto` and check that corresponding
      non-{function, thread, userdata} type values exist in the reference table.
      
      Closes #7897
      
      @TarantoolBot document
      Title: Document sending arbitrary IPROTO packets feature
      For the API description and usage examples, see:
      * [design document](https://www.notion.so/tarantool/box-iproto-override-44935a6ac7e04fb5a2c81ca713ed1bce#a2cc04da89d34fad8f8564c150cd9977);
      * tarantool/tarantool#7897.
      b9892247
  8. Dec 20, 2022
    • Mergen Imeev's avatar
      sql: refactor memory allocation system · 91fd360c
      Mergen Imeev authored
      This patch refactors the SQL memory allocation system. There are three
      main changes:
      1) now, when allocating memory, no additional 8 bytes are allocated to
      remember the size of the allocated memory, so instead of
      sql_malloc()/sqlRealloc()/sql_free(), the malloc()/realloc()/free()
      functions are used;
      2) the malloc()/realloc() functions were used through the
      xmalloc()/xrealloc() macros, so checks for memory allocation errors were
      removed;
      3) there is no need for an explicit "sql *db" argument for most of the
      functions, so it has been omitted.
      
      Part of #1544
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      91fd360c
    • Mergen Imeev's avatar
      sql: fix possible memleak in lemon.c · 1da1ac53
      Mergen Imeev authored
      This patch fixes possible memleak.
      
      NO_DOC=Possible bug
      NO_TEST=No proper way to test
      NO_CHANGELOG=Possible bug
      1da1ac53
  9. Dec 14, 2022
  10. Dec 12, 2022
    • Vladimir Davydov's avatar
      lua/digest: use OpenSSL version of SHA1 · c029e63f
      Vladimir Davydov authored
      Since commit f6ea7180 ("Try to load several variants of libssl.")
      the digest module uses an internal version of SHA1. Back then, we didn't
      link the OpenSSL library. Instead, we tried to load it dynamically.
      Since on some distributions the library could be missing, it was decided
      to implement an internal version of SHA1, see #405.
      
      However, since commit 59a55740 ("Link against libssl and libcrypto.
      Issue #1382") we link the OpenSSL library unconditionally so there's no
      need in having an internal implementation of SHA1. Let's drop it and
      switch the digest module to the version of SHA1 implemented by the
      crypto module using OpenSSL.
      
      Part of #7987
      
      NO_DOC=code cleanup
      NO_TEST=code cleanup
      NO_CHANGELOG=code cleanup
      c029e63f
  11. Dec 09, 2022
    • Ilya Verbin's avatar
      log: add log.new() function that creates a new logger · 24323448
      Ilya Verbin authored
      
      It allows to create a new instance of a log module, with a custom name:
      local my_log = require('log').new('my_module')
      
      The name is added to the log message after fiber name:
      YYYY-MM-DD hh:mm:ss.ms [PID]: CORD/FID/FIBERNAME/MODULENAME LEVEL> MSG
      
      Part of #3211
      
      NO_DOC=See next commit
      NO_CHANGELOG=See next commit
      
      Co-authored-by: default avatarAnastasMIPT <beliaev.ab@tarantool.org>
      24323448
    • Vladimir Davydov's avatar
      box: make auth subsystem pluggable · b5754d3f
      Vladimir Davydov authored
      This commit introduces an abstraction for the authentication code so
      that one can easily add new methods. To add a new method, one just needs
      to define a set of authentication callbacks in a struct auth_method and
      register it with auth_method_register.
      
      The IPROTO_AUTH and _user.auth formats were initially designed with
      extensibility in mind: both take the authentication method name
      (currently, only 'chap-sha1' is supported) so no changes to the schema
      are required.
      
      Note that although 'chap-sha1' is now implemented in its own file
      src/box/auth_chap_sha1.c, we don't merge src/scramble.c into it.
      This will be done later, in the scope of #7987.
      
      Since we call authentication plug-ins "methods" (not "mechanisms"),
      let's rename BOX_USER_FIELD_AUTH_MECH_LIST to BOX_USER_FIELD_AUTH while
      we are at it. Anyway, the corresponding field of the _user system space
      is called 'auth' (not 'auth_mech_list').
      
      Closes #7986
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      b5754d3f
  12. Dec 07, 2022
  13. Nov 29, 2022
    • Mergen Imeev's avatar
      sql: drop three parsing rules · 5ab45ba3
      Mergen Imeev authored
      This patch removes three rules in the parser.
      
      NO_CHANGELOG=will be added later
      
      @TarantoolBot document
      Title: Changes in parsing rules.
      
      Three rules related to foreign keys have been removed.
      
      The first is the "reference trigger action" rule, which determines the
      behavior when a referenced tuple is deleted. This rule has been dropped
      because the new foreign keys only support RESTRICT.
      
      The second is "constraint check time" rule, which determines when a
      foreign key constraint should be validated. This rule has been dropped
      because the new foreign keys only support INITIALLY IMMEDIATELY.
      
      The third is "match type" rule, which determines how inserted values are
      validated. This rule has been dropped because the new foreign keys only
      support FULL.
      5ab45ba3
  14. Nov 28, 2022
    • Andrey Saranchin's avatar
      box: introduce after in pairs · 5eee5d7e
      Andrey Saranchin authored
      The patch introduces pagination to pairs: one can create iterator which
      will start after specific tuple or position, described by option after.
      Tuple (both cdata and array) and position (obtained by index:tuple_pos
      or fetch_pos option of select) can be passed as option after.
      
      NO_CHANGELOG=next commit
      NO_DOC=next commit
      5eee5d7e
  15. Nov 18, 2022
  16. Nov 01, 2022
    • Nikolay Shirokovskiy's avatar
      box: straighten log configuration code · 571cdc3e
      Nikolay Shirokovskiy authored
      See [1] for some details on why the code for log configuration needs
      some care. In short log config validity checks are spread thru many
      places, on some code paths we use one checks and on other code paths
      other checks. And we make repetitive validity checks many times in
      runtime on single configure call.
      
      We can also reuse code for setting default values, checking options
      type and resetting values to default.
      
      - As a side effect of refactoring one can now reset values to default thru
        `log.cfg()` so now `log.cfg()` is on par with `box.cfg` in this respect.
      
      - This patch also drops conversion `log_level` from string to number.
      
        Before (shorten):
      
          tarantool> box.cfg{log_level='warn'}
          tarantool> box.cfg.log_level
          - info
          tarantool> log.cfg.level
          - 5
      
        Also:
          tarantool> log.cfg{level='info'}
          tarantool> log.cfg.level
          - 5
          tarantool> box.cfg{}
          tarantool> box.cfg.log_level
          - 5
      
        After patch if `log_level`/`level` is given as string than it is saved
        and returned as string too. I guess it should not affect users but looks
        more handy.
      
      - Also fixed issue with inconsistent setting `log_nonblock` thru
        `box.cfg()` and `log.cfg()`. In former case `nil` means setting default
        depending on logger type. In the latter case `nil` meant setting
        `nonblock` to `false`.
      
      - Also patch fixes #7447.
      
      Closes #7447.
      
      [1] PR for this refactoring
      https://github.com/tarantool/tarantool/pull/7454
      
      NO_DOC=refactoring/tiny API improvemnent
      571cdc3e
  17. Oct 18, 2022
    • Ilya Verbin's avatar
      box: use dd_version_id instead of _schema.version in get_version · 3e6393d5
      Ilya Verbin authored
      By default a user might not have privileges to access the _schema space,
      that will cause an error during schema_needs_upgrade(), which calls
      get_version(). Fix this by using C variable dd_version_id, which is
      updated in the _schema.version replace trigger.
      
      There's a special case for upgrade() during bootstrap() - triggers are
      disabled during bootstrap, that's why dd_version_id is not being updated.
      Handle this by passing _initial_version=1.7.5 to the upgrade function.
      
      Part of #7149
      
      NO_DOC=internal
      NO_CHANGELOG=internal
      3e6393d5
  18. Sep 29, 2022
    • Andrey Saranchin's avatar
      box: introduce pagination to memtx_tree and tuple position methods · ec1a71ff
      Andrey Saranchin authored
      The patch introduces C and Lua methods for extracting position
      of tuple in index. Multikey and functional indexes are not supported.
      
      Also this patch extends method index_create_iterator_after and adds
      implementation of iterator_position for memtx tree. Options
      after and fetch_pos are added to Lua select as well (both FFI and LuaC).
      All the types of memtx tree indexes are supported (multikey, functional).
      
      NO_CHANGELOG=see later commits
      NO_DOC=see later commits
      
      Closes #7633
      Closes #7636
      ec1a71ff
  19. Sep 13, 2022
    • Georgy Moshkin's avatar
      fiber: add fiber_set_ctx & fiber_get_ctx functions · 6a60768c
      Georgy Moshkin authored
      Before this change there was no way to create a fiber that accepts
      parameters without yielding from the current fiber using the c api. You
      could pass the function arguments when calling fiber_start, but that
      forces you to yield, which is not acceptable in some scenarios (e.g.
      within a transaction).
      
      This commit introduces 2 new functions to the api: fiber_set_ctx for
      setting an pointer to a context of the given fiber and fiber_get_ctx for
      accessing that context.
      
      Closes https://github.com/tarantool/tarantool/issues/7669
      
      @TarantoolBot document
      Title: fiber: add fiber_set_ctx & fiber_get_ctx functions
      
      Add 2 api functions: `fiber_set_ctx` & `fiber_get_ctx` which can be used
      for passing data to a fiber. Previously this could be done via the
      `fiber_start` function, except that this would force the current fiber
      to yield, which is not acceptable in some scenarios (e.g. during a
      transaction). Now you can create a fiber with `fiber_new`, set it's
      contents with `fiber_set_ctx`, make it ready for execution with
      `fiber_wakeup` and keep executing the current fiber.
      6a60768c
  20. Sep 12, 2022
    • Vladimir Davydov's avatar
      Use MT-Safe strerror_r instead of strerror · 44f46dc8
      Vladimir Davydov authored
      strerror() is MT-Unsafe, because it uses a static buffer under the hood.
      We should use strerror_r() instead, which takes a user-provided buffer.
      The problem is there are two implementations of strerror_r(): XSI and
      GNU. The first one returns an error code and always writes the message
      to the beginning of the buffer while the second one returns a pointer to
      a location within the buffer where the message starts. Let's introduce a
      macro HAVE_STRERROR_R_GNU set if the GNU version is available and define
      tt_strerror() which writes the message to the static buffer, like
      tt_cstr() or tt_sprintf().
      
      Note, we have to export tt_strerror(), because it is used by Lua via
      FFI. We also need to make it available in the module API header, because
      the say_syserror() macro uses strerror() directly. In order to avoid
      adding tt_strerror() to the module API, we introduce an internal helper
      function _say_strerror(), which calls tt_strerror().
      
      NO_DOC=bug fix
      NO_TEST=code is covered by existing tests
      44f46dc8
  21. Aug 26, 2022
    • Mergen Imeev's avatar
      sql: introduce new parsing rule · d882d9f4
      Mergen Imeev authored
      This commit introduces a new parse rule for compiling an unresolved
      single expression. This simplifies the current implementation of
      sql_expr_compile() and is useful for generating SQL expressions that can
      be used in the core check constraint. This rule is for internal use
      only.
      
      Part of #6986
      
      NO_DOC=will be added later
      NO_TEST=refactoring
      NO_CHANGELOG=will be added later
      d882d9f4
  22. Aug 05, 2022
    • Alexander Turenko's avatar
      lua/decimal: add Lua value accessors to module API · c75fbce1
      Alexander Turenko authored
      The Rust module (see the issue) needs a getter and a setter for decimal
      values on the Lua stack. Let's make them part of the module API.
      
      Part of #7228
      
      @TarantoolBot document
      Title: Lua/C functions for decimals in the module API
      
      The following functions are added into the module API:
      
      ```c
      /**
       * Allocate a new decimal on the Lua stack and return
       * a pointer to it.
       */
      API_EXPORT box_decimal_t *
      luaT_newdecimal(struct lua_State *L);
      
      /**
       * Allocate a new decimal on the Lua stack with copy of given
       * decimal and return a pointer to it.
       */
      API_EXPORT box_decimal_t *
      luaT_pushdecimal(struct lua_State *L, const box_decimal_t *dec);
      
      /**
       * Check whether a value on the Lua stack is a decimal.
       *
       * Returns a pointer to the decimal on a successful check,
       * NULL otherwise.
       */
      API_EXPORT box_decimal_t *
      luaT_isdecimal(struct lua_State *L, int index);
      ```
      c75fbce1
  23. Aug 04, 2022
    • Alexander Turenko's avatar
      decimal: add the library into the module API · 5c1bc3da
      Alexander Turenko authored
      The main decision made in this patch is how large the public
      `box_decimal_t` type should be. Let's look on some calculations.
      
      We're interested in the following values.
      
      * How much decimal digits is stored?
      * Size of an internal decimal type (`sizeof(decimal_t)`).
      * Size of a buffer to store a string representation of any valid
        `decimat_t` value.
      * Largest signed integer type fully represented in decimal_t (number of
        bits).
      * Largest unsigned integer type fully represented in decimal_t (number
        of bits).
      
      Now `decimal_t` is defined to store 38 decimal digits. It means the
      following values:
      
      | digits | sizeof | string | int???_t | uint???_t |
      | ------ | ------ | ------ | -------- | --------- |
      | 38     | 36     | 52     | 126      | 127       |
      
      In fact, decNumber (the library we currently use under the hood) allows
      to vary the 'decimal digits per unit' parameter, which is 3 by default,
      so we can choose density of the representation. For example, for given
      38 digits the sizeof is 36 by default, but it may vary from 28 to 47
      bytes:
      
      | digits | sizeof     | string | int???_t | uint???_t |
      | ------ | ---------- | ------ | -------- | --------- |
      | 38     | 36 (28-47) | 52     | 126      | 127       |
      
      If we'll want to store `int128_t` and `uint128_t` ranges, we'll need 39
      digits:
      
      | digits | sizeof     | string | int???_t | uint???_t |
      | ------ | ---------- | ------ | -------- | --------- |
      | 39     | 36 (29-48) | 53     | 130      | 129       |
      
      If we'll want to store `int256_t` and `uint256_t` ranges:
      
      | digits | sizeof     | string | int???_t | uint???_t |
      | ------ | ---------- | ------ | -------- | --------- |
      | 78     | 62 (48-87) | 92     | 260      | 259       |
      
      If we'll want to store `int512_t` and `uint512_t` ranges:
      
      | digits | sizeof       | string | int???_t | uint???_t |
      | ------ | ------------ | ------ | -------- | --------- |
      | 155    | 114 (84-164) | 169    | 515      | 514       |
      
      The decision here is what we consdider as possible and what as unlikely.
      The patch freeze the maximum amount of bytes in `decimal_t` as 64. So
      we'll able to store 256 bit integers and will NOT able to store 512 bit
      integers in a future (without the ABI breakage at least).
      
      The script, which helps to calculate those tables, is at end of the
      commit message.
      
      Next, how else `box_decimal_*()` library is different from the internal
      `decimal_*()`?
      
      * Added a structure that may hold any decimal value from any current or
        future tarantool version.
      * Added `box_decimal_copy()`.
      * Left `strtodec()` out of scope -- we can add it later.
      * Left `decimal_str()` out of scope -- it looks dangerous without at
        least a good explanation when data in the static buffer are
        invalidated. There is `box_decimal_to_string()` that writes to an
        explicitly provided buffer.
      * Added `box_decimal_mp_*()` for encoding to/decoding from msgpack.
        Unlike `mp_decimal.h` functions, here we always have `box_decimal_t`
        as the first parameter.
      * Left `decimal_pack()` out of scope, because a user unlikely wants to
        serialize a decimal value piece-by-piece.
      * Exposed `decimal_unpack()` as `box_decimal_mp_decode_data()` to keep a
        consistent terminogoly around msgpack encoding/decoding.
      * More detailed API description, grouping by functionality.
      
      The script, which helps to calculate sizes around `decimal_t`:
      
      ```lua
      -- See notes in decNumber.h.
      
      -- DECOPUN: DECimal Digits Per UNit
      local function unit_size(DECOPUN)
          assert(DECOPUN > 0 and DECOPUN < 10)
          if DECOPUN <= 2 then
              return 1
          elseif DECOPUN <= 4 then
              return 2
          end
          return 4
      end
      
      function sizeof_decimal_t(digits, DECOPUN)
          -- int32_t digits;
          -- int32_t exponent;
          -- uint8_t bits;
          -- <..padding..>
          -- <..units..>
          local us = unit_size(DECOPUN)
          local padding = us - 1
          local unit_count = math.ceil(digits / DECOPUN)
          return 4 + 4 + 1 + padding + us * unit_count
      end
      
      function string_buffer(digits)
          -- -9.{9...}E+999999999# (# is '\0')
          -- ^ ^      ^^^^^^^^^^^^
          return digits + 14
      end
      
      function binary_signed(digits)
          local x = 1
          while math.log10(2 ^ (x - 1)) < digits do
              x = x + 1
          end
          return x - 1
      end
      
      function binary_unsigned(digits)
          local x = 1
          while math.log10(2 ^ x) < digits do
              x = x + 1
          end
          return x - 1
      end
      
      function digits_for_binary_signed(x)
          return math.ceil(math.log10(2 ^ (x - 1)))
      end
      
      function digits_for_binary_unsigned(x)
          return math.ceil(math.log10(2 ^ x))
      end
      
      function summary(digits)
          print('digits', digits)
          local sizeof_min = math.huge
          local sizeof_max = 0
          local DECOPUN_sizeof_min
          local DECOPUN_sizeof_max
          for DECOPUN = 1, 9 do
              local sizeof = sizeof_decimal_t(digits, DECOPUN)
              print('sizeof', sizeof, 'DECOPUN', DECOPUN)
              if sizeof < sizeof_min then
                  sizeof_min = sizeof
                  DECOPUN_sizeof_min = DECOPUN
              end
              if sizeof > sizeof_max then
                  sizeof_max = sizeof
                  DECOPUN_sizeof_max = DECOPUN
              end
          end
          print('sizeof min', sizeof_min, 'DECOPUN', DECOPUN_sizeof_min)
          print('sizeof max', sizeof_max, 'DECOPUN', DECOPUN_sizeof_max)
          print('string', string_buffer(digits))
          print('int???_t', binary_signed(digits))
          print('uint???_t', binary_unsigned(digits))
      end
      ```
      
      Part of #7228
      
      @TarantoolBot document
      Title: Module API for decimals
      
      See the declarations in `src/box/decimal.h` in tarantool sources.
      5c1bc3da
  24. Aug 01, 2022
    • Alexander Turenko's avatar
      fiber_channel: add accessor to internal functions · 395c30e8
      Alexander Turenko authored
      The Rust module [1] leans on several internal symbols. They were open in
      Tarantool 2.8 (see #2971 and #5932), but never were in the public API.
      Tarantool 2.10.0 hides the symbols and we need a way to get them back to
      use in the module.
      
      We have the following options:
      
      1. Design and expose a module API for fiber channels.
      2. Export the symbols with a prefix like `tnt_internal_` (to don't spoil
         the global namespace).
      3. Provide a `dlsym()` alike function to get an address of an internal
         symbol for users who knows what they're doing.
      
      I think that the third way offers the best compromise between amount of
      effort, quality of the result and opportunities to extend. In this
      commit I hardcoded the list of functions to make the change as safe as
      possible. Later I'll return here to autogenerate the list.
      
      Exported the following function from the tarantool executable:
      
      ```c
      void *
      tnt_internal_symbol(const char *name);
      ```
      
      I don't add it into the module API headers, because the function is to
      perform a dark magic and we don't suggest it for users.
      
      While I'm here, added `static` to a couple of fiber channel functions,
      which are only used within the compilation unit.
      
      [1]: https://github.com/picodata/tarantool-module
      
      Part of #7228
      Related to #6372
      
      NO_DOC=don't advertize the dangerous API
      NO_CHANGELOG=don't advertize the dangerous API
      395c30e8
  25. Jul 26, 2022
    • Alexander Turenko's avatar
      tuple: add JSON path field accessor to module API · bcca0b2b
      Alexander Turenko authored
      Added a function (see the API in the documentation request below), which
      reflects the `tuple[json_path]` Lua API (see #1285).
      
      Part of #7228
      
      @TarantoolBot document
      Title: tuple: access a field using JSON path via module API
      
      The following function is added into the module API:
      
      ```c
      /**
       * Return a raw tuple field in the MsgPack format pointed by
       * a JSON path.
       *
       * The JSON path includes the outmost field. For example, "c" in
       * ["a", ["b", "c"], "d"] can be accessed using "[2][2]" path (if
       * index_base is 1, as in Lua). If index_base is set to 0, the
       * same field will be pointed by the "[1][1]" path.
       *
       * The first JSON path token may be a field name if the tuple
       * has associated format with named fields. A field of a nested
       * map can be accessed in the same way: "foo.bar" or ".foo.bar".
       *
       * The return value is valid until the tuple is destroyed, see
       * box_tuple_ref().
       *
       * Return NULL if the field does not exist or if the JSON path is
       * malformed or invalid. Multikey JSON path token [*] is treated
       * as invalid in this context.
       *
       * \param tuple a tuple
       * \param path a JSON path
       * \param path_len a length of @a path
       * \param index_base 0 if array element indexes in @a path are
       *        zero-based (like in C) or 1 if they're one-based (like
       *        in Lua)
       * \retval a pointer to a field data if the field exists or NULL
       */
      API_EXPORT const char *
      box_tuple_field_by_path(box_tuple_t *tuple, const char *path,
      			uint32_t path_len, int index_base);
      ```
      bcca0b2b
  26. Jul 22, 2022
  27. Jun 22, 2022
    • Mergen Imeev's avatar
      sql: drop testcase() · b93f68d2
      Mergen Imeev authored
      This macro does nothing, so it is dropped.
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      b93f68d2
  28. May 22, 2022
  29. May 20, 2022
    • Timur Safin's avatar
      datetime: implement date.isdst · aec6fbac
      Timur Safin authored
      Properly calculate `isdst` field in datetime Lua object and
      for attribute returned by `:totable()` function.
      
      NO_DOC=next commit
      aec6fbac
    • Maxim Kokryashkin's avatar
      luajit: bump submodule · f40ad50d
      Maxim Kokryashkin authored
      LuaJIT submodule is bumped to introduce the following changes:
      * sysprof: change C configuration API
      * sysprof: enrich symtab on a new trace or a proto
      * sysprof: fix SYSPROF_HANDLER_STACK_DEPTH
      * sysprof: make internal API functions static
      * sysprof: add LUAJIT_DISABLE_SYSPROF to Makefile
      * symtab: check the _GNU_SOURCE definition
      
      Within this changeset Tarantool-specific backtrace handler is introduced
      and set to be used by sysprof machinery.
      
      Besides, all new public Lua C API introduced within this changeset is
      added to extra/exports.
      
      Follows up #781
      
      NO_DOC=LuaJIT submodule bump
      NO_TEST=LuaJIT submodule bump
      NO_CHANGELOG=LuaJIT submodule bump
      f40ad50d
    • Mergen Imeev's avatar
      sql: introduce operator [] · 814befe8
      Mergen Imeev authored
      This patch introduces operator [] that allows to get elements from MAP
      and ARRAY values.
      
      Closes #4762
      Closes #4763
      Part of #6251
      
      @TarantoolBot document
      Title: Operator [] in SQL
      
      Operator `[]` allows to get an element of MAP and ARRAY values.
      Examples:
      ```
      tarantool> box.execute([[SELECT [1, 2, 3, 4, 5][3];]])
      ---
      - metadata:
        - name: COLUMN_1
          type: any
        rows:
        - [3]
      ...
      
      tarantool> box.execute([[SELECT {'a' : 123, 7: 'asd'}['a'];]])
      ---
      - metadata:
        - name: COLUMN_1
          type: any
        rows:
        - [123]
      ...
      ```
      
      The returned values is of type ANY.
      
      If the operator is applied to a value that is not a MAP or ARRAY or is
      NULL, an error is thrown.
      
      Example:
      ```
      tarantool> box.execute([[SELECT 1[1];]])
      ---
      - null
      - Selecting is only possible from map and array values
      ...
      ```
      
      However, if there are two or more operators next to each other, the
      second or following operators do not throw an error, but instead
      return NULL.
      
      Example:
      ```
      tarantool> box.execute([[select [1][1][2][3][4];]])
      ---
      - metadata:
        - name: COLUMN_1
          type: any
        rows:
        - [null]
      ...
      ```
      814befe8
  30. May 11, 2022
    • Timur Safin's avatar
      datetime: handle timezone names in tz · 7036b55a
      Timur Safin authored
      Since recently we partially support timezone names (i.e. as
      abbreviations) so we may modify tz attribute support for
      datetime constructors or :set() operations.
      
      Closes #7076
      Relates to #7007
      
      @TarantoolBot document
      Title: datetime tz attribute
      
      Now `tz` attribute is properly handled in datetime value
      constructors or `:set{}` method modifiers.
      
      ```
      tarantool> T = date.new{year = 1980, tz = 'MSK'}
      ---
      ...
      
      tarantool> T.tzoffset
      ---
      - 180
      ...
      
      tarantool> T.tz
      ---
      - MSK
      ...
      tarantool> T = date.new{year = 1980, tzoffset = 180}
      ---
      ...
      
      tarantool> T.tzindex
      ---
      - 0
      ...
      
      tarantool> T.tz
      ---
      -
      ...
      
      tarantool> T.tzoffset
      ---
      - 180
      ...
      
      tarantool> T:set{tz = 'MSK'}
      ---
      ...
      
      tarantool> T.tz
      ---
      - MSK
      ...
      
      ```
      7036b55a
  31. Apr 29, 2022
  32. Apr 28, 2022
    • Yaroslav Lobankov's avatar
      ci: fix jepsen testing · 45bc9281
      Yaroslav Lobankov authored
      Fix the following error:
      
          {"badRequest": {"message": "The requested availability zone is not
          available", "code": 400}}
      
      NO_DOC=testing stuff
      NO_TEST=testing stuff
      NO_CHANGELOG=testing stuff
      45bc9281
  33. Apr 25, 2022
    • Maxim Kokryashkin's avatar
      luajit: bump new version · c6b038b0
      Maxim Kokryashkin authored
      LuaJIT submodule is bumped to introduce the following changes:
      * GC64: disable sysprof support
      * build: make -DLUAJIT_DISABLE_SYSPROF work
      * test: disable sysprof C API tests with backtrace
      * tools: introduce parsers for sysprof
      * sysprof: introduce Lua API
      * memprof: add profile common section
      * core: introduce lua and platform profiler
      * memprof: move symtab to a separate module
      * core: separate the profiling timer from lj_profile
      * vm: save topframe info into global_State
      
      Within this changeset a parser for binary data dumped via the sampling
      profiler to Tarantool binary. It is a set of the following Lua modules:
      * sysprof/parse.lua: decode the sampling profiler event stream
      * sysprof/collapse.lua: collapse stacks obtained while profiling
      * sysprof.lua: Lua script and module to display data
      
      Besides, all new public Lua C API introduced within this changeset is
      added to extra/exports.
      
      Closes #781
      
      NO_DOC=LuaJIT submodule bump
      NO_TEST=LuaJIT submodule bump
      c6b038b0
    • Mergen Imeev's avatar
      sql: introduce field type INTERVAL · 1c0fccbb
      Mergen Imeev authored
      This patch introduces basic INTERVAL support in SQL. After this patch,
      it will be allowed to select INTERVAL values from spaces, insert them
      into spaces, and use them in functions. CAST() from INTERVAL to STRING
      and ANY is also supported.
      
      Part of #6773
      
      NO_DOC=Will be added later.
      NO_CHANGELOG=Will be added later.
      1c0fccbb
Loading