public inbox for [email protected]  
help / color / mirror / Atom feed
From: dfgpostgres <[email protected]>
To: [email protected]
Subject: can a linux program, running on the client side, generate data to load a temp table ?
Date: Thu, 18 Jun 2026 20:51:36 -0400
Message-ID: <CAAcmDX9-tCLi72BwpAgxXsM9tr4foPbYouMr_cTyFYKU0XXyxQ@mail.gmail.com> (raw)

v15.5 on linux

I've read about and tested a way for a query which calls a user function
which returns a temp table that gets its data from an external program.
Example...

CREATE OR REPLACE FUNCTION run_linux_script()
RETURNS TABLE (script_output text)
LANGUAGE plpgsql
AS $$
BEGIN
    -- Create a temporary table for this session
    CREATE TEMPORARY TABLE IF NOT EXISTS temp_script_results (
        output_line text
    );

    -- Truncate in case it was used previously in the same session
    TRUNCATE temp_script_results;

    -- Execute the script and insert the output into the table
    COPY temp_script_results (output_line)
    FROM PROGRAM '/path/to/my/script/linux_script.pl';

    -- Return the results to the calling user
    RETURN QUERY SELECT output_line FROM temp_script_results;

    -- Clean up
    DROP TABLE temp_script_results;
END;
$$;

SELECT * FROM run_linux_script();

It runs, sort of, but fails because it can't find the "linux_script.pl"
script because it's looking for it on the server side.

My question is about whether or not I can get something like this to run on
the client side (where the script can be found).

Thanks in Advance :-)


view thread (6+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: can a linux program, running on the client side, generate data to load a temp table ?
  In-Reply-To: <CAAcmDX9-tCLi72BwpAgxXsM9tr4foPbYouMr_cTyFYKU0XXyxQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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