Re: problem with TRUNCATE TABLE in plpgsql function - Mailing list pgsql-bugs

From Tom Lane
Subject Re: problem with TRUNCATE TABLE in plpgsql function
Date
Msg-id 26345.1036166628@sss.pgh.pa.us
Whole thread Raw
In response to problem with TRUNCATE TABLE in plpgsql function  (Pavel Stehule <stehule@kix.fsv.cvut.cz>)
List pgsql-bugs
Pavel Stehule <stehule@kix.fsv.cvut.cz> writes:
> I played with some own old plpgsql functions. I found "error" in plpgsql
> 7.3. When I use TRUNCATE TABLE in function I get
> TRUNCATE TABLE cannot be executed from a function.
> In 7.2.2. I can use this command. Why, now I can't use truncate table?

This is a deliberate change for safety reasons: if your function errors
out after performing TRUNCATE, you are in big trouble.

If TRUNCATE is ever rewritten to be rollback-safe, we will remove the
restriction.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Pavel Stehule
Date:
Subject: problem with TRUNCATE TABLE in plpgsql function
Next
From: "saurabh garg"
Date:
Subject: Re: hi-problem while installing postgressql 7.2 version