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 XAA22365 for postgres-redist; Sun, 26 Jun 1994 23:18:49 -0700
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199406270618.XAA22365@nobozo.CS.Berkeley.EDU>
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from faerie.CS.Berkeley.EDU (faerie.CS.Berkeley.EDU [128.32.149.14]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with ESMTP id XAA22355 for <postgres@postgres.Berkeley.EDU>; Sun, 26 Jun 1994 23:18:49 -0700
Received: from localhost (localhost [127.0.0.1]) by faerie.CS.Berkeley.EDU (8.6.4/8.1B) with SMTP id XAA29544; Sun, 26 Jun 1994 23:18:45 -0700
Message-Id: <199406270618.XAA29544@faerie.CS.Berkeley.EDU>
X-Authentication-Warning: faerie.CS.Berkeley.EDU: Host localhost didn't use HELO protocol
From: aoki@CS.Berkeley.EDU (Paul M. Aoki)
To: aataneja@cs.mtu.edu (Bruce Taneja.)
Cc: postgres@postgres.Berkeley.EDU
Subject: Re: " GetAttributeByName " .. 
Reply-To: aoki@CS.Berkeley.EDU (Paul M. Aoki)
In-reply-to: Your message of Sun, 26 Jun 1994 17:50:57 -0400 (EDT) 
	     <9406262150.AA16321@cs.mtu.edu> 
Date: Sun, 26 Jun 94 23:18:45 -0700
X-Sender: aoki@postgres.Berkeley.EDU
Resent-To: postgres-redist@postgres.Berkeley.EDU
X-Mts: smtp
Resent-Date: Sun, 26 Jun 94 23:18:49 -0700
Resent-XMts: smtp

aataneja@cs.mtu.edu (Bruce Taneja.) writes:
> /*        bca = (CIRCLE *) GetAttributeByName(t, "a");  */

GetAttributeByName has three arguments, one of which is a bool.

> .. has any body else had any good luck with GetAttributeByName(), 
> can any body see why the monitor program hangs for me .. ?

this is postgres 4.2 on ultrix.  sorry, haven't the time to load 4.1 
on a sparc, or to fix a bug in 4.1 if your problem is a bug.  here goes..

Script started on Sun Jun 26 23:15:17 1994
faerie:aoki (1)> createdb bruce
faerie:aoki (2)> monitor bruce < bruce.pq
Welcome to the POSTGRES terminal monitor

Go 
* 
Query sent to backend is "define function circle_in ( language = "c",                             returntype = circle )        arg is (any)        as "/faerie/aoki/postgres/src/regress/regress/obj/regress.o" "
NOTICE:Jun 27 06:15:46:ProcedureDefine: type 'circle' is not yet defined
NOTICE:Jun 27 06:15:46:ProcedureDefine: creating a shell for type 'circle'
DEFINE
Go 
* 
Query sent to backend is "define function circle_out ( language = "c",                               returntype = any )        arg is (any)        as "/faerie/aoki/postgres/src/regress/regress/obj/regress.o" "
DEFINE
Go 
* 
Query sent to backend is "define type circle ( internallength = 24,                       input = circle_in,                      output = circle_out ) "
DEFINE
Go 
* 
Query sent to backend is "load "/faerie/aoki/postgres/src/regress/regress/obj/regress.o" "
LOAD
Go 
* 
Query sent to backend is "create tutorial (a = circle) "
CREATE
Go 
* 
Query sent to backend is "append tutorial (a = "(15,12,1)"::circle) "
APPEND 21386
Go 
* 
Query sent to backend is "define function test (language = "c", returntype = bool)   arg is (tutorial, char16)   as "/faerie/aoki/postgres/src/regress/regress/obj/bruce.o" "
DEFINE
Go 
* 
Query sent to backend is "retrieve (x = test(t, "1"::char16)) from t in tutorial "
NOTICE:Jun 27 06:15:50:test: circle = (15.000000,12.000000,1.000000), string = 1
---------------
| x           |
---------------
| t           |
---------------

Go 
* faerie:aoki (3)> cat bruce.c
#include "tmp/postgres.h"
#include "tmp/libpq-fe.h"
#include "utils/geo-decls.h"
#include "utils/log.h"	/* for elog status codes */

typedef struct {
	POINT	center;
	double	radius;
} CIRCLE;

bool
test(t, s)
    TUPLE t;
    char *s;
{
    bool isnull = 0;
    CIRCLE *c = (CIRCLE *) GetAttributeByName(t, "a", &isnull);

    if (isnull)
	return(0);

    elog(NOTICE, "test: circle = (%f,%f,%f), string = %.16s",
	 c->center.x, c->center.y, c->radius, s);

    return(1);
}
faerie:aoki (4)> exit

script done on Sun Jun 26 23:16:01 1994
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  aoki@CS.Berkeley.EDU
                |  Berkeley, CA 94720-1776      |  ...!uunet!ucbvax!aoki

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
