agora inbox for postgres@postgres.berkeley.edu  
help / color / mirror / Atom feed
pgperl for 4.2?
5+ messages / 3 participants
[nested] [flat]

* pgperl for 4.2?
@ 1994-06-08 22:38  Robert Joop <rj@rainbow.in-berlin.de>
  0 siblings, 1 reply; 5+ messages in thread

From: Robert Joop @ 1994-06-08 22:38 UTC (permalink / raw)
  To: legacy

hi *,

has pgperl been ported to postgres 4.2 (and perl 4.036) already?

the code that's in 4.2's contrib can't be compiled because a symbol's
name (and meaning) has changed (it is commented out in a header file,
and substituting it with another #define that appears to have a similar
meaning, PORTALS_INITIAL_SIZE, leads to a pgperl that gets a SEGVIOL
during the `bmake runtest`. (actually, you'll only see this output if
you call `./pgperl testlibpq.pl` directly, because the pipe to tee
won't get flushed...):

~postgres/v4r2/src/contrib/pgperl> ./pgperl testlibpq.pl
Destroying database pgperltest
Creating database pgperltest
Accessing database pgperltest

Creating relation person:
query = create person (name = char16, age = int4, location = point)

Relation person before appends:
New tuple group:
name           age            location       

Appending to relation person:
query = append person (name = "fred", age = 50, location = "(50,10)"::point)
[...10 lines deleted...]

Relation person after appends:
New tuple group:
name           age            location       
fred           50             (50,10)        
[...10 lines deleted...]

Testing copy:

Relation person after copy:
New tuple group:
name           age            location       
fred           50             (50,10)        
[...12 lines deleted...]
sally          39             (5,6)          

Testing other things:
Opening 2 portals:
Number of portals open: 2
Segmentation fault
~postgres/v4r2/src/contrib/pgperl> 
)

so, if anybody already made the fix, please tell us about it!

best,
 rj

==============================================================================
   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] 5+ messages in thread

* Re: pgperl for 4.2?
@ 1994-06-16 11:40  Paul M. Aoki <aoki@CS.Berkeley.EDU>
  parent: Robert Joop <rj@rainbow.in-berlin.de>
  0 siblings, 0 replies; 5+ messages in thread

From: Paul M. Aoki @ 1994-06-16 11:40 UTC (permalink / raw)
  To: Robert Joop <rj@rainbow.in-berlin.de>; +Cc: legacy

