Skip to content
Snippets Groups Projects
  1. Jan 26, 2018
  2. Jan 25, 2018
  3. Jan 24, 2018
    • Nikita Pettik's avatar
      sql: add collations and DESC for ephemeral table · 98c2c276
      Nikita Pettik authored
       - Added ability to specify collations for ephemeral tables.
       - Enabled DESC sorting order. It is implemented as ASC, but rows are
         taken from sorting table in reversed order. Currently, it is
         impossbile to specify more than one sorting order for all columns in
         ORDER BY clause due to incapability of iterating through different
         orders in Tarantool.  As soon as this feature is added to Tarantool, it
         will be implemeted in SQL.
       - Fixed code generation for adding rows to ephemeral table while
         coroutine yields.
       - Temporary disabled tests which used different sorting orders in one
         query.
      
      Part of #2680
      98c2c276
    • Nikita Pettik's avatar
      sql: fix code generation for VIEWs · 0420a313
      Nikita Pettik authored
      Since VIEW materializes into ephemeral table with ROWID in original SQLite,
      it was requited to adapt code generation for UPDATE and DELETE
      statements on VIEWs.
      
      Part of #2680
      0420a313
    • Nikita Pettik's avatar
      sql: replace all usages of OP_OpenEphemeral · 10ccea4e
      Nikita Pettik authored
       - Autoindexes are temporary disabled since they rely on ephemeral
         tables with ROWID. WITHOUT ROWID (in SQLite meaning) tables are known
         to be unable to support autoindex optimization.
       - ORDER BY optimization is also temporary disabled: transient ephemeral
         table contains all columns from SELECT statement plus columns from
         ORDER BY statement without excluding their intersection.
       - Replaced all generated occurrences of OP_OpenEphemeral including
         those which used ROWID with OP_OpenTEphemeral opcode.
       - Fixed tests which rely on mnemonic of opcode creating epehemral
         table.
      
      Part of #2680
      10ccea4e
    • Nikita Pettik's avatar
      sql: add mechanism to emulate ROWID · 257cfeb2
      Nikita Pettik authored
      It is worth mentioning, that there are two types of ephemeral tables:
      one holds rows as they are inserted (all rows turn out to be distinct);
      another adds ROWID column in order to hold equal rows.  Inasmuch as
      original ROWID mechanism is to be removed, the purpose of this patch is
      to emulate ROWID behavior for ephemeral tables.
      
       - Substituted all ephemeral table opcodes which don't rely on SQLite's
         ROWID with Tarantool ones.
       - Implemeted opcode OP_NextIdEphemeral to emulate behavior of ROWID
         feature.  In current implemetation ROWID is not hidden PK index, but
         just another one column to keep in table equal tuples.
       - Substituted old ephemeral tables with ROWID for INSERT INTO ...
         SELECT ... FROM statement. It utilizes ephemeral tables as
         intermediate holder for data from SELECT
         (before it is inserted to table).
      
      Part of #2680
      257cfeb2
    • Nikita Pettik's avatar
      sql: complete API for ephemeral tables · 66169c92
      Nikita Pettik authored
       - Completed implementing tarantoolSqlite3Ephemeral* API.  Added
         functions: Last, Next, Previous, Delete, Unpack.
       - Added support of ephemeral tables for IN expression.
       - Added support of ephemeral tables for sub-select queries.
       - Fixed tests, which rely on the name of ephemeral creation opcode.
      
      Part of #2680
      66169c92
    • Nikita Pettik's avatar
      sql: introduce Tarantool's ephemeral tables · c741896d
      Nikita Pettik authored
       - Added intermediate functions between SQL and Tarantool,
         tarantoolSqlite3Ephemeral* in order to create and use Tarantool's
         ephemeral tables. Also, for this reason added BTCF_TEphemeral flag to
         BtCursor instead of BTCF_TaCursor to call appropriate functions.
       - Added struct space* to SQL cursor, which allows to delete ephemeral
         tables.  (since ephemeral tables don't have space_id and it is
         impossible to find them by traditional space_id lookup). Moreover, it
         enables us to avoid using box API inasmuch as we can directly call
         space_execute_* functions having struct space*.
       - As the first stage of implemenation, ephemeral tables were
         successfully replaced for DELETE FROM ... WHERE statement. It utilized
         ephemeral space as intermediate holder where all tuples to be removed
         are placed before actual deletion.
      
      Part of #2680
      c741896d
    • Nikita Pettik's avatar
      Add replace/delete functions for ephemeral spaces · 9a9d2786
      Nikita Pettik authored
      Ephemeral tables shouldn't be involved in any transaction routine,
      since they are used only for internal needs. Moreover, ephemeral spaces
      can be created and destroyed within one transaction, which may lead to
      incorrect behaviour. Thus, ephemeral replace and delete don't take txn
      as an argument.
      
      Furthermore, delete operation should work on tuples with nulls in primary key.
      As a rule, it is considered to be bad practice, due to ambiguity when
      deleting tuple from space with several tuples containing nulls in PK.
      On the other hand, ephemeral spaces are used only for internal needs,
      so if it is guaranteed that no such situation occur, it is OK to allow
      insertion nulls in PK. Hence, function which implements deletion on ephemeral
      tables, doesn't check tuple on null fields.
      
      Currently, supported only by memtx engine.
      9a9d2786
    • Nikita Pettik's avatar
      Rework memtx replace function · 880712c9
      Nikita Pettik authored
      By now, replace function takes new tuple and old tuple as arguments, instead
      of single txn_stmt. It has been done in order to avoid abusing txn_stmt:
      the only usage was extracting tuples from it.
      As a result, this function can be used by ephemeral tables
      without any patching.
      880712c9
    • Vladimir Davydov's avatar
      Introduce ephemeral spaces · d8593931
      Vladimir Davydov authored
      Ephemeral spaces are invisible via public API and they are not
      persistent. They are needed solely to do some transient calculations.
      
      To create an ephemeral space, use space_new_ephemeral() function,
      which takes a space definition and a list of index definitions as
      arguments. A space created with this function may be accessed and
      modified via internal API (space_execute_replace(), index_get(),
      etc).
      
      Currently, only the memtx engine supports ephemeral spaces.
      
      Closes #2776
      d8593931
    • Kirill Yukhin's avatar
      sql: add parser generated source · 41876f70
      Kirill Yukhin authored
      Add forgotten box/sql/parse.c source which is being
      regenerated in -DSQL_MAINTAINER_MODE=1 only.
      41876f70
    • Kirill Yukhin's avatar
      sql: Disable asserts for release builds · 8d7bfe97
      Kirill Yukhin authored
      Macro SQLITE_DEBUG was set unconditionally, so both release build
      modes had debugging enabled, including all asserts() and TESTCASE().
      Move this macro definition under check if mode is Debug and fix all
      warning which arised after disabling asserts().
      Most of them are unused variables.
      8d7bfe97
    • Kirill Yukhin's avatar
      sql: Enable asserts for box/sql.c · 7a8de281
      Kirill Yukhin authored
      Since asserts were always disbled in src/box/sql.c, number
      of issues were hidden. This patch enables asserts for mentioned
      file by disabling set of NDEBUG in box/src/sqliteInt.h.
      Also this patch fixes incorrect assertions about strlen() and
      assertion that fieldno should always be less than format->field_count.
      This assert is not always hold, e.g. for _schema space where max_id
      is stored behind formatted fields.
      
      Closes #3057
      7a8de281
    • Vladislav Shpilevoy's avatar
      Fix build on Mac · 76b8092f
      Vladislav Shpilevoy authored
      76b8092f
    • Georgy Kirichenko's avatar
      Fix typo · 4bceb9e6
      Georgy Kirichenko authored
      4bceb9e6
    • Kirill Yukhin's avatar
      sql: add regenerated pase file. · 67a9422e
      Kirill Yukhin authored
      Add forgotten in previous commit regenerated box/sql/parse.c
      67a9422e
  4. Jan 23, 2018
    • Vladislav Shpilevoy's avatar
      alter: introduce ModifySpaceFormat alter operation · 9f6113ab
      Vladislav Shpilevoy authored
      ModifySpaceFormat operation sets new names into old tuple formats.
      
      Closes #3011
      9f6113ab
    • Vladislav Shpilevoy's avatar
      tuple: move tuple field names hash to a separate shared struct · c94034df
      Vladislav Shpilevoy authored
      Struct tuple_dictionary stores hash of field names, defined in
      a space format. The structure is refable and are going to be used
      to share new field names with old space formats.
      
      Part of #3011
      c94034df
    • Vladimir Davydov's avatar
      txn: fix on_replace trigger chaining · 653cbcec
      Vladimir Davydov authored
      If there are multiple on_replace triggers installed for the same space
      and one of them creates a new statement (by issuing a DML request), then
      the trigger that is called next will get the statement created by the
      previous trigger instead of the original statement. To fix that, let's
      patch txn_current_stmt() so as to return the first statement at the
      current transaction level instead of the last statement and use it in
      txn_commit_stmt(). This will also allow us to issue DML requests from a
      before_replace trigger without disrupting the current statement.
      
      Needed for #2993
      Follow-up #3020
      653cbcec
    • Vladimir Davydov's avatar
      txn: fix rollback of sub-statements · 5ea035ba
      Vladimir Davydov authored
      If space.on_replace callback fails (throws), we must rollback all
      statements inserted by the callback before failing and the statement
      that triggered the callback while currently we only rollback the last
      statement on txn->stmts list. To fix this, let's remember the position
      to rollback to in case of failure for each sub statement, similarly to
      how we do with savepoints.
      
      Note, there's a comment to txn_rollback_stmt() that says that it doesn't
      remove the last statement from the txn->stmts list, just clears it:
      
              /**
               * Void all effects of the statement, but
               * keep it in the list - to maintain
               * limit on the number of statements in a
               * transaction.
               */
              void
              txn_rollback_stmt()
      
      It isn't going to hold after this patch, because this patch reuses the
      savepoint code to rollback statements on failure. Anyway, I haven't
      managed to figure out why we would ever need to keep statements on the
      list after rollback. The comment is clearly misleading as we don't have
      any limits on the number of statements, and even if we had, a statement
      counter would suffice. I guess the real reason why we don't delete
      statements from the list is that it is simply impossible to do in case
      of a singly linked list like stailq, but now it isn't going to be a
      problem. So remove the comment and the test case of engine/savepoint
      which relies on it.
      
      Needed for #2993
      Closes #3020
      5ea035ba
    • Vladimir Davydov's avatar
      Replace stailq_splice with stailq_cut_tail · 86c19c32
      Vladimir Davydov authored
      stailq_splice(head1, item, head2) moves elements from list 'head1'
      starting from 'item' to list 'head2'. To follow the protocol, it needs
      to know the element previous to 'item' in 'head1' so as to make it the
      new last element of 'head1'. To achieve that, it has to loop over
      'head1', which is inefficient. Actually, wherever we use this function,
      we know in advance the element stailq_splice() has to look up, but we
      still pass the next one, making its life difficult and obscuring the
      code at the caller's side.
      
      For example, look at how stailq_splice() is used in txn.c:
      
              if (stmt == NULL) {
                      rollback_stmts = txn->stmts;
                      stailq_create(&txn->stmts);
              } else {
                      stailq_create(&rollback_stmts);
                      stmt = stailq_next_entry(stmt, next);
                      stailq_splice(&txn->stmts, &stmt->next, &rollback_stmts);
              }
      
      while under the hood stailq_splice() has the loop to find 'stmt':
      
              stailq_splice(struct stailq *head1, struct stailq_entry *elem,
                            struct stailq *head2)
              {
                      if (elem) {
                              *head2->last = elem;
                              head2->last = head1->last;
                              head1->last = &head1->first;
                              while (*head1->last != elem)
                                      head1->last = &(*head1->last)->next;
                              *head1->last = NULL;
                      }
              }
      
      This is utterly preposterous.
      
      Let's replace stailq_splice() with a new method with the same signature,
      but with a slightly different semantics: move all elements from list
      'head1' starting from the element *following* 'item' to list 'head2'; if
      'item' is NULL, move all elements from 'head1' to 'head2'. This greatly
      simplifies the code for both parties, as the callee doesn't have to loop
      any more while the caller doesn't have to handle the case when 'item' is
      NULL.
      
      Also, let's change the name of this function, because stailq_splice()
      sounds kinda confusing: after all, this function tears a list in two
      first and only then splices the tail with another list. Let's remove the
      'splice' part altogether (anyway, there's another function for splicing
      lists - stailq_concat()) and call it stailq_cut_tail().
      86c19c32
    • Vladimir Davydov's avatar
      txn: zap txn_savepoint->is_first flag · 2634306f
      Vladimir Davydov authored
      This flag isn't necessary as we can set txn_savepoint->stmt to NULL when
      a savepoint is created inside an empty transaction. Using a separate
      flag for this purpose obscures the code flow and complicates further
      progress so let's remove it.
      2634306f
    • IlyaMarkovMipt's avatar
      box: make box.NULL available before box.cfg · 7bd84cc5
      IlyaMarkovMipt authored
      * Add NULL key word to whitelist of keywords available before box.cfg.
      
      Closes #3032
      7bd84cc5
    • Georgy Kirichenko's avatar
      Cache proc names for backtrace · 0280771a
      Georgy Kirichenko authored
      libunwind get_proc_name consumes too much time, so use a hash for
      to cache mapping of ip (instruction pointer) to proc_name+offset.
      
      Fixes #2877
      0280771a
    • AKhatskevich's avatar
      box: allow printable and only printable characters in identifiers · 4789babc
      AKhatskevich authored
      Before this patch, we would only allow alphabetical characters
      plus underscore in identifier names. And we did not treat
      all identifiers the same way: column names were not checked
      at all.
      
      SQL ANSI ISO allow delimited identifiers cantain any character
      from source language character set.
      
      After this patch, checks for allowed characters in identifier
      names follow the same ruls for all identifiers: column names,
      function names, user names, space names, index names.
      
      In other words, this patch makes tarantool itentifier rules closer
      to ANSI ones.
      
      Closes #2914
      4789babc
    • Kirill Yukhin's avatar
      sql: Ban ALTER TABLE ADD COLUMN · 5163872d
      Kirill Yukhin authored
      Currently, only ALTER TABLE RENAME is supported in SQL. Ban
      ALTER TABLE ADD COLUMN in the grammar until it is supported.
      Corresponding issue submitted: #3075
      
      Closes #2607
      5163872d
    • Konstantin Osipov's avatar
      lua: fix a typoe in error message · 07653cf8
      Konstantin Osipov authored
      07653cf8
  5. Jan 22, 2018
    • Konstantin Belyavskiy's avatar
      Fix compilation warning in cmp_def.h · f09860de
      Konstantin Belyavskiy authored
      According to offsetof(3) type of its return value is size_t.
      Assigning result of offsetof() to a variable of type ptrdiff_t
      may result in compilation warnings on certain platforms:
      
        src/box/key_def.cc:57:2: error: non-constant-expression cannot be narrowed from type 'size_t' (aka 'unsigned long') to 'ptrdiff_t' (aka 'long') in initializer list [-Wc++11-narrowing]
                OPT_DEF_ENUM(PART_OPT_TYPE, field_type, struct key_part_def, type,
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        src/box/opt_def.h:76:19: note: expanded from macro 'OPT_DEF_ENUM'
                { key, OPT_ENUM, offsetof(opts, field), sizeof(int), #enum_name, \
                                 ^~~~~~~~~~~~~~~~~~~~~
        src/trivia/util.h:193:32: note: expanded from macro 'offsetof'
        #define offsetof(type, member) ((size_t) &((type *)0)->member)
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Fix this by changing the type of opt_def::offset from ptrdiff_t to
      size_t.
      
      Closes #2930
      f09860de
    • Konstantin Osipov's avatar
  6. Jan 19, 2018
  7. Jan 18, 2018
    • Konstantin Osipov's avatar
      iproto: make compile under clang 3.8 · 359d3229
      Konstantin Osipov authored
      iproto_msg used to be a non-POD struct because of : public cmsg, and
      offsetof(), introduced in the fix for gh-946, couldn't be legally used
      with it.
      
      Make it a POD struct, in preparation for moving iproto to plain C.
      359d3229
    • Vladimir Davydov's avatar
      call: fail requests that do not close transaction · f003b489
      Vladimir Davydov authored
      Currently, if a CALL/EVAL request leaves an open transaction at return,
      we silently rollback it and print a warning to the log mentioning the
      function name or eval expression to facilitate further debugging. After
      issue #946 was fixed, we can't do that anymore, because request input,
      which stores CALL/EVAL parameters, may be discarded before request
      completion and hence be unavailable for logging. Without additional
      information pointing at the culprit, the log message is pointless (see
      issue #1100). We could copy the arguments, but that would slow down CALL
      execution, which can't be justified solely by the need of verbose
      logging. So let's stop being lenient and fail requests that do not close
      transaction at return. This should encourage negligent users to finally
      fix their code.
      
      Follow-up #946
      f003b489
    • Vladimir Davydov's avatar
      iproto: discard CALL/EVAL input on yield · 3bc7f4e6
      Vladimir Davydov authored
      Currently, a long polling request can stall all other connections,
      because the input buffer can't be reclaimed until it is completed.
      Funny thing is CALL/EVAL only needs input for a short time, to decode
      arguments from msgpack and push them to stack, after that point the
      input can be safely discarded.
      
      So this patch makes tx_process_call() setup a trigger before executing
      the CALL/EVAL request. The trigger is invoked on fiber yield. The
      trigger's callback sends a message back to the iproto thread notifying
      it that tx has processed the request input. Upon receiving such a
      message, iproto discards the request input and resumes suspended
      connections, if any.
      
      Closes #946
      3bc7f4e6
    • Vladimir Davydov's avatar
      call: separate function invocation from result encoding · d461caf3
      Vladimir Davydov authored
      The iproto subsystem switches between two output buffers once in a while
      in order to reclaim memory so passing a pointer to the output buffer
      directly to box_process_call() or box_process_eval() is incorrect in
      case the called function yields. To fix that, let's make these functions
      return the CALL/EVAL result in a port object, which then can then be
      encoded in msgpack with port_dump().
      
      Needed for #946
      d461caf3
    • Vladimir Davydov's avatar
      Make struct port abstract · d5e479ee
      Vladimir Davydov authored
      So that it can be used not only for serializing a list of tuples, but
      also for serializing a Lua stack that stores output of CALL/EVAL.
      
      Needed for #946
      d5e479ee
    • Kirill Yukhin's avatar
      sql: Fix build for FreeBSD · e2c08028
      Kirill Yukhin authored
      There're 3 places where FreeBSD specific routines
      contained (for compatibility) unused parameters.
      Mark them w/ unused attribute.
      
      Closes #3037
      e2c08028
    • Roman Tsisyk's avatar
      Travis CI: remove Ubuntu Zesty · 176b5d07
      Roman Tsisyk authored
      Remove all non-LTS versions of Ubuntu.
      176b5d07
Loading