3

I have a of inter-portability problem with parsing PosgreSQL array datatype to perl.

On one machine running PostgreSQL 8.3.7 on SUSE Linux 4.3.2 and perl v5.10.0 the postgres array datatype is parsed as perl array and on other machine running PostgreSQL 8.4.4 on Red Hat 4.1.2-46 and perl v5.8.8 the same datatype is parsed as a string representing an posgres array eg. '{{4,315}}'. In both cases same very simple code is used.

use DBI;
$dbh = DBI->connect(DBI:pg [...]);
$res = $dbh -> selectall_arrayref(select [...]);

And now the questions:

How can I force one behavior, preferably the former one (parsed as perl array)? On what does this behavior depend? (perl version? driver? postgres settings?, postgres version?)

1 Answer 1

2

Well, the official docs say you must set $dbh->{pg_expand_array} to a true value.

I haven't checked it myself though.

Sign up to request clarification or add additional context in comments.

5 Comments

Great, thanks! Unfortunately pg_expand_array does not exist on the machine which parses postgreSQL arrays as strings. Could be that DBI isn't compiled correctly?
And by "does not exist" I mean I can't print it or set it. :)
It must be DBD::Pg rather than DBI itself.
It appears to have arrays support since 2.0.0 released 2.0.0 Released February 10, 2008 (from the changelog)
Thanks! Yes it was the version issue - 1.49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.