Thread: loop on a rule

loop on a rule

From
Martín Marqués
Date:
As I said before, I am playing around with views and rules, and found out 
that I have something wrong in one of the rules. My delete rule says 
something like this:

CREATE RULE admin_delete AS ON
DELETE TO admin_view
DO INSTEAD (  DELETE FROM carrera WHERE id_curso=old.id_curso;  DELETE FROM inscripcion WHERE carrera=old.id_curso;
DELETEFROM resol WHERE carr=old.id_curso;  DELETE FROM modalidad WHERE carrera=old.id_curso;  INSERT INTO log_carrera
(accion,tabla)VALUES ('D','carrera');
 
);

Where id_curso is an identifier to which inscripcion.carrera, resol.carr and 
modalidad.carrera are REFERENCED to.

When I try to execute a query like this:

DELETE FROM admin_view WHERE id_curso=2;

I get a lost connection and this on the log:

2001-08-07 19:08:40 DEBUG:  ProcessQuery
2001-08-07 19:08:40 DEBUG:  CommitTransactionCommand
2001-08-07 19:08:43 DEBUG:  StartTransactionCommand
2001-08-07 19:08:43 DEBUG:  query: DELETE FROM admin_view WHERE id_curso=2;
XLogFlush: rqst 0/0; wrt 0/62940168; flsh 0/62940168
XLogFlush: rqst 0/57764568; wrt 0/62940168; flsh 0/62940168
2001-08-07 19:08:44 DEBUG:  ProcessQuery
INSERT @ 0/62940168: prev 0/62940128; xprev 0/0; xid 21593; bkpb 1: Heap - 
delete: node 290095/290371; tid 0/2
/usr/local/pgsql/bin/postmaster: reaping dead processes...
/usr/local/pgsql/bin/postmaster: CleanupProc: pid 12353 exited with status 138
Server process (pid 12353) exited with status 138 at Tue Aug  7 19:08:45 2001
Terminating any active server processes...
Server processes were terminated at Tue Aug  7 19:08:45 2001
Reinitializing shared memory and semaphores
invoking IpcMemoryCreate(size=1245184)
2001-08-07 19:08:45 DEBUG:  database system was interrupted at 2001-08-07 
19:08:13 GMT
2001-08-07 19:08:45 DEBUG:  CheckPoint record at (0, 62658256)
2001-08-07 19:08:45 DEBUG:  Redo record at (0, 62610224); Undo record at (0, 
0); Shutdown FALSE
2001-08-07 19:08:45 DEBUG:  NextTransactionId: 21527; NextOid: 313116
2001-08-07 19:08:45 DEBUG:  database system was not properly shut down; 
automatic recovery in progress...
/usr/local/pgsql/bin/postmaster: ServerLoop:            handling reading 6
/usr/local/pgsql/bin/postmaster: ServerLoop:            handling reading 6
/usr/local/pgsql/bin/postmaster: ServerLoop:            handling reading 6
/usr/local/pgsql/bin/postmaster: ServerLoop:            handling reading 6
The Data Base System is starting up
/usr/local/pgsql/bin/postmaster: ServerLoop:            handling writing 62

And after that tns of REDOs (which I guess are OK). Does that ServerLoop 
belong to REDO or is it part of my problem?

Any ideas?

-- 
Cualquiera administra un NT.
Ese es el problema, que cualquiera administre.
-----------------------------------------------------------------
Martin Marques                  |        mmarques@unl.edu.ar
Programador, Administrador      |       Centro de Telematica                      Universidad Nacional
        del Litoral
 
-----------------------------------------------------------------


Re: loop on a rule

From
Tom Lane
Date:
Martín Marqués <martin@bugs.unl.edu.ar> writes:
> As I said before, I am playing around with views and rules, and found out 
> that I have something wrong in one of the rules. My delete rule says 
> something like this:

> CREATE RULE admin_delete AS ON
> DELETE TO admin_view
> DO INSTEAD (
>    DELETE FROM carrera WHERE id_curso=old.id_curso;
>    DELETE FROM inscripcion WHERE carrera=old.id_curso;
>    DELETE FROM resol WHERE carr=old.id_curso;
>    DELETE FROM modalidad WHERE carrera=old.id_curso;
>    INSERT INTO log_carrera (accion,tabla) VALUES ('D','carrera');
> );

I think you need the patch for multi-action rules --- see
http://www.ca.postgresql.org/cgi/cvsweb.cgi/pgsql/src/backend/rewrite/rewriteHandler.c
You need version 1.93.2.1, assuming that you're on PG 7.1.2.
        regards, tom lane


Re: loop on a rule

From
Martín Marqués
Date:
On Mar 07 Ago 2001 20:53, you wrote:
> Martín Marqués <martin@bugs.unl.edu.ar> writes:
> > As I said before, I am playing around with views and rules, and found out
> > that I have something wrong in one of the rules. My delete rule says
> > something like this:
> >
> > CREATE RULE admin_delete AS ON
> > DELETE TO admin_view
> > DO INSTEAD (
> >    DELETE FROM carrera WHERE id_curso=old.id_curso;
> >    DELETE FROM inscripcion WHERE carrera=old.id_curso;
> >    DELETE FROM resol WHERE carr=old.id_curso;
> >    DELETE FROM modalidad WHERE carrera=old.id_curso;
> >    INSERT INTO log_carrera (accion,tabla) VALUES ('D','carrera');
> > );
>
> I think you need the patch for multi-action rules --- see
> http://www.ca.postgresql.org/cgi/cvsweb.cgi/pgsql/src/backend/rewrite/rewri
>teHandler.c You need version 1.93.2.1, assuming that you're on PG 7.1.2.

Yes, I'm on PostgreSQL 7.1.2. I have a resently updated cvs of pgsql (about 3 
hours old), but I don't want to put the cvs version on my stable server (I 
use it on my WorkStation only).

How can I patch the source of my pgsql 7.1.2 src tree? Any docs are welcomed!

Saludos..... and tons of thanks.... :-)

-- 
Cualquiera administra un NT.
Ese es el problema, que cualquiera administre.
-----------------------------------------------------------------
Martin Marques                  |        mmarques@unl.edu.ar
Programador, Administrador      |       Centro de Telematica                      Universidad Nacional
        del Litoral
 
-----------------------------------------------------------------