Re: Bug in psql - Postgresql 7.3.1? - Mailing list pgsql-sql

From Josh Berkus
Subject Re: Bug in psql - Postgresql 7.3.1?
Date
Msg-id 200310031315.52146.josh@agliodbs.com
Whole thread Raw
In response to Bug in psql - Postgresql 7.3.1?  ("John B. Scalia" <jscalia@cityblueprinting.com>)
List pgsql-sql
John,

> Yeah, I figured out my SQL was bad and had switched to the comma
> separated version, instead. In my mind, the first form should have
> caused an error. I've attached a cut-and-pasted session from psql where
> I used this syntax on a test table. While edited for brevity and to
> obscure passwords, this is how the output appeared.

Here's your problem:

accounting=# update all_user set usr_current = True AND usr_location = 1002;
UPDATE 3

PostgreSQL interpreted the expression "True AND usr_location = 1002" as a
single, unitary, boolean expression.   AND is the boolean AND operator.
Since none of the users on your list had "usr_location = 1002", you got:

user_current = (True AND (usr_location = 1002))
user_current = (True AND False)
user_current = False

Since all 3 rows already had false, they did not appear to get updated, but in
fact they were.

Time to look up your order of operations!

--
-Josh BerkusAglio Database SolutionsSan Francisco



pgsql-sql by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Bug in psql - Postgresql 7.3.1?
Next
From: Tom Lane
Date:
Subject: Re: Bug in psql - Postgresql 7.3.1?