Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Imeev Mergen <imeevma@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v3 2/4] sql: do not show IDs generated by trigger
Date: Mon, 15 Jul 2019 20:50:42 +0300	[thread overview]
Message-ID: <00F68DAB-ADEC-406C-9F1F-80F8B82831B3@tarantool.org> (raw)
In-Reply-To: <4c36c8fa80439c4900c9916dd89bac2bd8cf77f8.1562832978.git.imeevma@gmail.com>


I’ve edited commit message:

    sql: skip autoinc IDs generated inside SQL trigger
    
    Currently, if an INSERT is executed inside SQL trigger and it results
    in generated autoincrement identifiers, ones will be displayed as a
    result of the statement. This is wrong, since we are not able to divide
    IDs obtained into those that belong to the table mentioned in the
    statement and those that do not belong to this table. This has been
    fixed by adding a new opcode OP_SaveAutoincValue, which follows each
    OP_IdxInsert when there's autoincrement field. On the other hand, we can
    avoid adding this opcode while producing VDBE instructions for triggers.
    OP_SaveAutoincValue retrieves and saves recently generated identifiers
    into the list, which is held in VDBE itself. Note that from now we don't
    save autoincremented value to VDBE right in sequence_next() - this
    operation is moved to OP_SaveAutoincValue. So that, VDBE can be removed
    from struct txn.
    
    For example:
    box.execute('CREATE TABLE t1 (i INT PRIMARY KEY AUTOINCREMENT);')
    box.execute('CREATE TABLE t2 (i INT PRIMARY KEY AUTOINCREMENT);')
    box.execute('CREATE TRIGGER r AFTER INSERT ON t1 FOR EACH ROW '..
                'BEGIN INSERT INTO t2 VALUES (null); END')
    box.execute('INSERT INTO t2 VALUES (100);')
    box.execute('INSERT INTO t1 VALUES (NULL), (NULL), (NULL);')
    
    Result should be:
    ---
    - autoincrement_ids:
      - 1
      - 2
      - 3
      row_count: 3
    ...
    
    Closes #4188
    
    Closes #4188

  reply	other threads:[~2019-07-15 17:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-11  8:22 [tarantool-patches] [PATCH v3 0/4] " imeevma
2019-07-11  8:22 ` [tarantool-patches] [PATCH v3 1/4] sql: remove unnecessary AUTOINCREMENT ID generation imeevma
2019-07-15 17:50   ` [tarantool-patches] " n.pettik
2019-07-11  8:22 ` [tarantool-patches] [PATCH v3 2/4] sql: do not show IDs generated by trigger imeevma
2019-07-15 17:50   ` n.pettik [this message]
2019-07-11  8:22 ` [tarantool-patches] [PATCH v3 3/4] sql: remove VDBE from TXN imeevma
2019-07-11  8:22 ` [tarantool-patches] [PATCH v3 4/4] sql: do not show generated IDs if INSERT failed imeevma
2019-07-11  8:52   ` [tarantool-patches] " Mergen Imeev
2019-07-15 17:59   ` n.pettik

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=00F68DAB-ADEC-406C-9F1F-80F8B82831B3@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v3 2/4] sql: do not show IDs generated by trigger' \
    /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