From: Mergen Imeev <imeevma@tarantool.org> To: v.shpilevoy@tarantool.org, tsafin@tarantool.org, tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH 6/6] sql: remove OP_ApplyType Date: Thu, 28 May 2020 17:17:40 +0300 [thread overview] Message-ID: <b30753fd73baa19c2e25647a3cd6b0e130956da3.1590671266.git.imeevma@gmail.com> (raw) In-Reply-To: <cover.1590671266.git.imeevma@gmail.com> Opcode OP_ApplyType is not needed now, so it should be removed. Follow-up #4230 --- src/box/sql/expr.c | 30 ------------------------------ src/box/sql/sqlInt.h | 13 ------------- src/box/sql/vdbe.c | 29 ----------------------------- src/box/sql/wherecode.c | 2 +- 4 files changed, 1 insertion(+), 73 deletions(-) diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c index 8ec685cd9..55db089cc 100644 --- a/src/box/sql/expr.c +++ b/src/box/sql/expr.c @@ -2246,36 +2246,6 @@ sqlExprCanBeNull(const Expr * p) } } -bool -sql_expr_needs_no_type_change(const struct Expr *p, enum field_type type) -{ - u8 op; - if (type == FIELD_TYPE_SCALAR) - return true; - while (p->op == TK_UPLUS || p->op == TK_UMINUS) { - p = p->pLeft; - } - op = p->op; - if (op == TK_REGISTER) - op = p->op2; - switch (op) { - case TK_INTEGER: - return type == FIELD_TYPE_INTEGER; - case TK_FLOAT: - return type == FIELD_TYPE_DOUBLE; - case TK_STRING: - return type == FIELD_TYPE_STRING; - case TK_BLOB: - return type == FIELD_TYPE_VARBINARY; - case TK_COLUMN: - /* p cannot be part of a CHECK constraint. */ - assert(p->iTable >= 0); - return p->iColumn < 0 && sql_type_is_numeric(type); - default: - return false; - } -} - /* * pX is the RHS of an IN operator. If pX is a SELECT statement * that can be simplified to a direct table access, then return diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 37283e506..8314e7176 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -3229,19 +3229,6 @@ int sqlExprIsTableConstant(Expr *, int); int sqlExprIsInteger(Expr *, int *); int sqlExprCanBeNull(const Expr *); -/** - * Return TRUE if the given expression is a constant which would - * be unchanged by OP_ApplyType with the type given in the second - * argument. - * - * This routine is used to determine if the OP_ApplyType operation - * can be omitted. When in doubt return FALSE. A false negative - * is harmless. A false positive, however, can result in the wrong - * answer. - */ -bool -sql_expr_needs_no_type_change(const struct Expr *expr, enum field_type type); - /** * This routine generates VDBE code that causes a single row of a * single table to be deleted. Both the original table entry and diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 021e09d1e..1fea86098 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -2811,35 +2811,6 @@ case OP_Fetch: { break; } -/* Opcode: ApplyType P1 P2 * P4 * - * Synopsis: type(r[P1@P2]) - * - * Apply types to a range of P2 registers starting with P1. - * - * P4 is a string that is P2 characters long. The nth character of the - * string indicates the column type that should be used for the nth - * memory cell in the range. - */ -case OP_ApplyType: { - enum field_type *types = pOp->p4.types; - assert(types != NULL); - assert(types[pOp->p2] == field_type_MAX); - pIn1 = &aMem[pOp->p1]; - enum field_type type; - while((type = *(types++)) != field_type_MAX) { - assert(pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)]); - assert(memIsValid(pIn1)); - if (mem_apply_type(pIn1, type) != 0) { - diag_set(ClientError, ER_SQL_TYPE_MISMATCH, - sql_value_to_diag_str(pIn1), - field_type_strs[type]); - goto abort_due_to_error; - } - pIn1++; - } - break; -} - /* Opcode: CheckType P1 P2 * P4 * * Synopsis: type(r[P1@P2]) * diff --git a/src/box/sql/wherecode.c b/src/box/sql/wherecode.c index 1d7c76670..1ec9f4ed7 100644 --- a/src/box/sql/wherecode.c +++ b/src/box/sql/wherecode.c @@ -571,7 +571,7 @@ codeEqualityTerm(Parse * pParse, /* The parsing context */ * * Before returning, @types is set to point to a buffer containing a * copy of the column types array of the index allocated using - * sqlDbMalloc(). This array is passed to OP_ApplyType to provide + * sqlDbMalloc(). This array is passed to OP_CheckType to provide * correct implicit conversions. */ static int -- 2.25.1
next prev parent reply other threads:[~2020-05-28 14:17 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-28 14:17 [Tarantool-patches] [PATCH 0/6] Remove implicit cast Mergen Imeev 2020-05-28 14:17 ` [Tarantool-patches] [PATCH 1/6] sql: remove implicit cast for assignment Mergen Imeev 2020-06-01 17:03 ` Vladislav Shpilevoy 2020-06-09 11:41 ` Mergen Imeev 2020-06-09 22:28 ` Vladislav Shpilevoy 2020-05-28 14:17 ` [Tarantool-patches] [PATCH 2/6] sql: remove mem_apply_type() from OP_MakeRecord Mergen Imeev 2020-06-01 17:03 ` Vladislav Shpilevoy 2020-06-09 11:43 ` Mergen Imeev 2020-05-28 14:17 ` [Tarantool-patches] [PATCH 3/6] sql: replace ApplyType by CheckType for IN operator Mergen Imeev 2020-05-28 14:17 ` [Tarantool-patches] [PATCH 4/6] sql: remove mem_apply_type() from OP_MustBeInt Mergen Imeev 2020-06-01 17:04 ` Vladislav Shpilevoy 2020-06-09 11:47 ` Mergen Imeev 2020-06-09 22:28 ` Vladislav Shpilevoy 2020-05-28 14:17 ` [Tarantool-patches] [PATCH 5/6] sql: remove implicit cast from string for comparison Mergen Imeev 2020-06-01 17:04 ` Vladislav Shpilevoy 2020-06-09 11:51 ` Mergen Imeev 2020-06-09 22:29 ` Vladislav Shpilevoy 2020-05-28 14:17 ` Mergen Imeev [this message] 2020-06-09 22:29 ` [Tarantool-patches] [PATCH 6/6] sql: remove OP_ApplyType Vladislav Shpilevoy 2020-06-01 17:03 ` [Tarantool-patches] [PATCH 0/6] Remove implicit cast Vladislav Shpilevoy 2020-06-09 11:25 ` Mergen Imeev
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=b30753fd73baa19c2e25647a3cd6b0e130956da3.1590671266.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=tsafin@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 6/6] sql: remove OP_ApplyType' \ /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