Trigger Tangent (Was: bind (Was: sequences )) - Mailing list pgsql-hackers

From Clark Evans
Subject Trigger Tangent (Was: bind (Was: sequences ))
Date
Msg-id 36F1DEA9.B352B162@manhattanproject.com
Whole thread Raw
In response to Re: [HACKERS] Sequences....  ("D'Arcy" "J.M." Cain <darcy@druid.net>)
List pgsql-hackers
Caution:  Random Thoughts & Trigger Tangent

This whole discussion got me to thinking about triggers.
Are we making, in this case, a specialized trigger that 
populates a table column from a sequence on insert?  
Perhaps it may be instructive to look at the 
general case for enlightenment.

Aside, I really don't like Oracle's trigger concept:
"CREATE TRIGGER xxx ON INSERT OF tablename AS"

I'd rather see the trigger object as a stand alone 
block of code that is "bound" to one or more tables.
Thus, the above, would be a short hand for:

"CREATE TRIGGER xxx AS .... ; BIND xxx TO tablename ON INSERT;"

Now.. if you wanted to _way_ generalize this...
You can think of "INSERT/UPDATE/DELETE" as mutating actions
taken on a table object.  What mutating actions does a 
sequence object have?  NEXTVAL

So... perhaps the trigger concept could be extended
past tables but onto any object that has mutating actions?
(you have to excuse the lack of rule system knowledge here)

And... if you want go further into the muck, perhaps
we could have triggers that have a binding with more
than one object.. 

> FUNCTION bind( TABLE, COLUMN, SEQUENCE ) RETURNS OLD_SEQUENCE;

Becomes,
 FUNCTION bind( SEQUENCE_TRIGGER, TABLE, COLUMN, SEQUENCE )     RETURNS OLD_SEQUENCE;

Hmm.  Oh well I thought I was going somewhere....   better
re-name this a tangent.

:) Clark


pgsql-hackers by date:

Previous
From: Clark Evans
Date:
Subject: FUNCTION bind (TABLE, COLUMN, SEQUENCE) returns OLD_SEQUENCE? (Was: Re: [HACKERS] Sequences....)
Next
From: Zeugswetter Andreas IZ5
Date:
Subject: AW: [HACKERS] "CANNOT EXTEND" -