Re: access to original-statement predicates in an INSTEAD-OF row trigger

2019-11-16 Thread Tom Lane
John Lumby writes: > How can a row trigger access the original SQL statement at the root of > the current operation? It can't; at least not in any way that'd be reliable or maintainable. I concur with the upthread recommendation that switching to serializable mode would be a more manageable way

Re: access to original-statement predicates in an INSTEAD-OF row trigger

2019-11-16 Thread John Lumby
On 11/15/19 17:38, Adrian Klaver wrote: > On 11/15/19 1:54 PM, John Lumby wrote: >> Adrian Klaver wrote : >>> >> We need to run with Read Committed. >> >> I am looking for a solution which does not alter the application or >> overall behaviour, >> but just addresses detecting which predicates to a

Re: access to original-statement predicates in an INSTEAD-OF row trigger

2019-11-15 Thread Adrian Klaver
On 11/15/19 1:54 PM, John Lumby wrote: Adrian Klaver wrote : Seems you are looking for Serializable Isolation Level: True ,   that would solve the race condition,  but it is too drastic. We need to run with Read Committed. I am looking for a solution which does not alter the application or

Re: access to original-statement predicates in an INSTEAD-OF row trigger

2019-11-15 Thread John Lumby
Adrian Klaver wrote : > > Seems you are looking for Serializable Isolation Level: > True , that would solve the race condition, but it is too drastic. We need to run with Read Committed. I am looking for a solution which does not alter the application or overall behaviour, but just addresses

Re: access to original-statement predicates in an INSTEAD-OF row trigger

2019-11-15 Thread Adrian Klaver
On 11/15/19 12:57 PM, John Lumby wrote: Adrian Klaver wrote : On 11/15/19 10:37 AM, John Lumby wrote: Suppose the original statement is UPDATE myview VW set VW.counter = 11 where VW.primary_key = and VW.counter = 10; and my trigger constructs this statement UPDATE basetab

Re: access to original-statement predicates in an INSTEAD-OF row trigger

2019-11-15 Thread John Lumby
Adrian Klaver wrote : > > On 11/15/19 10:37 AM, John Lumby wrote: > > > Suppose the original statement is > > > UPDATE myview VW set VW.counter = 11 where VW.primary_key = and > > VW.counter = 10; > > > and my trigger constructs this statement > > > UPDATE basetable BT set BT.counte

Re: access to original-statement predicates in an INSTEAD-OF row trigger

2019-11-15 Thread Adrian Klaver
On 11/15/19 10:37 AM, John Lumby wrote: I have an INSTEAD-OF row trigger one of whose purposes is to re-direct the original statement (which is operating on a VIEW) to a different real base table. Suppose the original statement is           UPDATE myview VW set VW.counter = 11 where VW.primary

access to original-statement predicates in an INSTEAD-OF row trigger

2019-11-15 Thread John Lumby
I have an INSTEAD-OF row trigger one of whose purposes is to re-direct the original statement (which is operating on a VIEW) to a different real base table. Suppose the original statement is            UPDATE myview VW set VW.counter = 11 where VW.primary_key = and AND VW.counter = 10; an