On Mon, Dec 06, 2010 at 12:54:57AM -0800, Jonathan Leffler wrote:
> Two related questions (prompted by a question from people using
> DBD::Informix):
> 
> 1.  Are there any known problems with $sth->fetchall_arrayref({}, 50);?

Nope.

> 2.  Are there any requirements on a DBD module to make the limit on
> fetchall_arrayref({}, 50) notation work, or is it purely a DBI feature?

The DBI provides a default fetchall_arrayref method in DBI.pm that
implements fetching, slicing and maxrows.

There's also a fetchall_arrayref method in Driver.xst for added speed.
That one falls-back to the perl version if a slice is specified, but
otherwise expects dbdxst_fetchall_arrayref() to handle maxrows.
dbdxst_fetchall_arrayref() is defined in Driver_xst.h

Tim.

p.s. I took a quick look at DBD::Informix source and ran away fast! :)

> my $dbh = DBI->connect('dbi:Informix:stores', '', '') or die "Horribly 1";
> my $sth = $dbh->prepare(q{SELECT * FROM Elements}) or die "Horribly 2";
> $sth->execute;
> 
> #my $res = $sth->fetchall_arrayref;        # Works
> #my $res = $sth->fetchall_arrayref({}, 50);    # Fails: no data
> #my $res = $sth->fetchall_arrayref([], 50);    # Fails: no data
> #my $res = $sth->fetchall_arrayref([0,1,2]);    # Works
> my $res = $sth->fetchall_arrayref([0,1,2], 50);   # Fails: no data
> #my $res = $sth->fetchall_arrayref({});    # Works
> #my $res = $sth->fetchall_arrayref(undef, 50);  # Fails: no data
> foreach my $row (@{$res})
> {
>     # Use this section for printing arrays
>     foreach my $value (@{$row})
>     {
>         printf "%s ", $value;
>     }
>     print "\n";
>     # Use this section for printing hashes
>     #foreach my $key (sort keys %{$row})
>     #{
>     #    printf "%-15s = %s\n", $key, $row->{$key};
>     #}
> }
> 
> $dbh->disconnect;
> 
> Choose your own driver and database, etc; choose your own table (my table of
> elements has entries for hydrogen through ununoctium - 1..118; 50 is about
> half the table).  It seems that fetchall_arrayref() works fine with no
> arguments and with slice arguments, but none of the slice versions with a
> maximum count does anything.
> 
> Am I missing something?  Or is there a bug?
> 
> Perl 5.13.4 on MacOS X 10.6.5; DBI 1.615, DBD::Informix 2008.0513.
> 
> -- 
> Jonathan Leffler <jonathan.leff...@gmail.com>  #include <disclaimer.h>
> Guardian of DBD::Informix - v2008.0513 - http://dbi.perl.org
> "Blessed are we who can laugh at ourselves, for we shall never cease to be
> amused."

Reply via email to