Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UbqG8-0000Qc-Cp for pgsql-bugs@arkaria.postgresql.org; Mon, 13 May 2013 10:45:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UbqG7-00044v-MZ for pgsql-bugs@arkaria.postgresql.org; Mon, 13 May 2013 10:45:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UbqG6-00044p-Ry for pgsql-bugs@postgresql.org; Mon, 13 May 2013 10:45:34 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UbqG0-0004bD-VG for pgsql-bugs@postgresql.org; Mon, 13 May 2013 10:45:33 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id B723C286A0; Mon, 13 May 2013 03:45:26 -0700 (PDT) Received: from zcs-prod-ext-mta-2.vmware.com (zcs-prod-ext-mta-2.vmware.com [10.113.62.224]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id B1B86B0894; Mon, 13 May 2013 03:45:26 -0700 (PDT) Received: from zcs-prod-ext-mta-2.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTP id 86EC7C0052; Mon, 13 May 2013 03:45:21 -0700 (PDT) Received: from [192.168.1.90] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTPSA; Mon, 13 May 2013 03:45:19 -0700 (PDT) Message-ID: <5190C442.3000609@vmware.com> Date: Mon, 13 May 2013 13:45:22 +0300 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: Euler Taveira CC: Thomas Kellerer , pgsql-bugs@postgresql.org Subject: Re: Inconsistency between TO_CHAR() and TO_NUMBER() References: <51878292.6080003@fooby.de> <14272.1367850378@sss.pgh.pa.us> <5187C2FE.9000305@fooby.de> <8415.1368200958@sss.pgh.pa.us> <518D71FB.9050106@timbira.com.br> In-Reply-To: <518D71FB.9050106@timbira.com.br> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.5 (-------) 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 On 11.05.2013 01:17, Euler Taveira wrote: > On 10-05-2013 13:09, Thomas Kellerer wrote: >> Tom Lane wrote on 10.05.2013 17:49: >>> I looked into this, and find that the reason it misbehaves is that >>> NUM_numpart_from_char() will treat a '.' as being a decimal point >>> *without any regard to locale considerations*. So even if we have >>> a locale-dependent format string and a locale that says '.' is a >>> thousands separator, it does the wrong thing. >>> >>> It's a bit surprising nobody's complained of this before. >>> >>> I propose the attached patch. I'm slightly worried though about whether >>> this might break any existing applications that are (incorrectly) >>> depending on a D format specifier being able to match '.' regardless of >>> locale. Perhaps we should only apply this to HEAD and not back-patch? >> > +1 only in HEAD. That's because (a) it doesn't crash, (b) it doesn't > always produce the "wrong" answer (only in some specific situation) and > (c) it has been like that for years without a complain. For those > reasons, it is better to continue with this "wrong" behavior in back > branches than prevent important security updates to be applied (without > applying a patch to preserve the "wrong" answer). This argument is only > valid for legacy closed-source apps but seems to have more weight than > the bug scenario. +1 for HEAD-only. The Finnish language and locale uses comma (,) as the decimal separator, and it's a real pain in the ass. And if something goes wrong there, it can be *really* subtle. I once had to debug an application where all prices were suddenly rounded down to the nearest euro. And it only happened on some servers (those with locale set to Finnish). It was not a PostgreSQL application, but it turned out to be a bug in the JDBC driver of another DBMS. Would it be possible to be lenient, and also accept . as the decimal separator, when there is no ambiguity? Ie. when . is not the thousands separator. - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs