Re: [HACKERS] Triggers with DO functionality

2014-09-16 Thread Thom Brown
On 17 February 2012 22:42, Jaime Casanova ja...@2ndquadrant.com wrote: On Fri, Feb 17, 2012 at 4:46 PM, Tom Lane t...@sss.pgh.pa.us wrote: Has anybody stopped to look at the SQL standard for this? In-line trigger definitions are actually what they intend, IIRC. this is what i found

Re: [HACKERS] Triggers with DO functionality

2014-09-16 Thread Andres Freund
On 2014-09-16 13:15:59 +0100, Thom Brown wrote: On 17 February 2012 22:42, Jaime Casanova ja...@2ndquadrant.com wrote: On Fri, Feb 17, 2012 at 4:46 PM, Tom Lane t...@sss.pgh.pa.us wrote: Has anybody stopped to look at the SQL standard for this? In-line trigger definitions are

Re: [HACKERS] Triggers with DO functionality

2014-09-16 Thread Thom Brown
On 16 September 2014 13:29, Andres Freund and...@2ndquadrant.com wrote: On 2014-09-16 13:15:59 +0100, Thom Brown wrote: On 17 February 2012 22:42, Jaime Casanova ja...@2ndquadrant.com wrote: On Fri, Feb 17, 2012 at 4:46 PM, Tom Lane t...@sss.pgh.pa.us wrote: Has anybody stopped to

Re: [HACKERS] Triggers with DO functionality

2014-09-16 Thread Andres Freund
On 2014-09-16 13:42:22 +0100, Thom Brown wrote: The function can't be the target of CREATE OR REPLACE FUNCTION. That *really* sucks. To the point of making the feature useless in my eyes. That's really something frequently done. Why not CREATE OR REPLACE TRIGGER? Wouldn't the

Re: [HACKERS] Triggers with DO functionality

2014-09-16 Thread Thom Brown
On 16 September 2014 13:45, Andres Freund and...@2ndquadrant.com wrote: On 2014-09-16 13:42:22 +0100, Thom Brown wrote: The function can't be the target of CREATE OR REPLACE FUNCTION. That *really* sucks. To the point of making the feature useless in my eyes. That's really something

Re: [HACKERS] Triggers with DO functionality

2014-09-16 Thread Andres Freund
On 2014-09-16 13:54:49 +0100, Thom Brown wrote: On 16 September 2014 13:45, Andres Freund and...@2ndquadrant.com wrote: On 2014-09-16 13:42:22 +0100, Thom Brown wrote: The function can't be the target of CREATE OR REPLACE FUNCTION. That *really* sucks. To the point of making the

Re: [HACKERS] Triggers with DO functionality

2012-02-26 Thread Peter Eisentraut
On fre, 2012-02-24 at 13:55 -0600, Kevin Grittner wrote: By default, a trigger function runs as the table owner, ie it's implicitly SEC DEF to the table owner. Really? That's certainly what I would *want*, but it's not what I've seen. Yes, you're right, that was my recollection as

Re: [HACKERS] Triggers with DO functionality

2012-02-24 Thread Peter Eisentraut
On fre, 2012-02-17 at 16:46 -0500, Tom Lane wrote: But perhaps SECURITY DEFINER is a common enough need to justify including in this shorthand form. According to the SQL standard, trigger actions run in security definer mode. I would hope that we could go with that by default for inline

Re: [HACKERS] Triggers with DO functionality

2012-02-24 Thread Tom Lane
Peter Eisentraut pete...@gmx.net writes: On fre, 2012-02-17 at 16:46 -0500, Tom Lane wrote: But perhaps SECURITY DEFINER is a common enough need to justify including in this shorthand form. According to the SQL standard, trigger actions run in security definer mode. I would hope that we

Re: [HACKERS] Triggers with DO functionality

2012-02-24 Thread Peter Eisentraut
On fre, 2012-02-24 at 14:27 -0500, Tom Lane wrote: (Thinks some more...) Actually, the point of SECURITY DEFINER on a trigger function is to run as somebody other than the table owner, to wit the function owner. And with an anonymous function there couldn't be any other owner. So I guess

Re: [HACKERS] Triggers with DO functionality

2012-02-24 Thread Kevin Grittner
Tom Lane t...@sss.pgh.pa.us wrote: By default, a trigger function runs as the table owner, ie it's implicitly SEC DEF to the table owner. Really? That's certainly what I would *want*, but it's not what I've seen. test=# create user bob; CREATE ROLE test=# create user ted; CREATE ROLE

Re: [HACKERS] Triggers with DO functionality

2012-02-24 Thread Christopher Browne
On Fri, Feb 24, 2012 at 2:55 PM, Kevin Grittner kevin.gritt...@wicourts.gov wrote: Tom Lane t...@sss.pgh.pa.us wrote: By default, a trigger function runs as the table owner, ie it's implicitly SEC DEF to the table owner. Really?  That's certainly what I would *want*, but it's not what I've

Re: [HACKERS] Triggers with DO functionality

2012-02-23 Thread Thom Brown
On 23 February 2012 07:15, Gianni Ciolli gianni.cio...@2ndquadrant.it wrote: On Fri, Feb 17, 2012 at 11:43:53AM -0500, Andrew Dunstan wrote: On 02/17/2012 11:29 AM, David E. Wheeler wrote: On Feb 17, 2012, at 5:22 AM, Thom Brown wrote: The purpose being to only have a single statement to set

Re: [HACKERS] Triggers with DO functionality

2012-02-23 Thread Gianni Ciolli
On Thu, Feb 23, 2012 at 08:26:47AM +, Thom Brown wrote: On 23 February 2012 07:15, Gianni Ciolli gianni.cio...@2ndquadrant.it wrote: Another complication: anonymous triggers would either have to be alone, or provide a mechanism to manage a sequence of anonymous triggers on the same

