ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro-Mysql/Mysql.pm
(Generate patch)

Comparing Coro-Mysql/Mysql.pm (file contents):
Revision 1.9 by root, Thu Feb 17 02:05:14 2011 UTC vs.
Revision 1.12 by root, Thu Jul 26 21:38:00 2012 UTC

100 100
101sub readable { &Coro::Handle::FH::readable } 101sub readable { &Coro::Handle::FH::readable }
102sub writable { &Coro::Handle::FH::writable } 102sub writable { &Coro::Handle::FH::writable }
103 103
104BEGIN { 104BEGIN {
105 our $VERSION = '1.02'; 105 our $VERSION = '1.2';
106 106
107 require XSLoader; 107 require XSLoader;
108 XSLoader::load Coro::Mysql::, $VERSION; 108 XSLoader::load Coro::Mysql::, $VERSION;
109} 109}
110 110
119It is safe to call this function on any database handle (or just about any 119It is safe to call this function on any database handle (or just about any
120value), but it will only do anything to L<DBD::mysql> handles, others are 120value), but it will only do anything to L<DBD::mysql> handles, others are
121returned unchanged. That means it is harmless when applied to database 121returned unchanged. That means it is harmless when applied to database
122handles of other databases. 122handles of other databases.
123 123
124It is also safe to pass C<undef>, so code like this is works as expected:
125
126 my $dbh = DBI->connect ($database, $user, $pass)->Coro::Mysql::unblock
127 or die $DBI::errstr;
128
124=cut 129=cut
125 130
126sub unblock { 131sub unblock {
127 my ($DBH) = @_; 132 my ($DBH) = @_;
128 133
129 if ($DBH->{Driver}{Name} eq "mysql") { 134 if ($DBH && $DBH->{Driver}{Name} eq "mysql") {
130 my $sock = $DBH->{sock}; 135 my $sock = $DBH->{sock};
131 136
132 open my $fh, "+>&" . $DBH->{sockfd} 137 open my $fh, "+>&" . $DBH->{sockfd}
133 or croak "Coro::Mysql unable to clone mysql fd"; 138 or croak "Coro::Mysql unable to clone mysql fd";
134 139
135 if (AnyEvent::detect ne "AnyEvent::Impl::EV" || !_use_ev) { 140 if (AnyEvent::detect ne "AnyEvent::Impl::EV" || !_use_ev) {
136 require Coro::Handle; 141 require Coro::Handle;
137 $fh = Coro::Handle::unblock ($fh); 142 $fh = Coro::Handle::unblock ($fh);
138 } 143 }
139 144
140 _patch $sock, $DBH->{sockfd}, $fh, tied ${$fh}; 145 _patch $sock, $DBH->{sockfd}, $DBH->{mysql_clientversion}, $fh, tied ${$fh};
141 } 146 }
142 147
143 $DBH 148 $DBH
144} 149}
145 150

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines