[Tarantool-patches] [PATCH v2 2/2] sql: support column addition

Roman Khabibov roman.habibov at tarantool.org
Sat Sep 12 00:51:47 MSK 2020


> On Aug 20, 2020, at 01:20, Vladislav Shpilevoy <v.shpilevoy at tarantool.org> wrote:
> 
> Hi! Thanks for the patch!
> 
>>>> +	parser->has_autoinc = false;
>>>> 	region_create(&parser->region, &cord()->slabc);
>>>> }
>>>> 
>>>> diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
>>>> index aa6a470f8..3143ec521 100644
>>>> --- a/src/box/sql/sqlInt.h
>>>> +++ b/src/box/sql/sqlInt.h
>>>> @@ -2249,12 +2249,26 @@ struct Parse {
>>>> 		struct enable_entity_def enable_entity_def;
>>>> 	};
>>>> 	/**
>>>> -	 * Table def is not part of union since information
>>>> -	 * being held must survive till the end of parsing of
>>>> -	 * whole CREATE TABLE statement (to pass it to
>>>> -	 * sqlEndTable() function).
>>>> +	 * Table def or column def is not part of union since
>>>> +	 * information being held must survive till the end of
>>>> +	 * parsing of whole <CREATE TABLE> or
>>>> +	 * <ALTER TABLE ADD COLUMN> statement (to pass it to
>>>> +	 * sqlEndTable() sql_create_column_end() function).
>>>> 	 */
>>>> 	struct create_table_def create_table_def;
>>>> +	struct create_column_def create_column_def;
>>>> +	/**
>>>> +	 * FK and CK constraints appeared in a <CREATE TABLE> or
>>>> +	 * a <ALTER TABLE ADD COLUMN> statement.
>>>> +	 */
>>>> +	struct rlist fkeys;
>>>> +	struct rlist checks;
>>>> +	uint32_t fkey_count;
>>>> +	uint32_t check_count;
>>>> +	/** True, if column to be created has <AUTOINCREMENT>. */
>>>> +	bool has_autoinc;
>>> 
>>> 27. What column? This is struct Parse, it is not a column.
>> I know, but I haven't come up with anything better.
> 
> Why can't autoinc field be moved into create_column_def, since this is
> related to only one column?
Basically to make the current code reusable. The opcode for _sequence is
emitted at the end of table creation. All create_column_def already
worked at this point. We should know number of field with autoincrement.

> Can you move struct rlist fkeys and uint32_t fkey_count into a new struct
> like 'struct create_fkeys_def;', and the same for checks?
Yes.



More information about the Tarantool-patches mailing list