pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Harry Jackson <harryjackson@gmail.com>
To: pgsql-general@postgresql.org
Subject: Is this a bug?
Date: Sun, 1 Jul 2007 19:44:47 +0100
Message-ID: <45b42ce40707011144t20c7703bk11328bdbd6e17a6f@mail.gmail.com> (raw)

The following sql statement fails because the column "user_id" does
not exist in the users table.

=# select user_id from users WHERE  username = 'blah';
ERROR:  column "user_id" does not exist
LINE 1: select user_id from users WHERE  username = 'blah......
               ^

The following shows a valid statement where I want to delete one user
entry from the "map_users_roles" table

=# delete from map_users_roles where user_id = (select id from users
WHERE  username = 'blah');
DELETE 2

If I made a mistake and changed the "id" column to "user_id" then from
some the statement executes.

=# delete from map_users_roles where user_id = (select user_id from
users WHERE  username = 'blah');
DELETE 33631

I would have thought that the last statement would fail. Instead it
removed all the entries from the table. This is happening because I
did not qualify the column names as follows...

=# delete from map_users_roles where user_id = (select u.user_id from
users as u WHERE  username = 'blah');
ERROR:  column u.user_id does not exist
LINE 1: ...lete from map_users_roles where user_id = (select u.user_id ...

Still, this was quite a suprise to me and I would consider this a bug.

Thoughts?

-- 
Harry
http://www.uklug.co.uk
http://www.hjackson.org



view thread (35+ messages)  latest in thread

Message-ID: <45b42ce40707011144t20c7703bk11328bdbd6e17a6f@mail.gmail.com>
Permalink:  ../45b42ce40707011144t20c7703bk11328bdbd6e17a6f@mail.gmail.com/
Also on:    postgresql.org/message-id/45b42ce40707011144t20c7703bk11328bdbd6e17a6f@mail.gmail.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: harryjackson@gmail.com
  Subject: Re: Is this a bug?
  In-Reply-To: <45b42ce40707011144t20c7703bk11328bdbd6e17a6f@mail.gmail.com>
  References: <45b42ce40707011144t20c7703bk11328bdbd6e17a6f@mail.gmail.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