rj@rainbow.in-berlin.de (Robert Joop) writes:
> the code that's in 4.2's contrib can't be compiled because a symbol's
> name (and meaning) has changed (it is commented out in a header file,
> and substituting it with another #define that appears to have a similar
> meaning, PORTALS_INITIAL_SIZE, leads to a pgperl that gets a SEGVIOL
> during the `bmake runtest`. 

this is my cheap hack for dealing with it.  your actual mileage, as 
always, may vary.

*** 1.5	1993/06/14 19:47:35
--- pg-libpq.mus	1994/06/16 11:41:10
***************
*** 1,7 ****
  /*
   * Interface to Postgres from Perl
   *
!  * $Header: /faerie/aoki/postgres/src/contrib/pgperl/RCS/pg-libpq.mus,v 1.5 1993/06/14 19:47:35 aoki Exp $
   */
  
  /* 
--- 1,7 ----
  /*
   * Interface to Postgres from Perl
   *
!  * $Header: /home2/aoki/master/src/contrib/pgperl/RCS/pg-libpq.mus,v 1.7 1994/06/16 11:37:21 aoki Exp $
   */
  
  /* 
***************
*** 47,52 ****
--- 47,58 ----
  #include "tmp/libpq.h"
  #include "tmp/libpq-fe.h"	/* superset of ones also in libpq-be.h */
  
+ #ifdef PORTNAME_ultrix4
+ #include "config.h"
+ #undef HAS_MEMCPY
+ #undef HAS_MEMSET
+ #endif /* PORTNAME_ultrix4 */
+ 
  #include "EXTERN.h"
  #include "perl.h"
  
***************
*** 400,436 ****
  	if (items != 1)
  	    fatal("Usage: &PQpnames($rule_p)");
  	else {
! 	    int nnames;
! 	    char portalnames[MAXPORTALS][PortalNameLength];
! 	    char *pnames[MAXPORTALS];
! 	    int		rule_p =	(int)		str_gnum(st[1]);
  
  	    /* Fill in the pname array */
!             {
! 	      int i;
!               for (i = 0; i < MAXPORTALS; i += 1) {
!                 pnames[i] = portalnames[i];
!               }
!             }
! 
! 	    (void)PQpnames(pnames, rule_p);
! 
! 	    /* Count the number of strings */
! 	    for (nnames = 0; pnames[nnames] != NULL; nnames += 1);
  
  	    /* Return an array of strings */
  	    if (nnames <= 0) {
  	      st[0] = str_2mortal(str_make("",0));
! 	      return sp;
              } else {
- 	      int i;
  	      astore(stack, sp + nnames, NULL); /* force stack to grow */
  	      st = stack->ary_array + sp;  /* stack may have changed */
  	      for (i = 1; i <= nnames; i++) {
  		  st[i-1] = str_2mortal(str_make( pnames[i-1], 0 ));
  	      }
! 	      return sp + nnames - 1;
              }
  	}
  
  /*
--- 406,451 ----
  	if (items != 1)
  	    fatal("Usage: &PQpnames($rule_p)");
  	else {
! 	    int i, nnames, nportals;
! 	    char *p, *portalnames, **pnames;
! 	    int rule_p = (int) str_gnum(st[1]);
! 
! 	    /* Figure out the maximum number of portals we might have */
! 	    nportals = PQnportals(rule_p);
! 	    pnames = (char **) calloc(nportals, sizeof(char *));
! 	    portalnames = (char *) calloc(nportals, PortalNameLength + 1);
  
  	    /* Fill in the pname array */
! 	    for (i = 0, p = portalnames; i < nportals;
! 		 ++i, p += PortalNameLength + 1) {
! 		pnames[i] = p;
! 	    }
! 
! 	    PQpnames(pnames, rule_p);
! 
! 	    /* Count the number of valid strings */
! 	    nnames = 0;
! 	    for (i = 0; i < nportals; ++i) {
! 		if (pnames[i] && *pnames[i])
! 		    /* We don't care about the blank portal */
! 		    ++nnames;
! 	    }
  
  	    /* Return an array of strings */
  	    if (nnames <= 0) {
  	      st[0] = str_2mortal(str_make("",0));
! 	      i = sp;
              } else {
  	      astore(stack, sp + nnames, NULL); /* force stack to grow */
  	      st = stack->ary_array + sp;  /* stack may have changed */
  	      for (i = 1; i <= nnames; i++) {
  		  st[i-1] = str_2mortal(str_make( pnames[i-1], 0 ));
  	      }
! 	      i = sp + nnames - 1;
              }
+ 	    free(portalnames);
+ 	    free(pnames);
+ 	    return(i);
  	}
  
  /*
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  aoki@CS.Berkeley.EDU
                |  Berkeley, CA 94720           |  ...!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] 5+ messages in thread

* Re: pgperl for 4.2?
@ 1994-06-22 00:21  J. Douglas Dunlop <dunlop@ists.ists.ca>
  0 siblings, 1 reply; 5+ messages in thread

From: J. Douglas Dunlop @ 1994-06-22 00:21 UTC (permalink / raw)
  To: legacy

Postgres users:

rj@rainbow.in-berlin.de (Robert Joop) writes:
>> the code that's in 4.2's contrib can't be compiled because a symbol's
>> name (and meaning) has changed (it is commented out in a header file,
>> and substituting it with another #define that appears to have a similar
>> meaning, PORTALS_INITIAL_SIZE, leads to a pgperl that gets a SEGVIOL
>> during the `bmake runtest`.

And Paul M. Aoki replies:
>this is my cheap hack for dealing with it.  your actual mileage, as
>always, may vary.

Sorry to say that my mileage did vary. I didn't have the problem that
Robert Joop had running under HP-UX 9.03 with postgres v4r2beta. What
follows are 2 versions of the output from testlibpg.pl.

First I did substitute PORTALS_INITIAL_SIZE for MAXPORTALS as Robert tried
and things seems to work fine. (I arrived at this work-around even before I
saw Robert's post.) Next I applied Paul Aoki's patch and then I did have
the exact problem that Robert describes. And no I don't have the 2 results
mixed up.

Notice that where the error occurs following "Portal names:" I do get a
bunch of extra commas, but the test seems to pass. Am I missing something?

So you might ask if you weren't having a problem then why try to fix it.
Well it did strike me that the MAXPORTALS being dynamic now should not be
set to a fixed value even if it did pass this fairly simple test. I figured
that pgperl was likely to break if a gave it some real work to do. Paul's
patch seemed to address this issue.

Regards,
Doug

---- Output from pgperl testlibpq.pl using MAXPORTALS -> PORTALS_INITIAL_SIZE
eol 48: testlibpq.pl
Destroying database pgperltest
Creating database pgperltest
Accessing database pgperltest

Creating relation person:
query = create person (name = char16, age = int4, location = point)

Relation person before appends:
New tuple group:
name           age            location

Appending to relation person:
query = append person (name = "fred", age = 50, location = "(50,10)"::point)
query = append person (name = "fred", age = 60, location = "(60,10)"::point)
query = append person (name = "fred", age = 70, location = "(70,10)"::point)
query = append person (name = "fred", age = 80, location = "(80,10)"::point)
query = append person (name = "fred", age = 90, location = "(90,10)"::point)
query = append person (name = "fred", age = 100, location = "(100,10)"::point)
query = append person (name = "fred", age = 110, location = "(110,10)"::point)
query = append person (name = "fred", age = 120, location = "(120,10)"::point)
query = append person (name = "fred", age = 130, location = "(130,10)"::point)
query = append person (name = "fred", age = 140, location = "(140,10)"::point)
query = append person (name = "fred", age = 150, location = "(150,10)"::point)

Relation person after appends:
New tuple group:
name           age            location
fred           50             (50,10)
fred           60             (60,10)
fred           70             (70,10)
fred           80             (80,10)
fred           90             (90,10)
fred           100            (100,10)
fred           110            (110,10)
fred           120            (120,10)
fred           130            (130,10)
fred           140            (140,10)
fred           150            (150,10)

Testing copy:

Relation person after copy:
New tuple group:
name           age            location
fred           50             (50,10)
fred           60             (60,10)
fred           70             (70,10)
fred           80             (80,10)
fred           90             (90,10)
fred           100            (100,10)
fred           110            (110,10)
fred           120            (120,10)
fred           130            (130,10)
fred           140            (140,10)
fred           150            (150,10)
bill           21             (1,2)
bob            61             (3,4)
sally          39             (5,6)

Testing other things:
Opening 2 portals:
Number of portals open: 2
Portal names: eportal, fportal, , , , , , , , , , , , , , , , , , , , , , , , ,
, , , , , .
Portal eportal is not asynchronous.
Portal eportal has 14 tuples.
Portal eportal has 14 instances.
Portal eportal has 1 groups.
Portal eportal group 0 has 14 instances.
Portal eportal tuple 0 has 3 fields.
Portal eportal tuple 0 field 2 is 7 bytes long.
Portal eportal tuple 0 field 2 is type 600.
Portal eportal tuple 0 is in group 0.
Portal eportal tuple 0 field "location" is index 2.
Portal eportal tuple 0 field 1 is name "age".
Portal eportal tuples 0 and 1 are the same type.
Portal eportal group 0 field "location" is index 2.
Closing 2 portals:
Number of portals open: 0
Portal names: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , .

Removing from relation person:
query = delete person where person.age = 50
query = delete person where person.age = 60
query = delete person where person.age = 70
query = delete person where person.age = 80
query = delete person where person.age = 90
query = delete person where person.age = 100
query = delete person where person.age = 110
query = delete person where person.age = 120
query = delete person where person.age = 130
query = delete person where person.age = 140
query = delete person where person.age = 150

Relation person after removes:
New tuple group:
name           age            location
bill           21             (1,2)
bob            61             (3,4)
sally          39             (5,6)

Printing values of global variables:
PQhost = "localhost"
PQport = "4321"
PQtty = "/dev/null"
PQoption = ""
PQdatabase = "pgperltest"
PQportset = 1
PQxactid = 0
PQtracep = 0
PQerrormsg = ""

Tests complete!

---- Output from pgperl testlibpq.pl after applying Paul's patch ---
eol 58: testlibpq.pl
Destroying database pgperltest
Creating database pgperltest
Accessing database pgperltest

Creating relation person:
query = create person (name = char16, age = int4, location = point)

Relation person before appends:
New tuple group:
name           age            location

Appending to relation person:
query = append person (name = "fred", age = 50, location = "(50,10)"::point)
query = append person (name = "fred", age = 60, location = "(60,10)"::point)
query = append person (name = "fred", age = 70, location = "(70,10)"::point)
query = append person (name = "fred", age = 80, location = "(80,10)"::point)
query = append person (name = "fred", age = 90, location = "(90,10)"::point)
query = append person (name = "fred", age = 100, location = "(100,10)"::point)
query = append person (name = "fred", age = 110, location = "(110,10)"::point)
query = append person (name = "fred", age = 120, location = "(120,10)"::point)
query = append person (name = "fred", age = 130, location = "(130,10)"::point)
query = append person (name = "fred", age = 140, location = "(140,10)"::point)
query = append person (name = "fred", age = 150, location = "(150,10)"::point)

Relation person after appends:
New tuple group:
name           age            location
fred           50             (50,10)
fred           60             (60,10)
fred           70             (70,10)
fred           80             (80,10)
fred           90             (90,10)
fred           100            (100,10)
fred           110            (110,10)
fred           120            (120,10)
fred           130            (130,10)
fred           140            (140,10)
fred           150            (150,10)

Testing copy:

Relation person after copy:
New tuple group:
name           age            location
fred           50             (50,10)
fred           60             (60,10)
fred           70             (70,10)
fred           80             (80,10)
fred           90             (90,10)
fred           100            (100,10)
fred           110            (110,10)
fred           120            (120,10)
fred           130            (130,10)
fred           140            (140,10)
fred           150            (150,10)
bill           21             (1,2)
bob            61             (3,4)
sally          39             (5,6)

Testing other things:
Opening 2 portals:
Number of portals open: 2
Segmentation fault (core dumped)

---- End of output ----


Doug
________
                       Earth Observations Lab
    _/_/_/ _/_/_/ _/   Institute for Space and Terrestrial Sciences
   _/     _/  _/ _/    4850 Keele St.,2nd Floor
  _/_/   _/  _/ _/     North York, Ontario
 _/     _/  _/ _/      Canada,M3J-3K1           dunlop@ists.ists.ca
_/_/_/ _/_/_/ _/_/_/   W:416-665-5411 H:705-445-9320 F:416-665-2032
                       http://www.eol.ists.ca/~dunlop/dunlop.html



==============================================================================
   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] 5+ messages in thread

* Re: pgperl for 4.2?
@ 1994-06-22 01:35  Paul M. Aoki <aoki@CS.Berkeley.EDU>
  parent: J. Douglas Dunlop <dunlop@ists.ists.ca>
  0 siblings, 0 replies; 5+ messages in thread

From: Paul M. Aoki @ 1994-06-22 01:35 UTC (permalink / raw)
  To: J. Douglas Dunlop <dunlop@ists.ists.ca>; +Cc: legacy

dunlop@ists.ists.ca (J. Douglas Dunlop) writes:
> >this is my cheap hack for dealing with it.  your actual mileage, as
> >always, may vary.
> Sorry to say that my mileage did vary.

you might have missed this patch for src/backend/libpq/portal.c that 
was mumbled-about a few months ago.

(i have thus far successfully resisted getting organized about patches..
i know it's inconvenient, sorry.)

*** 1.18	1994/02/01 20:39:07
--- 1.19	1994/04/21 20:36:58
***************
*** 50,56 ****
   *	see utils/mmgr/portalmem.c for why. -cim 2/22/91
   *
   *   IDENTIFICATION
!  *	$Header: /faerie/aoki/postgres/src/backend/libpq/RCS/portal.c,v 1.18 1994/02/01 20:39:07 jolly Exp $
   * ----------------------------------------------------------------
   */
  
