From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v1 1/2] sql: introduce pragma sql_default_engine
Date: Tue, 26 Jun 2018 15:22:23 +0300 [thread overview]
Message-ID: <485804b9-8659-17a1-aaa9-cebc1d0e2893@tarantool.org> (raw)
In-Reply-To: <869f48ed-cf99-7e0a-f89b-8431dee2f72c@tarantool.org>
> 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.
> 3. Please, do not use sqlite3_ functions when possible. Why
> can not you use strcasecmp here?
> 4. You do not need compare lengths. 'engine_name' variable is
> zero-terminated already. And you use this fact several lines above.
> 5. Bad indentation.
> 6. Bad indentation.
+++ b/src/box/sql/pragma.c
@@ -235,6 +235,29 @@ printActivePragmas(struct session *user_session)
}
}
+/**
+ * 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;
+}
> 7. On language switch it should be reset, if we do not want to
> affect lua.
Don't know, what should I do.
> 8. Please, remove '_t'. We do not use it for enums.
ok
>
> 9. Please, add a formal comment. I know, it is obvious here,
> and I have tried to skip them, but Kostja again asked to write
> the comments.
ok.
> 10. Please, make this function be static inline in pragma.c.
ok.
> 11. Add a test with correct engines as well.
+test:do_catchsql_test(
+ "pragma-2.2",
+ [[
+ pragma sql_default_engine='vinyl';
+ ]], {
+ 0
+})
+
+test:do_catchsql_test(
+ "pragma-2.3",
+ [[
+ pragma sql_default_engine='memtx';
+ ]], {
+ 0
+})
next prev parent reply other threads:[~2018-06-26 12:22 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 [this message]
2018-06-26 13:34 ` Vladislav Shpilevoy
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=485804b9-8659-17a1-aaa9-cebc1d0e2893@tarantool.org \
--to=kshcherbatov@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=v.shpilevoy@tarantool.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