1
# This program is copyright 2011 Percona Inc.
2
# This program is copyright 2007-2009 Baron Schwartz.
3
# Feedback and improvements are welcome.
5
# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
6
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
7
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
9
# This program is free software; you can redistribute it and/or modify it under
10
# the terms of the GNU General Public License as published by the Free Software
11
# Foundation, version 2; OR the Perl Artistic License. On UNIX and similar
12
# systems, you can issue `man perlgpl' or `man perlartistic' to read these
15
# You should have received a copy of the GNU General Public License along with
16
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17
# Place, Suite 330, Boston, MA 02111-1307 USA.
18
# ###########################################################################
19
# MockSth package $Revision: 5266 $
20
# ###########################################################################
24
use warnings FATAL => 'all';
25
use English qw(-no_match_vars);
27
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
30
my ( $class, @rows ) = @_;
31
my $n_rows = scalar @rows;
39
return bless $self, $class;
45
$self->{Active} = $self->{n_rows};
49
sub fetchrow_hashref {
52
if ( $self->{cursor} < $self->{n_rows} ) {
53
$row = $self->{rows}->[$self->{cursor}++];
55
$self->{Active} = $self->{cursor} < $self->{n_rows};
59
sub fetchall_arrayref {
62
if ( $self->{cursor} < $self->{n_rows} ) {
63
my @cols = @{$self->{NAME}};
64
die "Cannot fetchall_arrayref() unless NAME is set" unless @cols;
65
@rows = map { [ @{$_}{@cols} ] }
66
@{$self->{rows}}[ $self->{cursor}..($self->{n_rows} - 1) ];
67
$self->{cursor} = $self->{n_rows};
69
$self->{Active} = $self->{cursor} < $self->{n_rows};
74
my ($package, undef, $line) = caller 0;
75
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
76
map { defined $_ ? $_ : 'undef' }
78
print STDERR "# $package:$line $PID ", join(' ', @_), "\n";
83
# ###########################################################################
85
# ###########################################################################