Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Tim Smith
> > > I knew I was missing something:( > http://www.postgresql.org/docs/9.4/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING > > "When an error is caught by an EXCEPTION clause, the local variables of the > PL/pgSQL function remain as they were when the error occurred, but all > c

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Adrian Klaver
On 06/26/2015 10:49 AM, Tim Smith wrote: Did not see the strict. In any case I thought cleanSessionTable was cleaning out app_security.app_sessions not app_security.app_val_session_vw. Yes. cleanSessionTable does the actual cleaning. The point of the select from app_security.app_val_session_

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Tim Smith
> > Did not see the strict. In any case I thought cleanSessionTable was cleaning > out app_security.app_sessions not app_security.app_val_session_vw. Yes. cleanSessionTable does the actual cleaning. The point of the select from app_security.app_val_session_vw is that if the session is valid, the

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Adrian Klaver
On 06/26/2015 10:02 AM, Tim Smith wrote: Me again, I've reworded it, but its still rolling back !!! Using the code below, if I call : select app_security.validateSession('XYZ','10.10.123.43','Z',5,5); I get an error raised on the select that follows cleanSessionTable. Which is fine. BUT, Postgr

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Adrian Klaver
On 06/26/2015 09:54 AM, Tim Smith wrote: Well that was my problem, I did not know what was intended. apt-get install mind-reading ;-) 1) Look before you leap I'm confused by this option ? My script reads as follows : perform app_security.cleanSessionTable(p_forcedTimeout,p_sessionTimeou

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Tim Smith
Me again, I've reworded it, but its still rolling back !!! Using the code below, if I call : select app_security.validateSession('XYZ','10.10.123.43','Z',5,5); I get an error raised on the select that follows cleanSessionTable. Which is fine. BUT, Postgresql is still rolling back ! If I go back

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Tim Smith
> Well that was my problem, I did not know what was intended. apt-get install mind-reading ;-) > 1) Look before you leap > I'm confused by this option ? My script reads as follows : perform app_security.cleanSessionTable(p_forcedTimeout,p_sessionTimeout); select * into strict v_row from app_s

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Adrian Klaver
On 06/26/2015 09:08 AM, Tim Smith wrote: Adrian, "what I want" is quite simple, I want the function to work as intended. ;-) Well that was my problem, I did not know what was intended. Let's step through the function : (1) perform app_security.cleanSessionTable(p_forcedTimeout,p_sessionTi

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Tim Smith
Adrian, "what I want" is quite simple, I want the function to work as intended. ;-) Let's step through the function : (1) perform app_security.cleanSessionTable(p_forcedTimeout,p_sessionTimeout); Function calls cleanSessionTable.cleanSessionTable is simple. It calls DELETE on the session

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread David G. Johnston
On Fri, Jun 26, 2015 at 11:38 AM, Tim Smith wrote: > Adrian, > > Ok, let's start fresh. > > app_security.validateSession() calls app_security.cleanSessionTable(). > > app_security.cleanSessionTable(), when called on its, own, does not > cause me any issues. It operates as designed. > > I have ad

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Adrian Klaver
On 06/26/2015 08:38 AM, Tim Smith wrote: Adrian, Ok, let's start fresh. app_security.validateSession() calls app_security.cleanSessionTable(). app_security.cleanSessionTable(), when called on its, own, does not cause me any issues. It operates as designed. I have added ROLLBACK TO SAVEPOINT

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Holger.Friedrich-Fa-Trivadis
Tim Smith wrote on Friday, June 26, 2015 5:38 PM: > ERROR: cannot begin/end transactions in PL/pgSQL > HINT: Use a BEGIN block with an EXCEPTION clause instead. > CONTEXT: PL/pgSQL function > app_security.validatesession(app_domains.app_uuid,inet,text,bigint,bigint) > line 16 at SQL statement >

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Tim Smith
Adrian, Ok, let's start fresh. app_security.validateSession() calls app_security.cleanSessionTable(). app_security.cleanSessionTable(), when called on its, own, does not cause me any issues. It operates as designed. I have added ROLLBACK TO SAVEPOINT to validateSession(), so that it now reads

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Adrian Klaver
On 06/26/2015 07:24 AM, Tim Smith wrote: So this is in a plpgsql function? It is yes, but I thought I would spare you a copy/paste of the entire thing. The error trapping section currently looks like this : EXCEPTION WHEN OTHERS THEN RA

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread David G. Johnston
On Fri, Jun 26, 2015 at 10:48 AM, Tim Smith wrote: > Hi David, > > I should have perhaps made clear this was a saved function, so my > understanding is ROLLBACK can't be used as its implicit. > ​I am pretty certain "ROLLBACK" cannot be used but the "ROLLBACK TO SAVEPOINT" can - they are and do t

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Tim Smith
Hi David, I should have perhaps made clear this was a saved function, so my understanding is ROLLBACK can't be used as its implicit. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Tim Smith
> You need to trap exceptions and in the handler block issue a > > ROLLBACK TO SAVEPOINT > > http://www.postgresql.org/docs/9.4/static/sql-rollback-to.html > > > otherwise the the ROLLBACK issued at pg-session end will simply rollback > everything. > > David J. > Thanks, will take a look. -- Se

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Tim Smith
> So this is in a plpgsql function? It is yes, but I thought I would spare you a copy/paste of the entire thing. The error trapping section currently looks like this : EXCEPTION WHEN OTHERS THEN RAISE EXCEPTION 'Failed to validate session fo

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Adrian Klaver
On 06/26/2015 06:38 AM, Tim Smith wrote: Hi, Apologies if I am being incredibly stupid, but I just can't seem to get this to work for me. I have a function that validates a web session is still active, so my code looks something like this : BEGIN perform app_security.cleanSessionTable(p_forced

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread David G. Johnston
On Fri, Jun 26, 2015 at 9:38 AM, Tim Smith wrote: > I have a function that validates a web session is still active, so my > code looks something like this : > > BEGIN > perform app_security.cleanSessionTable(p_forcedTimeout,p_sessionTimeout); > SAVEPOINT sp_cleanedSessionTable; > select * into st

[GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread Tim Smith
Hi, Apologies if I am being incredibly stupid, but I just can't seem to get this to work for me. I have a function that validates a web session is still active, so my code looks something like this : BEGIN perform app_security.cleanSessionTable(p_forcedTimeout,p_sessionTimeout); SAVEPOINT sp_cle