Skip to content
Snippets Groups Projects
  1. Oct 21, 2019
  2. Oct 20, 2019
    • Nikita Pettik's avatar
      sql: remove expmask from prepared statement · 8aa685fb
      Nikita Pettik authored
      expmask indicated necessity to recompile statement after parameter was
      bound: it might turn out that parameter can affect query plan. However,
      part of this mechanism has been removed long ago as a SQLite's legacy.
      In its current state expmask is likely to be useless and assertions
      involving it are obviously unsuitable. This patch completely removes
      expmask and related routines.
      
      Closes #4566
      8aa685fb
  3. Oct 17, 2019
    • Vladislav Shpilevoy's avatar
      console: fix usage of an undeclared variable · 89ec1d97
      Vladislav Shpilevoy authored
      
      Console client's eval() method in case of an error at
      reading from a socket was trying to return a variable
      declared in a different view scope. Instead, the
      error should be raised to drop the connection.
      
      Reviewed-by: default avatarAlexander Turenko <alexander.turenko@tarantool.org>
      89ec1d97
    • Cyrill Gorcunov's avatar
      box/console: test for exact command before setting eos · 092cd675
      Cyrill Gorcunov authored
      
      When we handle unix console connection we should setup
      eos if only we meet "\set output" command in a stream.
      For example there could be "\set language" which should
      not affect eos settings.
      
      Closes #4568
      
      Reported-by: default avatarAlexander Turenko <alexander.turenko@tarantool.org>
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      Reviewed-by: default avatarAlexander Turenko <alexander.turenko@tarantool.org>
      092cd675
    • Cyrill Gorcunov's avatar
      box/console: move param handlers into file scope · 44bfb4f1
      Cyrill Gorcunov authored
      
      This will allow us to reuse this map in other routines
      and same time optimize memory allocation a bit.
      
      Part-of #4568
      
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      Reviewed-by: default avatarAlexander Turenko <alexander.turenko@tarantool.org>
      44bfb4f1
    • Kirill Shcherbatov's avatar
      sql: check returned value type for UDF · 439a48f2
      Kirill Shcherbatov authored
      All user-defined functions feature type of returned value (if it
      is not specified during function creation, it is assumed to be
      ANY), but currently it is ignored. This patch introduces check
      which verifies that returned value is of specified in function's
      definition type. There's no attempt at implicit conversion to
      specified (target) type - returned value must be literally of
      the specified type.
      
      Closes #4387
      439a48f2
    • Kirill Shcherbatov's avatar
      sql: better LUA arguments conversion for UDFs · 0a6daf7a
      Kirill Shcherbatov authored
      Start using comprehensive serializer luaL_tofield() to prepare
      LUA arguments for UDFs. This allows to support cdata types
      returned from Lua function.
      
      Needed for #4387
      
      @TarantoolBot document
      Title: UDF returning nil or box.NULL in SQL
      
      Values nil and box.NULL returned by UDF in SQL
      both transformed to SQL NULL and are equal.
      
      Example:
      tarantool> box.execute("SELECT LUA('return box.NULL') is NULL
                                     and LUA('return nil') is NULL")
      ---
      - metadata:
        - name: LUA('return box.NULL') is NULL and LUA('return nil') is NULL
          type: boolean
        rows:
        - [true]
      ...
      0a6daf7a
    • Kirill Shcherbatov's avatar
      sql: errors for UDFs returning too many values · 50efe95e
      Kirill Shcherbatov authored
      This patch introduces handling the situation when UDF returns
      too many values. Previously Tarantool used to silently use
      the first value returned. Now an error is raised.
      
      Moreover a test coverage is improved also for the situation when
      no value is returned.
      
      Needed for #4387
      50efe95e
    • Vladislav Shpilevoy's avatar
      wal: drop rows_per_wal option · c6012920
      Vladislav Shpilevoy authored
      Rows_per_wal option was deprecated because it can be covered by
      wal_max_size. In order not to complicate WAL code with that
      option's support this commit drops it completely.
      
      In some tests the option was used to create several small xlog
      files. Now the same is done via wal_max_size. Where it was
      needed, number of rows per wal is estimated as wal_max_size / 50.
      Because struct xrow_header size ~= 50 not counting paddings and
      body.
      
      Note, file box/configuration.result was deleted here, because it
      is a stray result file, and it contained the rows_per_wal option
      mentioning. Its test was dropped much earlier in
      fdc3d1dd.
      
      Closes #3762
      c6012920
    • Vladislav Shpilevoy's avatar
      test: replication/misc cleanup box.cfg.replication · 399899a1
      Vladislav Shpilevoy authored
      In patch c6bea65f I
      added a bug - replication/misc leaves a bad value in
      box.cfg.replication. Before that patch the test was
      resetting this to empty replication. In my patch I
      forgot about that, and left there the value
      
          {box.cfg.listen, "12345"}
      
      This patch cleans it up.
      
      Follow up #3760
      399899a1
  4. Oct 16, 2019
    • Kirill Shcherbatov's avatar
      sql: use name instead of function pointer for UDF · de9a7b1a
      Kirill Shcherbatov authored
      This patch changes OP_Function parameters convention: now a
      function's name is passed instead of pointer to the function
      object. This allows to normally handle the situation, when UDF
      has been deleted to the moment of the VDBE code execution.
      In particular case this may happen with CK constraints that
      refers to a deleted persistent function.
      
      Closes #4176
      de9a7b1a
    • 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
    • Kirill Shcherbatov's avatar
      box: add an ability to disable CK constraints · 9a058bb2
      Kirill Shcherbatov authored
      Now it is possible to disable and enable ck constraints in LUA.
      This option is persistent. All ck constraints are constructed
      in enabled state when Tarantool is configured. This ability
      may be usefulwhen processed data is verified and constraints
      validation is not required. For instance, during casual recovery
      process there's no need to provide any checks since data is
      assumed to be consistent.
      
      Persisting is_enabled flag is an important feature.
      If the option is not stored the following scenario is
      possible:
      - the option is turned off
      - data is changed so that a constraint is violated
      - the system is restarted while the option state is lost
      - there is no way (even in theory) to discover it and find that
        data is incorrect.
      
      Part of #4244
      9a058bb2
  5. Oct 15, 2019
    • Alexander Turenko's avatar
      test: update test-run · 18864835
      Alexander Turenko authored
      test_run:wait_upstream() and test_run:wait_downstream() now wait until
      an upstream / a downstream appears. This prevents an attempt to index a
      nil value when one of those functions are called before a record about a
      peer appears in box.info.replication. It was observed on
      replication/show_error_on_disconnect test after commit
      c6bea65f ('replication: recfg with 0
      quorum returns immediately').
      
      Fixes #4563.
      18864835
    • Kirill Shcherbatov's avatar
      sql: remove redundant pointer in TriggerStep · a50be270
      Kirill Shcherbatov authored
      The trigger pointer in the sql_trigger structure is a dead code
      now, so it could be deleted.
      
      Needed for #4343
      a50be270
  6. Oct 14, 2019
    • Mergen Imeev's avatar
      sql: AUTOINCREMENT for multipart PK · 08c7d7c1
      Mergen Imeev authored
      Prior to this patch, the auto-increment feature could only be set
      in an INTEGER field of PRIMARY KEY if the PRIMARY KEY consisted of
      a single field. It was not possible to use this feature if the
      PRIMARY KEY consisted of more than one field. This patch defines
      two ways to set AUTOINCREMENT for any INTEGER or UNSIGNED field of
      PRIMARY KEY.
      
      Closes #4217
      
      @TarantoolBot document
      Title: The auto-increment feature for multipart PK
      The auto-increment feature can be set to any INTEGER or UNSIGNED
      field of PRIMARY KEY using one of two ways:
      1) AUTOINCREMENT in column definition:
      CREATE TABLE t (i INT, a INT AUTOINCREMENT, PRIMARY KEY (i, a));
      CREATE TABLE t (i INT AUTOINCREMENT, a INT, PRIMARY KEY (i, a));
      2) AUTOINCREMENT in PRIMARY KEY definition:
      CREATE TABLE t (i INT, a INT, PRIMARY KEY (i, a AUTOINCREMENT));
      CREATE TABLE t (i INT, a INT, PRIMARY KEY (i AUTOINCREMENT, a));
      08c7d7c1
  7. Oct 12, 2019
    • Vladislav Shpilevoy's avatar
      replication: recfg with 0 quorum returns immediately · c6bea65f
      Vladislav Shpilevoy authored
      Replication quorum 0 not only affects orphan status, but also,
      according to documentation, makes box.cfg() return immediately
      regardless of whether connections to upstreams are established.
      
      It was not so before the patch. What is worse, even with non 0
      quorum the instance was blocked on reconfiguration for connect
      timeout seconds, if at least one node is not connected.
      
      Now quorum is respected on reconfiguration. On a bootstrap it is
      still impossible to return earlier than
      replication_connect_timeout, because nodes need to choose some
      cluster settings. Too early start would make it impossible -
      cluster's participants will just start and choose different
      cluster UUIDs.
      
      Closes #3760
      c6bea65f
  8. Oct 09, 2019
    • Serge Petrenko's avatar
      replication: add is_orphan field to ballot · dc1e4009
      Serge Petrenko authored
      A successfully fetched remote instance ballot isn't updated during
      bootstrap procedure. This leads to a case when different instances
      choose different masters as their bootstrap leaders.
      
      Imagine such a situation.
      You start instance A without replication set up. Instance A successfully
      bootstraps.
      You also have instances B and C both with replication set up to {A, B,
      C} and replication_connect_quorum set to 3
      You first start instance B. It doesn't proceed to choosing a leader
      until one of the events happens: either the replication_connect_timeout
      runs out, or instance C is up and starts listening on its port.
      B has established connection to A and fetched its ballot, with some
      vclock, say, {1: 1}.
      B retries connection to C every replication_timeout seconds.
      Then you start instance C. Instance C succeeds in connecting to A and B
      right away and bootstraps from instance A. Instance A registers C in its
      _cluster table. This registration is replicated to instance C.
      Meanwhile, instance C is trying to sync with quorum instances (which is
      3), and stays in orphan mode.
      Now replication_timeout on instance B finally runs out. It retries a
      previously unsuccessful connection to C and succeeds. C sends its ballot
      to B with vclock = {1: 2, 2:0} (in our example), since it has already
      incremented it after _cluster registration.
      B sees that C has a greater vclock than A, and chooses to bootstrap from
      C instead of A. C is orphan and rejects B's attempt to join. B dies.
      
      To fix such ungentlemanlike behaviour of C, we should at least include
      loading status in ballot and prefer fully bootstrapped instances to the
      ones still syncing with other replicas.
      We also need to use a separate flag instead of ballot's already existent
      is_ro, since we still want to prefer loading instances over the ones
      explicitly configured to be read-only.
      
      Closes #4527
      dc1e4009
    • Kirill Yukhin's avatar
    • Cyrill Gorcunov's avatar
      box/console: Fix missing variable declaration · df821d0f
      Cyrill Gorcunov authored
      
      During rework of the console lua mode series
      the declaration of variable has been lost and
      this cause test case for remote unix console
      connection to fail.
      
      Fixes issue from c358398c
      
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@gmail.com>
      df821d0f
  9. Oct 04, 2019
  10. Oct 01, 2019
    • Roman Khabibov's avatar
      Fix 53d43160 · 0b9de586
      Roman Khabibov authored
      0b9de586
    • Roman Khabibov's avatar
      json: clarify bad syntax error messages · 53d43160
      Roman Khabibov authored
      Count lines in the json parsing structure. It is needed to print
      the number of line and column where a mistake was made.
      
      Closes #3316
      
      (cherry picked from commit 9f9bd3eb2d064129ff6b1a764140ebef242d7ff7)
      53d43160
    • Vladislav Shpilevoy's avatar
      app: exit gracefully when a main script throws an error · 157a2d88
      Vladislav Shpilevoy authored
      Code to run main script (passed via command line args, or
      interactive console) has a footer where it notifies systemd,
      logs a happened error, and panics.
      
      Before the patch that code was unreachable in case of any
      exception in a main script, because panic happened earlier. Now a
      happened exception is correctly carried to the footer with proper
      error processing.
      
      A first and obvious solution was replace all panics with diag_set
      and use fiber_join on the script runner fiber. But appeared, that
      the fiber running a main script can't be joined. This is because
      normally it exits via os.exit() which never returns and therefore
      its caller never dies = can't be joined.
      
      The patch solves this problem by passing main fiber diag to the
      script runner by pointer, eliminating fiber_join necessity.
      
      Closes #4382
      157a2d88
  11. Sep 27, 2019
    • Ilya Kosarev's avatar
      test: fix replica expectance in broken lsn test · cd01573c
      Ilya Kosarev authored
      xlog/panic_on_broken_lsn includes waiting for replica and then
      box.info.vclock usage. Sometimes box.info.vclock was giving wrong
      values. Now it is stable due to improved replica expectation
      criterion.
      
      Closes #4508
      cd01573c
  12. Sep 25, 2019
    • Vladislav Shpilevoy's avatar
      app: raise an error on too nested tables serialization · d7a8942a
      Vladislav Shpilevoy authored
      Closes #4434
      Follow-up #4366
      
      @TarantoolBot document
      Title: json/msgpack.cfg.encode_deep_as_nil option
      
      Tarantool has several so called serializers to convert data
      between Lua and another format: YAML, JSON, msgpack.
      
      YAML is a crazy serializer without depth restrictions. But for
      JSON, msgpack, and msgpackffi a user could set encode_max_depth
      option. That option led to crop of a table when it had too many
      nested levels. Sometimes such behaviour is undesirable.
      
      Now an error is raised instead of data corruption:
      
          t = nil
          for i = 1, 100 do t = {t} end
          msgpack.encode(t) -- Here an exception is thrown.
      
      To disable it and return the old behaviour back here is a new
      option:
      
          <serializer>.cfg({encode_deep_as_nil = true})
      
      Option encode_deep_as_nil works for JSON, msgpack, and msgpackffi
      modules, and is false by default. It means, that now if some
      existing users have cropping, even intentional, they will get the
      exception.
      d7a8942a
    • Vladislav Shpilevoy's avatar
      tuple: use global msgpack serializer in Lua tuple · 676369b1
      Vladislav Shpilevoy authored
      Tuple is a C library exposed to Lua. In Lua to translate Lua
      objects into tuples and back luaL_serializer structure is used.
      
      In Tarantool we have several global serializers, one of which is
      for msgpack. Tuples store data in msgpack, and in theory should
      have used that global msgpack serializer. But in fact the tuple
      module had its own private serializer because of tuples encoding
      specifics such as never encode sparse arrays as maps.
      
      This patch makes tuple Lua module use global msgpack serializer
      always. But how does tuple handle sparse arrays now? In fact,
      the tuple module still has its own serializer, but it is updated
      each time when the msgpack serializer is changed.
      
      Part of #4434
      676369b1
    • Vladislav Shpilevoy's avatar
      msgpack: make msgpackffi use encode_max_depth option · 4bb253f7
      Vladislav Shpilevoy authored
      Msgpack Lua module is not a simple set of functions. It is a
      global serializer object used by plenty of other Lua and C
      modules. Msgpack as a serializer can be configured, and in theory
      its configuration updates should affect all other modules. For
      example, a user could change encode_max_depth:
      
          require('msgpack').cfg({encode_max_depth = <new_value>})
      
      And that would make tuple:update() accept tables with <new_value>
      depth without a crop.
      
      But in fact msgpack configuration didn't affect some places, such
      as this one. And all the others who use msgpackffi.
      
      This patch fixes it, for encode_max_depth option. Other options
      are still ignored.
      
      Part of #4434
      4bb253f7
    • Vladislav Shpilevoy's avatar
      app: serializers update now is reflected in Lua · fe4a8047
      Vladislav Shpilevoy authored
      There are some objects called serializers - msgpack, cjson, yaml,
      maybe more. They are global objects affecting both Lua and C
      modules.
      
      A serializer have settings which can be updated. But before the
      patch an update changed only C structure of the serializer. It
      made impossible to use settings of the serializers from Lua.
      
      Now any update of any serializer is reflected both in its C and
      Lua structures.
      
      Part of #4434
      fe4a8047
Loading