Re: PL/PgSQL: EXIT USING ROLLBACK

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: PL/PgSQL: EXIT USING ROLLBACK
Дата
Msg-id CAFj8pRBT3g4HKDMGC=RyN_ovMoU5CrekZCQ7FcDnKX7mL5TgPA@mail.gmail.com
обсуждение исходный текст
Ответ на PL/PgSQL: EXIT USING ROLLBACK  (Marko Tiikkaja <marko@joh.to>)
Список pgsql-hackers
Hello


2014-07-26 19:14 GMT+02:00 Marko Tiikkaja <marko@joh.to>:
Hello,

Today I'd like to present a way to get rid of code like this:

  $$
  BEGIN

  BEGIN
    INSERT INTO foo VALUES (1);
    -- run some tests/checks/whatever
    RAISE EXCEPTION 'OK';
  EXCEPTION WHEN raise_exception THEN
    IF SQLERRM <> 'OK' THEN
      RAISE;
    END IF;
  END;

  RETURN 'success';
  END
  $$

And replace it with code like this:

  $$
  BEGIN

  <<testsomething>>
  BEGIN
    INSERT INTO foo VALUES (1);
    -- run some tests/checks/whatever
    EXIT USING ROLLBACK testsomething;
  EXCEPTION WHEN others THEN
    RAISE;
  END;

  RETURN 'success';
  END
  $$

I'm not set on the USING ROLLBACK syntax; it was the only thing I could come up with that seemed even remotely sane and didn't break backwards compatibility.

Thoughts?  Patch attached, if someone cares.

-1

I don't think, so we need to cobolize PL/pgSQL more.

There is not any strong reason why we should to introduce it. You don't save a code, you don't increase a performance

Regards

Pavel
 


.marko


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Mark Kirkwood
Дата:
Сообщение: Re: parametric block size?
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: PL/PgSQL: RAISE and the number of parameters