From: | Marko Tiikkaja <marko(at)joh(dot)to> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Assertions in PL/PgSQL |
Date: | 2013-09-14 18:47:27 |
Message-ID: | 5234AF3F.4000409@joh.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
Attachment | Content-Type | Size |
---|---|---|
plpgsql_assert.patch | text/plain | 15.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Marko Tiikkaja | 2013-09-14 18:52:40 | Re: Assertions in PL/PgSQL |
Previous Message | Josh Berkus | 2013-09-14 18:37:33 | git apply vs patch -p1 |