Re: [HACKERS] to_date_valid()

2016-09-27 Thread Tom Lane
Peter Eisentraut writes: > I think using ValidateDate() was the right idea. That is what we use > for checking date validity everywhere else. Note that we've got two different CF entries, and threads, covering fundamentally the same territory here, ie making to_timestamp et al behave more sanely

Re: [HACKERS] to_date_valid()

2016-09-21 Thread Peter Eisentraut
On 9/9/16 4:48 AM, Andreas 'ads' Scherbaum wrote: > ValidateDate() will tell you if it's a valid date. But not if the > transformation was correct: > > postgres=# SELECT to_date('2011 12 18', ' MM DD'); >to_date > > 2011-12-08 > (1 row) > > (with the patch from Artur) >

Re: [HACKERS] to_date_valid()

2016-09-09 Thread Andreas 'ads' Scherbaum
On 08.09.2016 17:31, Peter Eisentraut wrote: On 8/15/16 7:33 AM, Andreas 'ads' Scherbaum wrote: postgres=# SELECT to_date('2011 12 18', ' MM DD'); to_date 2011-12-08 (1 row) That is from the regression tests, and obviously handles the date transformation wrong. My atte

Re: [HACKERS] to_date_valid()

2016-09-08 Thread Peter Eisentraut
On 8/15/16 7:33 AM, Andreas 'ads' Scherbaum wrote: > postgres=# SELECT to_date('2011 12 18', ' MM DD'); >to_date > > 2011-12-08 > (1 row) > > > That is from the regression tests, and obviously handles the date > transformation wrong. My attempt catches this, because I c

Re: [HACKERS] to_date_valid()

2016-08-15 Thread Andreas 'ads' Scherbaum
On 15.08.2016 13:44, Artur Zakirov wrote: On 15.08.2016 14:33, Andreas 'ads' Scherbaum wrote: Is it right and "true" way to validate date by extra transforming and comparison? Maybe validate date by using ValidateDate(). Attached sample patch. This does not solve the problem at hand, and let'

Re: [HACKERS] to_date_valid()

2016-08-15 Thread Artur Zakirov
On 15.08.2016 14:33, Andreas 'ads' Scherbaum wrote: Is it right and "true" way to validate date by extra transforming and comparison? Maybe validate date by using ValidateDate(). Attached sample patch. This does not solve the problem at hand, and let's wrong dates/formats slip through: ./buil

Re: [HACKERS] to_date_valid()

2016-08-15 Thread Andreas 'ads' Scherbaum
On 15.08.2016 10:24, Artur Zakirov wrote: On 14.08.2016 01:52, Andreas 'ads' Scherbaum wrote: Attached is a patch to "do the right thing". The verification is in "to_date()" now, the extra function is removed. Regression tests are updated - two or three of them returned a wrong date before, and

Re: [HACKERS] to_date_valid()

2016-08-15 Thread Artur Zakirov
On 14.08.2016 01:52, Andreas 'ads' Scherbaum wrote: Attached is a patch to "do the right thing". The verification is in "to_date()" now, the extra function is removed. Regression tests are updated - two or three of them returned a wrong date before, and still passed. They fail now. Documentation

Re: [HACKERS] to_date_valid()

2016-08-13 Thread Andreas 'ads' Scherbaum
On 27.07.2016 05:00, Joshua D. Drake wrote: On 07/26/2016 06:25 PM, Peter Eisentraut wrote: On 7/5/16 4:24 AM, Albe Laurenz wrote: But notwithstanding your feeling that you would like your application to break if it makes use of this behaviour, it is a change that might make some people pretty

Re: [HACKERS] to_date_valid()

2016-07-29 Thread Jim Nasby
On 7/29/16 1:33 PM, Andreas 'ads' Scherbaum wrote: On 27.07.2016 05:00, Joshua D. Drake wrote: On 07/26/2016 06:25 PM, Peter Eisentraut wrote: On 7/5/16 4:24 AM, Albe Laurenz wrote: But notwithstanding your feeling that you would like your application to break if it makes use of this behaviour

