forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 argument to OP_IdxInsert. In case the argument is not 0, recently generated identifier is retrieved and saved 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_IdxInsert. 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 tarantool#4188
- Loading branch information
Showing
9 changed files
with
187 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters