agora inbox for postgres@postgres.berkeley.edu  
help / color / mirror / Atom feed
" GetAttributeByName " ..
6+ messages / 3 participants
[nested] [flat]

* " GetAttributeByName " ..
@ 1994-06-26 21:50 Bruce Taneja. <aataneja@cs.mtu.edu>
  1994-06-27 06:18 ` Re: " GetAttributeByName " .. Paul M. Aoki <aoki@CS.Berkeley.EDU>
  0 siblings, 1 reply; 6+ messages in thread

From: Bruce Taneja. @ 1994-06-26 21:50 UTC (permalink / raw)
  To: legacy


Howdy again ,
 
with respect to my last query , and the function below, which
I had in my circle.c , ..

--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
bool  test(t, char1)
 TUPLE t;
 char *char1;
{
        extern char * GetAttributeByName();
        CIRCLE * bca;

/*        bca = (CIRCLE *) GetAttributeByName(t, "a");  */

  return strncmp(char1, "1");
}
-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


                 define function test
  (language = "c", returntype = bool)
  arg is (tutorial, char16)
  as "/usr/local/postgres/circle.o" \g

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

....... Upon running the query           

retrieve (tutorial.all)
               where test(tutorial, "1"::char16) \g

, I get the expected results OK, BUT when I uncomment the above
line in the code i.e " bca = (CIRCLE *) GetAttributeByName(t, "a"); "
and run the same query, the computer hangs ... !

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

All comments appreciated !
Bruce.

==============================================================================
   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.
==============================================================================



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: " GetAttributeByName " ..
  1994-06-26 21:50 " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
@ 1994-06-27 06:18 ` Paul M. Aoki <aoki@CS.Berkeley.EDU>
  1994-06-27 19:10   ` Re: " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
  0 siblings, 1 reply; 6+ messages in thread

From: Paul M. Aoki @ 1994-06-27 06:18 UTC (permalink / raw)
  To: Bruce Taneja. <aataneja@cs.mtu.edu>; +Cc: legacy

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.
==============================================================================



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: " GetAttributeByName " ..
  1994-06-26 21:50 " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
  1994-06-27 06:18 ` Re: " GetAttributeByName " .. Paul M. Aoki <aoki@CS.Berkeley.EDU>
@ 1994-06-27 19:10   ` Bruce Taneja. <aataneja@cs.mtu.edu>
  1994-06-27 19:46     ` Re: " GetAttributeByName " .. George Hartzell <hartzell@postgres.Berkeley.EDU>
  0 siblings, 1 reply; 6+ messages in thread

From: Bruce Taneja. @ 1994-06-27 19:10 UTC (permalink / raw)
  To: legacy

> 
> 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);
> }


Hi Paul, 
Thanks for your help!

  After playing around with your exmaple above, I think I found
what was wrong, but I can't really explain it:

The above example runs perfectly even on ver 4.1 (  :)  ) , but 
as soon as I changed the line : 

>     CIRCLE *c = (CIRCLE *) GetAttributeByName(t, "a", &isnull);
  
to the following:

>     CIRCLE *c = (CIRCLE *) GetAttributeByName(t, "a");

  i.e removed the "&isnull)" and etc. in the test()  , the computer 
hanged !

Now why does the GetAttributeByName() work OK w/o the 3rd param.
when running the overpaid(EMP) example in the 8.4.3 section (user manual)
and simply hangs when used w/o the 3rd param in the circle example .. !?

thanks for your help!
Bruce.


==============================================================================
   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.
==============================================================================



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: " GetAttributeByName " ..
  1994-06-26 21:50 " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
  1994-06-27 06:18 ` Re: " GetAttributeByName " .. Paul M. Aoki <aoki@CS.Berkeley.EDU>
  1994-06-27 19:10   ` Re: " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
@ 1994-06-27 19:46     ` George Hartzell <hartzell@postgres.Berkeley.EDU>
  1994-06-27 19:48       ` Re: " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
  0 siblings, 1 reply; 6+ messages in thread

From: George Hartzell @ 1994-06-27 19:46 UTC (permalink / raw)
  To: Bruce Taneja. <aataneja@cs.mtu.edu>; +Cc: legacy

Bruce Taneja. writes:
 > 
 > Now why does the GetAttributeByName() work OK w/o the 3rd param.
 > when running the overpaid(EMP) example in the 8.4.3 section (user manual)
 > and simply hangs when used w/o the 3rd param in the circle example .. !?

