Skip to content
Snippets Groups Projects
  1. Mar 07, 2019
    • Nikita Pettik's avatar
      sql: replace BLOB as column type with SCALAR · 0d0f53aa
      Nikita Pettik authored
      BLOB column type is represented by SCALAR field type in terms of NoSQL.
      We attempted at emulating BLOB behaviour, but such efforts turn out to
      be not decent enough. For this reason, we've decided to abandon these
      attempts and fairly replace it with SCALAR column type.  SCALAR column
      type acts in the same way as it does in NoSQL: it is aggregator-type for
      INTEGER, NUMBER and STRING types. So, column declared with this type can
      contain values of these three (available in SQL) types. It is worth
      mentioning that CAST operator in this case does nothing.
      
      Still, we consider BLOB values as entries encoded in msgpack with MP_BIN
      format. To make this happen, values to be operated should be represented
      in BLOB form x'...' (e.g. x'000000'). What is more, there are two
      built-in functions returning BLOBs: randomblob() and zeroblob().  On the
      other hand, columns with STRING NoSQL type don't accept BLOB values.
      
      Closes #4019
      Closes #4023
      
      @TarantoolBot document
      Title: SQL types changes
      There are couple of recently introduced changes connected with SQL
      types.
      
      Firstly, we've removed support of DATE/TIME types from parser due to
      confusing behaviour of these types: they were mapped to NUMBER NoSQL
      type and have nothing in common with generally accepted DATE/TIME types
      (like in other DBs). In addition, all built-in functions related to
      these types (julianday(), date(), time(), datetime(), current_time(),
      current_date() etc) are disabled until we reimplement TIME-like types as
      a native NoSQL ones (see #3694 issue).
      
      Secondly, we've removed CHAR type (i.e. alias to VARCHAR and TEXT). The
      reason is that according to ANSI SQL CHAR(len) must accept only strings
      featuring length exactly equal to given in type definition. Obviously,
      now we don't provide such checks. Types VARCHAR and TEXT are still
      legal.
      
      For the same reason, we've removed NUMERIC and DECIMAL types, which were
      aliases to NUMBER NoSQL type. REAL, FLOAT and DOUBLE are still exist as
      aliases.
      
      Finally, we've renamed BLOB column type to SCALAR. We've decided that
      all our attempts to emulate BLOB behaviour using SCALAR NoSQL type don't
      seem decent enough, i.e. without native NoSQL type BLOB there always
      will be inconsistency, especially taking into account possible NoSQL-SQL
      interactions. In SQL SCALAR type works exactly in the same way as in
      NoSQL: it can store values of INTEGER, FLOAT and TEXT SQL types at the
      same time. Also, with this change behaviour of CAST operator has been
      slightly corrected: now cast to SCALAR doesn't affect type of value at
      all. Couple of examples:
      
      CREATE TABLE t1 (a SCALAR PRIMARY KEY);
      INSERT INTO t1 VALUES ('1');
      SELECT * FROM t1 WHERE a = 1;
      -- []
      Result is empty set since column "a" contains string literal value '1',
      not integer value 1.
      
      CAST(123 AS SCALAR); -- Returns 123 (integer)
      CAST('abc' AS SCALAR); -- Returns 'abc' (string)
      
      Note that in NoSQL values of BLOB type defined as ones decoded in
      msgpack with MP_BIN format. In SQL there are still a few ways to force
      this format: declaring literal in "BLOB" format (x'...') or using one of
      two built-in functions (randomblob() and zeroblob()). TEXT and VARCHAR
      SQL types don't accept BLOB values:
      
      CREATE TABLE t (a TEXT PRIMARAY KEY);
      INSERT INTO t VALUES (randomblob(5));
      ---
      - error: 'Tuple field 1 type does not match one required: expected string'
      ...
      
      BLOB itself is going to be reimplemented in scope of #3650.
      0d0f53aa
    • Nikita Pettik's avatar
      sql: remove support of NUMERIC type from parser · 696db264
      Nikita Pettik authored
      NMERIC and DECIMAL were allowed to be specified as column types. But in
      fact, they were just synonyms for FLOAT type and mapped to NUMERIC
      Tarantool NoSQL type. So, we've decided to remove this type from parser
      and return back when NUMERIC will be implemented as a native type.
      
      Part of #4019
      696db264
    • Nikita Pettik's avatar
      sql: remove support of DATE/TIME from parser · 3caeb33c
      Nikita Pettik authored
      Currently, there is no native (in Tarantool terms) types to represent
      time-like types. So, until we add implementation of those types, it
      makes no sense to allow to specify those types in table definition.
      Note that previously they were mapped to NUMBER type. For the same
      reason all built-in functions connected with DATE/TIME are disabled as
      well.
      
      Part of #4019
      3caeb33c
  2. Feb 27, 2019
  3. Feb 21, 2019
    • Michał Durak's avatar
      lua: add 'chars' param to string.strip functions · 16f58830
      Michał Durak authored
      Add optional 'chars' parameter to string.strip, string.lstrip
      and string.rstrip for specifying the unwanted characters.
      Behavior modeled after the equivalent Python built-ins.
      
      Closes: #2977
      
      @TarantoolBot document
      Title: string.strip(inp, chars)
      Update the documentation for string.strip,
      string.lstrip and string.rstrip to reflect
      the addition of the optional param.
      16f58830
  4. Feb 13, 2019
  5. Feb 11, 2019
  6. Jan 30, 2019
    • Serge Petrenko's avatar
      lua: patch os.exit() to execute on_shutdown triggers. · 6dc4c8d7
      Serge Petrenko authored
      Make os.exit() call tarantool_exit(), just like the signal handler does.
      Now on_shutdown triggers are not run only when a fatal signal is
      received.
      
      Closes #1607
      
      @TarantoolBot document
      Title: Document box.ctl.on_shutdown triggers
      on_shutdown triggers may be set similar to space:on_replace triggers:
      ```
      box.ctl.on_shutdown(new_trigger, old_trigger)
      ```
      The triggers will be run when tarantool exits due to receiving one of
      the signals: `SIGTERM`, `SIGINT`, `SIGHUP` or when user executes
      `os.exit()`.
      
      Note that the triggers will not be run if tarantool receives a fatal
      signal: `SIGSEGV`, `SIGABORT` or any signal causing immediate program
      termination.
      6dc4c8d7
    • Stanislav Zudin's avatar
      sql: prohibit type_def keywords in the VALUES statement · a10b1549
      Stanislav Zudin authored
      The "box.sql.execute('values(blob)')" causes an accert in the
      expression processing, because the parser doesn't distinguish the
      keyword "BLOB" from the binary value (in the form X'hex').
      
      This fix adds an additional checks in the SQL grammar.
      Thus the expressions such as "VALUES(BLOB)", "SELECT FLOAT"
      and so on are treated as a syntax errors.
      
      Closes #3888
      a10b1549
  7. Jan 05, 2019
  8. Dec 13, 2018
  9. Nov 15, 2018
    • N.Tatunov's avatar
      sql: remove GLOB from Tarantool · 5e3c0a1b
      N.Tatunov authored
      GLOB is a legacy extension for LIKE from SQLite. As we want our SQL to
      be close to ANSI SQL & LIKE to depend on collations, we do not want to
      support it. This patch totally removes it from Tarantool along with any
      mentions of it.
      
      Part of #3589
      Part of #3572
      5e3c0a1b
  10. Nov 02, 2018
    • Georgy Kirichenko's avatar
      sql: pass true types of columns to Tarantool · 7752cdfd
      Georgy Kirichenko authored
      As a main part of introducing strict typing in SQL it is required to
      prohibit typeless columns in parser's grammar. Originally, SQLite simply
      assigns typeless columns to BLOB affinity. Moreover, due to historical
      reasons, all columns were stored with <SCALAR> type in Tarantool core
      (except for <INTEGER> when it comes to primary key).  Column type should
      be defined on table creation. Allowed data types are: <TEXT>, <VARCHAR>,
      <CHAR>, <BLOB>, <INT[EGER]>, <REAL>, <FLOAT>, <NUMERIC>, <DECIMAL>,
      <DOUBLE> <DATE> and <DATETIME>. However, still any declared data type is
      converted to one of <BLOB>, <TEXT>, <REAL> or <INTEGER> affinities.
      While affinity reaches space format, it is (again) converted to
      Tarantool's field type. To be more precise, table of conversions:
      
      +----------+----------+------------+
      | SQL TYPE | AFFINITY | FIELD TYPE |
      +----------+----------+------------+
      | FLOAT    | REAL     | NUMBER     |
      | REAL     | REAL     | NUMBER     |
      | DOUBLE   | REAL     | NUMBER     |
      | NUMERIC  | REAL     | NUMBER     |
      | DECIMAL  | REAL     | NUMBER     |
      | INTEGER  | INTEGER  | INTEGER    |
      | TEXT     | TEXT     | STRING     |
      | VARCHAR  | TEXT     | STRING     |
      | CHAR     | TEXT     | STRING     |
      | BLOB     | BLOB     | SCALAR     |
      | DATETIME | REAL     | NUMBER     |
      | DATE     | REAL     | NUMBER     |
      | TIME     | REAL     | NUMBER     |
      +----------+----------+------------+
      
      <VARCHAR> and <CHAR> types should be specified with length
      (e.g. name VARCHAR(10)), but this length currently is not used when
      types are processed. Only purpose is to support ANSI syntax.
      The same for <NUMERIC> and <DECIMAL> - it is allowed to specify scale
      and precision, but they don't affect the way they are stored in memory.
      
      Note that patch is not self-sufficient: a lot of tests still fail due to
      wrong types conversions. Fix for that comes as next two patches.
      
      Closes #3018
      Closes #3104
      Closes #2494
      Closes #3459
      7752cdfd
  11. Sep 25, 2018
    • Serge Petrenko's avatar
      tarantoolctl: fix cat and play for empty body requests · 24a87ff2
      Serge Petrenko authored
      If space.before_replace returns the old tuple, the operation turns into
      no-op, but is still written to WAL as IPROTO_NOP for the sake of
      replication. Such a request doesn't have a body, and tarantoolctl failed
      to parse such requests in `tarantoolctl cat` and `tarantoolctl play`.
      Fix this by checking whether a request has a body. Also skip such
      requests in `play`, since they have no effect, and, while we're at it,
      make sure `play` and `cat` do not read excess rows with lsn>=to in case
      these rows are skipped.
      
      Closes #3675
      24a87ff2
  12. Sep 22, 2018
  13. Sep 19, 2018
    • Nikita Pettik's avatar
      sql: remove SQLite original struct Index · 6b8acd8f
      Nikita Pettik authored
      As a part of SQL DD integration it is required to substitute SQLite
      structure representing index with one from Tarantool internals.
      To make this happen, lets add surrogate space to Table, which will
      hold array of indexes. Those indexes are not real copies from Tarantool
      core, but contain only index_def, since only def is useful during query
      compilation.
      
      Note that in new implementation indexes are held as array and added to
      that array in straight order. In SQLite indexes are arranged in list and
      added to the head. Hence, the order of indexes is reversed. It results
      in different query plans: if planner must make choice of two equal
      indexes, it chooses simply first one. Due to this change, some tests are
      fixed.
      
      Moreover, alongside with substituting index struct, <REINDEX> statement
      and routine connected with it has been completely removed.
      
      Part of #3561
      6b8acd8f
  14. Sep 06, 2018
    • Georgy Kirichenko's avatar
      Tarantool static build ability · cb1c72da
      Georgy Kirichenko authored
      A possibility to build tarantool with included library dependencies.
      Use the flag -DBUILD_STATIC=ON to build statically against curl, readline,
      ncurses, icu and z.
      Use the flag -DOPENSSL_USE_STATIC_LIBS=ON to build with static
      openssl
      
      Changes:
        * Add FindOpenSSL.cmake because some distributions do not support the use of
        openssl static libraries.
        * Find libssl before curl because of build dependency.
        * Catch all bundled libraries API and export then it in case of static
        build.
        * Rename crc32 internal functions to avoid a name clash with linked libraries.
      
      Notes:
        * Bundled libyaml is not properly exported, use the system one.
        * Dockerfile to build static with docker is included
      
      Fixes #3445
      cb1c72da
  15. Aug 29, 2018
    • Nikita Pettik's avatar
      sql: remove support of ALTER TABLE ADD COLUMN · 0fc619b4
      Nikita Pettik authored
      We disabled ALTER TABLE ADD COLUMN long ago (i.e. banned in parser
      ability to process this statement), but internal functions for handling
      this routine have remained. This patch removes them as well.
      
      Part of #3561
      0fc619b4
  16. Aug 21, 2018
  17. Aug 20, 2018
    • Vladimir Davydov's avatar
      tarantoolctl: remove confusing message on eval error · dc648b99
      Vladimir Davydov authored
      If `tarantoolctl eval` fails, apart from returning 3 and printing the
      eval error to stderr, tarantoolctl will also emit the following message:
      
        Error while reloading config:
      
      This message is quite confusing and useless too, as we have the return
      code for that. Let's zap it.
      
      Closes #3560
      dc648b99
  18. Aug 16, 2018
  19. Aug 15, 2018
    • Eugine Blikh's avatar
      Introduce luaT_tolstring · 01c32701
      Eugine Blikh authored
      `lua_tostring`/`lua_tolstring` ignores metatable/boolean/nil and return NULL,
      but sometimes it's needed to have similar behaviour, like lua functions
      tostring. Lua 5.1 and LuaJIT ignores it by default, Lua 5.2 introduced
      auxilary function luaL_to(l)string with supporting of __tostring. This
      function is backport of Lua 5.1 "lauxlib.h"s luaL_tostring in the luaT
      namespace.
      01c32701
  20. Aug 14, 2018
  21. Aug 07, 2018
    • Nikita Pettik's avatar
      sql: remove SQLITE_OMIT_FOREIGN_KEY define guard · 502fb2b4
      Nikita Pettik authored
      We always compile with enabled foreign keys constraints. They still can
      be turned off by <pragma foreign_keys = false> in runtime.
      
      Follow-up #3271
      502fb2b4
    • Nikita Pettik's avatar
      sql: introduce ADD CONSTRAINT statement · 4fe0b812
      Nikita Pettik authored
      After introducing separate space for persisting foreign key
      constraints, nothing prevents us from adding ALTER TABLE statement to
      add or drop named constraints. According to ANSI syntax is following:
      
      ALTER TABLE <referencing table> ADD CONSTRAINT
        <referential constraint name> FOREIGN KEY
        <left paren> <referencing columns> <right paren> REFERENCES
        <referenced table> [ <referenced columns> ] [ MATCH <match type> ]
        [ <referential triggered action> ] [ <constraint check time> ]
      
      ALTER TABLE <referencing table> DROP CONSTRAINT <constrain name>
      
      In our terms it looks like:
      
      ALTER TABLE t1 ADD CONSTRAINT f1 FOREIGN KEY(id, a)
          REFERENCES t2 (id, b) MATCH FULL;
      ALTER TABLE t1 DROP CONSTRAINT f1;
      
      FK constraints which come with CREATE TABLE statement are also
      persisted with auto-generated name. They are coded after space and its
      indexes.
      
      Moreover, we don't use original SQLite foreign keys anymore: those
      obsolete structs have been removed alongside FK hash. Now FK constraints
      are stored only in space.
      
      Since types of referencing and referenced fields must match, and now in
      SQL only PK is allowed to feature INT (other fields are always SCALAR),
      some tests have been corrected to obey this rule.
      
      Part of #3271
      4fe0b812
  22. Aug 02, 2018
    • Mergen Imeev's avatar
      sql: tarantoolctl "enter" with set language · 0fad68d3
      Mergen Imeev authored
      This patch allow to use option "--language" with
      "tarantoolctl enter" command. Also default value
      for language were added in default configuration
      file. Language is either SQL or Lua.
      
      Closes #2385.
      
      @TarantoolBot document
      Title: Language selection for tarantoolctl
      "enter".
      User can select either Lua or SQL when he uses tarantoolctl
       "enter" command. It can be done using "--language=<language>"
      syntax. Default language is set in tarantoolctl config file.
      Usage:
      tarantoolctl enter <app_name> --language=SQL
      tarantoolctl enter <app_name> --language=Lua
      0fad68d3
  23. Jul 31, 2018
  24. Jul 27, 2018
    • Kirill Shcherbatov's avatar
      sql: introduce TRUNCATE TABLE operation · dbe38b0d
      Kirill Shcherbatov authored
      To implement new TRUNCATE operation, we have introduced a
      new P2 argument for OP_Clear opcode that calles box_truncate
      instead of tarantoolSqlite3ClearTable.
      This operation should work faster than DELETE FROM; but have
      a few restricts.
      
      Closes #2201.
      
      @TarantoolBot document
      Title: New TRUNCATE operation
      TRUNCATE is DDL operation.
      Removes all rows from a table or specified partitions of a table,
      without logging the individual row deletions.
      TRUNCATE TABLE is similar to the DELETE statement with no WHERE
      clause; however, TRUNCATE TABLE is faster and uses fewer system
      resources.
      It couldn't be used with system tables or with tables having FKs.
      It also couldn't be called in transaction.
      The triggers on table will have ignored.
      Example:
      TRUNCATE TABLE t1;
      dbe38b0d
  25. Jul 20, 2018
    • N.Tatunov's avatar
      sql: remove 'BEGIN TRANSACTION' · a00a128d
      N.Tatunov authored
      Previously "BEGIN" / "BEGIN TRANSACTION", "COMMIT TRANSACTION" /
      "END" / "END TRANSACTION", "ROLLBACK TRANSACTION" could be used
      to handle transactions. By changing these commands syntax in
      parser we're aiming on getting closer to ANSI SQL. Also found
      initialization in ifdef that caused some problems with error
      messages in occasions when the wrong syntax was used.
      
      With the patch applied only following commands can be used:
       - "START TRANSACTION" to begin transaction.
       - "COMMIT" to end transaction.
       - "ROLLBACK" to rollback transaction without savepoints.
       - "ROLLBACK TO .." to rollback transaction to savepoint.
      
      Closes #2164
      a00a128d
  26. Jul 13, 2018
  27. Jul 09, 2018
  28. Jul 05, 2018
    • Ilya Markov's avatar
      tarantoolctl: Add new options for rocks · 9d315ce4
      Ilya Markov authored
      Add propagation to luarocks of --only-server, --server keys.
      
      Closes #2640
      9d315ce4
    • Serge Petrenko's avatar
      Detect when instance is run or restarted by tarantoolctl. · b11e595a
      Serge Petrenko authored
      There are some hacks to know the instance was run by tarantoolctl,
      none of them are too reliable, though. This patch introduces 2
      environment variables set by tarantoolctl for the instance to
      know when it's being run or restarted.
      
      Closes: #3215
      
      @TarantoolBot document
      Title: tarantoolctl: document setting environment variables
      tarantoolctl sets the `TARANTOOLCTL` environment variable when starting
      an instance, and sets the `TARANTOOL_RESTARTED' environment variable
      when restarting.
      b11e595a
  29. Jun 29, 2018
    • AKhatskevich's avatar
      sql: export `sql_current_time` && enable tests · cebe6930
      AKhatskevich authored
      `sql_current_time` is exported only in debug mode and used to check
      builtin datetime sql functions behavior in specific time moments.
      
      Extra changes:
       * table-14.1 test is deleted, as it does not test anything.
         It was testing ddl inside of a transaction. This case is checked
         by 14.2 by now.
      
      Closes #2646
      cebe6930
  30. Jun 28, 2018
  31. Jun 19, 2018
  32. May 30, 2018
    • Mergen Imeev's avatar
      sql: IS is only applicable when dealing with NULL · b3a3ddb5
      Mergen Imeev authored
      According to ANSI Standard IS/IS NOT can be used to determine
      if values is null. At the same time in SQLite3 IS/IS NOT have an
      additional function - it can be used to check equality of two
      values. This feature isn't common for different versions of SQL
      (only in PL/SQL right operand can be NONE, TRUE of FALSE) This
      patch removes described function.
      b3a3ddb5
Loading