[Tarantool-patches] [PATCH v2 6/6] sql: remove unnecessary function initialization

imeevma at tarantool.org imeevma at tarantool.org
Mon Aug 9 10:19:04 MSK 2021


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/func_def.c |  8 --------
 src/box/sql/func.c | 49 ----------------------------------------------
 3 files changed, 64 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/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)
 {
-- 
2.25.1



More information about the Tarantool-patches mailing list