1

im trying to create a function that any user can call in order to copy data from/to a file... my idea is to set a function that acts as a superuser or one that is executed as "postgres" but I dont know were to start to begin with.

Can anyone point me in the right direction?

1 Answer 1

4

You're looking for "SECURITY DEFINER". See docs for details http://www.postgresql.org/docs/9.3/static/sql-createfunction.html

Sign up to request clarification or add additional context in comments.

3 Comments

That's awesome, thanks. Do you know if its possible to pass table, fields and file path as extensions to a function? lets say: COPY $table ($fields) FROM $path with csv; BTW I'm using postres 8.4 and testing as I write this :P
You'll want to use EXECUTE and also do some validation on your parameters.
Thanks I think I can find my way from here ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.