Re: A creepy story about dates. How to prevent it?

From: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: A creepy story about dates. How to prevent it?
Date: 2003-06-19 07:43:12
Message-ID: 1056008592.589.75.camel@haggis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2003-06-19 at 01:06, Joel Rees wrote:
> (Comments from the peanut gallery here)
>
> > > > IMHO it is a bug. We don't let postgresql "guess" about a lot of more
> > > > obvious things (i.e. int4 to int8 casting, etc...) and letting it guess
> > > > about dates makes it non-ACID compliant.
> > >
> > > How do you arrive at that conclusion?
> >
> > The same way I come to all my conclusions, logic. :-) but seriously...
> >
> > Why not accept a date of 04/44/2003 and just wrap it into May? It's
> > the same kind of thing.
>
> Is it? Similar, perhaps, but at least you can be pretty sure that 44 and
> 2003 are not valid months. (Not that I want the database fixing that for
> me, either.)
>
> > I told my database where I live, and expect it to
> > only accept dates that are valid in my locale.
>
> I wouldn't suggest that. Locale is not dependable because there is
> simply no dependable way of mapping, for example, IP address to a
> physical location, much less to a cultural location.

The locale specified by the SysAdmin should be canononical.

[snip]

> Good question. Another good question is how the database would implement
> the check.

Other databases do it. It can't be *that* hard to do.

OTOH, Andrew Snow's method (alway use ANSI standard YYYY-MM-DD)
is guaranteed to work. Have your app convert to that format before
inserting, and then PostgreSQL is guaranteed to puke if there's
a problem.

--
+-----------------------------------------------------------+
| Ron Johnson, Jr. Home: ron(dot)l(dot)johnson(at)cox(dot)net |
| Jefferson, LA USA http://members.cox.net/ron.l.johnson |
| |
| "Oh, great altar of passive entertainment, bestow upon me |
| thy discordant images at such speed as to render linear |
| thought impossible" (Calvin, regarding TV) |
+-----------------------------------------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message culley harrelson 2003-06-19 07:52:26 explicit joins vs implicit joins
Previous Message Shridhar Daithankar 2003-06-19 07:39:13 Re: PostgreSQL alternative to "Oracle Real Application Cluster"