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 1kk6Iu-0006CN-47 for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Dec 2020 14:06:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kk6It-0001cJ-0v for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Dec 2020 14:06:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kk6Is-0001bo-N2 for pgsql-hackers@lists.postgresql.org; Tue, 01 Dec 2020 14:06:50 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kk6Io-0006l9-OC for pgsql-hackers@lists.postgresql.org; Tue, 01 Dec 2020 14:06:48 +0000 Received: from [192.168.1.70] (109-252-183-137.dynamic.spd-mgts.ru [109.252.183.137]) (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 D8D7721C688B; Tue, 1 Dec 2020 17:06:44 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1606831604; bh=Xm+Aitu15fl9rDUn1F6E3kpybCkwo+xCPXK+o2J0ucE=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=N3lnf6ndsrxVTcVD2bF5750ybq0jUE94+O8xVHlj/eo9RscAWPDsDPw0xc6tyUaiM 0iTqpkBil4A7M3hZZ84gfSXLa7oLw8mbPuN05g48xzrdt+atnohnz308v2cFigLKY/ /Un2dzXcSujdBtE6Afff/wv7MLCWPzYWygs+2I74= Subject: Re: Strange behavior with polygon and NaN To: Kyotaro Horiguchi , tgl@sss.pgh.pa.us Cc: gkokolatos@pm.me, pgsql-hackers@lists.postgresql.org References: <20201124.135544.121959508317571971.horikyota.ntt@gmail.com> <290594.1606238981@sss.pgh.pa.us> <20201125.113939.692283304590689816.horikyota.ntt@gmail.com> <20201125.171406.1000330279258818376.horikyota.ntt@gmail.com> From: Anastasia Lubennikova Message-ID: <8d811be6-aebf-7276-0ec2-048ab58607ab@postgrespro.ru> Date: Tue, 1 Dec 2020 17:06:44 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201125.171406.1000330279258818376.horikyota.ntt@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 25.11.2020 11:14, Kyotaro Horiguchi wrote: > At Wed, 25 Nov 2020 11:39:39 +0900 (JST), Kyotaro Horiguchi wrote in >>> So that line of thought prompts me to tread *very* carefully when >>> trying to dodge NaN results. We need to be certain that we >>> introduce only logically-defensible special cases. Something like >>> float8_coef_mul() seems much more likely to lead us into errors >>> than away from them. >> Agreed on that point. I'm going to rewirte the patch in that >> direction. > Removed the function float8_coef_mul(). > > > I noticed that the check you proposed to add to line_closept_point > doesn't work for the following case: > > select line('{1,-1,0}') <-> point(1e300, 'Infinity'); > > Ax + By + C = 1 * 1e300 + -1 * Inf + 0 = -Inf is not NaN so we go on > the following steps. > > derive the perpendicular line: => line(-1, -1, Inf} > derive the cross point : => point(Inf, Inf) > calculate the distance : => NaN (which should be Infinity) > > So I left the check whether distance is NaN in this version. In the previous version the check is done before directly calculating the distance, but since we already have the result of Ax+Bx+C so I decided not to use point_dt() in this > version. > > Although I wrote that it should be wrong that applying FPzero() to > coefficients, there are some places already doing that so I followed > those predecessors. > > > Reverted the change of pg_hypot(). > > > While checking the regression results, I noticed that the follwoing > calculation, which seems wrong. > > select line('{3,NaN,5}') = line('{3,NaN,5}'); > ?column? > ---------- > t > > But after looking point_eq(), I decided to let the behavior alone > since I'm not sure the reason for the behavior of the functions. At > least the comment for point_eq() says that is the delibarate > behvior. box_same, poly_same base on the point_eq_point so they behave > the same way. > > > By the way, '=' doesn't compare the shape but compares the area. > However, what is the area of a line? That should be always 0 even if > we considered it. And it is also strange that we don't have > corresponding comparison ('<' and so) operators. It seems to me as if > a mistake of '~='. If it is correct, I should revert the change of > line_eq() along with fixing operator assignment. > > regards. > Status update for a commitfest entry. The commitfest is closed now and this entry is "Waiting on author". As far as I see, part of the fixes is already committed. Is there anything left to work on or this patch needs review/ ready for committer now? -- Anastasia Lubennikova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company