Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org, korablev@tarantool.org
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] [PATCH v2 0/5] sql: do not use OP_Delete+OP_Insert for UPDATES
Date: Sat, 29 Dec 2018 13:48:57 +0300	[thread overview]
Message-ID: <cover.1546079994.git.kshcherbatov@tarantool.org> (raw)

Introduced a new OP_Update opcode making Tarantool native Update
operation.
In case of UPDATE or REPLACE we can't use new OP_Update as it
has a complex SQL-specific semantics:

CREATE TABLE tj (s1 INT PRIMARY KEY, s2 INT);
INSERT INTO tj VALUES (1, 3),(2, 4),(3,5);
CREATE UNIQUE INDEX i ON tj (s2);
SELECT * FROM tj;
[1, 3], [2, 4], [3, 5]
UPDATE OR REPLACE tj SET s2 = s2 + 1;
SELECT * FROM tj;
[1, 4], [3, 6]

I.e. [1, 3] tuple is updated as [1, 4] and have replaced tuple
[2, 4]. This logic is implemented as preventive tuples deletion
by all corresponding indexes in SQL.

The other significant change is forbidden primary key update.
It was possible to deal with it the same way like with or
REPLACE specifier but we need an atomic UPDATE step for #3691
ticket to support "or IGNORE/or ABORT/or FAIL" specifiers.
Reworked tests to make testing avoiding primary key UPDATE where
possible.

Fixed bug in VDBE - sometimes temporal tuples in memory allocated
with sql_vdbe_mem_alloc_region were stored in Mem variable having
invalid flags set.

Changes in version 2:
  - Reworked part of code to close tikets #3035, #3918: reused
    a new routine mpstream_encode_vdbe_mem to encode tuples on
    region everywhere on Vdbe execution: got rid of routines
    sqlite3VdbeMsgpackRecordLen and sqlite3VdbeMsgpackRecordPut
    that became useless.
  - Fixed few spell mistakes in comments and commit messages
  - Minor code changes: better mpstream methods names, changed
    OP_IdxUpdate to OP_Update name.

Branch: http://github.com/tarantool/tarantool/tree/kshch/gh-3850-op-update
Issue: https://github.com/tarantool/tarantool/issues/3850

Kirill Shcherbatov (5):
  sql: clean-up vdbe_emit_constraint_checks
  sql: fix sql_vdbe_mem_alloc_region result memory
  sql: fix fkey exception for self-referenced table
  sql: encode tuples with mpstream on Vdbe run
  sql: do not use OP_Delete+OP_Insert for UPDATES

 src/box/sql.c                                 |  27 ++-
 src/box/sql/fkey.c                            |  58 ++++---
 src/box/sql/insert.c                          |  28 +--
 src/box/sql/sqliteInt.h                       |  14 ++
 src/box/sql/update.c                          |  88 +++++++---
 src/box/sql/vdbe.c                            | 138 +++++++++++++--
 src/box/sql/vdbeInt.h                         |  34 +++-
 src/box/sql/vdbeaux.c                         |  74 +-------
 src/box/sql/vdbemem.c                         |  65 +++++++
 src/mpstream.c                                |  30 ++++
 src/mpstream.h                                |  11 ++
 test/sql-tap/alter2.test.lua                  |  16 +-
 test/sql-tap/analyze9.test.lua                |  43 ++++-
 test/sql-tap/bigrow1.test.lua                 |  12 +-
 test/sql-tap/check.test.lua                   |  14 +-
 test/sql-tap/fkey2.test.lua                   | 161 +++++++++---------
 test/sql-tap/fkey3.test.lua                   |  25 ++-
 test/sql-tap/fkey4.test.lua                   |  32 ++--
 test/sql-tap/gh2140-trans.test.lua            |  26 +--
 .../gh2250-trigger-chain-limit.test.lua       |   8 +-
 test/sql-tap/gh2259-in-stmt-trans.test.lua    |  12 +-
 test/sql-tap/identifier_case.test.lua         |   2 +-
 test/sql-tap/index6.test.lua                  |   5 +-
 test/sql-tap/intpkey.test.lua                 |  23 ++-
 test/sql-tap/misc1.test.lua                   |  20 ++-
 test/sql-tap/quote.test.lua                   |   6 +-
 test/sql-tap/table.test.lua                   |   2 +-
 test/sql-tap/tkt-a8a0d2996a.test.lua          |   4 +-
 test/sql-tap/tkt2767.test.lua                 |  16 +-
 test/sql-tap/tkt2832.test.lua                 |  10 +-
 test/sql-tap/tkt3554.test.lua                 |  15 +-
 test/sql-tap/trigger2.test.lua                |  28 +--
 test/sql-tap/trigger7.test.lua                |   2 +-
 test/sql-tap/triggerB.test.lua                |  28 +--
 test/sql-tap/triggerC.test.lua                |  43 ++---
 test/sql-tap/triggerD.test.lua                |   4 +-
 test/sql-tap/update.test.lua                  |  31 ++--
 test/sql-tap/with1.test.lua                   |  24 +--
 test/sql/collation.result                     |  12 +-
 test/sql/collation.test.lua                   |  12 +-
 test/sql/on-conflict.result                   |   8 +-
 test/sql/on-conflict.test.lua                 |   8 +-
 test/sql/row-count.result                     |  10 +-
 test/sql/row-count.test.lua                   |  10 +-
 test/sql/triggers.result                      |  16 +-
 test/sql/triggers.test.lua                    |  16 +-
 46 files changed, 781 insertions(+), 490 deletions(-)

-- 
2.19.2

             reply	other threads:[~2018-12-29 10:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-29 10:48 Kirill Shcherbatov [this message]
2018-12-29 10:48 ` [tarantool-patches] [PATCH v2 1/5] sql: clean-up vdbe_emit_constraint_checks Kirill Shcherbatov
2018-12-29 10:48 ` [tarantool-patches] [PATCH v2 2/5] sql: fix sql_vdbe_mem_alloc_region result memory Kirill Shcherbatov
2018-12-29 10:49 ` [tarantool-patches] [PATCH v2 3/5] sql: fix fkey exception for self-referenced table Kirill Shcherbatov
2018-12-29 13:26   ` [tarantool-patches] " n.pettik
2018-12-29 10:49 ` [tarantool-patches] [PATCH v2 4/5] sql: encode tuples with mpstream on Vdbe run Kirill Shcherbatov
2018-12-29 13:26   ` [tarantool-patches] " n.pettik
2018-12-29 15:28     ` Kirill Shcherbatov
2019-01-09 12:29       ` n.pettik
2018-12-29 10:49 ` [tarantool-patches] [PATCH v2 5/5] sql: do not use OP_Delete+OP_Insert for UPDATES Kirill Shcherbatov
2018-12-29 13:35   ` [tarantool-patches] " n.pettik
2018-12-29 15:31     ` Kirill Shcherbatov
2019-01-10 12:30 ` [tarantool-patches] Re: [PATCH v2 0/5] " Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1546079994.git.kshcherbatov@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v2 0/5] sql: do not use OP_Delete+OP_Insert for UPDATES' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox