X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id 1EA73CD085 for ; Sun, 20 Jul 2003 06:11:01 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 05551-09 for ; Sun, 20 Jul 2003 06:11:36 +0000 (GMT) Received: from megazone.bigpanda.com (unknown [66.180.233.26]) by svr1.postgresql.org (Postfix) with ESMTP id 2D72FCD07E for ; Sun, 20 Jul 2003 03:10:59 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 047CAD635; Sat, 19 Jul 2003 23:11:34 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id E64085C14; Sat, 19 Jul 2003 23:11:34 -0700 (PDT) Date: Sat, 19 Jul 2003 23:11:34 -0700 (PDT) From: Stephan Szabo To: "Michael S. Tibbetts" Cc: Subject: Re: min() and NaN In-Reply-To: <3F145162.7010805@head-cfa.harvard.edu> Message-ID: <20030719230117.X55138-100000@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/299 X-Sequence-Number: 14413 On Tue, 15 Jul 2003, Michael S. Tibbetts wrote: > Hi, > > I have a table containing a double precision column. That column > contains at least one judiciously placed NaN. > > I'd expect the aggregate function min() to return the minimum, valid > numeric value. Instead, it seems to return the minimum value from the > subset of rows following the 'NaN'. This appears to be a bug in the min (and presumably max) aggregate function for floats. AFAICT It should use the same logic as the < (or >) comparison operator for the type (SQL92 6.5 GR2b iii I believe), but it's just doing a < (or >) in C on the two arguments which isn't the same. Changing it to follow those rules would give 2.718 for min and it looks like NaN for max.