Re: Run external command as part of an sql statement ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: David Gauthier <davegauthierpg(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Run external command as part of an sql statement ?
Date: 2018-05-07 21:52:22
Message-ID: 11260.1525729942@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Mon, May 7, 2018 at 2:35 PM, David Gauthier <davegauthierpg(at)gmail(dot)com>
> wrote:
>> I want to be able to run a shell command like this from within a stored
>> procedure. Is there a way to do this ?

> In core, you can probably use the untrusted​ version of Perl, Python, or
> Tcl to accomplish your goal. SQL and pl/pgSQL do not provide that
> capability.​

Depending on what you want to do, COPY TO/FROM PROGRAM might be a
serviceable option. But, just like the untrusted-PL variants, you
need to be superuser. Keep in mind that the program will run as
the database server owner (which is the reason for the superuser
restriction).

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2018-05-07 21:59:06 Re: How to manipulate tuples in C functions?
Previous Message David G. Johnston 2018-05-07 21:41:39 Re: Run external command as part of an sql statement ?