Return-Path: owner-postman 
Delivery-Date: Fri, 22 Apr 94 23:40:38 -0700
Return-Path: owner-postman
Received: from localhost (localhost [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id TAA12241 for postgres-redist; Fri, 22 Apr 1994 19:50:36 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199404230250.TAA12241@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from bush.cs.tamu.edu (BUSH.TAMU.EDU [128.194.134.200]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id TAA12232 for <postgres@postgres.berkeley.edu>; Fri, 22 Apr 1994 19:50:34 -0700
Received: from hrl6.cs.tamu.edu by  bush.cs.tamu.edu (4.1/SMI-4.1)
	id AA18473; Fri, 22 Apr 94 21:49:40 CDT
Date: Fri, 22 Apr 94 21:49:40 CDT
Message-Id: <9404230249.AA18473@ bush.cs.tamu.edu>
To: postgres@postgres.Berkeley.EDU
Subject: memory error while using portals
From: <alfredo@bush.cs.tamu.edu>
Resent-To: postgres-redist@postgres.Berkeley.EDU
Resent-Date: Fri, 22 Apr 94 19:50:36 -0700
Resent-XMts: smtp

postgresers,

I defined a simple C function using PQlib which checks whether
an object with a given oid exists. I call this function within a 
transaction from other PQlib-based programs and it's been workin ok.
However, one program is giving me trouble exactly when this
simple function is called. The error I get is:

signal SEGV (no mapping at the fault address) in pbuf_freeTuples at 0x9a90
pbuf_freeTuples+0x50:   ld      [%i3], %o3

and a stack trace gives:

(dbxtool) where
pbuf_freeTuples() at 0x9a90
pbuf_freeGroup() at 0x9b40
pbuf_freePortal() at 0x9b6c
pbuf_setup() at 0x9c2c
dump_data() at 0xadc8
process_portal() at 0x5744
PQexec() at 0x657c
OM_ObjectExists(id = 42272), line 41 in "OM/src/OM_ObjectExists.c"

Within the caller program, the OM_ObjectExists function is repeatedly called
with different oid and works well until this happens (5th time).
Has anyone had any similar problem or can suggest a reason for this?
I am including the C function below.

Thanks for any help,

-Alfredo Sanchez
alfredo@bush.cs.tamu.edu

-----------------------------
int OM_ObjectExists(id)

   unsigned long id;		/* ID OF OBJECT	TO LOOK FOR*/
{

   char postquery[512];		/* STORES QUERIES SUBMITTED TO POSTGRES */
   PortalBuffer *portalbuff;	/* POINTS TO DATA RETRIEVED FROM DB */
   char *result;		/* STORES RESULTS FROM PG OPERATIONS	*/
   int exists;			/* USED TO STORE THE FUNCTION'S RESULT */

   /* CHECK WHETHER OBJECT EXISTS */
   sprintf(postquery, "retrieve portal p1 (Objects.oid) \
                       where Objects.id = \"%ld\"",id);
   result = PQexec(postquery);
   if (result[0] != 'C') {
      HRLTdiag_Emit (HRLTdiag_Fatal, "Can't access Objects\n");
      return(PG_FAILED);
   }
   result = PQexec("fetch all in p1");
   if (result[0] != 'P') {
      HRLTdiag_Emit (HRLTdiag_Fatal, "Can't check whther Object exists\n");
      return(PG_FAILED);
   }
   portalbuff = PQparray("p1");
   if (PQntuples(portalbuff) == 0) 
      exists = FALSE;
   else
      exists = TRUE;
   /* CLOSE PORTAL */
   result = PQexec("close p1"); 
   if (result[0] != 'C') {  
      HRLTdiag_Emit (HRLTdiag_Fatal, "Can't close portal p1\n"); 
      return(PG_FAILED); 
   }
   return(exists);
}


