On Tue, Oct 09, 2007 at 11:48:35AM -0700, Jeff Davis wrote:
> On Tue, 2007-10-09 at 09:44 +0200, Kaare Rasmussen wrote:
> > > In SQL, "=" is both an assignment operator (e.g. UPDATE) and a
> > > comparison operator (e.g. WHERE clause). There are
> > > nondeterministic
> >
> > Why would that be a problem when they occur in different parts of
> > the statement?
>
> It can actually be in the same part of the statement:
>
> UPDATE foo SET b = a = 0;
Don't Do That(TM). It wouldn't even be wise to do it if there were
separate assignment and comparison operators because it's too easy to
mess up even then.
> is legal in PostgreSQL. How weird is that? At a glance, can you tell
> what it's doing?
Use parentheses, which is what you'd be wise to do even if there were
separate assignment and comparison operators. Watch out for phony
"elegance." :)
Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter
Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate