[Tarantool-patches] [PATCH v2 2/2] sql: support column addition

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sat Apr 25 01:56:20 MSK 2020


Thanks for the patch!

You didn't respond to my 18 review comments to the previous
version of the patch. Please, do that so as I would know what
was decided on each of them.

See 3 comments below.

On 03/04/2020 17:27, Roman Khabibov wrote:
> Enable to add column to existing space with
> <ALTER TABLE ADD [COLUMN]> statement. Column definition can be
> supplemented with the four types of constraints, <DEFAULT>,
> <COLLATE> clauses and <[NOT] NULL>, AUTOINCREMENT.
> 
> Closes #2349, #3075
> 
> @TarantoolBot document
> Title: Add columns to existing tables in SQL
> Now, it is possible to add columns to existing empty spaces using
> <ALTER TABLE table_name ADD [COLUMN] column_name column_type ...>

1. Why COLUMN keyword is optional? Is it allowed by the standard?

> statement. The column definition is the same as in <CREATE TABLE>
> statement, except that table constraints (PRIMARY KEY, UNIQUE,
> REFERENCES, CHECK) cannot be specified yet.

2. Issue 2349 is about ability to add a UNIQUE column. Here you said
you 'Closes' it, and yet it can't be done, according to what you say
above. Why?

I tried that example:

    tarantool> box.execute("ALTER TABLE te9 ADD s2 INT UNIQUE;")
    ---
    - row_count: 0
    ...

So it is not forbidden.

Also I tried to follow the template and add explicit COLUMN:

    tarantool> box.execute("ALTER TABLE te9 ADD COLUMN s2 INT UNIQUE;")
    ---
    - null
    - 'At line 1 at or near position 21: keyword ''COLUMN'' is reserved. Please use double
      quotes if ''COLUMN'' is an identifier.'
    ...

Why doesn't it work?

> 
> For example:
> 
> tarantool> box.execute([[CREATE TABLE test (
>                            a INTEGER PRIMARY KEY
>                       );]])
> ---
> - row_count: 1
> ...
> 
> tarantool> box.execute([[ALTER TABLE test ADD COLUMN
>                            b TEXT
>                            NOT NULL
>                            DEFAULT ('a')
>                            COLLATE "unicode_ci"
>                        ;]])

3. This example does not work. Gives the same error as the example above.

> ---
> - row_count: 0
> ...

I will continue the review once the comments above and the old 18 comments
are resolved


More information about the Tarantool-patches mailing list