Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / usr / share / doc / libdbd-mysql-perl / examples / | server ip : 104.21.89.46 your ip : 172.70.80.63 H O M E |
Filename | /usr/share/doc/libdbd-mysql-perl/examples/bug21028.pl |
Size | 2.17 kb |
Permission | rwxr-xr-x |
Owner | root : root |
Create time | 27-Apr-2025 10:10 |
Last modified | 18-Oct-2013 03:23 |
Last accessed | 07-Jul-2025 02:16 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use Test::More;
use Data::Dumper;
use English qw( -no_match_vars );
my $CONF = $ENV{MYCONF} || "$ENV{HOME}/.my.cnf";
my $emulate = 0;
my $dbh;
eval {
#
# change the connection statements
# to suit your purposes
$dbh =
DBI->connect("dbi:mysql:test",
'root',
'',
{RaiseError => 1, PrintError => 1} )
or die "can't connect : $DBI::errstr\n";
};
if ($EVAL_ERROR) {
plan (skip_all => " -- no connection available $EVAL_ERROR");
}
else {
plan ( tests => 10 );
}
print "\nEmulation of ps: $emulate, version: $DBD::mysql::VERSION\n";
print $dbh->{mysql_server_prepare},"\n";
my $drop_proc = qq{
drop procedure if exists test_multi_sets
};
my $create_proc = qq{
create procedure test_multi_sets ()
deterministic
begin
select user() as first_col;
select user() as first_col, now() as second_col;
select user() as first_col, now() as second_col, now() as third_col;
end
};
eval { $dbh->do($drop_proc) };
ok( ! $EVAL_ERROR, 'drop procedure' );
eval { $dbh->do($create_proc) };
ok( ! $EVAL_ERROR , 'create procedure');
my $sth;
print $dbh->{mysql_server_prepare},"\n";
eval { $sth = $dbh->prepare(qq{call test_multi_sets() }) } ;
ok( $sth , 'preparing statement handler');
eval { $sth->execute() };
ok( ! $EVAL_ERROR, 'executing sth - 1st time ' );
diag $EVAL_ERROR if $EVAL_ERROR;
my $dataset;
eval { $dataset = $sth->fetchrow_arrayref(); } ;
print Dumper($dataset),"\n";
ok( $dataset && @$dataset == 1 , 'fetching first dataset');
my $more_results;
eval { $more_results = $sth->more_results() };
ok( $more_results, 'more results available (1st time) ' ) ;
eval { $dataset = $sth->fetchrow_arrayref(); } ;
print Dumper($dataset),"\n";
ok( $dataset && @$dataset == 2 , 'fetching second dataset');
eval { $more_results = $sth->more_results() };
ok( $more_results, 'more results available (2nd time) ' ) ;
eval { $dataset = $sth->fetchrow_arrayref(); } ;
print Dumper($dataset),"\n";
ok( $dataset && @$dataset == 3 , 'fetching third dataset');
eval { $more_results = $sth->more_results() };
ok( ! $more_results, 'no more results available' ) ;
use strict;
use warnings;
use DBI;
use Test::More;
use Data::Dumper;
use English qw( -no_match_vars );
my $CONF = $ENV{MYCONF} || "$ENV{HOME}/.my.cnf";
my $emulate = 0;
my $dbh;
eval {
#
# change the connection statements
# to suit your purposes
$dbh =
DBI->connect("dbi:mysql:test",
'root',
'',
{RaiseError => 1, PrintError => 1} )
or die "can't connect : $DBI::errstr\n";
};
if ($EVAL_ERROR) {
plan (skip_all => " -- no connection available $EVAL_ERROR");
}
else {
plan ( tests => 10 );
}
print "\nEmulation of ps: $emulate, version: $DBD::mysql::VERSION\n";
print $dbh->{mysql_server_prepare},"\n";
my $drop_proc = qq{
drop procedure if exists test_multi_sets
};
my $create_proc = qq{
create procedure test_multi_sets ()
deterministic
begin
select user() as first_col;
select user() as first_col, now() as second_col;
select user() as first_col, now() as second_col, now() as third_col;
end
};
eval { $dbh->do($drop_proc) };
ok( ! $EVAL_ERROR, 'drop procedure' );
eval { $dbh->do($create_proc) };
ok( ! $EVAL_ERROR , 'create procedure');
my $sth;
print $dbh->{mysql_server_prepare},"\n";
eval { $sth = $dbh->prepare(qq{call test_multi_sets() }) } ;
ok( $sth , 'preparing statement handler');
eval { $sth->execute() };
ok( ! $EVAL_ERROR, 'executing sth - 1st time ' );
diag $EVAL_ERROR if $EVAL_ERROR;
my $dataset;
eval { $dataset = $sth->fetchrow_arrayref(); } ;
print Dumper($dataset),"\n";
ok( $dataset && @$dataset == 1 , 'fetching first dataset');
my $more_results;
eval { $more_results = $sth->more_results() };
ok( $more_results, 'more results available (1st time) ' ) ;
eval { $dataset = $sth->fetchrow_arrayref(); } ;
print Dumper($dataset),"\n";
ok( $dataset && @$dataset == 2 , 'fetching second dataset');
eval { $more_results = $sth->more_results() };
ok( $more_results, 'more results available (2nd time) ' ) ;
eval { $dataset = $sth->fetchrow_arrayref(); } ;
print Dumper($dataset),"\n";
ok( $dataset && @$dataset == 3 , 'fetching third dataset');
eval { $more_results = $sth->more_results() };
ok( ! $more_results, 'no more results available' ) ;