From: | Rod Taylor <pg(at)rbt(dot)ca> |
---|---|
To: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
Cc: | Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [subxacts] Aborting a function |
Date: | 2004-07-08 20:52:04 |
Message-ID: | 1089319923.5999.253.camel@jester |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> create function crashme2() returns int strict language plpgsql as '
> begin
> subbegin;
> select foo; -- aborts the transaction
> -- did not close the subxact
> end;';
I'm not sure I follow. Are you saying that the following code or
something similar will never work?
create function insertOrUpdateTabX(int, text) returns as '
BEGIN
SUBBEGIN;
INSERT INTO tab (key, col) VALUES ($1, $2);
GET DIAGNOSTICS status = SQLSTATE;
IF (status != 000000) THEN
-- Got an error, determine what it is
SUBABORT;
IF (status = 23505) THEN
-- This entry already exists. Update the value instead
UPDATE tab SET col = $2 WHERE key = $1;
ELSE
RAISE EXCEPTION ''Unrecoverable error'';
END IF
ELSE
SUBCOMMIT:
END IF;
END;
' language plpgsql;
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2004-07-08 21:08:51 | Re: [subxacts] Aborting a function |
Previous Message | Dave Page | 2004-07-08 20:44:22 | Re: [HACKERS] Initdb error |