Re: BUG in temp tables involving a temp table not properly hiding a regular table as well as allowing non-existent column names

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG in temp tables involving a temp table not properly hiding a regular table as well as allowing non-existent column names
Дата
Msg-id 9398.1118161966@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG in temp tables involving a temp table not properly hiding a regular table as well as allowing non-existent column names  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
Список pgsql-bugs
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(integer, 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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: BUG in temp tables involving a temp table not properly
Следующее
От: Frank van Vugt
Дата:
Сообщение: Re: BUG in temp tables involving a temp table not properly