Return-Path: owner-postman Delivery-Date: Mon, 09 May 94 18:32:56 -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 QAA02450 for postgres-redist; Mon, 9 May 1994 16:07:37 -0700 Resent-From: POSTGRES mailing list Resent-Message-Id: <199405092307.QAA02450@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 QAA02440 for ; Mon, 9 May 1994 16:07:36 -0700 Received: from localhost (localhost [127.0.0.1]) by faerie.CS.Berkeley.EDU (8.6.4/8.1B) with SMTP id QAA29229; Mon, 9 May 1994 16:07:31 -0700 Message-Id: <199405092307.QAA29229@faerie.CS.Berkeley.EDU> X-Authentication-Warning: faerie.CS.Berkeley.EDU: Host localhost didn't use HELO protocol From: aoki@postgres.Berkeley.EDU (Paul M. Aoki) To: "Patrick M. Landry" Cc: postgres@postgres.Berkeley.EDU Subject: Re: PQpnames help Reply-To: aoki@postgres.Berkeley.EDU (Paul M. Aoki) In-reply-to: Your message of Mon, 9 May 1994 09:03:26 -0500 <199405091403.AA06404@console.cacs.usl.edu> Date: Mon, 09 May 94 16:07:31 -0700 X-Sender: aoki@postgres.Berkeley.EDU Resent-To: postgres-redist@postgres.Berkeley.EDU X-Mts: smtp Resent-Date: Mon, 09 May 94 16:07:37 -0700 Resent-XMts: smtp "Patrick M. Landry" writes: > Could someone post a code fragment demostrating the use of PQpnames? > I am trying to compile pgperl with postgres4.2. The regression tests > don't seem to deal with PQpnames. Thanks someone pointed out to us that you can't use the PQpnames that's there without using portals_array_size, which is not the documented interface. dooh. (it was extended to allow variable numbers of portals, since the previous limit was just 10.) so this is the hack i came up with (it's for src/backend/libpq/portal.c). i think it matches the documented interface. *** 1.18 1994/02/01 20:39:07 --- portal.c 1994/04/21 20:39:45 *************** *** 50,56 **** * see utils/mmgr/portalmem.c for why. -cim 2/22/91 * * IDENTIFICATION ! * $Header: /usr/local/devel/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: /usr/local/devel/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: /usr/local/devel/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: /usr/local/devel/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@postgres.Berkeley.EDU | Berkeley, CA 94720 | ...!uunet!ucbvax!aoki =============================================================================== To add/remove yourself 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. ===============================================================================