Thread: plperl function has side-effects

plperl function has side-effects

From
Joachim Wieland
Date:
Hi,

I have a 7.4.3 installation where a small plperl function seems to have
side-effects. In the example below I run an ordinary SELECT first, nothing
special with the table. Thereafter I call the plperl function and then I
rerun the SELECT query. This time it doesn't return the expected result. The
problem seems to show up only after postgres has run for quite a while.
Futhermore this effect is limited to the current session. I'll upgrade the
machine to 7.4.7 during the weekend, however I haven't seen anything in the
release notes that seems to matter, does anybody know this effect or is this
issue even already solved?

(Crypt::PasswdMD5 1.3, perl 5.8.4)

db=> select login from subaccounts where login='web1p1';login
--------web1p1
(1 row)

db=> select md5password('bla1', 'Ao2ZaGKp');           md5password
------------------------------------$1$Ao2ZaGKp$XBDNeuZM3RSrqq9gruKXH1
(1 row)

db=> select login from subaccounts where login='web1p1';login
-------
(0 rows)



The definition of md5password:

CREATE FUNCTION md5password(varchar(20), varchar(50)) RETURNS varchar(50)
SECURITY DEFINER AS '
use Crypt::PasswdMD5;

my $password = $_[0];
my $salt = $_[1];

my $crypted = unix_md5_crypt($password, $salt);

return $crypted;
' LANGUAGE 'plperlu';


Thanks,
Joachim