Re: [HACKERS] to_date_valid()

2016-07-29 Thread Andreas 'ads' Scherbaum
On 27.07.2016 05:00, Joshua D. Drake wrote: On 07/26/2016 06:25 PM, Peter Eisentraut wrote: On 7/5/16 4:24 AM, Albe Laurenz wrote: But notwithstanding your feeling that you would like your application to break if it makes use of this behaviour, it is a change that might make some people pretty

Re: [HACKERS] to_date_valid()

2016-07-26 Thread Joshua D. Drake
On 07/26/2016 06:25 PM, Peter Eisentraut wrote: On 7/5/16 4:24 AM, Albe Laurenz wrote: But notwithstanding your feeling that you would like your application to break if it makes use of this behaviour, it is a change that might make some people pretty unhappy - nobody can tell how many. What is

Re: [HACKERS] to_date_valid()

2016-07-26 Thread Peter Eisentraut
On 7/5/16 4:24 AM, Albe Laurenz wrote: > But notwithstanding your feeling that you would like your application > to break if it makes use of this behaviour, it is a change that might > make some people pretty unhappy - nobody can tell how many. What is the use of the existing behavior? You get ba

Re: [HACKERS] to_date_valid()

2016-07-26 Thread Bruce Momjian
On Tue, Jul 5, 2016 at 07:41:15AM -0400, David G. Johnston wrote: > ​Surely these beta testers would test against the RC before putting it into > production so I don't see an issue.  I tend to agree generally but the point > of > beta is to find bugs and solicit suggestions for improvement to fea

Re: [HACKERS] to_date_valid()

2016-07-05 Thread David G. Johnston
On Tue, Jul 5, 2016 at 5:22 AM, Andreas 'ads' Scherbaum < adsm...@wars-nicht.de> wrote: > On 05.07.2016 04:33, David G. Johnston wrote: > >> On Mon, Jul 4, 2016 at 8:39 PM, Andreas 'ads' Scherbaum >> mailto:adsm...@wars-nicht.de>>wrote: >> >> On 04.07.2016 18:37, Pavel Stehule wrote: >> >> >>

Re: [HACKERS] to_date_valid()

2016-07-05 Thread Andreas 'ads' Scherbaum
On 05.07.2016 04:33, David G. Johnston wrote: On Mon, Jul 4, 2016 at 8:39 PM, Andreas 'ads' Scherbaum mailto:adsm...@wars-nicht.de>>wrote: On 04.07.2016 18:37, Pavel Stehule wrote: I don't know if the name "strict" is best, but the name "validate" is not good too. C

Re: [HACKERS] to_date_valid()

2016-07-05 Thread Andreas 'ads' Scherbaum
On 05.07.2016 06:05, Pavel Stehule wrote: 2016-07-05 2:39 GMT+02:00 Andreas 'ads' Scherbaum mailto:adsm...@wars-nicht.de>>: On 04.07.2016 18:37, Pavel Stehule wrote: I don't know if the name "strict" is best, but the name "validate" is not good too. Current to_dat

Re: [HACKERS] to_date_valid()

