Sender: owner-postgres95@postgres.Berkeley.EDU
X-Return-Path: andrew_yu
Received: from netcomsv.netcom.com (uucp4.netcom.com [163.179.3.4]) by nobozo.CS.Berkeley.EDU (8.6.10/8.6.3) with ESMTP id QAA15394 for <postgres95@postgres.berkeley.edu>; Tue, 14 Nov 1995 16:16:11 -0800
Received: from lincoln.UUCP by netcomsv.netcom.com with UUCP (8.6.12/SMI-4.1)
	id QAA15559; Tue, 14 Nov 1995 16:01:39 -0800
Received: from ZEXEL by lincoln.ZEXEL (4.1/SMI-4.1)
	id AA10510; Tue, 14 Nov 95 16:03:50 PST
Received: from simon.ZEXEL by ZEXEL (4.1/SMI-4.1)
	id AA07648; Tue, 14 Nov 95 16:03:51 PST
Date: Tue, 14 Nov 95 16:03:51 PST
From: lincoln!hlivka@netcom.com (Peter Hlivka)
Message-Id: <9511150003.AA07648@ZEXEL>
To: postgres95@postgres.Berkeley.EDU
Subject: programming help and backend not responding
Cc: lincoln!hlivka@netcom.com
Resent-To: postgres95-redist
Resent-Date: Tue, 14 Nov 95 16:16:12 -0800
Resent-From: pglite
Resent-XMts: smtp

HELP!!! if you can.  Below are two programs, the first one works just fine, but the second one, which seems to be almost identical to the first in the "major" ways, will crash after a few runs.  Although it might vary, I can usually run it successfully 3 times, but on the fourth it will abort both transactions I'm trying to run. This usually occurrs after the insert statements.(it could be in the FETCH ALL statement)  This leaves the databases being used by the program useless. Maybe the following information will be helpful -- I'm running postgres95, without any of the patches, on a SPARC platform running sunOS4.1.3, and I used gcc to build pg95.  In addition I sometimes get the message no response from backend when I try to destory a database? why does this happen once in awhile.

I would sure appreciate it if anyone could help me.

#include <stdio.h>
#include "libpq-fe.h"

main()
{
  PGconn *connect, *connect1 ;
  char *pghost, *pgport, *pgoptions, *pgtty, *dbName ;
  PGresult  *result, *result1;
  int i,j ;
  FILE *debug, *debug1;
  
  pghost = NULL; pgport = NULL; pgoptions = NULL; pgtty = NULL; dbName = "pgt";
  connect = PQsetdb(pghost,pgport,pgoptions,pgtty,dbName);
  dbName = "pgttwo";
  connect1 = PQsetdb(pghost,pgport,pgoptions,pgtty,dbName);
  debug = fopen("trace_it","w");
  debug1 = fopen("trace_it1","w");
  PQtrace(connect,debug);
  PQtrace(connect1,debug1);
  PQexec(connect,"BEGIN");
  PQexec(connect1,"BEGIN");
  PQexec(connect,"delete from employee");
  PQexec(connect1,"delete from employee");
/*********************************************************************************************/
  PQexec(connect1,"drop table employee");
  PQexec(connect1,"create table employee(first text, last text, date date)");
  PQexec(connect,"drop table employee");
  PQexec(connect,"create table employee(first text, last text, date date)");
/*********************************************************************************************/
  PQexec(connect1,"copy employee from '/db_work/usr/local/postgres95/data/base/tcopyt' using delimiters ';'");
  PQexec(connect,"insert into employee values('a','b','11/21/1995')");
  result1 = PQexec(connect1,"DECLARE allof CURSOR FOR select * from employee");
  result1 = PQexec(connect1,"FETCH ALL in allof");
  result = PQexec(connect,"DECLARE everyone CURSOR FOR select * from employee");
  result = PQexec(connect,"FETCH ALL in everyone");
  printf("NAME OF DB IS: %s\n", PQdb(connect));
  printf("NAME OF HOST IS: %s\n",PQhost(connect));
  printf("PORT TO BACKEND IS: %s\n",PQport(connect));
  for(i = 0; i < PQnfields(result); ++i)
    printf("%-10s",PQfname(result,i)) ;
  printf("\n") ;
  for(j = 0; j < PQntuples(result);++j)
  {
    for(i = 0; i < PQnfields(result); ++i)
      printf("%-10s",PQgetvalue(result,j,i));
    printf("\n");
  }
  printf("\n\n");
  printf("NAME OF DB IS: %s\n",PQdb(connect1));
  printf("NAME OF HOST IS: %s\n",PQhost(connect1));
  printf("PORT TO BACKEND IS: %s\n",PQport(connect1));
  for(i = 0; i < PQnfields(result1); ++i)
    printf("%-10s",PQfname(result1,i));
  printf("\n");
  for(j = 0; j < PQntuples(result1);++j)
  {
    for(i = 0; i < PQnfields(result1); ++i)
      printf("%-10s",PQgetvalue(result1,j,i));
    printf("\n");
  }
  PQexec(connect,"CLOSE everyone");
  PQexec(connect,"END");
  PQclear(result);
  PQfinish(connect);
  PQexec(connect1,"CLOSE allof");
  PQexec(connect1,"END");
  PQclear(result1);
  PQfinish(connect1);
}
 

