Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The follow code used to work in Postgresql 8.4.11 with perl v5.10.1:

=# select * From testfunction();

However, after doing a dump and load into Postgresql 9.1.3 with perl v5.14.2 I get:

ERROR:  PL/Perl function must return reference to hash or array
CONTEXT:  PL/Perl function "testfunction"

For reference, here is the function:

  use URI;
  return URI->new('')->canonical;
$$ LANGUAGE plperlu;

Again, the version of perl changed from v5.10.1 to v5.14.2; however, the return from Data::Peek is the same across both versions:

$ perl -MData::Peek -MURI -e'DPeek(

Output on both versions of perl:

share|improve this question
up vote 3 down vote accepted

Short answer, coerce what you return to a string, should work fine in 8.4 and 9.1:

return URI->new('')->canonical().'';

See for my full response.

share|improve this answer
I think even better for this applciation would be ->canonical->as_string() – Evan Carroll May 16 '12 at 17:48
Welcome to Alex and thanks for contributing here too :-) – Jack Douglas May 16 '12 at 20:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.