In general, if a function takes 3 arguments, and you pass it two, then
you really should expect trouble since it's going to go ahead and use
some randome system trash as it's third arg.  I'm not in a position to
go digging around in the source code to find out just what that
function does with that arg., but it's not surprising that giving it
something meaningless makes it blow up sometimes.

g.


==============================================================================
   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.
==============================================================================



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: " GetAttributeByName " ..
  1994-06-26 21:50 " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
  1994-06-27 06:18 ` Re: " GetAttributeByName " .. Paul M. Aoki <aoki@CS.Berkeley.EDU>
  1994-06-27 19:10   ` Re: " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
  1994-06-27 19:46     ` Re: " GetAttributeByName " .. George Hartzell <hartzell@postgres.Berkeley.EDU>
@ 1994-06-27 19:48       ` Bruce Taneja. <aataneja@cs.mtu.edu>
  1994-06-27 20:03         ` Re: " GetAttributeByName " .. Paul M. Aoki <aoki@CS.Berkeley.EDU>
  0 siblings, 1 reply; 6+ messages in thread

From: Bruce Taneja. @ 1994-06-27 19:48 UTC (permalink / raw)
  To: hartzell@postgres.Berkeley.EDU; +Cc: legacy

> 
> Bruce Taneja. writes:
>  > 
>  > Now why does the GetAttributeByName() work OK w/o the 3rd param.
>  > when running the overpaid(EMP) example in the 8.4.3 section (user manual)
>  > and simply hangs when used w/o the 3rd param in the circle example .. !?
> 
> In general, if a function takes 3 arguments, and you pass it two, then
> you really should expect trouble since it's going to go ahead and use
> some randome system trash as it's third arg.  I'm not in a position to
> go digging around in the source code to find out just what that
> function does with that arg., but it's not surprising that giving it
> something meaningless makes it blow up sometimes.


I think your explanation is quite clear and obvious and in fact goes
without saying .. 
  BUT .. WHY does the user manual do the example in sect.8.4.3. w/o the
 3rd param .. ??????  Was that a mistake ?? 
and what beats me is why did this example work while it failed for the 
circle.c ??

Bruce.

==============================================================================
   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.
==============================================================================



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: " GetAttributeByName " ..
  1994-06-26 21:50 " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
  1994-06-27 06:18 ` Re: " GetAttributeByName " .. Paul M. Aoki <aoki@CS.Berkeley.EDU>
  1994-06-27 19:10   ` Re: " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
  1994-06-27 19:46     ` Re: " GetAttributeByName " .. George Hartzell <hartzell@postgres.Berkeley.EDU>
  1994-06-27 19:48       ` Re: " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
@ 1994-06-27 20:03         ` Paul M. Aoki <aoki@CS.Berkeley.EDU>
  0 siblings, 0 replies; 6+ messages in thread

From: Paul M. Aoki @ 1994-06-27 20:03 UTC (permalink / raw)
  To: Bruce Taneja. <aataneja@cs.mtu.edu>; +Cc: hartzell@postgres.Berkeley.EDU; legacy

aataneja@cs.mtu.edu (Bruce Taneja.) writes:
> I think your explanation is quite clear and obvious and in fact goes
> without saying .. 
>   BUT .. WHY does the user manual do the example in sect.8.4.3. w/o the
>  3rd param .. ??????  Was that a mistake ?? 

well, as you say, this is quite clear and obvious.  yet another case of 
someone not updating the doc after changing an interface..

> and what beats me is why did this example work while it failed for the 
> circle.c ??

one of those mysteries of life.  i wouldn't spend much time thinking 
about it.
--
  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.
==============================================================================



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~1994-06-27 20:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1994-06-26 21:50 " GetAttributeByName " .. Bruce Taneja. <aataneja@cs.mtu.edu>
1994-06-27 06:18 ` Paul M. Aoki <aoki@CS.Berkeley.EDU>
1994-06-27 19:10   ` Bruce Taneja. <aataneja@cs.mtu.edu>
1994-06-27 19:46     ` George Hartzell <hartzell@postgres.Berkeley.EDU>
1994-06-27 19:48       ` Bruce Taneja. <aataneja@cs.mtu.edu>
1994-06-27 20:03         ` Paul M. Aoki <aoki@CS.Berkeley.EDU>

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