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 2/6] sql: refactor create_table_def and parse Date: Thu, 17 Sep 2020 16:43:53 +0200 [thread overview] Message-ID: <36bb1beb-a59a-57d9-a1ef-c0ef5af49d35@tarantool.org> (raw) In-Reply-To: <20200911215115.6622-3-roman.habibov@tarantool.org> Hi! Thanks for the patch! On 11.09.2020 23:51, Roman Khabibov wrote: > Move ck, fk constraint lists and autoincrement info from > struct create_table_def to struct Parse 1. You moved them into new defs, not into struct Parse. You need to revisit some commit messages in this branch after review fixes are done. > to make the code more > reusable when implementing <ALTER TABLE ADD COLUMN>. > > Needed for #3075 > --- > diff --git a/src/box/sql/parse_def.h b/src/box/sql/parse_def.h > index cb0ecd2fc..c44e3dbbe 100644 > --- a/src/box/sql/parse_def.h > +++ b/src/box/sql/parse_def.h > @@ -205,26 +205,16 @@ struct create_entity_def { > struct create_table_def { > struct create_entity_def base; > struct space *new_space; > - /** > - * Number of FK constraints declared within > - * CREATE TABLE statement. > - */ > - uint32_t fkey_count; > - /** > - * Foreign key constraint appeared in CREATE TABLE stmt. > - */ > - struct rlist new_fkey; > - /** > - * Number of CK constraints declared within > - * CREATE TABLE statement. > - */ > - uint32_t check_count; > - /** Check constraint appeared in CREATE TABLE stmt. */ > - struct rlist new_check; > - /** True, if table to be created has AUTOINCREMENT PK. */ > - bool has_autoinc; > - /** Id of field with AUTOINCREMENT. */ > - uint32_t autoinc_fieldno; > +}; > + > +struct create_checks_def { > + struct rlist checks; > + uint32_t count; > +}; > + > +struct create_fkeys_def { > + struct rlist fkeys; > + uint32_t count; *. All struct memebers should have a comment. At least it is worth documenting what are the members of checks and fkeys lists. > }; > > struct create_view_def { > @@ -500,12 +501,12 @@ create_view_def_init(struct create_view_def *view_def, struct Token *name, > } > > static inline void > -create_table_def_destroy(struct create_table_def *table_def) > +fkeys_def_destroy(struct create_fkeys_def *fkeys_def) 2. Methods of a struct should have a prefix with the struct name. It should be create_fkeys_def_destroy(). > { > - if (table_def->new_space == NULL) > + if (fkeys_def->count == 0) > return; > struct fk_constraint_parse *fk; > - rlist_foreach_entry(fk, &table_def->new_fkey, link) > + rlist_foreach_entry(fk, &fkeys_def->fkeys, link) > sql_expr_list_delete(sql_get(), fk->selfref_cols); > } > > diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h > index 5913d7614..7057c20b6 100644 > --- a/src/box/sql/sqlInt.h > +++ b/src/box/sql/sqlInt.h > @@ -2257,6 +2257,18 @@ struct Parse { > * sqlEndTable() function). > */ > struct create_table_def create_table_def; > + /* > + * FK and CK constraints appeared in a <CREATE TABLE>. > + */ > + struct create_fkeys_def fkeys_def; > + struct create_checks_def checks_def; 3. fkeys_def -> create_fkeys_def. checks_def -> create_checks_def. > + /* > + * True, if column within a <CREATE TABLE> statement to be > + * created has <AUTOINCREMENT>. > + */ > + bool has_autoinc; > + /* Id of field with <AUTOINCREMENT>. */ > + uint32_t autoinc_fieldno; > bool initiateTTrans; /* Initiate Tarantool transaction */ > /** If set - do not emit byte code at all, just parse. */ > bool parse_only; >
next prev parent reply other threads:[~2020-09-17 14:43 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 column addition 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 [this message] 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 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=36bb1beb-a59a-57d9-a1ef-c0ef5af49d35@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=roman.habibov@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v4 2/6] sql: refactor create_table_def and parse' \ /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