From: Mergen Imeev via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: v.shpilevoy@tarantool.org, tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v2 6/6] sql: remove unnecessary function initialization Date: Fri, 6 Aug 2021 22:59:13 +0300 [thread overview] Message-ID: <20210806195913.GF11107@tarantool.org> (raw) In-Reply-To: <20a13f2ae829a4fffcd95e120f31293efdfad506.1628081224.git.imeevma@gmail.com> I removed SQL built-ins support from func_def_check(). Diff and new patch below. On Wed, Aug 04, 2021 at 03:58:47PM +0300, Mergen Imeev via Tarantool-patches wrote: > After removing the SQL built-in functions from _func, the code used to > initialize these SQL built-in functions is no longer used and should be > removed. > > Follow-up #6106 > --- > src/box/func.c | 7 ------- > src/box/sql/func.c | 49 ---------------------------------------------- > 2 files changed, 56 deletions(-) > > diff --git a/src/box/func.c b/src/box/func.c > index 731f18a3b..04ae1b958 100644 > --- a/src/box/func.c > +++ b/src/box/func.c > @@ -394,10 +394,6 @@ restore_fail: > static struct func * > func_c_new(struct func_def *def); > > -/** Construct a SQL builtin function object. */ > -extern struct func * > -func_sql_builtin_new(struct func_def *def); > - > struct func * > func_new(struct func_def *def) > { > @@ -409,9 +405,6 @@ func_new(struct func_def *def) > case FUNC_LANGUAGE_LUA: > func = func_lua_new(def); > break; > - case FUNC_LANGUAGE_SQL_BUILTIN: > - func = func_sql_builtin_new(def); > - break; > default: > unreachable(); > } > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index 2a3a5d457..50014b756 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -2789,55 +2789,6 @@ sql_built_in_functions_cache_free(void) > mh_strnptr_delete(built_in_functions); > } > > -struct func * > -func_sql_builtin_new(struct func_def *def) > -{ > - assert(def->language == FUNC_LANGUAGE_SQL_BUILTIN); > - /** Binary search for corresponding builtin entry. */ > - int idx = -1, left = 0, right = nelem(sql_builtins) - 1; > - while (left <= right) { > - uint32_t mid = (left + right) / 2; > - int rc = strcmp(def->name, sql_builtins[mid].name); > - if (rc == 0) { > - idx = mid; > - break; > - } > - if (rc < 0) > - right = mid - 1; > - else > - left = mid + 1; > - } > - /* > - * All SQL built-in(s) (stubs) are defined in a snapshot. > - * Implementation-specific metadata is defined in > - * sql_builtins list. When a definition were not found > - * above, the function name is invalid, i.e. it is > - * not built-in function. > - */ > - if (idx == -1) { > - diag_set(ClientError, ER_CREATE_FUNCTION, def->name, > - "given built-in is not predefined"); > - return NULL; > - } > - struct func_sql_builtin *func = > - (struct func_sql_builtin *) calloc(1, sizeof(*func)); > - if (func == NULL) { > - diag_set(OutOfMemory, sizeof(*func), "malloc", "func"); > - return NULL; > - } > - func->base.def = def; > - func->base.vtab = &func_sql_builtin_vtab; > - func->flags = sql_builtins[idx].flags; > - func->call = sql_builtins[idx].call; > - func->finalize = sql_builtins[idx].finalize; > - def->param_count = sql_builtins[idx].param_count; > - def->is_deterministic = sql_builtins[idx].is_deterministic; > - def->returns = sql_builtins[idx].returns; > - def->aggregate = sql_builtins[idx].aggregate; > - def->exports.sql = sql_builtins[idx].export_to_sql; > - return &func->base; > -} > - > static void > func_sql_builtin_destroy(struct func *func) > { > -- > 2.25.1 > Diff: diff --git a/src/box/func_def.c b/src/box/func_def.c index 11d2bdb84..630b4a43c 100644 --- a/src/box/func_def.c +++ b/src/box/func_def.c @@ -116,14 +116,6 @@ func_def_check(struct func_def *def) return -1; } break; - case FUNC_LANGUAGE_SQL_BUILTIN: - if (def->body != NULL || def->is_sandboxed) { - diag_set(ClientError, ER_CREATE_FUNCTION, def->name, - "body and is_sandboxed options are not compatible " - "with SQL language"); - return -1; - } - break; default: break; } New patch: commit 79871a45476aca400ecb921a44550a3807c309ca Author: Mergen Imeev <imeevma@gmail.com> Date: Sat Jul 31 13:09:07 2021 +0300 sql: remove unnecessary function initialization After removing the SQL built-in functions from _func, the code used to initialize these SQL built-in functions is no longer used and should be removed. Follow-up #6106 diff --git a/src/box/func.c b/src/box/func.c index 731f18a3b..04ae1b958 100644 --- a/src/box/func.c +++ b/src/box/func.c @@ -394,10 +394,6 @@ restore_fail: static struct func * func_c_new(struct func_def *def); -/** Construct a SQL builtin function object. */ -extern struct func * -func_sql_builtin_new(struct func_def *def); - struct func * func_new(struct func_def *def) { @@ -409,9 +405,6 @@ func_new(struct func_def *def) case FUNC_LANGUAGE_LUA: func = func_lua_new(def); break; - case FUNC_LANGUAGE_SQL_BUILTIN: - func = func_sql_builtin_new(def); - break; default: unreachable(); } diff --git a/src/box/func_def.c b/src/box/func_def.c index 11d2bdb84..630b4a43c 100644 --- a/src/box/func_def.c +++ b/src/box/func_def.c @@ -116,14 +116,6 @@ func_def_check(struct func_def *def) return -1; } break; - case FUNC_LANGUAGE_SQL_BUILTIN: - if (def->body != NULL || def->is_sandboxed) { - diag_set(ClientError, ER_CREATE_FUNCTION, def->name, - "body and is_sandboxed options are not compatible " - "with SQL language"); - return -1; - } - break; default: break; } diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 2a3a5d457..50014b756 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -2789,55 +2789,6 @@ sql_built_in_functions_cache_free(void) mh_strnptr_delete(built_in_functions); } -struct func * -func_sql_builtin_new(struct func_def *def) -{ - assert(def->language == FUNC_LANGUAGE_SQL_BUILTIN); - /** Binary search for corresponding builtin entry. */ - int idx = -1, left = 0, right = nelem(sql_builtins) - 1; - while (left <= right) { - uint32_t mid = (left + right) / 2; - int rc = strcmp(def->name, sql_builtins[mid].name); - if (rc == 0) { - idx = mid; - break; - } - if (rc < 0) - right = mid - 1; - else - left = mid + 1; - } - /* - * All SQL built-in(s) (stubs) are defined in a snapshot. - * Implementation-specific metadata is defined in - * sql_builtins list. When a definition were not found - * above, the function name is invalid, i.e. it is - * not built-in function. - */ - if (idx == -1) { - diag_set(ClientError, ER_CREATE_FUNCTION, def->name, - "given built-in is not predefined"); - return NULL; - } - struct func_sql_builtin *func = - (struct func_sql_builtin *) calloc(1, sizeof(*func)); - if (func == NULL) { - diag_set(OutOfMemory, sizeof(*func), "malloc", "func"); - return NULL; - } - func->base.def = def; - func->base.vtab = &func_sql_builtin_vtab; - func->flags = sql_builtins[idx].flags; - func->call = sql_builtins[idx].call; - func->finalize = sql_builtins[idx].finalize; - def->param_count = sql_builtins[idx].param_count; - def->is_deterministic = sql_builtins[idx].is_deterministic; - def->returns = sql_builtins[idx].returns; - def->aggregate = sql_builtins[idx].aggregate; - def->exports.sql = sql_builtins[idx].export_to_sql; - return &func->base; -} - static void func_sql_builtin_destroy(struct func *func) {
next prev parent reply other threads:[~2021-08-06 19:59 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-04 12:58 [Tarantool-patches] [PATCH v2 0/6] Remove SQL built-in functions from _func Mergen Imeev via Tarantool-patches 2021-08-04 12:58 ` [Tarantool-patches] [PATCH v2 1/6] sql: introduce sql_func_flags() Mergen Imeev via Tarantool-patches 2021-08-05 22:14 ` Vladislav Shpilevoy via Tarantool-patches 2021-08-06 19:41 ` Mergen Imeev via Tarantool-patches 2021-08-04 12:58 ` [Tarantool-patches] [PATCH v2 2/6] sql: introduce sql_func_find() Mergen Imeev via Tarantool-patches 2021-08-05 22:15 ` Vladislav Shpilevoy via Tarantool-patches 2021-08-06 19:42 ` Mergen Imeev via Tarantool-patches 2021-08-04 12:58 ` [Tarantool-patches] [PATCH v2 3/6] sql: remove SQL built-in functions from _func Mergen Imeev via Tarantool-patches 2021-08-05 22:17 ` Vladislav Shpilevoy via Tarantool-patches 2021-08-06 19:45 ` Mergen Imeev via Tarantool-patches 2021-08-04 12:58 ` [Tarantool-patches] [PATCH v2 4/6] alter: parse data dictionary version Mergen Imeev via Tarantool-patches 2021-08-05 22:17 ` Vladislav Shpilevoy via Tarantool-patches 2021-08-06 19:47 ` Mergen Imeev via Tarantool-patches 2021-08-04 12:58 ` [Tarantool-patches] [PATCH v2 5/6] alter: disallow creation of SQL built-in function Mergen Imeev via Tarantool-patches 2021-08-05 22:18 ` Vladislav Shpilevoy via Tarantool-patches 2021-08-06 19:54 ` Mergen Imeev via Tarantool-patches 2021-08-04 12:58 ` [Tarantool-patches] [PATCH v2 6/6] sql: remove unnecessary function initialization Mergen Imeev via Tarantool-patches 2021-08-06 19:59 ` Mergen Imeev via Tarantool-patches [this message] 2021-08-08 12:08 ` [Tarantool-patches] [PATCH v2 0/6] Remove SQL built-in functions from _func Vladislav Shpilevoy via Tarantool-patches 2021-08-09 7:18 Mergen Imeev via Tarantool-patches 2021-08-09 7:19 ` [Tarantool-patches] [PATCH v2 6/6] sql: remove unnecessary function initialization Mergen Imeev via Tarantool-patches
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=20210806195913.GF11107@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imeevma@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 6/6] sql: remove unnecessary function initialization' \ /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