[tarantool-patches] Re: [PATCH v1 1/2] sql: introduce pragma sql_default_engine

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Jun 26 16:34:36 MSK 2018


Hello. Thanks for the fixes! See 5 comments below.

On 26/06/2018 15:22, Kirill Shcherbatov wrote:
>> 1. Please, declare engine enums in schema_def.h. If we want to allow
>> different engines for different languages, we need to see this enum
>> from non-sql files. And here please assign not to 0, but explicitly
>> memtx engine enum. You are allowed to assign enum values to int
>> variables.
> +++ b/src/box/schema_def.h
> @@ -243,6 +243,12 @@ enum schema_object_type {
>          schema_object_type_MAX = 8
>   };
>   +/** SQL Storage engine. */
> +enum sql_storage_engine_type {
> +    SQL_STORAGE_ENGINE_MEMTX = 0,
> +    SQL_STORAGE_ENGINE_VINYL = 1,
> +};
> 
> 
>> 2. Do you really need this function to use in a single place in a
>> single source file?
> Yep.

1. It was a rhetorical question. Please, remove it in the way
described in comment 6.

2. I do not see the new patch version. Please, put it after fixes.

> 
>> 7. On language switch it should be reset, if we do not want to
>> affect lua.
> Don't know, what should I do.
> 

3. My fault. I was confused by \set language.

Please, do not skip the rest of the comment. I will paste it
here for you:

> Maybe we should ask in a big red chat about this default engine
> for each language unless we will have to set default engine like
> this when use iproto:
> 
> c = netbox.connect(uri)
> c:execute('PRAGMA default_engine = "memtx"')
> c:eval('box.space.default_engine = "memtx"')
> ... -- etc for each language.
> 
> And it breaks our "celebratory interoperability" so much
> glorified on T+ conf.
> 
> Maybe it is a good question for Gulutzan. 

Please, do what I said here.

> @@ -510,6 +527,9 @@ sql_table_new(Parse *parser, char *name)
>  	if (table == NULL)
>  		return NULL;
>  
> +	snprintf(table->def->engine_name, sizeof(table->def->engine_name), "%s",
> +		 sql_default_engine_name());
> +

4. Here strcpy is enough. You do not need any formatting here,
and you know, that engine name fits in space_def.engine_name.

> +/**
> + * Set tarantool backend default engine for SQL interface.
> + * @param engine_name to set default.
> + * @retval -1 on error.
> + * @retval 0 on success.
> + */
> +static int
> +sql_default_engine_set(const char *engine_name)
> +{
> +	enum sql_storage_engine_type engine;
> +	if (strcasecmp(engine_name, "memtx") == 0) {
> +		engine = SQL_STORAGE_ENGINE_MEMTX;
> +	} else if (strcasecmp(engine_name, "vinyl") == 0) {
> +		engine = SQL_STORAGE_ENGINE_VINYL;
> +	} else {
> +		diag_set(ClientError, ER_NO_SUCH_ENGINE, engine_name);
> +		return -1;
> +	}
> +	current_session()->sql_default_engine = engine;
> +	return 0;
> +}

5. Please, do not use neither _t nor _type for enums.

6. Why do you need strcasecmp here? I do not think,
that we should allow 'MeMtX' or 'Memtx' or something. Only
'memtx' (and 'vinyl'). And in such a case you can declare
sql_storage_engine_strs and use STR2ENUM like it is done
for other enums visible to user.




More information about the Tarantool-patches mailing list