Re: [HACKERS] Re: trouble creating log table with rules

From: wieck(at)debis(dot)com (Jan Wieck)
To: wayne(at)senet(dot)com(dot)au (Wayne Piekarski)
Cc: pgsql-sql(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org, jmr(at)computing(dot)com
Subject: Re: [HACKERS] Re: trouble creating log table with rules
Date: 1999-06-25 12:09:28
Message-ID: m10xUnQ-0003kvC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

>
> > Date: Thu, 24 Jun 1999 01:53:05 -0500
> > From: Jim Rowan <jmr(at)computing(dot)com>
> > Subject: trouble creating log table with rules
> >
> > I've read the docs in the programmers manual, and can create rules like this:
> >
> > CREATE RULE "m_log_change" AS ON UPDATE TO "machine"
> > do (
> > INSERT INTO machine_log (who, date, machnum, col, newval)
> > SELECT getpgusername(), 'now'::text, old.machnum,
> > 'host', new.host
> > WHERE (new.host != old.host) or
> > (old.host IS NOT NULL and new.host IS NULL) or
> > (old.host IS NULL and new.host IS NOT NULL);
> >
> > INSERT INTO machine_log (who, date, machnum, col, newval)
> > SELECT getpgusername(), 'now'::text, old.machnum,
> > 'serial_num_cpu', new.serial_num_cpu
> > WHERE (new.serial_num_cpu != old.serial_num_cpu) or
> > (old.serial_num_cpu IS NOT NULL and new.serial_num_cpu IS NULL) or
> > (old.serial_num_cpu IS NULL and new.serial_num_cpu IS NOT NULL);
> > );
> >
> > My big problem is that if I replicate this enough times to cover the fields I
> > want, I get this error:
> >
> > pqReadData() -- backend closed the channel unexpectedly.
> > This probably means the backend terminated abnormally
> > before or while processing the request.
> > We have lost the connection to the backend, so further processing is impossible. Terminating.
> >

You didn't tell us which version of PostgreSQL and (more
important) if the error occurs during CREATE RULE or when
updating machine.

If it occurs during the CREATE RULE (what I hope for you) it
doesn't happen in the rewriter itself. For the rule actions
in the example above it isn't important in which order they
are processed. So you could setup single action rules per
field to get (mostly) the same results.

If you can create the entire multi action rule but get the
backend crash during UPDATE of machine, then it's a problem
in the rewriter which I cannot imagine looking at your rules.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck(at)debis(dot)com (Jan Wieck) #

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-06-25 12:59:58 Re: [HACKERS] The dangers of "-F"
Previous Message rafael 1999-06-25 11:22:30 postgres

Browse pgsql-sql by date

  From Date Subject
Next Message Chris Bitmead 1999-06-25 14:58:20 Severe SUBSELECT bug in 6.5 CVS
Previous Message Rudy Gireyev 1999-06-25 07:26:27 Re: [SQL] PHP + PG