--- 50,56 ----
   *	see utils/mmgr/portalmem.c for why. -cim 2/22/91
   *
   *   IDENTIFICATION
!  *	$Header: /faerie/aoki/postgres/src/backend/libpq/RCS/portal.c,v 1.19 1994/04/21 20:36:58 aoki Exp $
   * ----------------------------------------------------------------
   */
  
***************
*** 61,67 ****
  #include "tmp/libpq.h"
  #include "utils/exc.h"
  
! RcsId("$Header: /faerie/aoki/postgres/src/backend/libpq/RCS/portal.c,v 1.18 1994/02/01 20:39:07 jolly Exp $");
  
  /* ----------------
   *	exceptions
--- 61,67 ----
  #include "tmp/libpq.h"
  #include "utils/exc.h"
  
! RcsId("$Header: /faerie/aoki/postgres/src/backend/libpq/RCS/portal.c,v 1.19 1994/04/21 20:36:58 aoki Exp $");
  
  /* ----------------
   *	exceptions
***************
*** 190,196 ****
--- 190,202 ----
  /* --------------------------------
   *	PQpnames - Return all the portal names
   * 	If rule_p, only return asynchronous portals. 
+  *
   *         the caller must have allocated sufficient memory for char** pnames
+  *	   (an array of PQnportals strings of length PortalNameLength).
+  *
+  *	   notice that this assumes that the user is calling PQnportals and
+  *	   PQpnames with the same rule_p argument, and with no intervening
+  *	   portal closures.  if not, you can get in heap big trouble..
   * --------------------------------
   */
  void
