Can't quote_literal with COPY FROM PROGRAM

From: Mark Mikulec <mark(at)mikutech(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Can't quote_literal with COPY FROM PROGRAM
Date: 2018-12-31 17:36:53
Message-ID: CA+aX0efk8+9WAHGsC8vtiuxPsZPik=aUUHrPXyp5L7Kq9HNLHA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

This command, which generates a JSON object as output, has some escaped
data with backslashes: (see line 91 here: https://pastebin.com/D4it8ybS)

C:\\Portable\\curl\\curl.exe -k "
https://maps.googleapis.com/maps/api/directions/json?etcVariablesDeleted"'

I use the COPY command to pull it into a temp table like so:

COPY temp_maps_api from program 'C:\\Portable\\curl\\curl.exe -k "
https://maps.googleapis.com/maps/api/directions/json?etcVariablesDeleted"';

However copy eats those backslashes. I need to use quote_literal() but
that's a syntax error. For some reason the COPY command doesn't allow for
ESCAPE to work with programs, only CSV.

I tried using WITH BINARY but I get the error message: "COPY file signature
not recognized"

Does anyone know how to make COPY FROM PROGRAM take the output literally?

Thanks,
Mark

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2018-12-31 18:59:03 Re: Can't quote_literal with COPY FROM PROGRAM
Previous Message Chuck Martin 2018-12-31 17:35:43 Re: getting pg_basebackup to use remote destination