Re: [HACKERS] Triggers with DO functionality

2012-02-22 Thread Gianni Ciolli
On Fri, Feb 17, 2012 at 11:43:53AM -0500, Andrew Dunstan wrote: On 02/17/2012 11:29 AM, David E. Wheeler wrote: On Feb 17, 2012, at 5:22 AM, Thom Brown wrote: The purpose being to only have a single statement to set up the trigger rather than setting up a separate trigger function which will

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread David E. Wheeler
On Feb 17, 2012, at 5:22 AM, Thom Brown wrote: The purpose being to only have a single statement to set up the trigger rather than setting up a separate trigger function which will unlikely be re-used by other triggers... or is this of dubious benefit? +1, though I imagine it would just give

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Andrew Dunstan
On 02/17/2012 11:29 AM, David E. Wheeler wrote: On Feb 17, 2012, at 5:22 AM, Thom Brown wrote: The purpose being to only have a single statement to set up the trigger rather than setting up a separate trigger function which will unlikely be re-used by other triggers... or is this of dubious

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Thom Brown
On 17 February 2012 16:29, David E. Wheeler da...@justatheory.com wrote: On Feb 17, 2012, at 5:22 AM, Thom Brown wrote: The purpose being to only have a single statement to set up the trigger rather than setting up a separate trigger function which will unlikely be re-used by other

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Thom Brown
On 17 February 2012 16:43, Andrew Dunstan and...@dunslane.net wrote: On 02/17/2012 11:29 AM, David E. Wheeler wrote: On Feb 17, 2012, at 5:22 AM, Thom Brown wrote: The purpose being to only have a single statement to set up the trigger rather than setting up a separate trigger function

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Andrew Dunstan
On 02/17/2012 11:46 AM, Thom Brown wrote: On 17 February 2012 16:43, Andrew Dunstanand...@dunslane.net wrote: On 02/17/2012 11:29 AM, David E. Wheeler wrote: On Feb 17, 2012, at 5:22 AM, Thom Brown wrote: The purpose being to only have a single statement to set up the trigger rather than

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Peter Eisentraut
On fre, 2012-02-17 at 13:22 +, Thom Brown wrote: So instead of CREATE TRIGGER... EXECUTE PROCEDURE functioname(); you'd have: CREATE TRIGGER... DO $$ ... $$; I had wished for this many times and was about to propose something similar. We might wish to review the SQL standard

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Thom Brown
On 17 February 2012 17:26, Peter Eisentraut pete...@gmx.net wrote: On fre, 2012-02-17 at 13:22 +, Thom Brown wrote: So instead of CREATE TRIGGER... EXECUTE PROCEDURE functioname(); you'd have: CREATE TRIGGER... DO $$ ... $$; I had wished for this many times and was about to

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Dimitri Fontaine
Thom Brown t...@linux.com writes: And thinking about it, DO is a bit nonsense here, so maybe we'd just have something like: CREATE TRIGGER... AS $$ BEGIN END; $$; i.e. the same as a function. I like that. How do you tell which language the trigger is written in? I'm not so sure about

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Thom Brown
On 17 February 2012 20:40, Dimitri Fontaine dimi...@2ndquadrant.fr wrote: Thom Brown t...@linux.com writes: And thinking about it, DO is a bit nonsense here, so maybe we'd just have something like: CREATE TRIGGER... AS $$ BEGIN END; $$; i.e. the same as a function. I like that.  How

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Andrew Dunstan
On 02/17/2012 03:58 PM, Thom Brown wrote: On 17 February 2012 20:40, Dimitri Fontainedimi...@2ndquadrant.fr wrote: Thom Brownt...@linux.com writes: And thinking about it, DO is a bit nonsense here, so maybe we'd just have something like: CREATE TRIGGER... AS $$ BEGIN END; $$; i.e. the

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Thom Brown
On 17 February 2012 21:07, Andrew Dunstan and...@dunslane.net wrote: On 02/17/2012 03:58 PM, Thom Brown wrote: On 17 February 2012 20:40, Dimitri Fontainedimi...@2ndquadrant.fr  wrote: Thom Brownt...@linux.com  writes: And thinking about it, DO is a bit nonsense here, so maybe we'd just

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Tom Lane
Andrew Dunstan and...@dunslane.net writes: On 02/17/2012 03:58 PM, Thom Brown wrote: On 17 February 2012 20:40, Dimitri Fontainedimi...@2ndquadrant.fr wrote: I'm not so sure about other function properties (SET, COST, ROWS, SECURITY DEFINER etc) because applying default and punting users to

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Dimitri Fontaine
Tom Lane t...@sss.pgh.pa.us writes: Has anybody stopped to look at the SQL standard for this? In-line trigger definitions are actually what they intend, IIRC. In which language? Do we need to include PL/PSM to be compliant, and use that by default? In that case we might want to force people

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Tom Lane
Dimitri Fontaine dimi...@2ndquadrant.fr writes: Tom Lane t...@sss.pgh.pa.us writes: Has anybody stopped to look at the SQL standard for this? In-line trigger definitions are actually what they intend, IIRC. In which language? Do we need to include PL/PSM to be compliant, and use that by

Re: [HACKERS] Triggers with DO functionality

2012-02-17 Thread Jaime Casanova
On Fri, Feb 17, 2012 at 4:46 PM, Tom Lane t...@sss.pgh.pa.us wrote: Has anybody stopped to look at the SQL standard for this?  In-line trigger definitions are actually what they intend, IIRC. this is what i found there trigger definition ::=   CREATE TRIGGER trigger name trigger action time