[Tarantool-patches] [PATCH v5 44/52] sql: introduce mem_cast_implicit()
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Wed Apr 14 01:59:58 MSK 2021
Good job on the fixes!
> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
> index 29634841a..72a84e80d 100644
> --- a/src/box/sql/vdbe.c
> +++ b/src/box/sql/vdbe.c
> @@ -2092,23 +2092,12 @@ case OP_ApplyType: {
> while((type = *(types++)) != field_type_MAX) {
> assert(pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)]);
> assert(memIsValid(pIn1));
> - if (!mem_is_type_compatible(pIn1, type)) {
> - /* Implicit cast is allowed only to numeric type. */
> - if (!sql_type_is_numeric(type))
> - goto type_mismatch;
> - /* Implicit cast is allowed only from numeric type. */
> - if (!mem_is_num(pIn1))
> - goto type_mismatch;
> - /* Try to convert numeric-to-numeric. */
> - if (mem_cast_explicit(pIn1, type) != 0)
> - goto type_mismatch;
> + if (mem_cast_implicit(pIn1, type) != 0) {
> + diag_set(ClientError, ER_SQL_TYPE_MISMATCH,
> + mem_str(pIn1), field_type_strs[type]);
> + goto abort_due_to_error;
I think it would be better both for explicit and implicit casts
to have the diag_set() inside.
More information about the Tarantool-patches
mailing list