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 8062B22744 for ; Tue, 26 Jun 2018 09:35:03 -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 O97dUN0kLS-L for ; Tue, 26 Jun 2018 09:35:03 -0400 (EDT) Received: from smtp34.i.mail.ru (smtp34.i.mail.ru [94.100.177.94]) (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 C796521FBC for ; Tue, 26 Jun 2018 09:35:02 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v1 1/2] sql: introduce pragma sql_default_engine References: <869f48ed-cf99-7e0a-f89b-8431dee2f72c@tarantool.org> <485804b9-8659-17a1-aaa9-cebc1d0e2893@tarantool.org> From: Vladislav Shpilevoy Message-ID: <9085644e-030f-b1bc-6928-4819bc5ffed7@tarantool.org> Date: Tue, 26 Jun 2018 16:34:36 +0300 MIME-Version: 1.0 In-Reply-To: <485804b9-8659-17a1-aaa9-cebc1d0e2893@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Kirill Shcherbatov , tarantool-patches@freelists.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.