Re: BUG #3506: to_number silently ignore characters - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Re: BUG #3506: to_number silently ignore characters
Date
Msg-id 46B22BD7.5040508@enterprisedb.com
Whole thread Raw
In response to BUG #3506: to_number silently ignore characters  ("Laurent Martelli" <lmartelli@seditel.fr>)
Responses Re: BUG #3506: to_number silently ignore characters
List pgsql-bugs
Laurent Martelli wrote:
> to_number('123.0','999999') returns 1230, at least on version 7.4 and 8.1. I
> think it should return 123 or raise an error.

to_number will silently ignore any character that doesn't match the
pattern. That can be confusing, and not generally a very bright idea in
applications, but we can't really change the behavior because that could
break existing applications.

You can use the pattern '999999.' to get the behavior you want (returns
123).

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #3504: Some listening sessions never return from writing, problems ensue
Next
From: "Peter Koczan"
Date:
Subject: Re: BUG #3504: Some listening sessions never return from writing, problems ensue