pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Shell Command within function
3+ messages / 3 participants
[nested] [flat]

* Shell Command within function
@ 2018-10-26 12:22 Mike Martin <redtux1@gmail.com>
  2018-10-26 12:25 ` Re: Shell Command within function Andreas Kretschmer <andreas@a-kretschmer.de>
  2018-10-26 12:27 ` Re: Shell Command within function Andrew Gierth <andrew@tao11.riddles.org.uk>
  0 siblings, 2 replies; 3+ messages in thread

From: Mike Martin @ 2018-10-26 12:22 UTC (permalink / raw)
  To: pgsql-general

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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Shell Command within function
  2018-10-26 12:22 Shell Command within function Mike Martin <redtux1@gmail.com>
@ 2018-10-26 12:25 ` Andreas Kretschmer <andreas@a-kretschmer.de>
  1 sibling, 0 replies; 3+ messages in thread

From: Andreas Kretschmer @ 2018-10-26 12:25 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org; Mike Martin <redtux1@gmail.com>; pgsql-general

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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Shell Command within function
  2018-10-26 12:22 Shell Command within function Mike Martin <redtux1@gmail.com>
@ 2018-10-26 12:27 ` Andrew Gierth <andrew@tao11.riddles.org.uk>
  1 sibling, 0 replies; 3+ messages in thread

From: Andrew Gierth @ 2018-10-26 12:27 UTC (permalink / raw)
  To: Mike Martin <redtux1@gmail.com>; +Cc: pgsql-general

>>>>> "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)




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2018-10-26 12:27 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-26 12:22 Shell Command within function Mike Martin <redtux1@gmail.com>
2018-10-26 12:25 ` Andreas Kretschmer <andreas@a-kretschmer.de>
2018-10-26 12:27 ` Andrew Gierth <andrew@tao11.riddles.org.uk>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox