Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V6LJX-0008Ns-7j for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Aug 2013 13:59:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V6LJW-0000nt-Lm for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Aug 2013 13:59:10 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V61SX-0005OA-ME for pgsql-bugs@postgresql.org; Sun, 04 Aug 2013 16:47:09 +0000 Received: from forward3.mail.yandex.net ([2a02:6b8:0:602::3]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V61SO-0006Ey-Fz for pgsql-bugs@postgresql.org; Sun, 04 Aug 2013 16:47:08 +0000 Received: from web11d.yandex.ru (web11d.yandex.ru [77.88.47.156]) by forward3.mail.yandex.net (Yandex) with ESMTP id 76CF7B41446; Sun, 4 Aug 2013 20:46:56 +0400 (MSK) Received: from 127.0.0.1 (localhost.localdomain [127.0.0.1]) by web11d.yandex.ru (Yandex) with ESMTP id 1278A60214F6; Sun, 4 Aug 2013 20:46:56 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1375634816; bh=Bzt9674RskA1aVnNxLMg6o8Qpp8zzzVAVEMh2B6aFjM=; h=From:To:Cc:In-Reply-To:References:Subject:Date; b=NMRBe9/riBmq9l/4wyR9t1WMATcv5+rZF9kDhNwLRaR+Tzurja578KywQnDKWoJeV 4yfAKy+LwkYlbCAmze96toE9VPvqe9XQwZzH0s1rqJc4fLYKyLLjatdUMNrrHiAr7D NCYg5Q6QtgxceBCnzpdbLhxh+6NHMG4v0b4jQNKc= Received: from 27-33-220-62-dyn.hn.nnov.stream.ru (27-33-220-62-dyn.hn.nnov.stream.ru [62.220.33.27]) by web11d.yandex.ru with HTTP; Sun, 04 Aug 2013 20:46:55 +0400 From: Basil Peace To: Tom Lane Cc: "pgsql-bugs@postgresql.org" In-Reply-To: <8645.1375477524@sss.pgh.pa.us> References: <7861.1375475031@sss.pgh.pa.us> <8645.1375477524@sss.pgh.pa.us> Subject: Re: BUG #8355: PL/Python 3 can't convert infinity to PostgreSQL's value MIME-Version: 1.0 Message-Id: <1122541375634815@web11d.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Sun, 04 Aug 2013 20:46:55 +0400 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=koi8-r X-Pg-Spam-Score: 3.6 (+++) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org I based on the documentation of PostgreSQL š(http://www.postgresql.org/docs/9.2/static/datatype-numeric.html#DATATYPE-FLOAT) which says about 'Infinity' and '-Infinity' and doesn't mention other possible spellings, including 'inf'. And on my installation of 9.2.4 'inf' doesn't work too (as I supposed according to documentation): ššššššššSELECT 'inf'::float8 ššššššššERROR: šinvalid input syntax for type double precision: "inf" ššššššššLINE 2: SELECT 'inf'::float8 According to Python's documentation (http://docs.python.org/2/library/stdtypes.html#typesnumeric), handle of infinities and NaNs was added in 2.6. At least this works in 2.7.1: ššššššššPython 2.7.1 (r271:86832, Apr š1 2013, 01:27:27) [MSC v.1600 64 bit (AMD64)] onšwin32 ššššššššType "help", "copyright", "credits" or "license" for more information. >>> šfloat('inf') ššššššššinf >>> šfloat('infinity') ššššššššinf >>> šfloat('+inf') ššššššššinf >>> šfloat('-inf') šššššššš-inf So, Python is honest in this way. And, C99 says that style of representation ('inf' or 'infinity') is implementation-defined, so it is all OK with modern Python. > šWe already backstop strtod() for these cases: > > šššššššššNaN > šššššššššInfinity > ššššššššš-Infinity > > šbut the wording of the spec clearly requires +Infinity as well as the > šforms with just "inf". š(It also appears to require +/- NaN to be > šaccepted, but I have no idea what that would mean and suspect it to > šbe a thinko.) As I can judge, signed NaNs are from the same world as signed zeros and signed infinities. Strictly speaking: (-0)/(+0) is -NaN, (-inf)/(+inf) is -NaN, and so on. I think that PostgreSQL's ability to handle signed zeros (and all other rare stuff) depends on compiler used. Google says me that '-NaN' exists in modern glibc. I don't know about MSVC. My Python accepts '-nan' as input, but doesn't give me '-NaN' as output. So, I think it would be good if '-NaN' and other forms were workable. -- Best regards, Basil Peace -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs