Subject: portal problems?

From: [email-masked] (Gregory Klein)
Date: Mon, 4 Nov 91 09:49:54 -0800

Is there a problem with multiple open-closes of the same portal?
The following test program freezes after just a couple of loops.
Any suggestions are appreciated.

Greg Klein
Lawrence Berkeley Laboratory

/*
 * program for a quick libpq test
 */
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include "libpq.h"
#include "petdata.h"

main(argc, argv)
    int             argc;
    char           *argv[];
{
    extern char    *PQhost;
    int i, j;

    PQhost = LBL_PQHOST;
    /* set the database name */
    PQsetdb("junk");

    for(i=1;i<30;i++) {
	j = new_file("Q900110");

    }

    PQfinish();
}

/* determine whether file is already in database */
int
new_file(fileid)
char *fileid;
{

    char 	   query[1024];
    PortalBuffer   *p;
    int             ntuples;
    char *exec_return;

    strcpy(query, "retrieve portal mportal (f.fileid) where ");
    strcat(query, "f.fileid~\"");
    strcat(query, fileid);
    strcat(query, "\"");

    PQexec("begin");
    exec_return = (char *)PQexec(query);
    PQexec("fetch all in mportal");
    p = PQparray("mportal");
    ntuples = PQntuples(p);
    PQexec("close mportal");
    PQexec("end");

printf(" ntuples=%d\n",ntuples);

    if (ntuples > 0)
	return (0);		/* patient already in database */
    else
	return (1);		/* i.e. new patient */
}

----------------------------------------------------------------------------
		 Test database monitor output:

* create f (fileid=text) \g

Query sent to backend is "create f (fileid=text) "
CREATE
Go
* append f (fileid="Q900110B") \g

Query sent to backend is "append f (fileid="Q900110B") "
APPEND
Go
* append f (fileid="Q900110C") \g

Query sent to backend is "append f (fileid="Q900110C") "
APPEND
Go
* append f (fileid="Q900110D") \g

Query sent to backend is "append f (fileid="Q900110D") "
APPEND
Go
* retrieve (f.all) \g

Query sent to backend is "retrieve (f.all) "
---------------
| fileid      |
---------------
| Q900110B    |
---------------
| Q900110C    |
---------------
| Q900110D    |
---------------

			End of monitor Output
----------------------------------------------------------------------------

---

From: postarch (Postgres Mailing Archive)
Date: Mon, 11 Nov 91 12:37:04 PST

> Any suggestions are appreciated.

stuff deleted...

> printf(" ntuples=%d\n",ntuples);

This appears to be related to memory bug we're having with the
operator ~ and text attributes.  If you run this same query with 
f.fieldid defined as char16 it works every time.  This will be 
fixed in 3.1

Jeff Meredith
[email-masked]