Re: How to give input a file for a stored procedure

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: aravind chandu <avin_friends(at)yahoo(dot)com>
Cc: postgresql Forums <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to give input a file for a stored procedure
Date: 2008-07-29 07:11:56
Message-ID: 488EC2BC.7050108@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Poul Møller Hansen 2008-07-29 07:25:10 Re: Date index not used when selecting a date range
Previous Message Poul Møller Hansen 2008-07-29 07:08:49 Re: Date index not used when selecting a date range