Skip to content
Snippets Groups Projects
  1. Aug 20, 2019
    • Kirill Shcherbatov's avatar
      sql: remove SQL_FUNC_SLOCHNG flag · c33f0804
      Kirill Shcherbatov authored
      The SQL_FUNC_SLOCHNG flag was useful for datetime function
      that are currently not supported. So it could be removed.
      
      Needed for #2200, #4113, #2233
      c33f0804
    • Kirill Shcherbatov's avatar
      sql: rename OP_Function to OP_BuiltinFunction · 2437b059
      Kirill Shcherbatov authored
      Renamed OP_Function opcode to OP_BuiltinFunction to introduce a
      new OP_Function operation in a new meaning: a new OP_Function
      would call Tarantool's function with new port-based API while
      legacy OP_BuiltinFunction is an efficient implementation of
      SQL Builtins functions.
      
      Needed for #2200, #4113, #2233
      2437b059
    • Kirill Shcherbatov's avatar
      sql: rework SQL_FUNC_COUNT flag semantics · 1d69f568
      Kirill Shcherbatov authored
      Tarantool's SQL engine generates a different VDBE bytecode
      for ..COUNT(*).. and ..COUNT(fieldname).. operations:
      the first one produces a lightweight OP_Count operation that uses
      native mechanism to report the count of record in index while
      the second one pessimistically opens a space read iterator and
      uses Count aggregate function.
      
      A helper routine is_simple_count decides whether such
      optimisation is correct. It used to use SQL_FUNC_COUNT flag to
      mark a dummy (non-functional) function entry with 0 arguments.
      This patch changes SQL_FUNC_COUNT semantics: now it is a marker
      of any COUNT function, while is_simple_count relies on count
      of arguments to distinguish aggregate and non-aggregate
      functions.
      
      Needed for #2200, #4113, #2233
      1d69f568
    • Kirill Shcherbatov's avatar
      sql: wrap all trim functions in dispatcher · 77e4c842
      Kirill Shcherbatov authored
      A new dispatcher function trim_func calls corresponding trim_
      function implementation in relation with number of argc - a count
      of arguments.
      
      This is an important step to get rid of function's name
      overloading required for replace FuncDef cache with Tarantool's
      function cache.
      
      Needed for #2200, #4113, #2233
      77e4c842
    • Kirill Shcherbatov's avatar
      sql: GREATEST, LEAST instead of MIN/MAX overload · a46b5200
      Kirill Shcherbatov authored
      This patch does two things: renames existing scalar min/max
      functions and reserves names for them in NoSQL cache.
      
      Moreover it is an important step to get rid of function's name
      overloading required for replace FuncDef cache with Tarantool's
      function cache.
      
      Closes #4405
      Needed for #2200, #4113, #2233
      
      @TarantoolBot document
      Title: Scalar functions MIN/MAX are renamed to LEAST/GREATEST
      
      The MIN/MAX functions are typically used only as aggregate
      functions in other RDBMS(MSSQL, Postgress, MySQL, Oracle) while
      Tarantool's SQLite legacy code use them also in meaning
      GREATEST/LEAST scalar function. Now it fixed.
      a46b5200
    • Kirill Shcherbatov's avatar
      sql: remove SQL_PreferBuiltin flag · 79f3bf4b
      Kirill Shcherbatov authored
      The SQL_PreferBuiltin flag is redundant (because builtin names
      are forbidden for UDFs) so we may to remove it.
      
      Needed for #4113, #2200, #2233
      79f3bf4b
    • Kirill Shcherbatov's avatar
      sql: improve vdbe_field_ref fetcher · 72279c1c
      Kirill Shcherbatov authored
      Vdbe field ref is a dynamic index over tuple fields storing
      offsets to each field and filling the offset array on demand.
      It is highly used in SQL, because it strongly relies on fast and
      repetitive access to any field, not only indexed.
      
      There is an optimisation for the case when a requested field
      fieldno is indexed, and the tuple itself stores offset to the
      field in its own small field map, used by indexes. vdbe_field_ref
      then uses that map to retrieve offset value without decoding
      anything. But when SQL requests any field > fieldno, then
      vdbe_field_ref decodes the tuple from the beginning in the worst
      case. Even having previously accessed fieldno. But it could
      start decoding from the latter.
      
      An updated vdbe_field_ref fetcher class uses a bitmask of
      initialized slots to use pre-calculated offsets when possible.
      This speed-ups SQL in some corner case and doesn't damage
      performance in general scenarios.
      
      Closes #4267
      72279c1c
  2. Aug 19, 2019
  3. Aug 16, 2019
    • Konstantin Osipov's avatar
      gc: randomie the next checkpoint time also after a manual box.snapshot(). · 6277f48a
      Konstantin Osipov authored
      Before this patch, snapshot interval was set randomly within
      checkpoint_interval period. However, after box.snapshot(), the next
      snapshot was scheduled exactly checkpoint_interval from the current time.
      Many orchestration scripts snapshot entire cluster right after deployment,
      to take a backup. This kills randomness, since all instances begin to
      count the next checkpoint time from the current time.
      
      Randomize the next checkpoint time after a manual snapshot as well.
      
      Fixes gh-4432
      6277f48a
    • Alexander Turenko's avatar
      test: update test-run · 05fb6faa
      Alexander Turenko authored
      pretest_clean: preserve GREATEST and LEAST built-in functions.
      
      Needed for #4405.
      05fb6faa
    • 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
    • Nikita Pettik's avatar
      Hotfix for b7d595ac · 0894bec2
      Nikita Pettik authored
      It was forgotten to update result file of sql/bind.test.lua
      in previous patch. Let's fix that and refresh sql/bind.result with
      up-to-date results.
      0894bec2
  4. Aug 15, 2019
  5. Aug 14, 2019
    • Vladimir Davydov's avatar
      wal: make wal_sync fail on write error · 2d5e56ff
      Vladimir Davydov authored
      wal_sync() simply flushes the tx<->wal request queue, it doesn't
      guarantee that all pending writes are successfully committed to disk.
      This works for now, but in order to implement replica join off the
      current read view, we need to make sure that all pending writes have
      been persisted and won't be rolled back before we can use memtx
      snapshot iterators. So this patch adds a return code to wal_sync():
      since now on it returns -1 if rollback is in progress and hence
      some in-memory changes are going to be rolled back. We will use
      this method after opening memtx snapshot iterators used for feeding
      a consistent read view a newly joined replica so as to ensure that
      changes frozen by the iterators have made it to the disk.
      2d5e56ff
    • Alexander V. Tikhonov's avatar
      test: app/socket flaky fails at 1118 line · 952d8d1d
      Alexander V. Tikhonov authored
      Found that on high loaded hosts the test flaky fails at:
      
      [004] --- app/socket.result	Mon Jul 15 07:18:57 2019
      [004] +++ app/socket.reject	Tue Jul 16 16:37:35 2019
      [004] @@ -1118,7 +1118,7 @@
      [004]  ...
      [004]  ch:get(1)
      [004]  ---
      [004] -- true
      [004] +- null
      [004]  ...
      [004]  s:error()
      [004]  ---
      
      Found that the test in previous was used for testing the
      the channel get() function timeout and the error occurred
      on it, but later the checking error changed to:
      "builtin/socket.lua: attempt to use closed socket" and the
      test became not correct. Because for now it passes when the
      socket read function runs before the socket closing, but in
      this way read call doesn't wait. In the other way on high
      loaded hosts the close call may occure before read call and
      in this way read call halts and socket get call returns
      'null'. As seen both ways are not correct to check the error.
      Decided to remove this subtest.
      
      Check commit ba7a4fee ("Add tests for socket:close closes #360")
      
      Fixes #4354
      952d8d1d
    • Vladimir Davydov's avatar
      xrow: factor out helper for setting REPLACE request body · e687cacd
      Vladimir Davydov authored
      We will reuse it to relay a snapshot to a newly joined replica.
      e687cacd
    • Vladimir Davydov's avatar
      memtx: allow snapshot iterator to fail · aef84078
      Vladimir Davydov authored
      Memtx iterators never fail, that's why the snapshot iterator interface
      doesn't support failures. However, once we introduce snapshot iterator
      support for vinyl, we will need a way to handle errors in the API.
      aef84078
    • Vladimir Davydov's avatar
      memtx: don't store pointers to index internals in iterator · a22f2219
      Vladimir Davydov authored
      It's pointless as we can always access the index via iterator->index.
      a22f2219
    • Vladimir Davydov's avatar
      vinyl: move reference counting from vy_lsm to index · 7e11dd4f
      Vladimir Davydov authored
      Now, as vy_lsm and index are basically the same object, we can implement
      reference counting right in struct index. This will allow us to prevent
      an index from destruction when a space object it belongs to is freed
      anywhere in the code, not just in vinyl.
      7e11dd4f
    • Vladimir Davydov's avatar
      vinyl: embed index in vy_lsm · 576611eb
      Vladimir Davydov authored
      There's no point in having vinyl_engine and vinyl_index wrapper structs
      to bind vy_env and vy_lsm to struct engine and index. Instead we can
      simply embed engine and index in vy_env and vy_lsm. This will simplify
      further development, e.g. this will allow us to move reference counting
      from vy_lsm up to struct index so that it can be used in the generic
      code.
      576611eb
    • Vladimir Davydov's avatar
      vinyl: embed engine in vy_env · a771c2e5
      Vladimir Davydov authored
      There's no point in having vinyl_engine and vinyl_index wrapper structs
      to bind vy_env and vy_lsm to struct engine and index. Instead we can
      simply embed engine and index in vy_env and vy_lsm. This will simplify
      further development, e.g. this will allow us to move reference counting
      from vy_lsm up to struct index so that it can be used in the generic
      code.
      a771c2e5
    • Serge Petrenko's avatar
      decimal: add modulo operator · 8ea7106a
      Serge Petrenko authored
      Part of #4403
      
      @TarantoolBol document
      Title: Document decimal modulo operator
      
      There is now a modulo operator for decimal numbers:
      ```
      a = decimal.new(172.51)
      a % 1
      ---
      - '0.51'
      ...
      a % 0.3
      ---
      - '0.01'
      ...
      a % 13.27
      ---
      - '0.00'
      ...
      a % 173
      ---
      - '172.51'
      ...
      a % 72
      ---
      - '28.51'
      ...
      720 % a
      ---
      - '29.96'
      ...
      ```
      8ea7106a
  6. Aug 13, 2019
    • Vladislav Shpilevoy's avatar
      json: detect a new invalid json path case · ef64ee51
      Vladislav Shpilevoy authored
      JSON paths has no a strict standard, but definitely there is no
      an implementation, allowing to omit '.' after [], if a next token
      is a key. For example:
      
          [1]key
      
      is invalid. It should be written like that:
      
          [1].key
      
      Strangely, but we even had tests on the invalid case.
      
      Closes #4419
      ef64ee51
  7. Aug 11, 2019
  8. Aug 09, 2019
    • Vladislav Shpilevoy's avatar
      test: fix flaky swim/errinj.test.lua · 4b893910
      Vladislav Shpilevoy authored
      In one place that test sends a packet and expects that it has
      arrived two lines below. Under high load it may take more time.
      The patch makes the test explicitly wait for the packet arrival.
      
      Closes #4392
      4b893910
  9. Aug 08, 2019
    • Yaroslav Dynnikov's avatar
      Expose tarantool_package value to lua api (#4412) · 2e97c607
      Yaroslav Dynnikov authored
      There is compile time option PACKAGE in cmake to define
      current build distribution info. By default it's
      "Tarantool" for the community version and "Tarantool Enterprise"
      for the enterprise version.
      
      It's displayed in console greeting and in `box.info().package`,
      but, unfortunately, it can't be accessed from Lua before `box.cfg`.
      
      This patch exposes `require('tarantool').package`.
      
      Close #4408
      
      @TarantoolBot document
      Title: Extend module "tarantool" with the field "package"
      
      Beside from build info and version, module "tarantool" now provides
      "package" field. By default it equals string "Tarantool", but
      can differ for other distributions like "Tarantool Enterprise".
      
      Example:
      
      ```console
      tarantool> require('tarantool')
      ---
      - version: 2.3.0-3-g302bb3241
        build:
          target: Linux-x86_64-RelWithDebInfo
          options: cmake . -DCMAKE_INSTALL_PREFIX=/opt/tarantool-install
      -DENABLE_BACKTRACE=ON
          mod_format: so
          flags: ' -fexceptions -funwind-tables -fno-omit-frame-pointer
      -fno-stack-protector
            -fno-common -fopenmp -msse2 -std=c11 -Wall -Wextra
      -Wno-strict-aliasing -Wno-char-subscripts
            -Wno-format-truncation -fno-gnu89-inline -Wno-cast-function-type'
          compiler: /usr/bin/cc /usr/bin/c++
        pid: 'function: 0x40016cd0'
        package: Tarantool
        uptime: 'function: 0x40016cb0'
      ...
      
      ```
      2e97c607
  10. Aug 06, 2019
    • Kirill Shcherbatov's avatar
      box: make functional index creation transactional · 302bb324
      Kirill Shcherbatov authored
      The _func_index space trigger used to reject an insertion of a
      tuple that defines an invalid functional index.
      As insertion in _index space had been completed before, a garbage
      is kept in _index space in such case.
      
      We need to do something with the yelding _func_index trigger(that
      rebuilds an index) to wrap all index creation operation in DDL
      transaction in further patches (because only the first DDL
      operation may yeld now).
      
      This problem could be trivially solved with preparatory
      initialization of index_def function ponter: the memtx_tree
      index construction would perform all required job in such case.
      Therefore the following index rebuild in _func_index trigger
      becomes redundant and should be omitted.
      
      In other words, a trivial prefetch operation makes possible
      a transactional index creation (with space:create_index operation).
      
      As for index construction during recovery (a lack of function
      cache during recovery was the main motivation to introduce
      _func_index space), it's workflow is kept unchanged.
      
      Follow up #1250
      Needed for #4348
      Closes #4401
      302bb324
    • Vladimir Davydov's avatar
      rfc: vylog ups and downs · 27436b40
      Vladimir Davydov authored
      As per request by Kostja, commit an RFC document with a brief history of
      the vinyl metadata log infrastructure, issues it was intended to solve,
      problems we are facing now, and possible ways to solve them.
      27436b40
  11. Aug 02, 2019
    • Vladimir Davydov's avatar
      relay: stop relay on subscribe error · 35ef3320
      Vladimir Davydov authored
      In case an error occurs between relay_start() and cord_costart() in
      relay_subscribe(), the relay status won't be reset to STOPPED. As a
      result, any further attempt to re-subscribe will fail with ER_CFG:
      duplicate connection with the same replica UUID. This may happen, for
      example, if the WAL directory happens to be temporarily inaccessible on
      the master.
      
      Closes #4399
      35ef3320
    • Kirill Yukhin's avatar
    • Cyrill Gorcunov's avatar
      box/console: Don't allow arguments in get_default_output · 4138645e
      Cyrill Gorcunov authored
      The function
      
       | require('console').get_default_output()
      
      requires no arguments. Make it explcicit and print
      an error otherwise.
      
      Part-of #3834
    • Cyrill Gorcunov's avatar
      box/console: Test for nil value in args directly · 69d4d53d
      Cyrill Gorcunov authored
      Instead of allocating a variable for optional args
      testing we should use dot notation instead. Otherwise
      it won't work for trivial test case as
      
      ```
      require('console').set_default_output('lua,block')
      require('decimal').new('1234.5678')
      ```
      
       | builtin/box/console.lua:47: expected decimal, number or string as 2 argument
      
      and program exits.
      
      Part-of #3834
      69d4d53d
    • Cyrill Gorcunov's avatar
      box/console: Drop redundant status parameter from return · df71cbdc
      Cyrill Gorcunov authored
      In output_verify_opts and output_parse we return status variable
      to point if function processed without error. This is redundant
      we can simply return either error or nil, which is enough.
      
      Part-of #3834
      df71cbdc
    • Nikita Pettik's avatar
      sql: make default type of NULL be boolean · ffccbbd8
      Nikita Pettik authored
      It was decided that null value in SQL by default should be of type
      boolean. Justification of such change is that according to ANSI boolean
      type in fact has three different values: true, false and unknown. The
      latter is basically an alias to null value.
      ffccbbd8
    • Nikita Pettik's avatar
      sql: make default constraint names be consistent · 45f61e0d
      Nikita Pettik authored
      If during creation of constraint its name is not specified, then it is
      generated automatically. Occasionally, default names for each type of
      constraint turn out to be different. This patch makes them follow the
      same pattern: "shortcut"_unnamed_"table_name"_"ordinal_numb". For
      instance: fk_unnamed_T1_1 or ck_unnamed_T1_3 etc
      45f61e0d
    • Nikita Pettik's avatar
      sql: don't mangle name of unique constraint · 1f783f26
      Nikita Pettik authored
      If UNIQUE constraint is specified in CREATE TABLE statement and it has
      given name, one is mangled with pattern "unique_%s_%d", where %s is
      original name of constraint and %d - current iid. For instance:
      
      CREATE TABLE t (id INT PRIMARY KEY, a INT CONSTRAINT i1 UNIQUE);
      
      This statement results in secondary index creation with name
      "unique_I1_1". Justification for mangling is that constraint namespace
      should be independent from index namespace. However, ALTER TABLE ADD
      CONSTRAINT UNIQUE which is alias to CREATE INDEX doesn't mangle name.
      What is more, users may wonder why name of index is different from
      name of created constraint. Hence, it has been decided to remove this
      mangling and create index exactly with specified constraint's name.
      1f783f26
Loading