[tarantool-patches] Re: [PATCH 6/6] sql: introduce ALTER TABLE ADD CONSTRAINT UNIQUE/PRIMARY KEY

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Wed Jan 16 23:54:07 MSK 2019


>>> +	sqlite3VdbeAddOp2(v, OP_Integer, space_id, tmp_reg);
>>> +	int found_addr = sqlite3VdbeAddOp4Int(v, OP_NotFound, cursor, 0,
>>> +					     tmp_reg, 1);
>>> +	sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_ERROR, ON_CONFLICT_ACTION_FAIL, 0,
>>> +			  "multiple primary keys are not allowed", P4_STATIC);
>>> +	sqlite3VdbeJumpHere(v, found_addr);
>>> +}
>>> +
>>>   /**
>>>    * Add new index to table's indexes list.
>>>    * We follow convention that PK comes first in list.
>>> diff --git a/test/sql-tap/alter.test.lua b/test/sql-tap/alter.test.lua
>>> index 1aad555c0..925753749 100755
>>> --- a/test/sql-tap/alter.test.lua
>>> +++ b/test/sql-tap/alter.test.lua
>>> @@ -517,6 +517,62 @@ test:do_catchsql_test(
>>>           -- </alter-7.11>
>>>       })
>>>   +test:do_test(
>>> +    "alter-8.1.0",
>>> +    function()
>>> +        format = {}
>>> +        format[1] = { name = 'id', type = 'scalar'}
>>> +        format[2] = { name = 'f2', type = 'scalar'}
>>> +        s = box.schema.create_space('T', {format = format})
>>> +    end,
>>> +    {})
>>> +
>>> +test:do_catchsql_test(
>>> +    "alter-8.1.1",
>>> +    [[
>>> +        ALTER TABLE t ADD CONSTRAINT pk PRIMARY KEY("id");
>>> +    ]], {
>>> +        0
>>> +    })
>>> +
>>> +test:do_test(
>>> +    "alter-8.1.2",
>>> +    function()
>>> +        i = box.space.T.index[0]
>>> +        return i.id
>>
>> 3. Why not return box.space.T.index[0].id?
> 
>
I know, nit, but I do not like excess useless lines. Cuts the eye, sorry.

> 
> diff --git a/test/sql-tap/alter.test.lua b/test/sql-tap/alter.test.lua
> index 925753749..318b0f68d 100755
> --- a/test/sql-tap/alter.test.lua
> +++ b/test/sql-tap/alter.test.lua
> @@ -538,8 +538,7 @@ test:do_catchsql_test(
>   test:do_test(
>       "alter-8.1.2",
>       function()
> -        i = box.space.T.index[0]
> -        return i.id
> +        return box.space.T.index[0].id
>       end, 0)
> 
> 




More information about the Tarantool-patches mailing list