Re: Assertions in PL/PgSQL
От | Pavel Stehule |
---|---|
Тема | Re: Assertions in PL/PgSQL |
Дата | |
Msg-id | CAFj8pRCcirtjw4wjg_xosYypZs8G8ViRseNcvop8ui0Aweo7ig@mail.gmail.com обсуждение исходный текст |
Ответ на | Assertions in PL/PgSQL (Marko Tiikkaja <marko@joh.to>) |
Ответы |
Re: Assertions in PL/PgSQL
|
Список | pgsql-hackers |
Hello
a few other comments:2013/9/14 Marko Tiikkaja <marko@joh.to>
Hi,
Attached is a patch for supporting assertions in PL/PgSQL. These are similar to the Assert() backend macro: they can be disabled during compile time, but when enabled, abort execution if the passed expression is not true.
A simple example:
CREATE FUNCTION delete_user(username text) RETURNS VOID AS $$
BEGIN
DELETE FROM users WHERE users.username = delete_user.username;
ASSERT FOUND;
END
$$ LANGUAGE plpgsql;
SELECT delete_user('mia');
ERROR: Assertion on line 4 failed
CONTEXT: PL/pgSQL function delete_user(text) line 4 at ASSERT
Again, I'll add this to the open commitfest, but feedback is greatly appreciated.
Regards,
Marko Tiikkaja
--
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 по дате отправления: