Subject: Re: pgperl for 4.2?

From: [email-masked] (J. Douglas Dunlop)
Date: Tue, 21 Jun 1994 20:21:46 -0400

Postgres users:

[email-masked] (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           [email-masked]
_/_/_/ _/_/_/ _/_/_/   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 "[email-masked]"

   If this fails, send mail to "[email-masked]" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================

---

From: [email-masked] (Paul M. Aoki)
Date: Tue, 21 Jun 94 18:35:37 -0700

[email-masked] (J. Douglas Dunlop) writes:
> 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  |  [email-masked]
                |  Berkeley, CA 94720           |  ...!uunet!ucbvax!aoki