DELETE Weirdness

From: Ravi Chemudugunta <chemuduguntar(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: DELETE Weirdness
Date: 2010-01-15 00:55:10
Message-ID: 7a4208ef1001141655l1a6ffa82u9d884d24b23967bd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

There are two ways of deleting things,

DELETE FROM <table> WHERE PK IN ( ...SET... );

DELETE FROM <table> USING <table2>
WHERE <join condition> AND <filter clause>;

I am deleting from a table where the rows are inter-related (it is a
tree); using the first version with IN, it does not delete all rows;
there is a trigger that rearranges the rows when a row is deleted
(updating references etc.). Disabling this trigger results in correct
behavoir.

However, using the second version (using USING) works as expected with
or without disabling the said triggers.

I cannot quite understand this; Are the contents of the IN query
worked out ONCE per outer query and therefore become invalid when
DELETE comes along and changes items that were part of the set ? (for
e.g.)

-ravi

--
:wq

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Davis 2010-01-15 01:20:48 Re: DELETE Weirdness
Previous Message Craig Ringer 2010-01-15 00:21:02 Re: Memory Access Violation While Using PQexec