Re: Shell Command within function

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Mike Martin <redtux1(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Shell Command within function
Date: 2018-10-26 12:27:42
Message-ID: 87va5o7v3k.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>>> "Mike" == Mike Martin <redtux1(at)gmail(dot)com> writes:

Mike> Is this possible?

In an untrusted pl language, yes, but it's a bad idea because:

Mike> I have a script which imports csvlogs into a table, and it would
Mike> be useful to truncate the log files after import

If you had an error after truncating the file but before committing the
transaction, then the imported data would be gone, but the file would be
gone too, so you'd have lost it.

Things like this need to be handled _after_ commit, not before, so a
function is the wrong place for it.

--
Andrew (irc:RhodiumToad)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2018-10-26 12:44:07 Re: Should pg 11 use a lot more memory building an spgist index?
Previous Message Andreas Kretschmer 2018-10-26 12:25:22 Re: Shell Command within function