Skip to content

Commit 30b9b52

Browse files
Edmund MerglEdmund Mergl
authored andcommitted
1.7.0
1 parent b34841d commit 30b9b52

File tree

7 files changed

+233
-88
lines changed

7 files changed

+233
-88
lines changed

src/interfaces/perl5/Changes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
Revision history for Perl extension Pg.
22

3+
1.7.0 Feb 20 1998
4+
- adapted to PostgreSQL-6.3:
5+
add host=localhost to the conninfo-string
6+
of test.pl and example-scripts
7+
- connectdb() converts dbname to lower case,
8+
unless it is surrounded by double quotes
9+
- added new method fetchrow, now you can do:
10+
while (@row = $result->fetchrow)
11+
312
1.6.3 Sep 25 1997
413
- README update
514

src/interfaces/perl5/Makefile.PL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#-------------------------------------------------------
22
#
3-
# $Id: Makefile.PL,v 1.4 1997/09/25 21:14:41 mergl Exp $
3+
# $Id: Makefile.PL,v 1.5 1998/02/20 21:25:32 mergl Exp $
44
#
55
# Copyright (c) 1997 Edmund Mergl
66
#

src/interfaces/perl5/Pg.pm

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#-------------------------------------------------------
22
#
3-
# $Id: Pg.pm,v 1.4 1997/09/25 21:14:43 mergl Exp $
3+
# $Id: Pg.pm,v 1.5 1998/02/20 21:25:35 mergl Exp $
44
#
55
# Copyright (c) 1997 Edmund Mergl
66
#
77
#-------------------------------------------------------
88

99
package Pg;
1010

11-
use strict;
11+
#use strict;
1212
use Carp;
1313
use vars qw($VERSION @ISA @EXPORT $AUTOLOAD);
1414

@@ -84,7 +84,7 @@ require 5.002;
8484
PGRES_InvalidOid
8585
);
8686

87-
$Pg::VERSION = '1.6.3';
87+
$Pg::VERSION = '1.7.0';
8888

8989
sub AUTOLOAD {
9090
# This AUTOLOAD is used to 'autoload' constants from the constant()
@@ -115,25 +115,21 @@ sub doQuery {
115115
my $query = shift;
116116
my $array_ref = shift;
117117

118-
my ($result, $status, $nfields, $ntuples, $i, $j);
118+
my ($result, $status, $i, $j);
119119

120-
$result = PQexec($conn, $query);
121-
$status = PQresultStatus($result);
122-
return($status) if (2 != $status);
123-
124-
$nfields = PQnfields($result);
125-
$ntuples = PQntuples($result);
126-
for ($i=0; $i < $ntuples; $i++) {
127-
for ($j=0; $j < $nfields; $j++) {
128-
$$array_ref[$i][$j] = PQgetvalue($result, $i, $j);
120+
if ($result = $conn->exec($query)) {
121+
if (2 == ($status = $result->resultStatus)) {
122+
for $i (0..$result->ntuples - 1) {
123+
for $j (0..$result->nfields - 1) {
124+
$$array_ref[$i][$j] = $result->getvalue($i, $j);
125+
}
126+
}
129127
}
130128
}
131-
132-
PQclear($result);
133-
134-
return 1;
129+
return $status;
135130
}
136131

132+
137133
1;
138134

139135
__END__
@@ -192,6 +188,11 @@ about freeing the connection- and result-structures.
192188
Perl calls the destructor whenever the last reference
193189
to an object goes away.
194190
191+
The method fetchrow can be used to fetch the next row from
192+
the server: while (@row = $result->fetchrow).
193+
Columns which have NULL as value will be set to C<undef>.
194+
195+
195196
=head2 old style
196197
197198
All functions and constants are imported into the calling
@@ -205,7 +206,6 @@ to be freed by the user:
205206
PQsetdb, use PQfinish to free memory.
206207
PQexec, use PQclear to free memory.
207208
208-
209209
Pg.pm contains one convenience function: doQuery. It fills a
210210
two-dimensional array with the result of your query. Usage:
211211
@@ -252,12 +252,14 @@ identification. Before using $conn you should call $conn->status to ensure,
252252
that the connection was properly made. Use the methods below to access
253253
the contents of the PGconn structure.
254254
255-
$conn = Pg::connectdb("option = value")
255+
$conn = Pg::connectdb("option1=value option2=value ...")
256256
257257
Opens a new connection to the backend using connection information in a string.
258-
The connection identifier $conn ( a pointer to the PGconn structure ) must be
259-
used in subsequent commands for unique identification. Before using $conn you
260-
should call $conn->status to ensure, that the connection was properly made.
258+
Possible options are: dbname, host, user, password, authtype, port, tty, options.
259+
The database-name will be converted to lower-case, unless it is surrounded by
260+
double quotes. The connection identifier $conn (a pointer to the PGconn structure)
261+
must be used in subsequent commands for unique identification. Before using $conn
262+
you should call $conn->status to ensure, that the connection was properly made.
261263
Use the methods below to access the contents of the PGconn structure.
262264
263265
$Option_ref = Pg::conndefaults()

0 commit comments

Comments
 (0)