Shell Command within function

Started by Mike Martinover 7 years ago3 messagesgeneral
Jump to latest
#1Mike Martin
redtux1@gmail.com

Is this possible?
I have a script which imports csvlogs into a table, and it would be useful
to truncate the log files after import

thanks

Mike

#2Andreas Kretschmer
andreas@a-kretschmer.de
In reply to: Mike Martin (#1)
Re: Shell Command within function

On 26 October 2018 13:22:19 WEST, Mike Martin <redtux1@gmail.com> wrote:

Is this possible?
I have a script which imports csvlogs into a table, and it would be
useful
to truncate the log files after import

You can use an untrusted language (pl/perlu, pl/sh, ...).

Regards, Andreas

--
2ndQuadrant - The PostgreSQL Support Company

#3Andrew Gierth
andrew@tao11.riddles.org.uk
In reply to: Mike Martin (#1)
Re: Shell Command within function

"Mike" == Mike Martin <redtux1@gmail.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)