possibly spurious `EXCEPT ... may not refer to other relation...'

From: Brandon Craig Rhodes <brandon(at)oit(dot)gatech(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: possibly spurious `EXCEPT ... may not refer to other relation...'
Date: 2003-02-20 23:13:57
Message-ID: w64r6y35qi.fsf@guinness.ts.gatech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The current CVS version of PostgreSQL gives us the error:

ERROR: UNION/INTERSECT/EXCEPT member statement
may not refer to other relations of same query level

when given the following test case, despite the fact that the EXCEPT
clause does not refer to any other relation involved in the same
query. We suspect this to be a bug. (This simple test case has been
drastically reduced from the actual code we want to run, which is a
more complicated INSERT INTO SELECT ... EXCEPT whose goal is to avoid
inserting rows that are already in the destination table; so whereas
here the except clause involves a third, dummy table, we would
actually like to check for whether the row exists in the table which
is the target of the INSERT.)

CREATE TABLE current ( number INTEGER );
CREATE TABLE former ( number INTEGER );
CREATE TABLE trash ( number INTEGER) ;

CREATE OR REPLACE RULE current_delete AS
ON DELETE TO current
DO INSERT INTO former (number)
SELECT number FROM current
WHERE number = OLD.number
EXCEPT
SELECT number FROM trash;

--
Brandon Craig Rhodes http://www.rhodesmill.org/brandon
Georgia Tech brandon(at)oit(dot)gatech(dot)edu

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2003-02-20 23:35:44 Re: Tuning scenarios (was Changing the default
Previous Message Josh Berkus 2003-02-20 22:33:02 Re: Tuning scenarios (was Changing the default configuration)