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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-novice by date

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