[tarantool-patches] Re: [PATCH v2 1/1] sql: cleanup on failed creation operation

n.pettik korablev at tarantool.org
Thu Oct 11 18:09:01 MSK 2018


>>> +--
>>> +-- Check that _space, _index and _sequence have the same number of
>>> +-- records.
>>> +--
>>> +space_count == #box.space._space:select()
>>> +index_count == #box.space._index:select()
>>> +sequence_count == #box.space._sequence:select()
>>> +
>>> +box.schema.user.drop('tmp’)
>> I see no tests involving FK constraints. Add them as well.
>> 
> Added.


> diff --git a/test/sql/drop-table.test.lua b/test/sql/drop-table.test.lua
> index 1bc8894..f86e3d8 100644
> --- a/test/sql/drop-table.test.lua
> +++ b/test/sql/drop-table.test.lua
> 
> +-- Give user right to write in _sequence. Still have not enough
> +-- rights to write in _fk_constraint.
> +--
> +box.schema.user.grant('tmp', 'write', 'space', '_sequence')
> +box.session.su('tmp')
> +
> +box.sql.execute('CREATE TABLE t3(a INTEGER PRIMARY KEY);')
> +--
> +-- Error: user do not have rights to write in _fk_constraint.
> +--
> +box.sql.execute('CREATE TABLE t4(x INTEGER PRIMARY KEY REFERENCES t3);')
> +box.sql.execute('DROP TABLE t3;’)

You misunderstood me a bit. I mean following test:

fk_count = #box.space._fk_constraints:select()

box.sql.execute('CREATE TABLE t4(x INTEGER PRIMARY KEY REFERENCES t3, a INT UNIQUE, c INT REFERENCES t3);’)

Here creation of last FK fails - for instance due to type mismatch.
Then, number of created FK constraints (and indexes) should be unchanged:

fk_count == #box.space._fk_constraints:select()
index_count == #box.space._fk_constraints:select()

Note that FK constraints are created after indexes.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20181011/25648dd0/attachment.html>


More information about the Tarantool-patches mailing list