Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJ2nc-0000Y0-P6 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2020 22:22:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jJ2nb-0006Zj-N2 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2020 22:22:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJ2nb-0006YF-Cn for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2020 22:22:27 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jJ2nX-0002MI-MO for pgsql-hackers@postgresql.org; Mon, 30 Mar 2020 22:22:26 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id BD57421C5703; Tue, 31 Mar 2020 01:22:21 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.0.103] (unknown [188.235.32.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 9332921C08BB; Tue, 31 Mar 2020 01:22:20 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1585606941; bh=hBYHKRUcwiAFRUWijKF2YQVhRbTl7dKHz40++Cy5S9o=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=YCIklQnp2OjMHI36fH6czdW74/Ow5SPPyamwKEubGIEANAgC0d6/esDEXCdJMIjnk oB/a+mgSfTe2o5e9STyJg8ob5+VcR4Meo3oIOAjFi9bU29fRiKH8DQg0JR8PLiqVBz 0yS2SctUXN8zrTCN/t0SFXfolTajm9CqGOVV6XS0= Subject: Re: fix for BUG #3720: wrong results at using ltree To: Tom Lane , Pgsql Hackers Cc: =?UTF-8?Q?Filip_Rembia=c5=82kowski?= , Tomas Vondra , Alexander Korotkov , Oleg Bartunov , Thomas Munro , Teodor Sigaev References: <28639.1554565562@sss.pgh.pa.us> <5eedfd9e-2f14-a2df-3bd9-4c92eb0f08a5@postgrespro.ru> <20200124182915.zz7hzdkijzsb4ic4@development> <19375.1585438012@sss.pgh.pa.us> <15582.1585529626@sss.pgh.pa.us> <23304.1585591242@sss.pgh.pa.us> <943dc224-eb82-8abd-15c3-f4b516f89767@postgrespro.ru> <3007.1585605566@sss.pgh.pa.us> <3843.1585606362@sss.pgh.pa.us> From: Nikita Glukhov Organization: Postgres Professional Message-ID: <9247ddc2-d1e0-7d62-55a6-62a089e99a8a@postgrespro.ru> Date: Tue, 31 Mar 2020 01:22:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <3843.1585606362@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------A07A481D6D4018384DDFA13A" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------A07A481D6D4018384DDFA13A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 31.03.2020 1:12, Tom Lane wrote: > I wrote: >> I dunno, that doesn't really seem clearer to me (although some of it >> might be that you expended no effort on making the comments match >> the new code logic). > ... although looking closer, this formulation does have one very nice > advantage: for the typical non-star case with high = low = 1, the > only recursive call is a tail recursion, so it ought to consume less > stack space than what I wrote. And we even can simply transform this tail call into a loop: -if (tlen > 0 && qlen > 0) +while (tlen > 0 && qlen > 0) > Let me see what I can do with the comments. Thanks. -- Nikita Glukhov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company --------------A07A481D6D4018384DDFA13A Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

On 31.03.2020 1:12, Tom Lane wrote:

I wrote:
I dunno, that doesn't really seem clearer to me (although some of it
might be that you expended no effort on making the comments match
the new code logic).
... although looking closer, this formulation does have one very nice
advantage: for the typical non-star case with high = low = 1, the
only recursive call is a tail recursion, so it ought to consume less
stack space than what I wrote.
And we even can simply transform this tail call into a loop:

-if (tlen > 0 && qlen > 0)
+while (tlen > 0 && qlen > 0)

Let me see what I can do with the comments.
Thanks.

-- 
Nikita Glukhov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

--------------A07A481D6D4018384DDFA13A--