From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id B3A7624599 for ; Mon, 15 Jul 2019 13:50:44 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oyhRbCY3pnUE for ; Mon, 15 Jul 2019 13:50:44 -0400 (EDT) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 744D92458A for ; Mon, 15 Jul 2019 13:50:44 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: [tarantool-patches] Re: [PATCH v3 2/4] sql: do not show IDs generated by trigger From: "n.pettik" In-Reply-To: <4c36c8fa80439c4900c9916dd89bac2bd8cf77f8.1562832978.git.imeevma@gmail.com> Date: Mon, 15 Jul 2019 20:50:42 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <00F68DAB-ADEC-406C-9F1F-80F8B82831B3@tarantool.org> References: <4c36c8fa80439c4900c9916dd89bac2bd8cf77f8.1562832978.git.imeevma@gmail.com> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Imeev Mergen I=E2=80=99ve edited commit message: sql: skip autoinc IDs generated inside SQL trigger =20 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. =20 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);') =20 Result should be: --- - autoincrement_ids: - 1 - 2 - 3 row_count: 3 ... =20 Closes #4188 =20 Closes #4188=