From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id E67B06EC41; Mon, 5 Jul 2021 18:06:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E67B06EC41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1625497576; bh=pocfsOrL/Md5gA2GunEPy79eT5b20wEfGhpD6TMKdjI=; h=To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=oqY9u++oC3D8toN9hzfHLhteB6oxPIHkyZLca7R/o+wVW6LZY2V2mKSJSk/bQDntw 3QDL2SPRyomlY8ZfZotZ3V0f8juDGqcaumMfPlLPLTHr7Im9BM280Z5PsAKwnmu4Z3 Tx7L6zgRWBIqDwLK3n0gSzJBZ45Lc0e7tmZmWHwM= Received: from smtpng2.i.mail.ru (smtpng2.i.mail.ru [94.100.179.3]) (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 EFFDB6EC40 for ; Mon, 5 Jul 2021 18:06:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EFFDB6EC40 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1m0QAn-0003Mf-8r; Mon, 05 Jul 2021 18:06:13 +0300 To: v.shpilevoy@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Mon, 5 Jul 2021 18:06:12 +0300 Message-Id: <9f12b130a632224a7783e516c182febeecef4fb9.1625497228.git.imeevma@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD954DFF1DC42D673FB703477AD6D36A6E3513B6A65BE508F5F182A05F538085040FDB681C644E662CF0D2831AC8D9D69A6B03275D40DA1697D603B0A7C11AAAB1F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71D6E7AC8529A326CEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637334E2757C55E8D4EEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F28CC70CC850EE56497A9DA81E52C960B3CC7F00164DA146DAFE8445B8C89999728AA50765F790063783E00425F71A4181389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC82FFDA4F57982C5F4F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8BDAE3FA6833AEA0C275ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C62E2A2CC9B321AEEBBE76AAEEF253499B59241D4315D7C369C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFB1D0AC14175A0720699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D349379E7F8541B6C9A946DBD4D4540132361EAB661DBE99E53FF6E65B067837FF5E77F0FA7FEECEFFD1D7E09C32AA3244C6152A7F36D6C6DC24282E3EE1D8140E63A76366E8A9DE7CA729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXj8QT+zeI9PXfbEARo0L/uI X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DB3F58D18E5EF814348C87B0346BAEA5683D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v1 1/3] sql: introduce uuid to quote() X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mergen Imeev via Tarantool-patches Reply-To: imeevma@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Prior to this patch, built-in SQL function quote() could not work with uuid. It now returns a string representation of the received uuid. Part of #6164 --- src/box/sql/func.c | 24 ++++++++++++------- test/sql-tap/gh-6164-uuid-follow-ups.test.lua | 16 +++++++++++++ 2 files changed, 31 insertions(+), 9 deletions(-) create mode 100755 test/sql-tap/gh-6164-uuid-follow-ups.test.lua diff --git a/src/box/sql/func.c b/src/box/sql/func.c index f93ae867d..aa565277c 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -1098,8 +1098,8 @@ quoteFunc(sql_context * context, int argc, sql_value ** argv) { assert(argc == 1); UNUSED_PARAMETER(argc); - switch (sql_value_type(argv[0])) { - case MP_DOUBLE:{ + switch (argv[0]->type) { + case MEM_TYPE_DOUBLE:{ double r1, r2; char zBuf[50]; r1 = mem_get_double_unsafe(argv[0]); @@ -1113,14 +1113,20 @@ quoteFunc(sql_context * context, int argc, sql_value ** argv) SQL_TRANSIENT); break; } - case MP_UINT: - case MP_INT:{ + case MEM_TYPE_UUID: { + char buf[UUID_STR_LEN + 1]; + tt_uuid_to_string(&argv[0]->u.uuid, &buf[0]); + sql_result_text(context, buf, UUID_STR_LEN, SQL_TRANSIENT); + break; + } + case MEM_TYPE_UINT: + case MEM_TYPE_INT: { sql_result_value(context, argv[0]); break; } - case MP_BIN: - case MP_ARRAY: - case MP_MAP: { + case MEM_TYPE_BIN: + case MEM_TYPE_ARRAY: + case MEM_TYPE_MAP: { char *zText = 0; char const *zBlob = mem_as_bin(argv[0]); int nBlob = mem_len_unsafe(argv[0]); @@ -1146,7 +1152,7 @@ quoteFunc(sql_context * context, int argc, sql_value ** argv) } break; } - case MP_STR:{ + case MEM_TYPE_STR: { int i, j; u64 n; const unsigned char *zArg = mem_as_ustr(argv[0]); @@ -1174,7 +1180,7 @@ quoteFunc(sql_context * context, int argc, sql_value ** argv) } break; } - case MP_BOOL: { + case MEM_TYPE_BOOL: { sql_result_text(context, SQL_TOKEN_BOOLEAN(mem_get_bool_unsafe(argv[0])), -1, SQL_TRANSIENT); diff --git a/test/sql-tap/gh-6164-uuid-follow-ups.test.lua b/test/sql-tap/gh-6164-uuid-follow-ups.test.lua new file mode 100755 index 000000000..d8fa700ea --- /dev/null +++ b/test/sql-tap/gh-6164-uuid-follow-ups.test.lua @@ -0,0 +1,16 @@ +#!/usr/bin/env tarantool +local test = require("sqltester") +test:plan(1) + +box.execute([[select quote(cast('11111111-1111-1111-1111-111111111111' as uuid));]]) + +-- Make sure that function quote() can work with uuid. +test:do_execsql_test( + "gh-6164-1", + [[ + SELECT quote(cast('11111111-1111-1111-1111-111111111111' as uuid)); + ]], { + '11111111-1111-1111-1111-111111111111' + }) + +test:finish_test() -- 2.25.1