Skip site navigation (1) Skip section navigation (2)

SQLSTATE again

From: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
To: pgsql-patches(at)postgresql(dot)org
Cc: neilc(at)samurai(dot)com, <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: SQLSTATE again
Date: 2005-05-30 07:05:32
Message-ID: Pine.LNX.4.44.0505300858440.11699-200000@kix.fsv.cvut.cz (view raw or flat)
Thread:
Lists: pgsql-patches
Hello

I changed implementation of SQLSTATE from block scope variables on 
function scope variables. I am not sure if it's moust elegant solution, 
but is very similar Oracle behavior (there is session scope variable)

CREATE OR REPLACE FUNCTION ff() RETURNS void AS $$
BEGIN
  RAISE NOTICE 'No exception: % %', SQLSTATE, SQLERRM;
  DECLARE x integer;
  BEGIN
    x := 10/0;
    EXCEPTION WHEN OTHERS THEN
    BEGIN
      RAISE NOTICE 'Div: % %', SQLSTATE, SQLERRM;
        BEGIN
          RAISE NOTICE 'Div2: % %', SQLSTATE, SQLERRM;
          RAISE EXCEPTION 'My user exception';
        EXCEPTION WHEN OTHERS THEN
          RAISE NOTICE 'User: % %', SQLSTATE, SQLERRM;
        END;
        RAISE NOTICE '1: % %', SQLSTATE, SQLERRM;
    END;
    RAISE NOTICE '2: % %', SQLSTATE, SQLERRM;
  END;
  RAISE NOTICE '3: % %', SQLSTATE, SQLERRM;
END;
$$ LANGUAGE plpgsql;
select ff();


NOTICE:  No exception: 00000 Successful completion
NOTICE:  Div: 22012 division by zero
NOTICE:  Div2: 22012 division by zero
NOTICE:  User: P0001 My user exception
NOTICE:  1: 00000 Successful completion
NOTICE:  2: 00000 Successful completion
NOTICE:  3: 00000 Successful completion

Any comments?

Regards
Pavel Stehule



Attachment: sqlstate.diff
Description: text/plain (6.3 KB)

Responses

pgsql-patches by date

Next:From: Neil ConwayDate: 2005-05-30 07:41:26
Subject: Re: skip FK trigger on UPDATE
Previous:From: Neil ConwayDate: 2005-05-30 07:04:41
Subject: Re: O_DIRECT for WAL writes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group