pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Luca Pireddu <luca@cs.ualberta.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: problem (bug?) with "in (subquery)"
Date: Fri, 15 Jul 2005 08:10:37 -0600
Message-ID: <20050715141037.GA30461@winnie.fuhr.org> (raw)
In-Reply-To: <10971.1121435967@sss.pgh.pa.us>
References: <200507140134.21133.luca@cs.ualberta.ca>
	<10971.1121435967@sss.pgh.pa.us>

On Fri, Jul 15, 2005 at 09:59:27AM -0400, Tom Lane wrote:
> Luca Pireddu <luca@cs.ualberta.ca> writes:
> > So, am I wrong in expecting each strain record to appear only once in the 
> > result set?  Or is there something wrong with PostgreSQL?
> 
> Could we see a self-contained example (table definitions and sample data
> as a SQL script)?  I don't really have time to reverse-engineer a test
> case from your description ...

I've been reverse-engineering and simplifying this.  Here's something
that I think is close:

CREATE TABLE foo (id integer);
CREATE TABLE bar (id1 integer, id2 integer);

INSERT INTO foo VALUES (1);

INSERT INTO bar VALUES (1, 1);
INSERT INTO bar VALUES (2, 2);
INSERT INTO bar VALUES (3, 1);

SELECT *
FROM foo
WHERE id IN (SELECT id2 FROM (SELECT DISTINCT id1, id2 FROM bar) AS s);
 id 
----
  1
  1
(2 rows)

SELECT *
FROM foo
WHERE id IN (SELECT id2 FROM (SELECT id1, id2 FROM bar) AS s);
 id 
----
  1
(1 row)

8.0.3 and HEAD behave as shown.  7.4.8, 7.3.10, and 7.2.8 return a
single row for both queries.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



view thread (7+ messages)  latest in thread

Message-ID: <20050715141037.GA30461@winnie.fuhr.org>
Permalink:  ../20050715141037.GA30461@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20050715141037.GA30461@winnie.fuhr.org

 · 

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: mike@fuhr.org, tgl@sss.pgh.pa.us, luca@cs.ualberta.ca
  Subject: Re: problem (bug?) with "in (subquery)"
  In-Reply-To: <20050715141037.GA30461@winnie.fuhr.org>

* 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