From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id AB06828E97 for ; Wed, 27 Mar 2019 09:00:51 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OddG5HoJmrAG for ; Wed, 27 Mar 2019 09:00:51 -0400 (EDT) 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 turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id F3BC228E82 for ; Wed, 27 Mar 2019 09:00:50 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: [tarantool-patches] Re: [PATCH v2 1/5] sql: introduce structs assembling DDL arguments during parsing From: "n.pettik" In-Reply-To: <573b3a69-3b68-c40d-e0b5-2d36a45964fb@tarantool.org> Date: Wed, 27 Mar 2019 16:00:47 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <39DC5EC0-E609-4DB9-B6A3-9B5824B88C96@tarantool.org> References: <0fcc585532a1f1200a7dfd4a8e911ecf9f2c94aa.1548265148.git.korablev@tarantool.org> <45655E85-4DBB-4AC4-8161-5B783C66C688@tarantool.org> <6e4d0aae-5dbe-f8d6-3bfe-7723ea2f3d9d@tarantool.org> <78138FFB-162A-4703-9A8F-CB88FD0570EE@tarantool.org> <4841a3f7-5b21-10ea-4f58-160a5639b7d9@tarantool.org> <89C4A9F1-CB69-4F7B-95FF-9FEF751F1BB6@tarantool.org> <611D6548-9882-4FB0-9D2A-828E2CAFF83D@tarantool.org> <573b3a69-3b68-c40d-e0b5-2d36a45964fb@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Vladislav Shpilevoy > On 26 Mar 2019, at 21:06, Vladislav Shpilevoy = wrote: >=20 > Thanks for the fixes! This commit LGTM. > Lets proceed to the next patches, and start > with a rebase, which is going to be hard. Ok. Then I would like to clarify some details to avoid wasting time. In previous patch version, I used next (reworked) grammar to add FK constraints using ALTER: cmd ::=3D alter_table_start alter_table_action . alter_table_start ::=3D ALTER TABLE fullname(Z) . (1) alter_table_action ::=3D add_constraint_def. alter_table_action ::=3D drop_constraint_def. alter_table_action ::=3D rename. add_constraint_def ::=3D add_constraint_start constraint_def. add_constraint_start(N) ::=3D ADD CONSTRAINT nm(Z). (2) constraint_def ::=3D foreign_key_def. foreign_key_def ::=3D FOREIGN KEY LP eidlist(FA) RP REFERENCES nm(T) eidlist_opt(TA) matcharg(M) refargs(R) = defer_subclause_opt(D). Now obviously I can=E2=80=99t use it since foreign_key_def should call create_fk_def_init() which in turn requires table name and name of constraint defined in rules (1) and (2). Why I want to use grammar mentioned above: it allows to remove code duplication. Rules to parse constraints are defined three times: 1. ccons rule - that is part of column definition: =E2=80=A6, a INT = REFERENCES t1); 2. tcons rule - that is part of CREATE TABLE: =E2=80=A6, CONSTRAINT c = FOREIGN KEY =E2=80=A6); 3. ALTER TABLE statement All of them use the same grammar to parse statement starting from REFERENCES keyword. The same applies to UNIQUE and CHECK constraints.=20 IDK how to avoid using alter_entity_def_init() and = create_constraint_def_init() and at the same time divide constraint definition into several stages. Ofc, we can still use simple approach like: cmd ::=3D ALTER TABLE fullname(Z) ADD CONSTRAINT nm(Z) FOREIGN KEY LP eidlist(FA) RP REFERENCES nm(T) eidlist_opt(TA) = matcharg(M) refargs(R) defer_subclause_opt(D) cmd ::=3D ALTER TABLE fullname(Z) ADD CONSTRAINT nm(Z) UNIQUE LP sortlist(X) RP cmd ::=3D ALTER TABLE fullname(Z) ADD CONSTRAINT nm(Z) PRIMARY KEY LP sortlist(X) RP cmd ::=3D ALTER TABLE fullname(Z) ADD CONSTRAINT nm(Z) CHECK =E2=80=A6 cmd ::=3D ALTER TABLE fullname(Z) RENAME TO nm(N) . Is this OK?