Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>,
	tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH v1 1/2] sql: introduce pragma sql_default_engine
Date: Tue, 26 Jun 2018 16:34:36 +0300	[thread overview]
Message-ID: <9085644e-030f-b1bc-6928-4819bc5ffed7@tarantool.org> (raw)
In-Reply-To: <485804b9-8659-17a1-aaa9-cebc1d0e2893@tarantool.org>

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.

  reply	other threads:[~2018-06-26 13:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-20 17:06 [tarantool-patches] [PATCH v1 0/2] sql: default engine pragma Kirill Shcherbatov
2018-06-20 17:06 ` [tarantool-patches] [PATCH v1 1/2] sql: introduce pragma sql_default_engine Kirill Shcherbatov
2018-06-22 20:04   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-26 12:22     ` Kirill Shcherbatov
2018-06-26 13:34       ` Vladislav Shpilevoy [this message]
2018-06-26 17:09         ` Kirill Shcherbatov
2018-06-27 12:32           ` Vladislav Shpilevoy
2018-06-27 15:59             ` Kirill Shcherbatov
2018-06-20 17:06 ` [tarantool-patches] [PATCH v1 2/2] sql: enable multi-engine tests for SQL Kirill Shcherbatov
2018-06-22 20:04   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-26 12:22     ` Kirill Shcherbatov
2018-06-26 13:34       ` Vladislav Shpilevoy
2018-06-26 17:09         ` Kirill Shcherbatov
2018-06-26 12:23 ` [tarantool-patches] [PATCH v1 2/3] sql: fix SQL Count for vinyl engine Kirill Shcherbatov
2018-06-28 15:35 ` [tarantool-patches] Re: [PATCH v1 0/2] sql: default engine pragma Vladislav Shpilevoy
2018-06-28 16:00   ` n.pettik

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=9085644e-030f-b1bc-6928-4819bc5ffed7@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v1 1/2] sql: introduce pragma sql_default_engine' \
    /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