COPY TO (query) allows no function arguments

From: Färber, Franz-Josef (StMUK) <Franz-Josef(dot)Faerber(at)stmuk(dot)bayern(dot)de>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: COPY TO (query) allows no function arguments
Date: 2021-03-10 14:48:34
Message-ID: 609326d4d6854085aeb909ae564d4ccb@stmuk.bayern.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello all,

it is as simple as the subject says:

The COPY TO (query) statement does not allow the passing of function arguments - is this by intent or a bug?

Minimal working example:

CREATE OR REPLACE FUNCTION a(myparam text)
RETURNS void LANGUAGE plpgsql AS $func$
BEGIN
COPY (SELECT myparam) TO '/tmp/a.txt';
END;
$func$

SELECT a('b');

... will fail with

SQL-Fehler [42703]: FEHLER: Spalte »myparam« existiert nicht
Wobei: PL/pgSQL-Funktion a(text) Zeile 3 bei SQL-Anweisung

Sorry, my installation is German. This roughly translates to "column myparam does not exist".

I am using Postgres 13.

Regards,
Franz-Josef Färber

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2021-03-10 15:16:00 Re: pg_upgrade from PostgreSQL 12.4 to PostgreSQL 13.2 on Windows 10 failes because of missing function pg_catalog.ascii_to_mic
Previous Message Marcus Müller 2021-03-10 10:46:04 pg_upgrade from PostgreSQL 12.4 to PostgreSQL 13.2 on Windows 10 failes because of missing function pg_catalog.ascii_to_mic