Re: check date validity - Mailing list pgsql-general

From Bill Gribble
Subject Re: check date validity
Date
Msg-id 1074262417.1334.9.camel@serrano
Whole thread Raw
In response to Re: check date validity  (Harald Fuchs <hf99@protecting.net>)
List pgsql-general
On Fri, 2004-01-16 at 06:58, Harald Fuchs wrote:
> In article <20040116054046.E4E751C173283@smtp.vip.163.com>,
> "LitelWang" <wlxyk@vip.163.com> writes:
> > I need this function :
> > CheckDate('2002-02-29') return false
> > CheckDate('2002-02-28') return true
>
> Why would you want to do that?  Just try to insert '2002-02-29' into
> your DATE column, and PostgreSQL will complain.

But it won't complain usefully.  It will just abort the transaction.
It's difficult to determine what went wrong when Postgres craps out,
which is at least in part why many on this list recommend duplicating
all the database validation logic in your application for EVERY type.

To me, this seems like a waste of effort, since both the application and
the DB server have to confirm that every date (for example, but applies
to every other type as well) is valid.  But I can't see how to do it any
other way, since the prevailing consensus among the PG devs seems to be
that any problem with the values of data is an application problem, not
a database problem, so don't expect to get any help from the server
other than "Sorry, that transaction is now gone.  Hope you can reproduce
the work! Have a nice day."

Thanks,
b.g.




pgsql-general by date:

Previous
From: Shridhar Daithankar
Date:
Subject: Re: Huge Data
Next
From: Jack Orenstein
Date:
Subject: Detecting database corruption