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 432016E1C9; Thu, 11 Nov 2021 13:57:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 432016E1C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1636628257; bh=3w77yOe4AaayOMnBlF110Mr+OTFjzni0c9xMRQEJz/Q=; 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=CaNEQBuWLDva3vwQRImqlyDIEQ0KG22DKnyfnzGHxivPJnjeSc81R1p4m+5HL9hFE J2TYd4UJEuzqZ8NhAFMyFtlIzTQlK+Ag9CKzAz+HD3PPDaGzVMk4WDNWT3vyrQUFlw VoKYrpL5Hfce8hQZl0LngMCcF+yWIBFbV2mylC8A= 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 7F4217106D for ; Thu, 11 Nov 2021 13:49:17 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7F4217106D Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1ml7ds-000574-Gk; Thu, 11 Nov 2021 13:49:16 +0300 To: kyukhin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Thu, 11 Nov 2021 13:49:16 +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: 4F1203BC0FB41BD9731B3922EC063979A442978D427656AE2233A9C8B25E6BF500894C459B0CD1B99688662D68732A0348D4ABC67E5B1A58BD7B9CED87D255670C2C9DC93A1268B0 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77EB2E345998A721DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063790C8302959DAAF098638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D86D2DA6E96FFF05AB8800FDAC05372048117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735209ECD01F8117BC8BEA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C289736CE4F78F08343847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C7E9FEBB9C11794A129BE8CE276AA437FCFD00779715456109C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFCDE59DDCCE53AF2B699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3455049D7B43D89D64739672C907FD1A0EA5410E120606FCEE59183D52135DAC2A52F32FCC8E6206801D7E09C32AA3244C77545BCEAECBD2F16E2E3450AE0FA234259227199D06760A729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj4t8MBgWr8bISwedRgjxhYw== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DEBFABF5DF89A519A90AFDACBDAAC226983D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v1 15/21] sql: refactor 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 69d4e7347..ed4d681fc 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -1591,16 +1591,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]) { @@ -1621,12 +1616,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