***************
*** 198,204 ****
      char **pnames;
      int rule_p;
  {
!     int i;
      
      if (!valid_pointer("PQpnames: invalid name buffer", pnames))
  	return;
--- 204,210 ----
      char **pnames;
      int rule_p;
  {
!     int i, cur_pname = 0;
      
      if (!valid_pointer("PQpnames: invalid name buffer", pnames))
  	return;
***************
*** 206,216 ****
      for (i = 0; i < portals_array_size; ++i) {
  	if (portals[i] && portals[i]->portal) {
  	    if (!rule_p || portals[i]->portal->rule_p) {
! 		(void) strncpy(pnames[i], portals[i]->name, PortalNameLength);
! 		continue;
  	    }
  	}
- 	pnames[i][0] = '\0';
      }
  }
  
--- 212,221 ----
      for (i = 0; i < portals_array_size; ++i) {
  	if (portals[i] && portals[i]->portal) {
  	    if (!rule_p || portals[i]->portal->rule_p) {
! 		(void) strncpy(pnames[cur_pname], portals[i]->name, PortalNameLength);
! 		++cur_pname;
  	    }
  	}
      }
  }
  
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  aoki@CS.Berkeley.EDU
                |  Berkeley, CA 94720           |  ...!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] 5+ messages in thread

