From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org, korablev@tarantool.org
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] [PATCH v2 6/8] sql: rename OP_Function to OP_BuiltinFunction
Date: Thu, 8 Aug 2019 17:50:50 +0300 [thread overview]
Message-ID: <2857f87171c95dfbd279f7237f06960c03e5c45d.1565275469.git.kshcherbatov@tarantool.org> (raw)
In-Reply-To: <cover.1565275469.git.kshcherbatov@tarantool.org>
Renamed OP_Function opcode to OP_BuiltinFunction to introduce a
new OP_Function operation in a new meaning: a new OP_Function
would call Tarantool's function with new port-based API while
legacy OP_BuiltinFunction is an efficient implementation of
SQL Builtins functions.
Needed for #2200, #4113, #2233
---
src/box/sql/vdbeInt.h | 3 ++-
src/box/sql/analyze.c | 8 ++++----
src/box/sql/expr.c | 2 +-
src/box/sql/vdbe.c | 29 +++++++++++++++--------------
4 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h
index 5582d9506..f77c019fb 100644
--- a/src/box/sql/vdbeInt.h
+++ b/src/box/sql/vdbeInt.h
@@ -312,7 +312,8 @@ struct sql_context {
FuncDef *pFunc; /* Pointer to function information */
Mem *pMem; /* Memory cell used to store aggregate context */
Vdbe *pVdbe; /* The VM that owns this context */
- int iOp; /* Instruction number of OP_Function */
+ /** Instruction number of OP_BuiltinFunction0. */
+ int iOp;
/*
* True, if an error occurred during the execution of the
* function.
diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c
index 3d45adf32..bd52d12df 100644
--- a/src/box/sql/analyze.c
+++ b/src/box/sql/analyze.c
@@ -718,7 +718,7 @@ callStatGet(Vdbe * v, int regStat4, int iParam, int regOut)
struct FuncDef *func =
sqlFindFunction(sql_get(), "_sql_stat_get", 2, 0);
assert(func != NULL);
- sqlVdbeAddOp4(v, OP_Function0, 0, regStat4, regOut,
+ sqlVdbeAddOp4(v, OP_BuiltinFunction0, 0, regStat4, regOut,
(char *)func, P4_FUNCDEF);
sqlVdbeChangeP5(v, 2);
}
@@ -858,8 +858,8 @@ vdbe_emit_analyze_space(struct Parse *parse, struct space *space)
struct FuncDef *init_func =
sqlFindFunction(sql_get(), "_sql_stat_init", 3, 0);
assert(init_func != NULL);
- sqlVdbeAddOp4(v, OP_Function0, 0, stat4_reg + 1, stat4_reg,
- (char *)init_func, P4_FUNCDEF);
+ sqlVdbeAddOp4(v, OP_BuiltinFunction0, 0, stat4_reg + 1,
+ stat4_reg, (char *)init_func, P4_FUNCDEF);
sqlVdbeChangeP5(v, 3);
/*
* Implementation of the following:
@@ -959,7 +959,7 @@ vdbe_emit_analyze_space(struct Parse *parse, struct space *space)
struct FuncDef *push_func =
sqlFindFunction(sql_get(), "_sql_stat_push", 3, 0);
assert(push_func != NULL);
- sqlVdbeAddOp4(v, OP_Function0, 1, stat4_reg, tmp_reg,
+ sqlVdbeAddOp4(v, OP_BuiltinFunction0, 1, stat4_reg, tmp_reg,
(char *)push_func, P4_FUNCDEF);
sqlVdbeChangeP5(v, 3);
sqlVdbeAddOp2(v, OP_Next, idx_cursor, next_row_addr);
diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index 88c602fde..1f9d91705 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -4132,7 +4132,7 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
sqlVdbeAddOp4(v, OP_CollSeq, 0, 0, 0,
(char *)coll, P4_COLLSEQ);
}
- sqlVdbeAddOp4(v, OP_Function0, constMask, r1,
+ sqlVdbeAddOp4(v, OP_BuiltinFunction0, constMask, r1,
target, (char *)pDef, P4_FUNCDEF);
sqlVdbeChangeP5(v, (u8) nFarg);
if (nFarg && constMask == 0) {
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index e096e1f65..28552f64a 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -1664,7 +1664,7 @@ case OP_CollSeq: {
break;
}
-/* Opcode: Function0 P1 P2 P3 P4 P5
+/* Opcode: BuiltinFunction0 P1 P2 P3 P4 P5
* Synopsis: r[P3]=func(r[P2@P5])
*
* Invoke a user function (P4 is a pointer to a FuncDef object that
@@ -1676,9 +1676,9 @@ case OP_CollSeq: {
* function was determined to be constant at compile time. If the first
* argument was constant then bit 0 of P1 is set.
*
- * See also: Function, AggStep, AggFinal
+ * See also: BuiltinFunction, AggStep, AggFinal
*/
-/* Opcode: Function P1 P2 P3 P4 P5
+/* Opcode: BuiltinFunction P1 P2 P3 P4 P5
* Synopsis: r[P3]=func(r[P2@P5])
*
* Invoke a user function (P4 is a pointer to an sql_context object that
@@ -1690,16 +1690,17 @@ case OP_CollSeq: {
* function was determined to be constant at compile time. If the first
* argument was constant then bit 0 of P1 is set.
*
- * SQL functions are initially coded as OP_Function0 with P4 pointing
- * to a FuncDef object. But on first evaluation, the P4 operand is
- * automatically converted into an sql_context object and the operation
- * changed to this OP_Function opcode. In this way, the initialization of
- * the sql_context object occurs only once, rather than once for each
- * evaluation of the function.
+ * SQL functions are initially coded as OP_BuiltinFunction0 with
+ * P4 pointing to a FuncDef object. But on first evaluation,
+ * the P4 operand is automatically converted into an sql_context
+ * object and the operation changed to this OP_BuiltinFunction
+ * opcode. In this way, the initialization of the sql_context
+ * object occurs only once, rather than once for each evaluation
+ * of the function.
*
- * See also: Function0, AggStep, AggFinal
+ * See also: BuiltinFunction0, AggStep, AggFinal
*/
-case OP_Function0: {
+case OP_BuiltinFunction0: {
int n;
sql_context *pCtx;
@@ -1717,11 +1718,11 @@ case OP_Function0: {
pCtx->argc = n;
pOp->p4type = P4_FUNCCTX;
pOp->p4.pCtx = pCtx;
- pOp->opcode = OP_Function;
- /* Fall through into OP_Function */
+ pOp->opcode = OP_BuiltinFunction;
+ /* Fall through into OP_BuiltinFunction */
FALLTHROUGH;
}
-case OP_Function: {
+case OP_BuiltinFunction: {
int i;
sql_context *pCtx;
--
2.22.0
next prev parent reply other threads:[~2019-08-08 14:51 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-08 14:50 [tarantool-patches] [PATCH v2 0/8] sql: uniform SQL and Lua functions subsystem Kirill Shcherbatov
2019-08-08 14:50 ` [tarantool-patches] [PATCH v2 1/8] sql: remove SQL_PreferBuiltin flag Kirill Shcherbatov
2019-08-09 16:07 ` [tarantool-patches] " n.pettik
2019-08-12 21:58 ` Konstantin Osipov
2019-08-08 14:50 ` [tarantool-patches] [PATCH v2 2/8] sql: GREATEST, LEAST instead of MIN/MAX overload Kirill Shcherbatov
2019-08-09 17:37 ` [tarantool-patches] " n.pettik
2019-08-13 8:26 ` Kirill Shcherbatov
2019-08-12 21:59 ` Konstantin Osipov
2019-08-08 14:50 ` [tarantool-patches] [PATCH v2 3/8] sql: wrap all trim functions in dispatcher Kirill Shcherbatov
2019-08-09 18:05 ` [tarantool-patches] " n.pettik
2019-08-13 8:28 ` Kirill Shcherbatov
2019-08-13 22:19 ` n.pettik
2019-08-12 22:00 ` Konstantin Osipov
2019-08-08 14:50 ` [tarantool-patches] [PATCH v2 4/8] sql: get rid of SQL_FUNC_COUNT flag Kirill Shcherbatov
2019-08-12 22:01 ` [tarantool-patches] " Konstantin Osipov
2019-08-13 20:35 ` n.pettik
2019-08-14 7:25 ` Kirill Shcherbatov
2019-08-08 14:50 ` [tarantool-patches] [PATCH v2 5/8] sql: introduce a signature_mask for functions Kirill Shcherbatov
2019-08-12 22:04 ` [tarantool-patches] " Konstantin Osipov
2019-08-13 8:32 ` Kirill Shcherbatov
2019-08-13 8:44 ` Konstantin Osipov
2019-08-13 20:38 ` n.pettik
2019-08-14 7:21 ` Kirill Shcherbatov
2019-08-08 14:50 ` Kirill Shcherbatov [this message]
2019-08-12 22:04 ` [tarantool-patches] Re: [PATCH v2 6/8] sql: rename OP_Function to OP_BuiltinFunction Konstantin Osipov
2019-08-13 20:36 ` n.pettik
2019-08-08 14:50 ` [tarantool-patches] [PATCH v2 7/8] sql: get rid of FuncDef function hash Kirill Shcherbatov
2019-08-12 22:11 ` [tarantool-patches] " Konstantin Osipov
2019-08-13 7:29 ` Kirill Shcherbatov
2019-08-13 8:42 ` Konstantin Osipov
2019-08-13 9:45 ` Kirill Shcherbatov
2019-08-13 20:40 ` n.pettik
2019-08-16 12:57 ` Kirill Shcherbatov
2019-08-20 16:06 ` n.pettik
2019-08-08 14:50 ` [tarantool-patches] [PATCH v2 8/8] box: get rid of box.internal.sql_function_create Kirill Shcherbatov
2019-08-13 20:43 ` [tarantool-patches] " n.pettik
2019-08-16 12:57 ` Kirill Shcherbatov
2019-08-20 19:36 ` 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=2857f87171c95dfbd279f7237f06960c03e5c45d.1565275469.git.kshcherbatov@tarantool.org \
--to=kshcherbatov@tarantool.org \
--cc=korablev@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH v2 6/8] sql: rename OP_Function to OP_BuiltinFunction' \
/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