pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: john@7fff.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14645: Can't use psql from within program used by "copy ... from program" script?
Date: Sat, 06 May 2017 17:18:03 +0000
Message-ID: <20170506171803.24361.76643@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14645
Logged by:          John Norman
Email address:      john@7fff.com
PostgreSQL version: 9.4.11
Operating system:   OS/X
Description:        

Here's a little .sql script in a directory bug/ in my home.

drop database if exists bug;
create database bug;
\c bug
create table bug (id int);
copy bug(id) from program '$HOME/bug/data' csv header;
select * from bug;

It calls a script called data. I run it with psql -X -f
$HOME/bug/setup.sql

This works for the "data" script:

#/bin/bash
echo "id"
echo "1"
echo "2"

This doesn't:

#/bin/bash
echo "id"
echo "1"
psql -X -t -q -c "select 2" | xargs

I can't figure out if psql is disallowed from the program referenced by the
copy program; or if somehow standard out is getting nuked.

The xargs is to remove the spaces are the "2" generated by the psql
command.

My use case was that I wanted part of the script referenced via copy program
to get something out of the database. Didn't work.




-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


view thread (7+ messages)  latest in thread

Message-ID: <20170506171803.24361.76643@wrigleys.postgresql.org>
Permalink:  ../20170506171803.24361.76643@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20170506171803.24361.76643@wrigleys.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: john@7fff.com
  Subject: Re: BUG #14645: Can't use psql from within program used by "copy ... from program" script?
  In-Reply-To: <20170506171803.24361.76643@wrigleys.postgresql.org>
  References: <20170506171803.24361.76643@wrigleys.postgresql.org>

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

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