> 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
WHEREkey = $1; ELSE RAISE EXCEPTION ''Unrecoverable error''; END IF ELSE SUBCOMMIT: END IF;
END;
' language plpgsql;