Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iCtD1-0006lQ-Nj for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Sep 2019 22:23:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iCtD0-0005a5-KF for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Sep 2019 22:22:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iCtD0-0005Ya-5T for pgsql-hackers@lists.postgresql.org; Tue, 24 Sep 2019 22:22:58 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1iCtCw-0002SY-UG for pgsql-hackers@postgresql.org; Tue, 24 Sep 2019 22:22:57 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 443A621C450F; Wed, 25 Sep 2019 01:22:52 +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 [10.100.236.30] (unknown [195.82.154.49]) (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 C65C921C44C3; Wed, 25 Sep 2019 01:22:51 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1569363771; bh=dR4T8/6tO1zy12jpxWz2hIalwnfE4k7DU/rT3m2X7gs=; h=Subject:From:To:Cc:References:Date:In-Reply-To; b=mcXyroHIQDQt0pX+2zZodARmYBmAm82w+tyU5k/gzs5dyaEnJF+NKOqlGKA4JYKUq DsRpFnw0OObhhajKBZFakQWUDxFndkTmlcDIA7Q4FwksdAQOwT2yN816loe62qOuA/ AIi5ml6pvyTIVewuFQCPDvkfczGz+pD2ejjSss8c= Subject: Re: Bug in GiST paring heap comparator From: Nikita Glukhov To: Alexander Korotkov , pgsql-hackers Cc: Heikki Linnakangas References: <7362fcac-3664-d960-f0fa-77c24e62a7b3@iki.fi> <826f57ee-afc7-8977-c44c-6111d18b02ec@postgrespro.ru> <907ff6e7-001c-8e86-e05f-ffe5483c2634@postgrespro.ru> <426580d3-a668-b9d1-7b8e-f74d1a6524e0@postgrespro.ru> Organization: Postgres Professional Message-ID: <53536807-784c-e029-6e92-6da802ab8d60@postgrespro.ru> Date: Wed, 25 Sep 2019 01:19:52 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <426580d3-a668-b9d1-7b8e-f74d1a6524e0@postgrespro.ru> Content-Type: multipart/mixed; boundary="------------CAFD5497F917965B65AE5DD1" 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. --------------CAFD5497F917965B65AE5DD1 Content-Type: multipart/alternative; boundary="------------D1E3ED95C46FA0576CB2DFC4" --------------D1E3ED95C46FA0576CB2DFC4 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 20.09.2019 0:15, Nikita Glukhov wrote: > On 19.09.2019 22:14, Alexander Korotkov wrote: >> Pushed. > Attached patch fixes premature xs_orderbynulls[] assignment.  The old value > of NULL flag, not the new, should be checked before pfree()ing the old value. Attached another one-line patch that fixes incorrect number of distances used in pairingheap_SpGistSearchItem_cmp(): - for (i = 0; i < so->numberOfOrderBys; i++) + for (i = 0; i < so->numberOfNonNullOrderBys; i++) This change was present in my original commit, but it seems to have been missed after the rebase. Sorry. -- Nikita Glukhov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company --------------D1E3ED95C46FA0576CB2DFC4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 20.09.2019 0:15, Nikita Glukhov wrote:
On 19.09.2019 22:14, Alexander Korotkov wrote:
Pushed.
Attached patch fixes premature xs_orderbynulls[] assignment.  The old value 
of NULL flag, not the new, should be checked before pfree()ing the old value.
Attached another one-line patch that fixes incorrect number of distances used 
in pairingheap_SpGistSearchItem_cmp():
-    for (i = 0; i < so->numberOfOrderBys; i++)
+    for (i = 0; i < so->numberOfNonNullOrderBys; i++)


This change was present in my original commit, but it seems to have been 
missed after the rebase.  Sorry.

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

--------------D1E3ED95C46FA0576CB2DFC4-- --------------CAFD5497F917965B65AE5DD1 Content-Type: text/x-patch; name="0001-Fix-number-of-distances-in-pairingheap_SpGistSearchI.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Fix-number-of-distances-in-pairingheap_SpGistSearchI.pa"; filename*1="tch" From 2e58a94fd2f973257d1c8a3d9cd0b907c719a859 Mon Sep 17 00:00:00 2001 From: Nikita Glukhov Date: Tue, 24 Sep 2019 01:33:03 +0300 Subject: [PATCH] Fix number of distances in pairingheap_SpGistSearchItem_cmp() --- src/backend/access/spgist/spgscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/access/spgist/spgscan.c b/src/backend/access/spgist/spgscan.c index cfba470..6e940fd 100644 --- a/src/backend/access/spgist/spgscan.c +++ b/src/backend/access/spgist/spgscan.c @@ -56,7 +56,7 @@ pairingheap_SpGistSearchItem_cmp(const pairingheap_node *a, else { /* Order according to distance comparison */ - for (i = 0; i < so->numberOfOrderBys; i++) + for (i = 0; i < so->numberOfNonNullOrderBys; i++) { if (isnan(sa->distances[i]) && isnan(sb->distances[i])) continue; /* NaN == NaN */ -- 2.7.4 --------------CAFD5497F917965B65AE5DD1--