Обсуждение: infinite recursion detected in rules for relation "..."
Hello all, i have a problem migrating my application from version 7.4 to 8.0. Everything is fine in 7.4 but with 8.0 i get the following error: infinite recursion detected in rules for relation "..." I've been able to narrow the problem down to the attached SQL. I don't know wether its a bug or a "feature". Can someone explain me this behaviour. Thanks in advance Sebastian CREATE TABLE ref ( name TEXT NOT NULL PRIMARY KEY ); CREATE TABLE test ( id SERIAL PRIMARY KEY, col1 TEXT NOT NULL UNIQUE, col2 TEXT NOT NULL REFERENCES ref ON UPDATE CASCADE ); CREATE TABLE log ( id INTEGER NOT NULL, col1 TEXT NOT NULL, col2 TEXT NOT NULL ); CREATE OR REPLACE RULE log AS ON UPDATE TO test DO INSERT INTO log VALUES (OLD.id,OLD.col1,OLD.col2); CREATE VIEW bug AS SELECT * FROM test; CREATE OR REPLACE RULE upd AS ON UPDATE TO bug DO INSTEAD NOTHING; CREATE OR REPLACE RULE upd_col1 AS ON UPDATE TO bug WHERE NEW.col1 <> OLD.col1 DO UPDATE test SET col1 = NEW.col1 WHERE id = OLD.id; CREATE OR REPLACE RULE upd_col2 AS ON UPDATE TO bug WHERE NEW.col2 <> OLD.col2 DO UPDATE test SET col2 = NEW.col2 WHERE id = OLD.id; INSERT INTO ref (name) VALUES ('Name'); INSERT INTO test (col1,col2) VALUES ('Test 1','Name'); UPDATE bug SET col1 = 'Test' WHERE id = 1;
=?ISO-8859-1?Q?Sebastian_B=F6ck?= <sebastianboeck@freenet.de> writes: > i have a problem migrating my application from version > 7.4 to 8.0. Everything is fine in 7.4 but with 8.0 i get > the following error: > infinite recursion detected in rules for relation "..." > I don't know wether its a bug or a "feature". It's a bug. Thanks for the report. regards, tom lane
=?ISO-8859-1?Q?Sebastian_B=F6ck?= <sebastianboeck@freenet.de> writes: > infinite recursion detected in rules for relation "..." If you need a patch immediately, here it is. *** src/backend/rewrite/rewriteHandler.c.orig Sat Nov 6 12:46:35 2004 --- src/backend/rewrite/rewriteHandler.c Sat Nov 20 12:47:21 2004 *************** *** 1267,1272 **** --- 1267,1274 ---- newstuff = RewriteQuery(pt, rewrite_events); rewritten = list_concat(rewritten, newstuff); } + + rewrite_events = list_delete_first(rewrite_events); } } regards, tom lane
Tom Lane wrote: > =?ISO-8859-1?Q?Sebastian_B=F6ck?= <sebastianboeck@freenet.de> writes: > >>infinite recursion detected in rules for relation "..." > > > If you need a patch immediately, here it is. > > *** src/backend/rewrite/rewriteHandler.c.orig Sat Nov 6 12:46:35 2004 > --- src/backend/rewrite/rewriteHandler.c Sat Nov 20 12:47:21 2004 > *************** > *** 1267,1272 **** > --- 1267,1274 ---- > newstuff = RewriteQuery(pt, rewrite_events); > rewritten = list_concat(rewritten, newstuff); > } > + > + rewrite_events = list_delete_first(rewrite_events); > } > } > > > regards, tom lane Thanks for the quick patch! Everything is working now. Sebastian