#include <stdio.h>
#include "libpq-fe.h"

main()
{
  PGconn *connect, *connect1;
  char *pghost, *pgport, *pgoptions, *pgtty, *dbName = "pgt"  ;
  PGresult *result, *result1 ;
  char *namezz, *name1zz, *hostzz, *host1zz,  *portzz, *port1zz ;
  int i, j ;
  FILE *debug, *debug1;

  pghost = NULL; pgport = NULL; pgoptions = NULL; pgtty = NULL; 
  connect = PQsetdb(pghost,pgport,pgoptions,pgtty,dbName) ;
  dbName = "pgttwo";
  connect1 = PQsetdb(pghost,pgport,pgoptions,pgtty,dbName) ;
  namezz = PQdb(connect) ;
  name1zz = PQdb(connect1) ;
  hostzz = PQhost(connect) ;
  host1zz = PQhost(connect1) ;
  portzz = PQport(connect) ;
  port1zz = PQport(connect1) ;
  debug = fopen("trace_it","w") ;
  debug1 = fopen("trace_it1", "w") ;
  PQtrace(connect,debug) ;
  PQtrace(connect1,debug1) ;
  PQexec(connect, "BEGIN");
  PQexec(connect1, "BEGIN");
  printf("AFTER BEGIN\n");
  PQexec(connect1, "delete from employee") ;
  PQexec(connect, "delete from employee") ;
  printf("AFTER DELETE\n");
  PQexec(connect, "drop table employee") ;
  PQexec(connect1, "drop table employee") ;
  printf("AFTER DROP\n");
  PQexec(connect,"create table employee(first text, last text)");
  PQexec(connect1,"create table employee(first text, last text)");
  printf("AFTER CREATE\n");
  PQexec(connect1,"insert into employee values('a','b')") ;
  PQexec(connect,"insert into employee values('Peter', 'Hlivka')");
  PQexec(connect,"insert into employee values('Simon','Desai')") ;
  printf("AFTER INSERT\n");
  result = PQexec(connect, "DECLARE everyone CURSOR FOR select * from employee") ;
  result = PQexec(connect, "FETCH ALL in everyone") ;
  printf("AFTER DECLARE AND FETCH for connect\n");
  result1 = PQexec(connect1, "DECLARE allofthem CURSOR FOR select * from employee");
  result1 = PQexec(connect1, "FETCH ALL in allofthem") ;
  printf("AFTER DECLARE AND FETCH for connect1\n");
  printf("NAME OF DB IS: %s\n",namezz) ;
  printf("NAME OF HOST IS: %s\n",hostzz) ;
  printf("PORT TO BACKEND IS: %s\n",portzz) ;
  for(i = 0; i < PQnfields(result); ++i)
    printf("%-10s", PQfname(result,i)) ;
  printf("\n");
  for (j = 0; j < PQntuples(result); ++j)
  {
    for (i = 0; i < PQnfields(result) ; ++i)
      printf("%-10s",PQgetvalue(result,j,i));
    printf("\n") ;
  }
  printf("\n");
  printf("NAME OF DB IS: %s\n",name1zz) ;
  printf("NAME OF HOST IS: %s\n",host1zz) ;
  printf("PORT TO BACKEND IS: %s\n",port1zz) ;
  for(i = 0; i < PQnfields(result1); ++i)
    printf("%-10s", PQfname(result1, i));
  printf("\n") ;
  for(j = 0; j < PQntuples(result1); ++j)
  {
    for(i = 0; i < PQnfields(result1); ++i)
      printf("%-10s",PQgetvalue(result1,j,i)) ;
    printf("\n") ;
  }
  printf("\n") ;
  PQexec(connect, "CLOSE everyone");
  PQexec(connect1, "CLOSE  allofthem");
  PQexec(connect1, "END") ;
  PQexec(connect, "END") ;
  PQclear(result) ;
  PQclear(result1) ;
  PQfinish(connect1) ;
  PQfinish(connect);
}
  
  
_________________________________________
Peter Hlivka
ZEXEL USA Corporation
Navigation Systems Division
1249 Innsbruck Drive
Sunnyvale, California 94089
Work: hlivka@zexel.com
Phone: (408) 541-9075
Fax: 541-9701

===============================================================================
  To unsubscribe from the Postgres95 mailing list, send mail with the subject
  line "DEL" to "postgres95-request@postgres.Berkeley.EDU". 
============  URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres95/  ===========
