Skip to content
Snippets Groups Projects
  1. Jul 19, 2018
    • Kirill Yukhin's avatar
      sql: do not allow oversized integer literals · bb93eeae
      Kirill Yukhin authored
      Before the patch, big integer constants were silently
      converted to floating point values. Fix that by issuing
      error message if value doesn't fit in int64_t range.
      
      Also, refactor surrounding code as per Tarantool's code style.
      
      Closes #2347
      bb93eeae
  2. Jul 17, 2018
    • Ivan Koptelov's avatar
      sql: add index_def to Index · 0bc63674
      Ivan Koptelov authored
      Now every sqlite struct Index is created with tnt
      struct index_def inside. This allows us to use tnt
      index_def in work with sqlite indexes in the same
      manner as with tnt index and is a step to remove
      sqlite Index with tnt index.
      Fields coll_array, coll_id_array, aiColumn,
      sort_order, aiRowLogEst and zName are removed from
      Index. All usages of this fields changed to usage of
      corresponding index_def or index_def->opts fields.
      index_is_unique(), sql_index_collation() and
      index_column_count() are removed with calls of
      index_def corresponding fields.
      Also there is small change in behavior: before the
      patch a statement like
      CREATE TABLE t1(a,b, PRIMARY KEY(a,b), UNIQUE(a,b))
      created only one constraint index (for primary key)
      and no index for UNIQUE constraint (since it is upon
      the same columns), neither it is named or non-named
      constraint.
      After the patch index will be always created for named
      constraints. It is a temporary solution. In future
      it's preferable not to create an index, but to make
      some record in _constraints space that this named
      unique constraint implemented with the same index as
      primary key constraint.
      
      Closes: #3369, #3498
      0bc63674
    • Kirill Yukhin's avatar
      Merge branch '1.10' into 2.0 · 09d7a5da
      Kirill Yukhin authored
      09d7a5da
    • Kirill Shcherbatov's avatar
      sql: assertion fault on select after analyze · b92589c7
      Kirill Shcherbatov authored
      Binary search in whereKeyStats function that uses routine
      sqlite3VdbeRecordCompareMsgpack returned invalid result,
      because it made wrong assumption about the number of
      coinciding index columns based on _sql_stat4.
      But all collected index statistics were wrong.
      
      The analyzeOneTable routine used to call sqlite3GetTempRange
      and sqlite3ReleaseTempRange functions inside of cycle intensively
      changes Parser->nMem value. Thanks this pattern routine
      sqlite3ReleaseTempRange could push nMem variable onto aTempReg
      queue. As Parser->nMem could be bigger next time, this
      variable may be used twice:
      
                [74, 'Column', 4, 1, 11, '', '00', 'r[11]=']
                [75, 'Column', 4, 2, 12, '', '00', 'r[12]=']
      |->       [76, 'Column', 4, 3, 13, '', '00', 'r[13]=']
                [77, 'Column', 4, 4, 14, '', '00', 'r[14]=']
      !rewrite  [78, 'Column', 4, 0, 13, '', '00', 'r[13]=ID']
                [79, 'MakeRecord', 13, 1, 6, '', '00',
                 'r[6]=mkrec(r[13])']
      
      Thus all assumptions about data below should be invalid and
      some artifacts could exhibit.
      
      Example:
      \set language sql
      CREATE TABLE t1(id INTEGER PRIMARY KEY AUTOINCREMENT, a,
      		b, c, f, d, e);
      CREATE INDEX i1 ON t1(a, b, c, f, d);
      \set language lua
      for i = 0, 100 do
          box.sql.execute(string.format("INSERT INTO t1 VALUES(null,
      		    'x', 'y', 'z', 'a', %s, %s);", i,
      		    math.floor(i / 2)))
      end
      \set language sql
      SELECT * FROM "_sql_stat4";
      ---
      ['T1', 'I1', '101 101 1 1 1', '0 0 44 44 44', '0 0 44 44 44',
       ['x', 'y', 'z', 'a', 44]]
      ---
      
      Expected:
      ---
      ['T1', 'I1', '101 101 101 101 1', '0 0 0 0 44', '0 0 0 0 44',
       ['x', 'y', 'z', 'a', 44]]
      ---
      
      Resolves #2847.
      b92589c7
    • Vladimir Davydov's avatar
      vinyl: fix potential use-after-free in vy_read_view_merge · 18d1acbd
      Vladimir Davydov authored
      If is_first_insert flag is set and vy_stmt_type(rv->tuple) equals
      IPROTO_DELETE, we free rv->tuple, but then we dereference it via
      an on-stack variable to check if we need to turn a REPLACE into an
      INSERT or vice versa. Fix this.
      18d1acbd
    • Vladimir Davydov's avatar
      vinyl: do not pass region explicitly to write iterator functions · 32854f40
      Vladimir Davydov authored
      This is not necessary, as we can use fiber()->gc, as we usually do.
      32854f40
    • Vladimir Davydov's avatar
      test: unit/vy_write_iterator: minor refactoring · 8c447591
      Vladimir Davydov authored
      Move key_def creation to compare_write_iterator_results as it is the
      same for all test cases. Performance is not an issue here, obviously, so
      we can close our eyes to the fact that now we create a new key def for
      each test cases.
      8c447591
    • Vladimir Davydov's avatar
      stailq: add stailq_insert function · 37502562
      Vladimir Davydov authored
      The new function inserts a new item into the list at the specified
      postion.
      37502562
  3. Jul 16, 2018
  4. Jul 13, 2018
  5. Jul 12, 2018
  6. Jul 11, 2018
    • Vladimir Davydov's avatar
      box: factor out local recovery function · ab5c8a22
      Vladimir Davydov authored
       - Factor out local_recovery() from box_cfg_xc(). Make it setup
         replication and handle local recovery and hot standby cases.
       - Move replication setup in case of initial bootstrap from box_cfg_xc()
         to bootstrap() to make bootstrap() consistent with local_recovery().
       - Move initial snapshot creation from bootstrap() to bootsrap_master()
         and bootstrap_from_master().
      
      Needed for #461
      ab5c8a22
    • Vladimir Davydov's avatar
      box: connect to remote peers before starting local recovery · 2c32252b
      Vladimir Davydov authored
      box_sync_replication() can now be called before recovery, right after
      box_listen(). This is a step toward detecting if the instance fell too
      much behind its peers in the cluster and so needs to be rebootstrapped.
      
      Needed for #461
      2c32252b
    • Vladimir Davydov's avatar
      box: open the port before starting local recovery · 601bb92a
      Vladimir Davydov authored
      In order to find out if the current instance fell too much behind its
      peers in the cluster and so needs to be re-bootstrapped we need to
      connect it to remote peers before proceeding to local recovery. The
      problem is box.cfg.replication may have an entry corresponding to the
      instance itself so before connecting we have to start listening to
      incoming connections. So this patch moves the call to box_listen()
      before recoery is started unless the instance in hot standby mode.
      It also folds box_bind() into box_listen() as it is no longer needed
      as a separate function.
      
      Needed for #461
      601bb92a
    • Vladimir Davydov's avatar
      box: retrieve end vclock before starting local recovery · 0695fbbb
      Vladimir Davydov authored
      In order to find out if the current instance fell too much behind its
      peers in the cluster and so needs to be rebootstrapped, we need to know
      its vclock before we start local recovery. To do that, let's scan the
      most recent xlog. In future, we can optimize that by either storing end
      vclock in xlog eof marker or by making a new xlog on server stop.
      
      Needed for #461
      0695fbbb
    • Vladimir Davydov's avatar
      xlog: get rid of xlog_meta::has_prev_vclock · fa46ed59
      Vladimir Davydov authored
      Introduce vclock_is_set() helper and use it on xlog_meta::prev_vclock
      instead.
      
      Follow-up ac90b498 ("xlog: store prev vclock in xlog header").
      fa46ed59
    • Vladislav Shpilevoy's avatar
      sql: remove OP_LoadPtr · 9c36ef5b
      Vladislav Shpilevoy authored
      This opcode was used when Vdbe had to store key_def in P4 for
      OP_OpenRead/Write, so P4 was occupied and OP_LoadPtr was used to
      store space pointer in another opcode. But now P4 is free for
      OpenRead/Write and space pointer can be stored here.
      
      Alongside, some useless key_def duplications are removed.
      9c36ef5b
    • Kirill Shcherbatov's avatar
      sql: refactor vdbe_emit_open_cursor calls · 6c6162e4
      Kirill Shcherbatov authored
      Made vdbe_emit_open_cursor calls consistent:
      now it uses index id everywhere.
      This required to change a way to detect that
      VDBE has openned Read cursor to specified table
      in vdbe_has_table_read to write result of insert
      in temp table if required.
      6c6162e4
    • Kirill Shcherbatov's avatar
      sql: remove usless sqlite3NestedParse function · b118296b
      Kirill Shcherbatov authored
      As sqlite3NestedParse became totaly useless, let's
      remove unreacheble code and all mentioning.
      
      Resolves #3496.
      b118296b
    • Kirill Shcherbatov's avatar
      sql: get rid off sqlite3NestedParse in clean stats · 47e1e4db
      Kirill Shcherbatov authored
      Now we manually generate AST structures to drop outdated
      stats from _sql_stat1 and _sql_stat4 spaces instead of
      starting sqlite3NestedParse. This function becomes totally
      useless and could be removed.
      
      Part of #3496.
      47e1e4db
  7. Jul 10, 2018
Loading