Home > Archive > PostgreSQL Bugs > June 2005 > Re: BUG in temp tables involving a temp table not properly hiding a regular table as well as allowi









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: BUG in temp tables involving a temp table not properly hiding a regular table as well as allowi
Tom Lane

2005-06-07, 11:24 am

Frank van Vugt <ftm.van.vugt@foxi.nl> writes:
> Looking forward to your analysis of the following bug:


This is not a bug, it is user error.

> CREATE TYPE full_sequence_type AS (id int);


> CREATE OR REPLACE FUNCTION full_sequence(intege
r, integer)
> RETURNS SETOF full_sequence_type
> ...


> create table f1 as select id as id2 from full_sequence(1, 100);


> create temp table f1 as select id as id2 from full_sequence(1, 100);


Since both tables have column id2, not id, the problem has certainly not
got anything to do with referencing the wrong table.

> select count(*) from full_sequence(1, 100) where id in (select id from f1);


The actual problem here is that "id" is a perfectly valid outer
reference from the sub-select. Think of this as

select count(*) from full_sequence(1, 100) as x
where x.id in (select x.id from f1);

That WHERE clause will always succeed as long as f1 isn't empty
(and id isn't null).

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com