From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 2FA4E446439 for ; Sun, 4 Oct 2020 16:45:56 +0300 (MSK) References: <20200911215115.6622-1-roman.habibov@tarantool.org> <20200911215115.6622-7-roman.habibov@tarantool.org> From: Vladislav Shpilevoy Message-ID: <35c0b3b1-c3a8-a1c0-e12a-fc0535ed0f8c@tarantool.org> Date: Sun, 4 Oct 2020 15:45:54 +0200 MIME-Version: 1.0 In-Reply-To: <20200911215115.6622-7-roman.habibov@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH v4 6/6] sql: support column addition List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Roman Khabibov , tarantool-patches@dev.tarantool.org Thanks for the patch! > * !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 > @@ -1921,29 +2110,42 @@ sql_create_foreign_key(struct Parse *parse_context) > - if (!is_alter) { > + if (!is_alter_add_constr) { > if (create_def->name.n == 0) { > - constraint_name = > - sqlMPrintf(db, "fk_unnamed_%s_%d", > - space->def->name, > - ++parse_context->fkeys_def.count); > + uint32_t idx = ++parse_context->fkeys_def.count; > + /* > + * If it is we > + * should count the existing FK > + * constraints in the space and form a > + * name based on this. > + */ > + if (table_def->new_space == NULL) { > + struct space *original_space = > + space_by_name(space->def->name); > + assert(original_space != NULL); > + struct rlist *child_fk = > + &original_space->child_fk_constraint; > + struct fk_constraint *fk; > + rlist_foreach_entry(fk, child_fk, > + in_child_space) > + idx++; > + } > + constraint_name = sqlMPrintf(db, "fk_unnamed_%s_%d", > + space->def->name, idx); idx is uint32_t, but the format is %d, which is int. > } else { > constraint_name = > sql_name_from_token(db, &create_def->name);