Re: [SQL] problem (bug?) with in (subquery)

2005-07-15 Thread Michael Fuhr
On Thu, Jul 14, 2005 at 01:34:21AM -0600, Luca Pireddu wrote: I have the following query that isn't behaving like I would expect: select * from strains s where s.id in (select strain_id from pathway_strains); Any reason the subquery isn't doing SELECT DISTINCT strain_id? I would expect each

Re: [SQL] problem (bug?) with in (subquery)

2005-07-15 Thread Tom Lane
Luca Pireddu [EMAIL PROTECTED] 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

Re: [SQL] problem (bug?) with in (subquery)

2005-07-15 Thread Michael Fuhr
On Fri, Jul 15, 2005 at 09:59:27AM -0400, Tom Lane wrote: Luca Pireddu [EMAIL PROTECTED] 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

Re: [SQL] problem (bug?) with in (subquery)

2005-07-15 Thread Tom Lane
Michael Fuhr [EMAIL PROTECTED] writes: 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

Re: [SQL] problem (bug?) with in (subquery)

2005-07-15 Thread Luca Pireddu
On July 15, 2005 07:34, Michael Fuhr wrote: On Thu, Jul 14, 2005 at 01:34:21AM -0600, Luca Pireddu wrote: I have the following query that isn't behaving like I would expect: Thanks for creating the reduced test case Michael. My apologies for not doing it myself. select * from strains s

Re: [SQL] problem (bug?) with in (subquery)

2005-07-15 Thread Tom Lane
Luca Pireddu [EMAIL PROTECTED] writes: On July 15, 2005 08:58, Tom Lane wrote: Ah-hah: this one is the fault of create_unique_path, which quoth In any case, it looks like Tom has already found the problem :-) Thanks guys! On closer analysis, the test in create_unique_path is almost but not

[SQL] problem (bug?) with in (subquery)

2005-07-14 Thread Luca Pireddu
I have the following query that isn't behaving like I would expect: select * from strains s where s.id in (select strain_id from pathway_strains); I would expect each strain record to appear only once. Instead I get output like this, where the same strain id appears many times: id |