Re: We aren't a relational database ... ?

From: David Fetter <david(at)fetter(dot)org>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Kaare Rasmussen <kaare(at)jasonic(dot)dk>, pgsql-advocacy(at)postgresql(dot)org
Subject: Re: We aren't a relational database ... ?
Date: 2007-10-09 19:13:23
Message-ID: 20071009191322.GG6801@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-advocacy

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(at)fetter(dot)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

In response to

Responses

Browse pgsql-advocacy by date

  From Date Subject
Next Message Jeff Davis 2007-10-09 19:30:43 Re: We aren't a relational database ... ?
Previous Message Jeff Davis 2007-10-09 18:48:35 Re: We aren't a relational database ... ?