pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
To: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Subject: to_date_valid()
Date: Sun, 3 Jul 2016 03:04:16 +0200
Message-ID: <57786490.9010201@wars-nicht.de> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>


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, because the database happily accepts invalid dates and ends up 
writing something completely different into the table.

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.

-- 
				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

Attachments:

  to_date_valid.patch.gz (application/gzip, 3.1K) download

view thread (37+ messages)  latest in thread

Message-ID: <57786490.9010201@wars-nicht.de>
Permalink:  ../57786490.9010201@wars-nicht.de/
Also on:    postgresql.org/message-id/57786490.9010201@wars-nicht.de

 · 

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: adsmail@wars-nicht.de
  Subject: Re: to_date_valid()
  In-Reply-To: <57786490.9010201@wars-nicht.de>
  References: <57786490.9010201@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