pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: John B. Scalia <jscalia@cityblueprinting.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Bug in psql - Postgresql 7.3.1?
Date: Fri, 3 Oct 2003 13:16:10 -0700
Message-ID: <200310031315.52146.josh@agliodbs.com> (raw)
In-Reply-To: <004401c389e9$ac7acc60$2501a8c0@John>
References: <004401c389e9$ac7acc60$2501a8c0@John>

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 Berkus
 Aglio Database Solutions
 San Francisco




view thread (6+ messages)  latest in thread

Message-ID: <200310031315.52146.josh@agliodbs.com>
Permalink:  ../200310031315.52146.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200310031315.52146.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, jscalia@cityblueprinting.com
  Subject: Re: Bug in psql - Postgresql 7.3.1?
  In-Reply-To: <200310031315.52146.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox