Re: A creepy story about dates. How to prevent it?
Ron Johnson <ron.l.johnson@cox.net>
From: Ron Johnson <ron.l.johnson@cox.net>
To: pgsql-general@postgresql.org
Date: 2003-06-19T07:43:12Z
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.l.johnson@cox.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) | +-----------------------------------------------------------