COPY vs \COPY FROM PROGRAM $$ quoting difference?

From: Alexander Stoddard <alexander(dot)stoddard(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: COPY vs \COPY FROM PROGRAM $$ quoting difference?
Date: 2017-09-29 16:27:39
Message-ID: CADDNc-D83E-FadbEpk4M2N3pE1WdfYdcY4ThpoQ5wVdEJsxCvA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2017-09-29 16:54:25 Re: COPY vs \COPY FROM PROGRAM $$ quoting difference?
Previous Message Andy Colson 2017-09-29 14:52:43 Re: PG 10 and perl