Skip to content

Rt36730 num of fields #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
2013-09-17 Michiel Beijen, Patrick Galbraith, DBI/DBD community
2013-??-?? Patrick Galbraith, Michiel Beijen, DBI/DBD community (4.025)
* Fix example in POD doc for NUM_OF_FIELDS - RT36730, reported by tapoutmma.

2013-09-17 Michiel Beijen, Patrick Galbraith, DBI/DBD community (4.024)
* Fix memory leak if mysql_server_prepare is enabled - RT76462 - Masahiro Chiba
* Small dist improvements: Michiel Beijen <michiel.beijen@otrs.com>
* Undefined $DBI::errstr on execute fail on Windows: Michiel Beijen <michiel.beijen@otrs.com>
Expand Down
4 changes: 3 additions & 1 deletion eg/proc_example1.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/perl

use strict;
use warnings;

use DBI;

my $db='test';
Expand Down Expand Up @@ -34,7 +36,7 @@
$sth->execute || die DBI::err.": ".$DBI::errstr;
do {
print "\nResult set ".++$i."\n---------------------------------------\n\n";
for my $colno (0..$sth->{NUM_OF_FIELDS}) {
for my $colno (0..$sth->{NUM_OF_FIELDS}-1) {
print $sth->{NAME}->[$colno]."\t";
}
print "\n";
Expand Down
4 changes: 3 additions & 1 deletion eg/proc_example2.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/perl

use strict;
use warnings;

use DBI;
use Data::Dumper;

Expand Down Expand Up @@ -43,7 +45,7 @@ BEGIN
$sth->execute || die DBI::err.": ".$DBI::errstr;
do {
print "\nResult set ".++$i."\n---------------------------------------\n\n";
for my $colno (0..$sth->{NUM_OF_FIELDS}) {
for my $colno (0..$sth->{NUM_OF_FIELDS}-1) {
print $sth->{NAME}->[$colno]."\t";
}
print "\n";
Expand Down
8 changes: 4 additions & 4 deletions lib/DBD/mysql.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1501,13 +1501,13 @@ header of table names together with all rows:
die "Error:" . $sth->errstr . "\n";
}
my $names = $sth->{'NAME'};
my $numFields = $sth->{'NUM_OF_FIELDS'};
for (my $i = 0; $i < $numFields; $i++) {
my $numFields = $sth->{'NUM_OF_FIELDS'} - 1;
for my $i ( 0..$numFields ) {
printf("%s%s", $i ? "," : "", $$names[$i]);
}
print "\n";
while (my $ref = $sth->fetchrow_arrayref) {
for (my $i = 0; $i < $numFields; $i++) {
for my $i ( 0..$numFields ) {
printf("%s%s", $i ? "," : "", $$ref[$i]);
}
print "\n";
Expand Down Expand Up @@ -1764,7 +1764,7 @@ An example would be:
$sth->execute || die DBI::err.": ".$DBI::errstr; $rowset=0;
do {
print "\nRowset ".++$i."\n---------------------------------------\n\n";
foreach $colno (0..$sth->{NUM_OF_FIELDS}) {
foreach $colno (0..$sth->{NUM_OF_FIELDS}-1) {
print $sth->{NAME}->[$colno]."\t";
}
print "\n";
Expand Down