[GENERAL] COPY vs \COPY FROM PROGRAM $$ quoting difference? - Mailing list pgsql-general

From Alexander Stoddard
Subject [GENERAL] COPY vs \COPY FROM PROGRAM $$ quoting difference?
Date
Msg-id CADDNc-D83E-FadbEpk4M2N3pE1WdfYdcY4ThpoQ5wVdEJsxCvA@mail.gmail.com
Whole thread Raw
Responses Re: [GENERAL] COPY vs \COPY FROM PROGRAM $$ quoting difference?  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
I found what seems to be an odd difference between COPY and \copy parsing.

I am using a bash pipeline of sed commands to clean up a source data file before importing it into a table.  This works fine when working from the command line and piping the result to psql on STDIN. 

However I attempted to put this same workflow into a psql script (as opposed to a shell script). To avoid quoting issues with the shell pipeline I put my pipeline command string in dollar quotes.

eg.
COPY dest_table FROM PROGRAM $$ sed 's/x/y/' | etc... $$ 

To my surprise this worked with COPY but not \COPY which failed with:
\copy: parse error at "$$"

Is this an undocumented difference? Is this even the appropriate email list to ask this kind of question or report such a difference?

Thank you,
Alex Stoddard

pgsql-general by date:

Previous
From: Andy Colson
Date:
Subject: Re: [GENERAL] PG 10 and perl
Next
From: "David G. Johnston"
Date:
Subject: Re: [GENERAL] COPY vs \COPY FROM PROGRAM $$ quoting difference?