Tuesday, July 29, 2008

Re: [GENERAL] How to give input a file for a stored procedure

aravind chandu wrote:
> Hi,
>
> I am writing a stored procedure where the input to it is a file.I did not have any idea of how to give input as a file for a stored procedure.could you please help me.

I assume that by "a file" you mean a file in the filesystem, outside the
database, rather than BLOB in the database.

If so, then there are functions in one of the contrib modules that
provide filesystem access from the PostgreSQL server. They're only
available to superusers, but if you were REALLY careful you could use
them in a SECURITY DEFINER stored procedure. This is a VERY DANGEROUS
thing to do unless you absolutely trust all users of the database. If
you do not know what the above means, then do not do it.

Read the PostgreSQL documentation to find out more. Start here:

http://www.postgresql.org/docs/8.3/static/index.html

Pay particular attention to the section "Additional Supplied Modules" in
the appendices.

Note that those functions do not get you access to the *client*
filesystem. Access is to the server file system with the rights of the
user the postgresql server runs under.

If you want to access a file from the client with the rights of the user
the client is running under, you will need to have your client
application load the file and send it to the server. You might load the
file into the database as a BLOB, or just pass it as a bytea field.

Perhaps if you explained the purpose of what you were attempting you
might get more useful answers.

--
Craig Ringer

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

No comments: