Re: UPDATE statement with syntax error doesn't raise a warning?

From: David W Noon <dwnoon(at)ntlworld(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: UPDATE statement with syntax error doesn't raise a warning?
Date: 2009-09-25 15:36:43
Message-ID: 20090925163643.6f6935c6@dwnoon.ntlworld.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 25 Sep 2009 17:05:13 +0200, Mirko Pace wrote about [GENERAL]
UPDATE statement with syntax error doesn't raise a warning?:

>I've ran an update statement like this (obviously wrong, I know!):

Not so obvious.

>update my_table
> set boolean_field = true AND
> my_notes = 'something'
>where id in
> (select id from my_table order by random() limit 4000);
>
>in my psql client and I had a "UPDATE 4000" result but, correctly,
>anything was changed in my_table.

I presume you meant "nothing" rather than "anything".

>So... why pg didn't raise a warning about syntax issue?

If we add some redundant parentheses, the SET clause becomes:

SET boolean_field = (true AND my_notes = 'something')

As you can see, this is a valid Boolean expression. There is no syntax
error. It just doesn't mean what you wanted.
--
Regards,

Dave [RLU #314465]
=======================================================================
david(dot)w(dot)noon(at)ntlworld(dot)com (David W Noon)
=======================================================================

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message InterRob 2009-09-25 16:34:48 stored procedure: RETURNS record
Previous Message Andy Colson 2009-09-25 15:26:02 Re: UPDATE statement with syntax error doesn't raise a warning?