Re: Function to execute a program - Mailing list pgsql-hackers

From Stephen Frost
Subject Re: Function to execute a program
Date
Msg-id 20200914143300.GG3063@tamriel.snowman.net
Whole thread Raw
In response to Function to execute a program  (Magnus Hagander <magnus@hagander.net>)
Responses Re: Function to execute a program  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Greetings,

* Magnus Hagander (magnus@hagander.net) wrote:
> Would it make sense to have a pg_execute_program() that corresponds to COPY
> FROM PROGRAM? This would obviously have the same permissions restrictions
> as COPY FROM PROGRAM.

Eh, perhaps.

> The usecase would be to for example execute a command that returns json
> format output, which could then be parsed and processed as part of a query.
> Today, COPY FROM PROGRAM cannot do this, as we can't read a multiline json
> value with COPY.

I'd rather come up with a way to import this kind of object into PG by
using COPY rather than adding a different way to pull them in.

In the "this is a crazy idea" category- have a way to specify an input
function to COPY, or a target data type (and then use it's input
function) to which COPY just keeps feeding bytes until the function
comes back with "ok, I got a value to return" or something.

Would be really neat to have a way to COPY in a JSON, XML, or whatever
even if it's multi-line and even if it has multiple objects (ie: 10
complete JSON documents in a single file would become 10 rows of jsonb).

Thanks,

Stephen

Attachment

pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: 回复:how to create index concurrently on partitioned table
Next
From: Pavel Stehule
Date:
Subject: Re: On login trigger: take three