Subject: Is notification possible using rules and fns?

From: [email-masked] (Alfredo Sanchez)
Date: Wed, 9 Jun 93 22:33:09 -0700

Hello,

I was trying to use rules to implement some sort of notification
upon changes to some instances but I've found a few probs.
It seems that I need to review the writings on the semantics of
instance-level and rewrite rules, but before digging into the papers,
I'd like to check whether someone else has done something similar.

In essence, I have a class called "Attributes" with fields
"name" and "value", both of them of type "text".

I define a function like:

define function notify_user
(language = "c", returntype = bool, trusted = false)
as "/home/accts/joseash//notify.o"\g

The C function is a trial one:

#include <stdio.h>
int notify_user()
{
 printf("Document status has been changed");
}

Then I define a rule:

define rewrite rule notify_user
is on replace to Attributes.value where Attributes.name = "Doc_Status"
do retrieve (x=notify_user())\g

When a "replace" is done, it seems that the where-clause is 
ignored, I suppose because this is a rewrite rule. The problem is
I couldn't define it as instance-level, as postgres would complain
requiring that

WARN:Jun  9 23:38:36:`on retrieve ... do retrieve' tuple rules must 
have an `instead' (And I do want to execute the function in addition to
replacing)

So the rule is always fired. 
What happens to the function's output?
Do I have other alternatives to do this?
Will listen/notify in upcoming releases help?

Thanks a lot for your help.

Best regards,

J Alfredo Sanchez H
-------------------
Hypermedia Research Lab
Texas A&M University

---

From: George Hartzell <[email-masked]>
Date: Thu, 10 Jun 93 08:35:00 -0700

Alfredo Sanchez writes:
   >[...]
   >[...]
   >[...]

I can't help you with the rules part of your question, but the
disappearing printf is right up my alley.

Functions that are dynamically loaded run in the back end (which may
well be on another machine...), so the printf isn't doing what you
expect.  If you change it to:

  elog(NOTICE, "Document status has been changed");

then you should see the message.  You'd better check the syntax of the
elog(), since I'm operating from home, but I think that's it.

g.
George Hartzell                                     [email-masked]
Computer Science, 570 Evans Hall,
University of California, Berkeley, CA 94720