From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [94.100.177.99]) (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 2817C446439 for ; Mon, 5 Oct 2020 00:44:25 +0300 (MSK) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) From: Roman Khabibov In-Reply-To: <35c0b3b1-c3a8-a1c0-e12a-fc0535ed0f8c@tarantool.org> Date: Mon, 5 Oct 2020 00:44:24 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20200911215115.6622-1-roman.habibov@tarantool.org> <20200911215115.6622-7-roman.habibov@tarantool.org> <35c0b3b1-c3a8-a1c0-e12a-fc0535ed0f8c@tarantool.org> 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: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org > On Oct 4, 2020, at 16:45, Vladislav Shpilevoy = wrote: >=20 > Thanks for the patch! >=20 >> * !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 =3D=3D 0) { >> - constraint_name =3D >> - sqlMPrintf(db, "fk_unnamed_%s_%d", >> - space->def->name, >> - = ++parse_context->fkeys_def.count); >> + uint32_t idx =3D = ++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 =3D=3D NULL) { >> + struct space *original_space =3D >> + space_by_name(space->def->name); >> + assert(original_space !=3D NULL); >> + struct rlist *child_fk =3D >> + = &original_space->child_fk_constraint; >> + struct fk_constraint *fk; >> + rlist_foreach_entry(fk, child_fk, >> + in_child_space) >> + idx++; >> + } >> + constraint_name =3D sqlMPrintf(db, = "fk_unnamed_%s_%d", >> + space->def->name, = idx); >=20 > idx is uint32_t, but the format is %d, which is int. Fixed in the previous commit. >> } else { >> constraint_name =3D >> sql_name_from_token(db, = &create_def->name);