Re: Triggers on Stored Procedures - Mailing list pgsql-admin

From Kevin Grittner
Subject Re: Triggers on Stored Procedures
Date
Msg-id 4D1870EB0200002500038BBD@gw.wicourts.gov
Whole thread Raw
In response to Triggers on Stored Procedures  (Omer Anson <oaanson@gmail.com>)
List pgsql-admin
Omer Anson <oaanson@gmail.com> wrote:

> First of all, I apologise if I am posting this in the wrong place.

Not a bad place to start, I guess.  If it gets into the realm of an
enhancement request or proposal it might belong on -hackers, but
since you're asking about how it might be done now, this is good.

> I would like to implement aspect-oriented programming in SQL. To
> that end, I figured I need a notification method whenever a stored
> procedure is executed (If possible, with rudimentary filtering).

Well, PostgreSQL doesn't have stored procedures, but it has
functions, which are similar in many respects.

> I have seen that this can be done with triggers for INSERT,
> UPDATE, and DELETE commands, and with RULES  for SELECT commands.
>
> My question is: Is there a way to do this to stored procedures,
> without modifying the stored procedure code?

You could put "pointcut" schemas ahead of "concern" schemas (both
business logic and cross-cutting).  The "join points" would
effectively be the business logic concern functions and the "advice"
would be embodied in the cross-cutting concern functions.  You would
just need to build a tool to create the appropriate pointcut methods
to tie them together as desired, changing the searchpath locally, or
specifying concern function names with schema-qualification.

Of course, you could do the pointcut specification manually, one
method at a time, but that's not very "enterprisy".

-Kevin

pgsql-admin by date:

Previous
From: Omer Anson
Date:
Subject: Triggers on Stored Procedures
Next
From: ℓєѕℓιє ѕαмυєℓ
Date:
Subject: Unable to install 9.0 postgre in debian-lenny