2016-07-05 Thread Albe Laurenz
Andreas Karlsson wrote: > On 07/04/2016 10:55 PM, Pavel Stehule wrote: >> 2016-07-04 22:15 GMT+02:00 Andreas Karlsson wrote: >>> I do not see a clear conclusion in the linked threads. For example >>> Bruce calls it a bug in one of the emails >>> (https://www.postgresql.org/message-id/201107200103.p

Re: [HACKERS] to_date_valid()

2016-07-04 Thread Pavel Stehule
2016-07-05 2:39 GMT+02:00 Andreas 'ads' Scherbaum : > On 04.07.2016 18:37, Pavel Stehule wrote: > >> >> I don't know if the name "strict" is best, but the name "validate" is >> not good too. Current to_date does some validations too. >> > > Obviously not enough, because it allows invalid dates. I'

Re: [HACKERS] to_date_valid()

2016-07-04 Thread Pavel Stehule
2016-07-05 4:33 GMT+02:00 David G. Johnston : > On Mon, Jul 4, 2016 at 8:39 PM, Andreas 'ads' Scherbaum < > adsm...@wars-nicht.de> wrote: > >> On 04.07.2016 18:37, Pavel Stehule wrote: >> >>> >>> I don't know if the name "strict" is best, but the name "validate" is >>> not good too. Current to_dat

Re: [HACKERS] to_date_valid()

2016-07-04 Thread David G. Johnston
On Mon, Jul 4, 2016 at 8:39 PM, Andreas 'ads' Scherbaum < adsm...@wars-nicht.de> wrote: > On 04.07.2016 18:37, Pavel Stehule wrote: > >> >> I don't know if the name "strict" is best, but the name "validate" is >> not good too. Current to_date does some validations too. >> > > Obviously not enough,

Re: [HACKERS] to_date_valid()

2016-07-04 Thread Andreas 'ads' Scherbaum
On 04.07.2016 18:37, Pavel Stehule wrote: I don't know if the name "strict" is best, but the name "validate" is not good too. Current to_date does some validations too. Obviously not enough, because it allows invalid dates. I'd say that the current to_date() merely validates the input format

Re: [HACKERS] to_date_valid()

2016-07-04 Thread Andreas Karlsson
On 07/04/2016 10:55 PM, Pavel Stehule wrote: 2016-07-04 22:15 GMT+02:00 Andreas Karlsson mailto:andr...@proxel.se>>: I do not see a clear conclusion in the linked threads. For example Bruce calls it a bug in one of the emails (https://www.postgresql.org/message-id/201107200103.p6K13i

Re: [HACKERS] to_date_valid()

2016-07-04 Thread Pavel Stehule
2016-07-04 22:15 GMT+02:00 Andreas Karlsson : > On 07/03/2016 12:36 PM, Andreas 'ads' Scherbaum wrote: > >> On 03.07.2016 07:05, Jaime Casanova wrote: >> >>> Shouldn't we fix this instead? Sounds like a bug to me. We don't usually >>> want to be bug compatible so it doesn't matter if we break some

Re: [HACKERS] to_date_valid()

2016-07-04 Thread Andreas Karlsson
On 07/03/2016 12:36 PM, Andreas 'ads' Scherbaum wrote: On 03.07.2016 07:05, Jaime Casanova wrote: Shouldn't we fix this instead? Sounds like a bug to me. We don't usually want to be bug compatible so it doesn't matter if we break something. There are previous discussions about such a change, a

Re: [HACKERS] to_date_valid()

2016-07-04 Thread Pavel Stehule
2016-07-04 18:24 GMT+02:00 Andreas 'ads' Scherbaum : > On 04.07.2016 05:51, Pavel Stehule wrote: > >> >> >> 2016-07-04 5:19 GMT+02:00 Pavel Stehule > >: >> >> >> >> 2016-07-04 4:25 GMT+02:00 Craig Ringer > >: >> >> On 3

Re: [HACKERS] to_date_valid()

2016-07-04 Thread Andreas 'ads' Scherbaum
On 04.07.2016 05:51, Pavel Stehule wrote: 2016-07-04 5:19 GMT+02:00 Pavel Stehule mailto:pavel.steh...@gmail.com>>: 2016-07-04 4:25 GMT+02:00 Craig Ringer mailto:cr...@2ndquadrant.com>>: On 3 July 2016 at 09:32, Euler Taveira mailto:eu...@timbira.com.br>> wrote: On

Re: [HACKERS] to_date_valid()

2016-07-04 Thread Andreas 'ads' Scherbaum
On 04.07.2016 16:33, Amit Kapila wrote: On Sun, Jul 3, 2016 at 6:34 AM, Andreas 'ads' Scherbaum wrote: Hello, we have customers complaining that to_date() accepts invalid dates, and returns a different date instead. This is a known issue: http://sql-info.de/postgresql/notes/to_date-to_timest

Re: [HACKERS] to_date_valid()

2016-07-04 Thread Amit Kapila
On Sun, Jul 3, 2016 at 6:34 AM, Andreas 'ads' Scherbaum wrote: > > Hello, > > we have customers complaining that to_date() accepts invalid dates, and > returns a different date instead. This is a known issue: > > http://sql-info.de/postgresql/notes/to_date-to_timestamp-gotchas.html > > On the othe

Re: [HACKERS] to_date_valid()

2016-07-03 Thread Pavel Stehule
2016-07-04 5:19 GMT+02:00 Pavel Stehule : > > > 2016-07-04 4:25 GMT+02:00 Craig Ringer : > >> On 3 July 2016 at 09:32, Euler Taveira wrote: >> >>> On 02-07-2016 22:04, Andreas 'ads' Scherbaum wrote: >>> > The attached patch adds a new function "to_date_valid()" which will >>> > validate the date

Re: [HACKERS] to_date_valid()

2016-07-03 Thread Gavin Flower
On 04/07/16 15:19, Pavel Stehule wrote: 2016-07-04 4:25 GMT+02:00 Craig Ringer >: On 3 July 2016 at 09:32, Euler Taveira mailto:eu...@timbira.com.br>> wrote: On 02-07-2016 22 :04, Andreas 'ads' Scherbaum wrote: > The attached patch ad

Re: [HACKERS] to_date_valid()

2016-07-03 Thread Pavel Stehule
2016-07-04 4:25 GMT+02:00 Craig Ringer : > On 3 July 2016 at 09:32, Euler Taveira wrote: > >> On 02-07-2016 22:04, Andreas 'ads' Scherbaum wrote: >> > The attached patch adds a new function "to_date_valid()" which will >> > validate the date and return an error if the input and output date do >>

Re: [HACKERS] to_date_valid()

2016-07-03 Thread Craig Ringer
On 3 July 2016 at 09:32, Euler Taveira wrote: > On 02-07-2016 22:04, Andreas 'ads' Scherbaum wrote: > > The attached patch adds a new function "to_date_valid()" which will > > validate the date and return an error if the input and output date do > > not match. Tests included, documentation update

Re: [HACKERS] to_date_valid()

2016-07-03 Thread Andreas 'ads' Scherbaum
On 03.07.2016 07:05, Jaime Casanova wrote: El 2/7/2016 20:33, "Euler Taveira" mailto:eu...@timbira.com.br>> escribió: > > On 02-07-2016 22:04, Andreas 'ads' Scherbaum wrote: > > The attached patch adds a new function "to_date_valid()" which will > > validate the date and return an error if th

Re: [HACKERS] to_date_valid()

2016-07-02 Thread Jaime Casanova
El 2/7/2016 20:33, "Euler Taveira" escribió: > > On 02-07-2016 22:04, Andreas 'ads' Scherbaum wrote: > > The attached patch adds a new function "to_date_valid()" which will > > validate the date and return an error if the input and output date do > > not match. Tests included, documentation update

Re: [HACKERS] to_date_valid()

2016-07-02 Thread Euler Taveira
On 02-07-2016 22:04, Andreas 'ads' Scherbaum wrote: > The attached patch adds a new function "to_date_valid()" which will > validate the date and return an error if the input and output date do > not match. Tests included, documentation update as well. > Why don't you add a third parameter (say, v

[HACKERS] to_date_valid()

2016-07-02 Thread Andreas 'ads' Scherbaum
Hello, we have customers complaining that to_date() accepts invalid dates, and returns a different date instead. This is a known issue: http://sql-info.de/postgresql/notes/to_date-to_timestamp-gotchas.html On the other hand this leads to wrong dates when loading dates into the database, bec