| 1 | package DBIx::Class::Storage::DBI::Cursor; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 139 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 139 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 139 | ▶ | use base qw/DBIx::Class::Cursor/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 139 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 139 | ▶ | use Scalar::Util qw/refaddr weaken/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 139 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 139 | __PACKAGE__->mk_group_accessors('simple' => | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | qw/storage args attrs/ | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | DBIx::Class::Storage::DBI::Cursor - Object representing a query cursor on a | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | resultset. | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | my $cursor = $schema->resultset('CD')->cursor(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # raw values off the database handle in resultset columns/select order | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | my @next_cd_column_values = $cursor->next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # list of all raw values as arrayrefs | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | my @all_cds_column_values = $cursor->all; | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | A Cursor represents a query cursor on a L<DBIx::Class::ResultSet> object. It | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | allows for traversing the result set with L</next>, retrieving all results with | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | L</all> and resetting the cursor with L</reset>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | Usually, you would use the cursor methods built into L<DBIx::Class::ResultSet> | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | to traverse it. See L<DBIx::Class::ResultSet/next>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | L<DBIx::Class::ResultSet/reset> and L<DBIx::Class::ResultSet/all> for more | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | information. | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | Returns a new L<DBIx::Class::Storage::DBI::Cursor> object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 139 | my %cursor_registry; | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 3514 | ▶ | my ($class, $storage, $args, $attrs) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 3514 | ▶ | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | storage => $storage, | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | args => $args, | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | attrs => $attrs, | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | }, ref $class || $class; | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 3514 | if (DBIx::Class::_ENV_::HAS_ITHREADS) { | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # quick "garbage collection" pass - prevents the registry | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # from slowly growing with a bunch of undef-valued keys | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | defined $cursor_registry{$_} or delete $cursor_registry{$_} | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | for keys %cursor_registry; | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | weaken( $cursor_registry{ refaddr($self) } = $self ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 3514 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | sub CLONE { | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | for (keys %cursor_registry) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # once marked we no longer care about them, hence no | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # need to keep in the registry, left alone renumber the | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # keys (all addresses are now different) | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | my $self = delete $cursor_registry{$_} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $self->{_intra_thread} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | =head2 next | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | =item Arguments: none | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | =item Return Value: \@row_columns | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | Advances the cursor to the next row and returns an array of column | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | values (the result of L<DBI/fetchrow_array> method). | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 139 | sub next { | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | 6023 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next: called CC=13 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 6023 | ▶ | return if $self->{_done}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 6010 | my $sth; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 6010 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%8/8
$self->{"attrs"}{"software_limit"} and $self->{"attrs"}{"rows"} and ($self->{"_pos"} || 0) >= $self->{"attrs"}{"rows"}
$self->{"attrs"}{"software_limit"} and $self->{"attrs"}{"rows"}
$self->{'_pos'} || 0
MC/DC100%3/3
$self->{"attrs"}{"software_limit"} and $self->{"attrs"}{"rows"} and ($self->{"_pos"} || 0) >= $self->{"attrs"}{"rows"}
$self->{"attrs"}{"software_limit"}
$self->{"attrs"}{"rows"}
$self->{'_pos'}
Truth table100%4/4
A and B and C
A= $self->{"attrs"}{"software_limit"}B= $self->{"attrs"}{"rows"}C= $self->{'_pos'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | $self->{attrs}{software_limit} | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | && $self->{attrs}{rows} | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | && ($self->{_pos}||0) >= $self->{attrs}{rows} | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | ▶ | if ($sth = $self->sth) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # explicit finish will issue warnings, unlike the DESTROY below | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | ▶ | $sth->finish if $sth->FETCH('Active'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | $self->{_done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 6008 | ▶ | unless ($sth = $self->sth) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2616 | (undef, $sth, undef) = $self->storage->_select( @{$self->{args}} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 2600 | $self->{_results} = [ (undef) x $sth->FETCH('NUM_OF_FIELDS') ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | 2600 | $sth->bind_columns( \( @{$self->{_results}} ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 2600 | ▶ | if ( $self->{attrs}{software_limit} and $self->{attrs}{offset} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"attrs"}{"software_limit"} and $self->{"attrs"}{"offset"}
MC/DC100%2/2
$self->{"attrs"}{"software_limit"} and $self->{"attrs"}{"offset"}
$self->{"attrs"}{"software_limit"}
$self->{"attrs"}{"offset"}
Truth table100%3/3
A and B
A= $self->{"attrs"}{"software_limit"}B= $self->{"attrs"}{"offset"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | $sth->fetch for 1 .. $self->{attrs}{offset}; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2600 | $self->sth($sth); | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 5992 | ▶ | if ($sth->fetch) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 5172 | $self->{_pos}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | 5172 | return @{$self->{_results}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 820 | $self->{_done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | 820 | return (); | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | =head2 all | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | =item Arguments: none | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | =item Return Value: \@row_columns+ | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | Returns a list of arrayrefs of column values for all rows in the | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | L<DBIx::Class::ResultSet>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | sub all { | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1501 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all: called CC=7 SCAR=23.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # delegate to DBIC::Cursor which will delegate back to next() | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1501 | ▶ | if ($self->{attrs}{software_limit} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$self->{"attrs"}{"software_limit"} and $self->{"attrs"}{"offset"} || $self->{"attrs"}{"rows"}
$self->{"attrs"}{"offset"} or $self->{"attrs"}{"rows"}
MC/DC0%0/3
$self->{"attrs"}{"software_limit"} and $self->{"attrs"}{"offset"} || $self->{"attrs"}{"rows"}
$self->{"attrs"}{"software_limit"}
$self->{"attrs"}{"offset"}
$self->{"attrs"}{"rows"}
Truth table25%1/4
A and B or C
A= $self->{"attrs"}{"software_limit"}B= $self->{"attrs"}{"offset"}C= $self->{"attrs"}{"rows"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | && ($self->{attrs}{offset} || $self->{attrs}{rows})) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | return $self->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1500 | my $sth; | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1500 | ▶ | if ($sth = $self->sth) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # explicit finish will issue warnings, unlike the DESTROY below | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | $sth->finish if ( ! $self->{_done} and $sth->FETCH('Active') ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->{"_done"} and $sth->FETCH("Active")
MC/DC0%0/2
not $self->{"_done"} and $sth->FETCH("Active")
not $self->{"_done"}
$sth->FETCH("Active")
Truth table0%0/3
not(A) and B
A= not $self->{"_done"}B= $sth->FETCH("Active")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $self->sth(undef); | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1500 | (undef, $sth) = $self->storage->_select( @{$self->{args}} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1491 | return @{$sth->fetchall_arrayref}; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | sub sth { | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 13073 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sth: called CC=8 SCAR=22.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 13073 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 5563 | delete @{$self}{qw/_pos _done _pid _intra_thread/}; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 5563 | $self->{sth} = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | 5563 | ▶ | $self->{_pid} = $$ if ! DBIx::Class::_ENV_::BROKEN_FORK and $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ▶ | elsif ($self->{sth} and ! $self->{_done}) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"sth"} and not $self->{"_done"}
MC/DC50%1/2
$self->{"sth"} and not $self->{"_done"}
$self->{"sth"}
not $self->{"_done"}
Truth table66%2/3
A and not(B)
A= $self->{"sth"}B= not $self->{"_done"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 3394 | my $invalidate_handle_reason; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3394 | ▶ | if (DBIx::Class::_ENV_::HAS_ITHREADS and $self->{_intra_thread} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | $invalidate_handle_reason = 'Multi-thread'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | elsif (!DBIx::Class::_ENV_::BROKEN_FORK and $self->{_pid} != $$ ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $invalidate_handle_reason = 'Multi-process'; | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 3394 | ▶ | if ($invalidate_handle_reason) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | $self->storage->throw_exception("$invalidate_handle_reason access attempted while cursor in progress (position $self->{_pos})") | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if $self->{_pos}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # reinvokes the reset logic above | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $self->sth(undef); | |||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 13073 | return $self->{sth}; | |||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | =head2 reset | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | Resets the cursor to the beginning of the L<DBIx::Class::ResultSet>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | sub reset { | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 2963 | ▶ | $_[0]->__finish_sth if $_[0]->{sth}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 2963 | $_[0]->sth(undef); | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 3514 | ▶ | $_[0]->__finish_sth if $_[0]->{sth}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | sub __finish_sth { | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # It is (sadly) extremely important to finish() handles we are about | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # to lose (due to reset() or a DESTROY() ). $rs->reset is the closest | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # thing the user has to getting to the underlying finish() API and some | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # DBDs mandate this (e.g. DBD::InterBase will segfault, DBD::Sybase | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # won't start a transaction sanely, etc) | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # We also can't use the accessor here, as it will trigger a fork/thread | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # check, and resetting a cursor in a child is perfectly valid | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2600 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__finish_sth: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # No need to care about failures here | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1778 | ▶ | try { local $SIG{__WARN__} = sub {}; $self->{sth}->finish } if ( | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2600 | ▶ | $self->{sth} and ! try { ! $self->{sth}->FETCH('Active') } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2600 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"sth"} and not &try(sub {
not $self->{"sth"}->FETCH("Active");
}
)
MC/DC50%1/2
$self->{"sth"} and not &try(sub {
not $self->{"sth"}->FETCH("Active");
}
)
$self->{"sth"}
not &try(sub {
not $self->{"sth"}->FETCH("Active");
}
)
Truth table66%2/3
A and not(B)
A= $self->{"sth"}B= not &try(sub {
not $self->{"sth"}->FETCH("Active");
}
)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 139 | 1; | |||||||||||||||||||||||||||||||||||||||||||||