From: Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
To: Pavel Stehule <pavel.stehule@gmail.com>
To: Craig Ringer <craig@2ndquadrant.com>
Cc: Euler Taveira <euler@timbira.com.br>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Subject: Re: to_date_valid()
Date: Mon, 4 Jul 2016 18:24:40 +0200
Message-ID: <577A8DC8.2040505@wars-nicht.de> (raw)
In-Reply-To: <CAFj8pRD25suv626vN6K0Kz=2W=TBJwoi07DhiWWU5gZZ6KPXhg@mail.gmail.com>
References: <57786490.9010201@wars-nicht.de>
<dcdebc73-ffdd-13a3-d6cd-73e1944a066b@timbira.com.br>
<CAMsr+YHkfZ3KtRwrX+cYOLMXgUzFLTyfNnuNMB7KjOLhi6Mrig@mail.gmail.com>
<CAFj8pRDR7cX7C-vc=_6WWmRau1gd8ZEk3S06Zq6XP7BZt+8c+w@mail.gmail.com>
<CAFj8pRD25suv626vN6K0Kz=2W=TBJwoi07DhiWWU5gZZ6KPXhg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
On 04.07.2016 05:51, Pavel Stehule wrote:
>
>
> 2016-07-04 5:19 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com
> <mailto:pavel.stehule@gmail.com>>:
>
>
>
> 2016-07-04 4:25 GMT+02:00 Craig Ringer <craig@2ndquadrant.com
> <mailto:craig@2ndquadrant.com>>:
>
> On 3 July 2016 at 09:32, Euler Taveira <euler@timbira.com.br
> <mailto:euler@timbira.com.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:
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
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: adsmail@wars-nicht.de, pavel.stehule@gmail.com, craig@2ndquadrant.com, euler@timbira.com.br
Subject: Re: to_date_valid()
In-Reply-To: <577A8DC8.2040505@wars-nicht.de>
References: <57786490.9010201@wars-nicht.de> <dcdebc73-ffdd-13a3-d6cd-73e1944a066b@timbira.com.br> <CAMsr+YHkfZ3KtRwrX+cYOLMXgUzFLTyfNnuNMB7KjOLhi6Mrig@mail.gmail.com> <CAFj8pRDR7cX7C-vc=_6WWmRau1gd8ZEk3S06Zq6XP7BZt+8c+w@mail.gmail.com> <CAFj8pRD25suv626vN6K0Kz=2W=TBJwoi07DhiWWU5gZZ6KPXhg@mail.gmail.com> <577A8DC8.2040505@wars-nicht.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox