From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: Roman Khabibov <roman.habibov@tarantool.org>, tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v4 6/6] sql: support column addition Date: Thu, 17 Sep 2020 17:45:59 +0200 [thread overview] Message-ID: <791ca74b-ec48-1fac-e674-1c5d78ae100d@tarantool.org> (raw) In-Reply-To: <20200911215115.6622-7-roman.habibov@tarantool.org> Thanks for the patch! See 3 comments below. On 11.09.2020 23:51, 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 ...> > statement. The column definition is the same as in <CREATE TABLE> > statement. > > 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 > > CHECK (LENGTH(b) > 1) > > NOT NULL > > DEFAULT ('aa') > > COLLATE "unicode_ci" > > ]]) > --- > - row_count: 0 1. It is row_count 1, not 0. > ... > ``` > --- > diff --git a/src/box/errcode.h b/src/box/errcode.h > index 3c21375f5..ec16399a0 100644 > --- a/src/box/errcode.h > +++ b/src/box/errcode.h > @@ -271,6 +271,7 @@ struct errcode_record { > /*216 */_(ER_SYNC_QUORUM_TIMEOUT, "Quorum collection for a synchronous transaction is timed out") \ > /*217 */_(ER_SYNC_ROLLBACK, "A rollback for a synchronous transaction is received") \ > /*218 */_(ER_TUPLE_METADATA_IS_TOO_BIG, "Can't create tuple: metadata size %u is too big") \ > + /*219 */_(ER_SQL_CANT_ADD_AUTOINC, "Can't add AUTOINCREMENT: the space '%s' already has one auto incremented field") \ 2. Probably it can be used inside sql_add_autoincrement() too. To make the same error have the same message. > /* > * !IMPORTANT! Please follow instructions at start of the file > diff --git a/src/box/sql/build.c b/src/box/sql/build.c > index d1d240315..677099b48 100644 > --- a/src/box/sql/build.c > +++ b/src/box/sql/build.c > @@ -1032,18 +1180,21 @@ vdbe_emit_fk_constraint_create(struct Parse *parse_context, > P4_DYNAMIC); > /* > * In case we are adding FK constraints during execution > - * of <CREATE TABLE ...> statement, we don't have child > - * id, but we know register where it will be stored. > + * of <CREATE TABLE ...> or <ALER TABLE ADD COLUMN ...> 3. ALER -> ALTER.
next prev parent reply other threads:[~2020-09-17 15:46 UTC|newest] Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-11 21:51 [Tarantool-patches] [PATCH v4 0/6] Support " Roman Khabibov 2020-09-11 21:51 ` [Tarantool-patches] [PATCH v4 1/6] sql: rename TK_COLUMN to TK_COLUMN_NAME Roman Khabibov 2020-09-16 13:17 ` Nikita Pettik 2020-09-28 23:29 ` Roman Khabibov 2020-09-11 21:51 ` [Tarantool-patches] [PATCH v4 2/6] sql: refactor create_table_def and parse Roman Khabibov 2020-09-16 13:27 ` Nikita Pettik 2020-09-17 14:43 ` Vladislav Shpilevoy 2020-09-18 12:31 ` Nikita Pettik 2020-09-18 13:21 ` Roman Khabibov 2020-09-28 23:29 ` Roman Khabibov 2020-09-17 14:43 ` Vladislav Shpilevoy 2020-10-02 22:08 ` Vladislav Shpilevoy 2020-10-03 21:37 ` Roman Khabibov 2020-10-04 13:45 ` Vladislav Shpilevoy 2020-10-04 21:44 ` Roman Khabibov 2020-10-05 21:22 ` Vladislav Shpilevoy 2020-10-07 13:53 ` Roman Khabibov 2020-10-07 22:35 ` Vladislav Shpilevoy 2020-10-08 10:32 ` Roman Khabibov 2020-09-17 15:16 ` Vladislav Shpilevoy 2020-10-02 22:08 ` Vladislav Shpilevoy 2020-09-11 21:51 ` [Tarantool-patches] [PATCH v4 3/6] schema: add box_space_field_MAX Roman Khabibov 2020-09-11 21:51 ` [Tarantool-patches] [PATCH v4 4/6] sql: use parser's region of "index" array Roman Khabibov 2020-09-16 13:30 ` Nikita Pettik 2020-09-28 23:29 ` Roman Khabibov 2020-09-17 14:53 ` Vladislav Shpilevoy 2020-09-23 14:25 ` Roman Khabibov 2020-09-24 21:30 ` Vladislav Shpilevoy 2020-10-05 21:22 ` Vladislav Shpilevoy 2020-10-07 13:53 ` Roman Khabibov 2020-09-11 21:51 ` [Tarantool-patches] [PATCH v4 5/6] box: disallow to modify format of a view Roman Khabibov 2020-09-16 13:37 ` Nikita Pettik 2020-09-22 15:59 ` Roman Khabibov 2020-09-17 15:01 ` Vladislav Shpilevoy 2020-09-22 15:59 ` Roman Khabibov 2020-09-11 21:51 ` [Tarantool-patches] [PATCH v4 6/6] sql: support column addition Roman Khabibov 2020-09-16 20:18 ` Nikita Pettik 2020-09-17 15:19 ` Vladislav Shpilevoy 2020-09-18 12:59 ` Nikita Pettik 2020-09-28 23:28 ` Roman Khabibov 2020-10-02 22:08 ` Vladislav Shpilevoy 2020-10-03 21:37 ` Roman Khabibov 2020-09-17 15:45 ` Vladislav Shpilevoy [this message] 2020-10-04 13:45 ` Vladislav Shpilevoy 2020-10-04 21:44 ` Roman Khabibov 2020-09-11 22:00 ` [Tarantool-patches] [PATCH v4 0/6] Support " Roman Khabibov 2020-10-08 22:07 ` Vladislav Shpilevoy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=791ca74b-ec48-1fac-e674-1c5d78ae100d@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=roman.habibov@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v4 6/6] sql: support column addition' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox