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 833DA6E46A; Fri, 8 Oct 2021 20:39:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 833DA6E46A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633714758; bh=7f0ExTwC1nSqmre1ePEL6iWUaGHU5awbwcljn2rN8sY=; 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=tFK9kxMxN0LnIUhSM/9+k203HpX7UpgkDz8WAq/64l6kf8R6RMPJpA2YTVb3ggVvF CaxRU104rYzp69E3uPlIII0vnGBWf08xsapnZXgYaBwBopzFhvOSndmcYqkAw4mzAL DG1/8EAcpWSBrUKvcIA1BbykR10wxq2pQHGLW7ws= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 3813A6E46D for ; Fri, 8 Oct 2021 20:32:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3813A6E46D Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mYtiy-00086u-Lb; Fri, 08 Oct 2021 20:32:01 +0300 To: v.shpilevoy@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Fri, 8 Oct 2021 20:32:00 +0300 Message-Id: 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: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9A6D4E3B1981C4C7DD6313C0D12430C2EBE99D9AA6174C4CF182A05F538085040209E09766000AF33312CEC5D6549BD615B49BA8A5F205B1A490D413B6A3E5811 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE75012335B19220D49EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E25DEE08FA4D750E8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D87445E72AE05FEE88503D3F480AA62780117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735209ECD01F8117BC8BEA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CD1D040B6C1ECEA3F43847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C650BD2383FF25EF5D727B600409F5970A72EE540B23CE5239C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF520746E264B47742699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D342B8615F5CFAD9D026347322817F3FDFBB76CE7600BD473D0125EBF38ACFF1875B5A9B046C2A10E591D7E09C32AA3244C843A549A6CF6759B593CFB4A3929A31F5A1673A01BA68E40729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMZ06aokA6bqkCpDUqEe8Pw== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DF57DBAEAFE4F66C5694D318AB68F3B7583D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v1 15/21] sql: refactor of SOUNDEX() function 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" Part of #4145 --- src/box/sql/func.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 5e12ef729..a3ca53545 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -1555,16 +1555,11 @@ soundexFunc(struct sql_context *context, int argc, struct Mem *argv) 1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0, }; assert(argc == 1); - if (mem_is_bin(&argv[0]) || mem_is_map(&argv[0]) || - mem_is_array(&argv[0])) { - diag_set(ClientError, ER_SQL_TYPE_MISMATCH, - mem_str(&argv[0]), "string"); - context->is_aborted = true; - return; - } - zIn = (u8 *) mem_as_ustr(&argv[0]); - if (zIn == 0) + assert(mem_is_null(&argv[0]) || mem_is_str(&argv[0])); + if (mem_is_null(&argv[0]) || argv[0].n == 0) zIn = (u8 *) ""; + else + zIn = (unsigned char *)argv[0].z; for (i = 0; zIn[i] && !sqlIsalpha(zIn[i]); i++) { } if (zIn[i]) { @@ -1585,12 +1580,10 @@ soundexFunc(struct sql_context *context, int argc, struct Mem *argv) zResult[j++] = '0'; } zResult[j] = 0; - sql_result_text(context, zResult, 4, SQL_TRANSIENT); + if (mem_copy_str(context->pOut, zResult, 4) != 0) + context->is_aborted = true; } else { - /* IMP: R-64894-50321 The string "?000" is returned if the argument - * is NULL or contains no ASCII alphabetic characters. - */ - sql_result_text(context, "?000", 4, SQL_STATIC); + mem_set_str_static(context->pOut, "?000", 4); } } -- 2.25.1