Re: AW: AW: [HACKERS] Rule system

From: jwieck(at)debis(dot)com (Jan Wieck)
To: vadim(at)krs(dot)ru (Vadim Mikheev)
Cc: jwieck(at)debis(dot)com, hackers(at)postgreSQL(dot)org
Subject: Re: AW: AW: [HACKERS] Rule system
Date: 1998-08-14 07:33:47
Message-ID: m0z7EMu-000EBPC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> Jan Wieck wrote:
> >
> > It might look like:
> >
> > create trigger mytrig before insert or update on mytab
> > for each row do (
> ^^
> Why not EXECUTE ?

Just to indicate that this time a function body, for which a
trigger function has to be created on the fly, follows
instead of the name of an existing function to be called.

But for bison it should be no problem to decide whether
EXECUTE PROCEDURE proname(args) or EXECUTE PROCEDURE (body)
is used. I don't really care about the final syntax.

>
> > begin
> > new.lastupdate := 'now';
> > return new;
> > end;
> > ) language 'plpgsql';
> >
> > This would be easy. Just an enhancement to the parser and to
> > the create trigger utility processing so it creates the
> > required function on the fly. Modification of new, raising
> > errors via elog() and suppressing the operation itself by
> > returning NULL is already there in PL/pgSQL. We would need
> > something smart for the functions name, because using the
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > trigger name only would break the current possibility to
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > define the same trigger name on different tables with
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > different actions. Something like __trig_<oid> would be good.
> ^^^^^^^^^^^^^^^^^
> I missed here. What did you mean?

What I have in mind for

CREATE TRIGGER ... EXECUTE PROCEDURE (body)

is, that this time a trigger function is automatically
created before the usual trigger is defined. For the function
there is a name required. Currently the following is
possible:

CREATE TRIGGER on_insert AFTER INSERT on emp
FOR EACH ROW EXECUTE PROCEDURE on_ins_emp();

CREATE TRIGGER on_insert AFTER INSERT on payroll
FOR EACH ROW EXECUTE PROCEDURE on_ins_payroll();

The name of the trigger is the same but the table they
triggered for differs and they call different functions. I
don't want to loose this so we cannot use the name of the
trigger (on_insert) to create the trigger function since
overloading depends on different call arguments. But both
functions have no call arguments.

Clear now?

>
> Vadim
> P.S. Sorry, I'm very busy currently :((
>
>

Jan

--

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dr. Michael Meskes 1998-08-14 08:49:01 ecpg problem
Previous Message The Hermit Hacker 1998-08-14 05:32:26 Re: [HACKERS] HELP all women were raped during the May riots in Jakarta