X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 207899DC813 for ; Thu, 16 Feb 2006 07:26:20 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63579-07 for ; Thu, 16 Feb 2006 07:26:22 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id E5A219DC80D for ; Thu, 16 Feb 2006 07:26:17 -0400 (AST) Received: from mail.ritek.hu (82-131-192-50.vnet.hu [82.131.192.50]) by svr4.postgresql.org (Postfix) with ESMTP id 14F945AF02F for ; Thu, 16 Feb 2006 11:26:20 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.ritek.hu (Postfix) with ESMTP id F296C19C169 for ; Thu, 16 Feb 2006 12:26:11 +0100 (CET) Received: from mail.ritek.hu ([127.0.0.1]) by localhost (mail.ritek.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 24548-09 for ; Thu, 16 Feb 2006 12:26:09 +0100 (CET) Received: from [10.1.2.11] (unknown [10.1.2.11]) by mail.ritek.hu (Postfix) with ESMTP id 182F019C168 for ; Thu, 16 Feb 2006 12:26:09 +0100 (CET) Message-ID: <43F4617E.9060708@ritek.hu> Date: Thu, 16 Feb 2006 12:26:54 +0100 From: Antal Attila User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: VIEWs and TEMP tables problem Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ritek.hu X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200602/201 X-Sequence-Number: 24211 Hi! I found a problem with the views in PostgreSQL if I want to use temporary tables in it. See the next case! CREATE TABLE a(...., code INT4,...); INSERT INTO a(...,code,...) VALUES (...,23,...); CREATE TABLE actual_code(code INT4); If I execute the next query, the result is empty. SELECT * FROM actual_code; CREATE VIEW a_view AS SELECT * FROM a JOIN actual_code AC ON (a.code = AC.code); CREATE TEMP TABLE actual_code AS SELECT 23::INT4 AS code; If I execute the next query, the result contains exactly one row (code: 23). This is perfect. SELECT * FROM actual_code; After it if I compare the the next two queries, there will be differences in the results. 1) SELECT * FROM a JOIN actual_code AC ON (a.code = AC.code); (Result has one row!) 2) SELECT * FROM a_view; (Result is empty!) In my opinion this queries should be equivalent with same results. The problem is that the view use the original permanent table, but the 1) query use the temporary actual_code table. I read the temporally table definition in the documentation (http://www.postgresql.org/docs/8.1/interactive/sql-createtable.html) and I concluded it should be working. Is it BUG, or FEATURE? Has anybody got good ideas for solve this problem? This construction came to my mind, because I tried to solve my another question: http://groups.google.co.hu/group/pgsql.performance/browse_thread/thread/c7aec005f4a1f3eb/83fa0053cad33dea Thanks your ideas! Regards, Antal Attila