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 91FAE6D3F5; Mon, 25 Oct 2021 11:19:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 91FAE6D3F5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635149974; bh=weveN090P4/m9LCKlWBEElVf4A7L91qYk3gaAbA7910=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=UlxlEjtv0wlqBYEqV31Li9vEmPDTvJRM3XfYyfocFwmtBTlVmw+RepwUd4lP+tiIM BtoPNmJLRDdmmilKBnBrPBQzwPoNR+HngYJyb4IHllUAjRuGOK4/NLRafSPX585Nkp uBtfFH+k3WHmZ8H0ZaIWyGpnfVFGZmgGBEBYai98= 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 95B276D3F5 for ; Mon, 25 Oct 2021 11:19:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 95B276D3F5 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mevCf-0007wA-07; Mon, 25 Oct 2021 11:19:33 +0300 Date: Mon, 25 Oct 2021 11:19:31 +0300 To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Message-ID: <20211025081931.GC36295@tarantool.org> References: <30a2f5e5-ccf8-2103-bc67-ac55264213cd@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <30a2f5e5-ccf8-2103-bc67-ac55264213cd@tarantool.org> X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9C7814344C8C501C83E7F929BE7EA671116302D09E268010D182A05F5380850408BF29513F9717BABF7FE87108CA58AC3B00C4FA7E6D7AD89A71627B4D445082C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D6964C9E324ABA58EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F1FEB73A813C0D3B8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D84A69D691EEF58E82D8F64EC637D76C91117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B62CFFCC7B69C47339089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5C79D1DEDFBAF4653B9CD855CF6FD8EB10588D13FC4F8BCAFD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75FA7FF33AA1A4D21C410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34E54F8089C01448AA1AC80C8376879044B90299BCAC9B47A51DFCE9959718E81F33D75DD2E67502FF1D7E09C32AA3244C1E9985AAF28A07BCA9BC4E7FB9789DA8F94338140B71B8EE729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojPL6H901iH3GuZVoH7TDmKQ== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D937C1F270CAC6C0897ABE736FD473A5583D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 03/21] sql: refactor HEX() 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: Mergen Imeev Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thank you for the review! My answer and diff below. Also, I added a description of the function. On Fri, Oct 15, 2021 at 12:43:14AM +0200, Vladislav Shpilevoy wrote: > Good job on the patch! > > > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > > index 7886f5f40..e5d763be1 100644 > > --- a/src/box/sql/func.c > > +++ b/src/box/sql/func.c > > @@ -800,6 +800,39 @@ func_greatest_least(struct sql_context *ctx, int argc, struct Mem *argv) > > ctx->is_aborted = true; > > } > > > > +/** Implementation of the HEX() function. */ > > +static const char hexdigits[] = { > > + '0', '1', '2', '3', '4', '5', '6', '7', > > + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' > > +}; > > + > > +static void > > +func_hex(struct sql_context *ctx, int argc, struct Mem *argv) > > +{ > > + assert(argc == 1); > > + (void)argc; > > + struct Mem *arg = &argv[0]; > > + if (mem_is_null(arg)) > > + return mem_set_null(ctx->pOut); > > Isn't pOut already null? I thought it is created as null. True, fixed. Diff: diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 96525ed3a..2abf6811d 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -796,7 +796,11 @@ func_greatest_least(struct sql_context *ctx, int argc, struct Mem *argv) ctx->is_aborted = true; } -/** Implementation of the HEX() function. */ +/** + * Implementation of the HEX() function. + * + * The HEX() function returns the hexadecimal representation of the argument. + */ static const char hexdigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' @@ -809,7 +813,7 @@ func_hex(struct sql_context *ctx, int argc, struct Mem *argv) (void)argc; struct Mem *arg = &argv[0]; if (mem_is_null(arg)) - return mem_set_null(ctx->pOut); + return; assert(mem_is_bin(arg) && arg->n >= 0); if (arg->n == 0)