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 1431426AC5 for ; Thu, 8 Aug 2019 10:51:01 -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 72bqm7-uae1K for ; Thu, 8 Aug 2019 10:51:00 -0400 (EDT) Received: from smtp5.mail.ru (smtp5.mail.ru [94.100.179.24]) (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 C2A0C26A96 for ; Thu, 8 Aug 2019 10:51:00 -0400 (EDT) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v2 6/8] sql: rename OP_Function to OP_BuiltinFunction Date: Thu, 8 Aug 2019 17:50:50 +0300 Message-Id: <2857f87171c95dfbd279f7237f06960c03e5c45d.1565275469.git.kshcherbatov@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: tarantool-patches@freelists.org, korablev@tarantool.org Cc: Kirill Shcherbatov 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