Re: Assertions in PL/PgSQL - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: Assertions in PL/PgSQL
Date
Msg-id CAFj8pRDeK1NfJKJ_AnJ=04bOZCNAqFpixBrWUScTWDX8=CDxQA@mail.gmail.com
Whole thread Raw
In response to Assertions in PL/PgSQL  (Marko Tiikkaja <marko@joh.to>)
Responses Re: Assertions in PL/PgSQL
Re: Assertions in PL/PgSQL
List pgsql-hackers
Hello

There is a significant issue - new reserved keyword. There is high probability so lot of users has a functions named "assert".

I like this functionality, but I dislike any compatibility break for feature, that can be implemented as extension without any lost of compatibility or lost of functionality.

So can you redesign this without new keyword?


Regards

Pavel


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 by date:

Previous
From: Marko Tiikkaja
Date:
Subject: Re: Assertions in PL/PgSQL
Next
From: Jaime Casanova
Date:
Subject: Re: Assertions in PL/PgSQL