pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: JESUS AVILA MOLINA <avimolje@tuguri.eupmt.es>
To: pgsql-sql@postgresql.org
Cc: pgsql-general@postgresql.org
Subject: Postgresql-Perl -->PQexec() -- there is no connection to the backend
Date: Mon, 15 Jun 1998 07:51:33 +0100 (WET DST)
Message-ID: <Pine.SOL.3.95.980615074202.3332D-200000@tuguri.eupmt.es> (raw)

Hello PostgreSQL LIST!

My name is Jesus Avila and I'm studying Telematics Engineering.
Nowadays I'm doing the final project of the speciality and
it consists of managing the PostgreSQL through PERL language
using the Apache Server in RedHat.
The problem I have is the following:
* Everytime I try to access to the database, in a file where I
keep all the traces I find this:

  UW PICO(tm) 2.9               File: pgtrace.out

PQexec() -- There is no connection to the backend.


The system is the following. I have a form in an .html file who
calls the CGI 'proba.pl' to insert the data into the data base.
The program who makes the error is attached (it's name is proba.pl). 
The same error appears when I do "INSERT" and also when I do "SELECT".
In it you can see the path from the pgtrace.out and how I create it.
Could you help me? I'm desperate! I don't know how can i solve
the problem! Thank you very much in advance!

The Following things are some data that I've considered
in order to help to try to solve my problem. I have only two 
weeks left to finish the project and I need the database
functioning for yesterday. So please, could you help me.
I'll be very grateful for your help.
Thank you very much in advance.


Version of the programs I use!!!
-----------------------------------

PosgreSQL version 6.3  (postgresql-6.3.2.tar.gz)
PERL version 5.004 patch 1
RedHat 5.0
Server version Apache/1.2.4.

* Accessing to the database typing "psql proba" functions, I can
  INSERT, DELETE, CREATE TABLE, ...
* The database "postgres" is created.
* When I type postgres, those are the things that appears on the screen:
	
	[postgres@localhost pgsql]$   postgres

        	---debug info---
        	Quiet =        f
        	Noversion =    f
        	timings   =    f
        	dates     =    Normal
        	bufsize   =    64
        	sortmem   =    512
        	query echo =   f
        	DatabaseName = [postgres]
        	----------------

        	InitPostgres()..

	POSTGRES backend interactive interface
	$Revision: 1.67 $ $Date: 1998/02/26 04:36:31 $
	>

-> What is the meaning of that?
-> and Which are the things you can do with that?


The configuration of the file ".bash_profile"!!!
------------------------------------------------
PATH=$PATH:$HOME/bin
ENV=$HOME/.bashrc
USERNAME="postgres"

export USERNAME ENV PATH

PATH=$PATH:/usr/local/pgsql/bin
MANPATH=$MANPATH:/usr/local/pgsql/man
PGLIB=/usr/local/pgsql/lib
PGDATA=/usr/local/pgsql/data
export PATH MANPATH PGLIB PGDATA

nohup postmaster -d > server.log 2>&1 &

If I open the file "server.log" the things I find are the folliwing:
--------------------------------------------------------------------

FindBackend: searching PATH ...
FindBackend: found "/usr/local/pgsql/bin/postgres" using PATH


The implementation of the database i try to access!!!
-----------------------------------------------------

Database    = proba
 +------------------+----------------------------------+----------+
 |  Owner           |             Relation             |   Type   |
 +------------------+----------------------------------+----------+
 | postgres         | dada                             | table    |
 +------------------+----------------------------------+----------+

Table    = dada
+----------------------------------+-----------------------------+-------+
|              Field               |              Type           | Length|
+----------------------------------+-----------------------------+-------+
| nom                              | varchar()                   |    40 |
| cog1                             | varchar()                   |    40 |
| cog2                             | varchar()                   |    40 |
| edat                             | int2                        |     2 |
| sexe                             | varchar()                   |     4 |
+----------------------------------+-----------------------------+-------+

GRANT select,insert,delete,update ON dada TO nobody;

Thank you very much another time !!!
--------------------------------

Attachments:

proba.pl (text/plain, 2.6K) download #!/usr/bin/perl print("Content-Type: text/html\n\n"); #Es llegeix la cadena URL $| = 1; read(STDIN, $buffer, $ENV{'CONTENT_LENGHT'}); @parelles=split(/&/, $buffer); foreach $par (@parelles) { ($nom, $valor)= split(/=/, $par); $valor =~ tr/+/ /; $valor =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $contingut{$nom}=$valor; } ### Declaració de variables $pghost = 'localhost'; $pgport = '5432'; $pgoptions = ''; $pgtty = ''; $dbname = 'proba'; $trace = '/tmp/pgtrace.out'; $DEBUG = 1; $correcte = 1; use Pg; ### Connexió a la base de dades $conn=PQsetdb($pghost,$pgport,$pgoptions,$pgtty,$dbname); cmp_eq(PGRES_CONNECTION_OK, PQstatus($conn)); ### Debuger if ($DEBUG) { open(TRACE, ">$trace") || die "can not open $trace: $!"; PQtrace($conn, TRACE); } ### Insertem les dades $res=exe(PGRES_COMMAND_OK,"insert into dada values(\'$contingut{'nom'}\',\'$contingut{'cog1'}\', \'$contingut{'cog2'}\',\'$contingut{'edat'}\',\'$contingut{'sexe'}\')"); cmp_ne(0,PQoidStatus($res)); ### Debuger if ($DEBUG) { close(TRACE) || die "bad TRACE: $!"; PQuntrace($conn); } ### Desconnexió de la base de dades PQfinish($conn); if ($correcte==1){ print <<FER; <HTML><HEAD><TITLE>Què vols fer?</TITLE> </HEAD><BODY> Dades Insertades <h2>Què vols fer?</h2> <hr align='CENTER'> <form ACTION='http://127.0.0.1/cgi-bin/consulta.pl' METHOD='POST'> <INPUT TYPE='submit' VALUE="Consulta"> </form> <A HREF="http://127.0.01/html/proba.htm">Insertar</A> </BODY></HTML> FER } else { print <<CAGADA; <HTML><HEAD><TITLE>Dades no insertades</TITLE></HEAD><BODY> <H1>Dades no insertades</H1> GRAN CAGADA <h2>Què vols fer?</h2> <form ACTION='http://127.0.0.1/cgi-bin/proba.pl' METHOD='POST'> <INPUT TYPE='submit' VALUE='Consulta'> <A HREF='http://127.0.0.1/html/proba.htm'>Insertar</A> </FORM></BODY></HTML> CAGADA } ### funcions utilitzades sub cmp_eq { my $cmp = shift; my $ret = shift; if ("$cmp" eq "$ret") { $correcte = 1; } else { $correcte = 0; } } sub cmp_ne { my $cmp = shift; my $ret = shift; if ("$cmp" ne "$ret") { $correcte = 1; } else { $correcte = 0; } } sub exe { my $cmp = shift; my $cmd = shift; my $result; my $status; $result = PQexec($conn, $cmd); $status = PQresultStatus($result); if ("$cmp" eq "$status") { $correcte = 1; } else { $correcte = 0; print TRACE PQerrorMessage($conn); } return $result; }

view thread (2+ messages)  latest in thread

Message-ID: <Pine.SOL.3.95.980615074202.3332D-200000@tuguri.eupmt.es>
Permalink:  ../Pine.SOL.3.95.980615074202.3332D-200000@tuguri.eupmt.es/
Also on:    postgresql.org/message-id/Pine.SOL.3.95.980615074202.3332D-200000@tuguri.eupmt.es

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: avimolje@tuguri.eupmt.es, pgsql-general@postgresql.org
  Subject: Re: Postgresql-Perl -->PQexec() -- there is no connection to the backend
  In-Reply-To: <Pine.SOL.3.95.980615074202.3332D-200000@tuguri.eupmt.es>
  References: <Pine.SOL.3.95.980615074202.3332D-200000@tuguri.eupmt.es>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox