pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Artur Zakirov <a.zakirov@postgrespro.ru>
To: Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
To: Joshua D. Drake <jd@commandprompt.com>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Albe Laurenz <laurenz.albe@wien.gv.at>
To: Andreas Karlsson *EXTERN* <andreas@proxel.se>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Jaime Casanova <jaime.casanova@2ndquadrant.com>
Cc: Euler Taveira <euler@timbira.com.br>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: to_date_valid()
Date: Mon, 15 Aug 2016 14:44:19 +0300
Message-ID: <198c569d-4bd0-7ddb-05c7-113845aec37b@postgrespro.ru> (raw)
In-Reply-To: <81ed5480-9bca-361b-9aa0-cbafc2ec2f63@wars-nicht.de>
References: <57786490.9010201@wars-nicht.de>
	<dcdebc73-ffdd-13a3-d6cd-73e1944a066b@timbira.com.br>
	<CAJGNTeO75ZPm3qDk9rze7coGyvCZyWm68iEFY3WOYb5w=7OdBg@mail.gmail.com>
	<5778EA94.1020706@wars-nicht.de>
	<af97b147-3542-7a55-b651-e0ecae0c8c00@proxel.se>
	<CAFj8pRDHaeVdwHtZQPXKCSaeAQ_2_jeXHpPCssiOdFYs7UoUTw@mail.gmail.com>
	<2bc6bcef-cada-1ac7-f9a2-2f6128ca4c3c@proxel.se>
	<A737B7A37273E048B164557ADEF4A58B5386992E@ntex2010i.host.magwien.gv.at>
	<b28373f4-7e37-3bc4-25a5-65aef4006cf0@2ndquadrant.com>
	<579823DF.3080903@commandprompt.com>
	<e9617e30-1b47-54ec-b978-2c84c6420b12@wars-nicht.de>
	<95738e12-6ed6-daf5-9dcf-6336072e6b15@postgrespro.ru>
	<81ed5480-9bca-361b-9aa0-cbafc2ec2f63@wars-nicht.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

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:
>
> ./buildclient.py -v -c demo-config-pg.yaml --run-configure --run-make
> --run-install --no-clean-at-all --patch
> 'https://www.postgresql.org/message-id/95738e12-6ed6-daf5-9dcf-6336072e6b15%40postgrespro.ru';
>
>
>
> postgres=# SELECT to_date('2011 12  18', 'YYYY 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 compare the
> date with the input date, and do not rely on a valid date only.

I suppose that your sample query is an another issue, not date validate 
task. I sent the patch to the thread 
https://www.postgresql.org/message-id/b2a39359-3282-b402-f4a3-057aae500ee7@postgrespro.ru 
. It fixes formatting issues.

I thought that it is better to distinguish this issues to:
- validation of input date/timestmap string and input format string
- result date/timestamp validation

-- 
Artur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (37+ messages)  latest in thread

Message-ID: <198c569d-4bd0-7ddb-05c7-113845aec37b@postgrespro.ru>
Permalink:  ../198c569d-4bd0-7ddb-05c7-113845aec37b@postgrespro.ru/
Also on:    postgresql.org/message-id/198c569d-4bd0-7ddb-05c7-113845aec37b@postgrespro.ru

 · 

reply

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: a.zakirov@postgrespro.ru, adsmail@wars-nicht.de, jd@commandprompt.com, peter.eisentraut@2ndquadrant.com, laurenz.albe@wien.gv.at, andreas@proxel.se, pavel.stehule@gmail.com, jaime.casanova@2ndquadrant.com, euler@timbira.com.br
  Subject: Re: to_date_valid()
  In-Reply-To: <198c569d-4bd0-7ddb-05c7-113845aec37b@postgrespro.ru>
  References: <57786490.9010201@wars-nicht.de> <dcdebc73-ffdd-13a3-d6cd-73e1944a066b@timbira.com.br> <CAJGNTeO75ZPm3qDk9rze7coGyvCZyWm68iEFY3WOYb5w=7OdBg@mail.gmail.com> <5778EA94.1020706@wars-nicht.de> <af97b147-3542-7a55-b651-e0ecae0c8c00@proxel.se> <CAFj8pRDHaeVdwHtZQPXKCSaeAQ_2_jeXHpPCssiOdFYs7UoUTw@mail.gmail.com> <2bc6bcef-cada-1ac7-f9a2-2f6128ca4c3c@proxel.se> <A737B7A37273E048B164557ADEF4A58B5386992E@ntex2010i.host.magwien.gv.at> <b28373f4-7e37-3bc4-25a5-65aef4006cf0@2ndquadrant.com> <579823DF.3080903@commandprompt.com> <e9617e30-1b47-54ec-b978-2c84c6420b12@wars-nicht.de> <95738e12-6ed6-daf5-9dcf-6336072e6b15@postgrespro.ru> <81ed5480-9bca-361b-9aa0-cbafc2ec2f63@wars-nicht.de> <198c569d-4bd0-7ddb-05c7-113845aec37b@postgrespro.ru>

* 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