plperlu user function.
plperlu user function.
От:
David Harel <hareldvd@gmail.com>
Дата:
Greetings,
I am trying to write a user function on the server to retrive image files. Currently I wrote the following:
CREATE OR REPLACE FUNCTION perl_getfile(text)
RETURNS OID AS
$BODY$
my $tmpfile = shift;
open my $IFHAND, '<', $tmpfile
or elog(ERROR, qq{could not open the file "$tmpfile": $!});
binmode $IFHAND;
my $result = '';
while(my $buffer = <$IFHAND>)
{
$result .= $buffer;
}
return $result;
$BODY$
LANGUAGE 'plperlu';
on the client I do (PHP sniplet):
$result = pg_query($dbcnx, "SELECT perl_getfile('/home/harel/Misc/At_work.jpg')");
and I get an error:
Warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid input syntax for type oid: "ÿØÿà" in /home/harel/Prj/php/testImages/mysqlImage1/image.php
Any recommendation how to do it right?
-- Regards. David Harel, ================================== Home office +972 77 7657645 Cellular: +972 54 4534502 Snail Mail: Amuka D.N Merom Hagalil 13802 Israel Email: hareldvd@ergolight-sw.com
Re: plperlu user function.
От:
Alex Hunsaker <badalex@gmail.com>
Дата:
On Tue, May 18, 2010 at 15:29, David Harel wrote: > Greetings, > > I am trying to write a user function on the server to retrive image files. > Currently I wrote the following: > CREATE OR REPLACE FUNCTION perl_getfile(text) > RETURNS OID AS I think you meant returns bytea or text or something... else
Re: plperlu user function.
От:
silly sad <sad@bankir.ru>
Дата:
On 05/19/10 01:29, David Harel wrote: > I am trying to write a user function on the server to retrive image > files. Currently I wrote the following: > my $tmpfile = shift; > open my $IFHAND, '<', $tmpfile > Any recommendation how to do it right? first of all, stop opening files at all, return to a client a pathname, then give to Caesar what is Caesar's, and to God what is God's.