[Tarantool-patches] [PATCH v1 1/1] sql: remove implicit cast for COMPARISON

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun Apr 26 21:22:27 MSK 2020


Hi! Seems like you didn't push the latest version.

> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
> index 724bc18..34bd38d 100644
> --- a/src/box/sql/vdbe.c
> +++ b/src/box/sql/vdbe.c
> @@ -3471,6 +3459,26 @@ skip_truncate:
>  	assert(oc!=OP_SeekLT || r.default_rc==+1);
>  
>  	r.aMem = &aMem[pOp->p3];
> +	for (int i = 0; i < r.nField; ++i) {
> +		enum field_type type = r.key_def->parts[i].type;
> +		struct Mem *mem = &r.aMem[i];
> +		if ((mem->flags & MEM_Str) != 0 && sql_type_is_numeric(type)) {
> +			diag_set(ClientError, ER_SQL_TYPE_MISMATCH,
> +				field_type_strs[type], mem_type_to_str(mem));
> +			goto abort_due_to_error;
> +		}
> +		if (mem_apply_type(mem, type) != 0) {
> +			diag_set(ClientError, ER_SQL_TYPE_MISMATCH,
> +				field_type_strs[type], mem_type_to_str(mem));
> +			goto abort_due_to_error;
> +		}
> +		if ((mem->flags & MEM_Real) != 0 &&
> +		    (type == FIELD_TYPE_INTEGER ||
> +		     type == FIELD_TYPE_UNSIGNED)) {
> +			res = 1;
> +			goto seek_not_found;
> +		}
> +	}

What is happening in this cycle and the cycle below?

>  #ifdef SQL_DEBUG
>  	{ int i; for(i=0; i<r.nField; i++) assert(memIsValid(&r.aMem[i])); }
>  #endif
> diff --git a/test/sql-tap/in1.test.lua b/test/sql-tap/in1.test.lua
> index 570cc17..e2f4988 100755
> --- a/test/sql-tap/in1.test.lua
> +++ b/test/sql-tap/in1.test.lua
> @@ -637,12 +637,12 @@ test:do_test(
>      "in-11.2",
>      function()
>          -- The '2' should be coerced into 2 because t6.b is NUMERIC

The comment is irrelevant now. And therefore the test probably too. Please,
locate all other tests, which become wrong after this commit, and fix their
comments or remove completely.


More information about the Tarantool-patches mailing list