The thing is, arrays are not extremely well supported in PostgreSQL
itself, and there are all sorts of what you can do and can't do with them,
you are not encouraged to use arrays in first place.
None of other postgresql interfaces (JDBC, libpq) provide any kind of
support dealing with arrays, and I think it probably will be misplaced to
do it in DBD::Pg.
To work around it, its fairly easy. Make a function to
serialize/deserialize array ref, and call it at appropriate moment.
If you really want to get it in DBD::Pg, write a patch :)
Oh, and you might want to consider DBD::PgSPI and plperlu on server end,
this way you can serialize complex structures and pass them to a
server-side perl program :)
(both require 7.2, which is in beta)
-alex
On 15 Nov 2001, Jason E. Stewart wrote:
> "Edmund Mergl" <[EMAIL PROTECTED]> writes:
>
> > Jason E. Stewart wrote:
> >
> > > Also, I'm interested in adding support for the builtin array
> > > types. Do
> >
> > I prefer a patch
>
> What I want is not to have to serialize my Perl arrays into strings
> before passing them to execute() or do(), and not have to split() them
> into arrays after a SELECT:
>
> my $sql = 'SELECT int_array_col FROM foo';
> my $ref = $dbh->selectall_arrayref($sql);
> foreach my $row (@{$ref->[0]}) {
> my @int_array_cols = @{$row}; # <= returns an array ref
> }
>
> or
>
> my $sql = 'INSERT INTO foo (int_array_col) values (?)';
> my $sth = $dbh->prepare($sql);
> $sth->execute(\@array); # <= accepts an array ref
>
> or
>
> my $sql = 'SELECT int_array_col FROM foo';
> my $sth = $dbh->prepare($sql);
> $sth->bind_col(1, \@array); # <= accepts an array ref
> $sth->execute();
>
> So I have the first case working for int, float, and char array types
> by modifying dbd_st_execute().
>
> This issue that I've run into is that the bind mechanism seems to be
> completely set up to handle only scalars, and it wants to convert
> everything into a string.
>
> Is this something fundamental with DBI, and I should give up, or is it
> just something Pg specific?
>
> Thanks,
> jas.
>
>