| From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> | 
|---|---|
| To: | "Andreas 'ads' Scherbaum" <adsmail(at)wars-nicht(dot)de> | 
| Cc: | Craig Ringer <craig(at)2ndquadrant(dot)com>, Euler Taveira <euler(at)timbira(dot)com(dot)br>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> | 
| Subject: | Re: to_date_valid() | 
| Date: | 2016-07-04 16:37:00 | 
| Message-ID: | CAFj8pRChHJgZUzcoe6avYf=7yuOgX=rPqDOdahUGaugdhkSrMw@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
2016-07-04 18:24 GMT+02:00 Andreas 'ads' Scherbaum <adsmail(at)wars-nicht(dot)de>:
> On 04.07.2016 05:51, Pavel Stehule wrote:
>
>>
>>
>> 2016-07-04 5:19 GMT+02:00 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com
>> <mailto:pavel(dot)stehule(at)gmail(dot)com>>:
>>
>>
>>
>>     2016-07-04 4:25 GMT+02:00 Craig Ringer <craig(at)2ndquadrant(dot)com
>>     <mailto:craig(at)2ndquadrant(dot)com>>:
>>
>>         On 3 July 2016 at 09:32, Euler Taveira <euler(at)timbira(dot)com(dot)br
>>         <mailto:euler(at)timbira(dot)com(dot)br>> wrote:
>>
>>             On 02-07-2016 22 <tel:02-07-2016%2022>: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, validate = true |
>>             false)
>>             instead of creating another function? The new parameter
>>             could default to
>>             false to not break compatibility.
>>
>>
>>         because
>>
>>
>>             SELECT to_date('blah', 'pattern', true)
>>
>>         is less clear to read than
>>
>>             SELECT to_date_valid('blah', 'pattern')
>>
>>         and offers no advantage. It's likely faster to use a separate
>>         function too.
>>
>>
>>     personally I prefer first variant - this is same function with
>>     stronger check.
>>
>>
>> Currently probably we have not two similar function - one  fault
>> tolerant and second stricter. There is only one example of similar
>> behave - parse_ident with "strict" option.
>>
>> The three parameters are ok still - so I don't see a reason why we have
>> to implement new function. If you need to emphasize the fact so behave
>> should be strict, you can use named parameters
>>
>> select to_date('blah', 'patter', strict => true)
>>
>
> The new function is not "strict", it just adds a validation step:
>
I understand - I know, so this has zero relation to function flag STRICT
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.
Regards
Pavel
>
> postgres=# select to_date_valid(NULL, NULL);
>  to_date_valid
> ---------------
>
>
>
> (1 row)
>
> --
>                                 Andreas 'ads' Scherbaum
> German PostgreSQL User Group
> European PostgreSQL User Group - Board of Directors
> Volunteer Regional Contact, Germany - PostgreSQL Project
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrew Borodin | 2016-07-04 17:05:56 | Re: Re: GiST optimizing memmoves in gistplacetopage for fixed-size updates [PoC] | 
| Previous Message | Andreas 'ads' Scherbaum | 2016-07-04 16:24:40 | Re: to_date_valid() |