Re: Triggers on Stored Procedures

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Omer Anson" <oaanson(at)gmail(dot)com>,<pgsql-admin(at)postgresql(dot)org>
Subject: Re: Triggers on Stored Procedures
Date: 2010-12-27 16:56:43
Message-ID: 4D1870EB0200002500038BBD@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Omer Anson <oaanson(at)gmail(dot)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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message ℓєѕℓιє ѕαмυєℓ 2010-12-27 17:09:24 Unable to install 9.0 postgre in debian-lenny
Previous Message Omer Anson 2010-12-27 09:38:40 Triggers on Stored Procedures