Skip site navigation (1) Skip section navigation (2)

Re: pg_atoi error

From: george young <gry(at)ll(dot)mit(dot)edu>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: pg_atoi error
Date: 2004-02-04 14:22:00
Message-ID: 20040204092200.56694fab.gry@ll.mit.edu (view raw or flat)
Thread:
Lists: pgsql-novice
On Fri, 23 Jan 2004 12:59:15 -0500
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> threw this fish to the penguins:

> LIANHE SHAO <lshao2(at)jhmi(dot)edu> writes:
> > Actually I am wondering if pgsql can work on its own
> > with garbage data like mysql. for example if it
> > should be expid ='1' but I use it with expid='xyz'.
> > In this case, MySql will seliently give you 0 row
> > instead of error message.
> 
> This is a fundamental difference in philosophy between the two projects.
> You are wasting your breath trying to convince any Postgres developer
> that this aspect of MySQL's behavior is a wise design.  And I'm sure you
> would get equally much push-back from the MySQL developers if you tried
> to persuade them to tighten their error checking.  If MySQL's philosophy
> agrees with your worldview, then you should probably go use MySQL.
> 
> Alternatively, you can write your own conversion function that does what
> you want, as several people have suggested already.  You can even cause
> it to become the default behavior in your installation (just change the
> input function for type int4).  But it's not going to become the
> standard behavior for Postgres.
> 
> 			regards, tom lane

Philosophy aside, I would object strongly to postgres quietly accepting
garbage as a zero.  If some application is feeding a string value to the
wrong field, I certainly want it to fail, with clanging bells and crashing
the app (or at least generating an exception...).  Otherwise leads to
data corruption that could be dangerous and very difficult to unravel.
It's the application's job to validate data, not postgres.

-- 
"Are the gods not just?"  "Oh no, child.
What would become of us if they were?" (CSL)

In response to

pgsql-novice by date

Next:From: BantamessDate: 2004-02-04 15:15:45
Subject: Dual Primary keys
Previous:From: Tom LaneDate: 2004-02-03 23:11:26
Subject: Re: Can a user change their own password?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group