Function problem - Mailing list pgsql-general

From Sharon Cowling
Subject Function problem
Date
Msg-id 200201172137.g0HLbmv02882@lambton.sslnz.com
Whole thread Raw
List pgsql-general
I have a problem with a function containing the copy command.

The command below does exactly what I need it to do:
\COPY person2 TO '/usr/local/pgsql/report.csv' USING DELIMITERS ','

However I need this in a function to call from the front-end code, it creates fine but errors when I call it:


user=# CREATE FUNCTION getreport10() returns int as '
user'# BEGIN
user'# \COPY person2 TO ''/usr/local/pgsql/report.csv'' USING DELIMITERS '','';
user'# return 1;
user'# END;'
user-# LANGUAGE 'plpgsql';
CREATE

user=# select getreport10();
ERROR:  You must have Postgres superuser privilege to do a COPY directly to or from a file.  Anyone can COPY to stdout
orfrom stdin.  Psql's \copy command also works for anyone. 

It does work if I give the user superuser privileges but I don't really want to do this!
Any suggestions?

Regards,

Sharon Cowling


pgsql-general by date:

Previous
From: Neil Conway
Date:
Subject: Re: Is It Too Big ? - Customer Data Warehouse Growth
Next
From: Bruce Momjian
Date:
Subject: Books on PostgreSQL