* Re: pgperl for 4.2?
@ 1994-06-22 03:06  J. Douglas Dunlop <dunlop@ists.ists.ca>
  0 siblings, 0 replies; 5+ messages in thread

From: J. Douglas Dunlop @ 1994-06-22 03:06 UTC (permalink / raw)
  To: legacy

Dear Postgres users:

To followup my last posting which said:
>Sorry to say that my mileage did vary. I didn't have the problem that
>Robert Joop had running under HP-UX 9.03 with postgres v4r2beta. What
>follows are 2 versions of the output from testlibpg.pl.
>
>First I did substitute PORTALS_INITIAL_SIZE for MAXPORTALS as Robert tried
>and things seems to work fine. (I arrived at this work-around even before I
>saw Robert's post.) Next I applied Paul Aoki's patch and then I did have
>the exact problem that Robert describes. And no I don't have the 2 results
>mixed up.

I have now received an additional patch from Paul Aoki which I had
previously missed. This patches src/backend/libpq/portal.c. After applying
this patch and using the patch for pg-libpq.mus which he also posted I now
have pgperl working even better than before. By that I mean that the
difference between my output and the sample output is null, whereas before
I got differences that I thought were unimportant.

Thanks for all your help Paul!

Regards,

Doug
________
                       Earth Observations Lab
    _/_/_/ _/_/_/ _/   Institute for Space and Terrestrial Sciences
   _/     _/  _/ _/    4850 Keele St.,2nd Floor
  _/_/   _/  _/ _/     North York, Ontario
 _/     _/  _/ _/      Canada,M3J-3K1           dunlop@ists.ists.ca
_/_/_/ _/_/_/ _/_/_/   W:416-665-5411 H:705-445-9320 F:416-665-2032
                       http://www.eol.ists.ca/~dunlop/dunlop.html



==============================================================================
   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] 5+ messages in thread


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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1994-06-08 22:38 pgperl for 4.2? Robert Joop <rj@rainbow.in-berlin.de>
1994-06-16 11:40 ` Paul M. Aoki <aoki@CS.Berkeley.EDU>
1994-06-22 00:21 Re: pgperl for 4.2? J. Douglas Dunlop <dunlop@ists.ists.ca>
1994-06-22 01:35 ` Paul M. Aoki <aoki@CS.Berkeley.EDU>
1994-06-22 03:06 Re: pgperl for 4.2? J. Douglas Dunlop <dunlop@ists.ists.ca>

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