Thread: Weird Behavior!!!

Weird Behavior!!!

From
Renê Salomão
Date:
Hi list,

 Me and Perl again... =o)

 I have two versions of Pg in my machine!!!! 7.2.3 & 7.3.1

 I have the perl code to connect to Pg, however I'm only able to connect
to Pg 7.2.3, the error message in Pg 7.3.1 is :

Pg 7.2.3: perl pg_connect.pl

[pgsql@ibizs04 examples]$ perl pg_connect.pl
Connected!!!
97422620003680    bompreco Lj. Cabula    bompreco Lj. Cabula
97422620003761    bompreco Lj. FINAL 03761    bompreco Lj. FINAL 03761
Disconnected!!!

Pg 7.3.1: perl pg_connect.pl

[pgsql@ibizs04 examples]$ perl pg_connect.pl
FATAL:  No pg_hba.conf entry for host 164.35.10.17, user pgsql, database
corban DBI
connect('dbname=corban;host=164.35.10.17;port=5432','pgsql',...) failed:
FATAL:  No pg_hba.conf entry for host 164.35.10.17, user pgsql, database
corban at pg_connect.pl line 16

Perl Package version:
=====================
[pgsql@ibizs04]$ perl -e 'use DBI; use DBD::Pg; print "DBI:
$DBI::VERSION, DBD::Pg $DBD::Pg::VERSION\n";'

DBI: 1.32, DBD::Pg 1.21


PG_CONNECT.PL
=============
#!/usr/bin/perl

use DBI;
use DBD::Pg;
use strict;

my $dbh;

my $dbname='corban';
my $host='164.35.10.17';
my $port='5432';
my $options='';
my $username='pgsql';
my $password='pgsql';

$dbh = DBI->connect("dbi:Pg:dbname=$dbname;host=$host;port=$port",
                    "$username",
                    "$password",
                    { RaiseError => 1, AutoCommit => 0 }) || die
$DBI::errstr;

print "Connected!!!\n";

my $hSt = $dbh->prepare('SELECT * FROM table Limit 2;');

$hSt->execute;

while(my @raD = $hSt->fetchrow_array()){ print
"$raD[0]\t$raD[1]\t$raD[2]\n";}

$hSt->finish;

$dbh->disconnect;

print "Disconnected!!!\n";



[pgsql@corban:5432]#select version();
-[ RECORD 1 ]--------------------------------------------------------
version | PostgreSQL 7.3.1 on i586-pc-linux-gnu, compiled by GCC 2.96

[pgsql@ibizs04 examples]$ /usr/local/postgresql-7.3.1/bin/psql -l
       List of databases
   Name    | Owner | Encoding
-----------+-------+-----------
 corban    | pgsql | SQL_ASCII
 db        | pgsql | LATIN1
 template0 | pgsql | SQL_ASCII
 template1 | pgsql | SQL_ASCII
(4 rows)

pg_hba.conf
===========
# TYPE  DATABASE    USER        IP-ADDRESS        IP-MASK         METHOD

local   all         all                                             md5
host    all         all         164.35.10.0       255.255.255.0     md5


[pgsql@corban:5433]#select version();
-[ RECORD 1 ]--------------------------------------------------------
version | PostgreSQL 7.2.3 on i586-pc-linux-gnu, compiled by GCC 2.96

[pgsql@ibizs04 examples]$ psql -l
 List of databases
   Name    | Owner
-----------+-------
 corban    | pgsql
 db        | pgsql
 template0 | pgsql
 template1 | pgsql
(4 rows)

pg_hba.conf
===========
# TYPE   DATABASE    IP_ADDRESS    MASK            AUTH_TYPE
# AUTH_ARGUMENT
#
local    all                                         crypt
host     all         164.35.10.0   255.255.255.0     crypt

-----------------------------
Renê Salomão
Ibiz Tecnologia -- www.ibiz.com.br
(011) 5579-3178 - R. 211