> 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;



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to