From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E9E5B43040B for ; Wed, 12 Aug 2020 18:15:47 +0300 (MSK) From: imeevma@tarantool.org Date: Wed, 12 Aug 2020 18:15:47 +0300 Message-Id: <3d38cd163a24bf14298a16ee7231086a4df56015.1597244875.git.imeevma@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v1 2/7] sql: do not return UNSIGNED in built-in functions List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: v.shpilevoy@tarantool.org Cc: tarantool-patches@dev.tarantool.org This patch forces functions to return INTEGER instead of UNSIGNED. Part of #4159 --- src/box/sql/vdbeapi.c | 2 +- test/sql/types.result | 12 ++++++++++++ test/sql/types.test.lua | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index 7c59ef83f..d1eeaf114 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -328,7 +328,7 @@ sql_result_double(sql_context * pCtx, double rVal) void sql_result_uint(sql_context *ctx, uint64_t u_val) { - mem_set_u64(ctx->pOut, u_val); + mem_set_int(ctx->pOut, u_val, false); } void diff --git a/test/sql/types.result b/test/sql/types.result index 442245186..95f7713e8 100644 --- a/test/sql/types.result +++ b/test/sql/types.result @@ -2795,3 +2795,15 @@ box.execute([[DROP TABLE ts;]]) --- - row_count: 1 ... +-- +-- gh-4159: Make sure that functions returns values of type INTEGER +-- instead of values of type UNSIGNED. +-- +box.execute([[SELECT typeof(length('abc'));]]) +--- +- metadata: + - name: COLUMN_1 + type: string + rows: + - ['integer'] +... diff --git a/test/sql/types.test.lua b/test/sql/types.test.lua index 0270d9f8a..fff0057bd 100644 --- a/test/sql/types.test.lua +++ b/test/sql/types.test.lua @@ -623,3 +623,9 @@ box.execute([[DROP TABLE tb;]]) box.execute([[DROP TABLE tt;]]) box.execute([[DROP TABLE tv;]]) box.execute([[DROP TABLE ts;]]) + +-- +-- gh-4159: Make sure that functions returns values of type INTEGER +-- instead of values of type UNSIGNED. +-- +box.execute([[SELECT typeof(length('abc'));]]) -- 2.25.1