Обсуждение: backend -> interface communication

Поиск
Список
Период
Сортировка

backend -> interface communication

От
Hankin
Дата:
how is a notice sent from the backend?
does it send a Nxxxxx\n  or a VNxxxxx\n ??

Whenever I do a lo_close() I get a NOTICE: tablerelease: no lock found.
and PQfn() tries to read a VNxxxxx\n  when the backend sends a Nxxxxx\n

Re: [HACKERS] backend -> interface communication

От
Peter T Mount
Дата:
On Tue, 3 Mar 1998, Hankin wrote:

> how is a notice sent from the backend?
> does it send a Nxxxxx\n  or a VNxxxxx\n ??
>
> Whenever I do a lo_close() I get a NOTICE: tablerelease: no lock found.
> and PQfn() tries to read a VNxxxxx\n  when the backend sends a Nxxxxx\n

This last bit sounds familiar. I thought it was fixed a long time ago
(after I noticed it while implementing PQfn in Java)

--
Peter T Mount  petermount@earthling.net or pmount@maidast.demon.co.uk
Main Homepage: http://www.demon.co.uk/finder
Work Homepage: http://www.maidstone.gov.uk Work EMail: peter@maidstone.gov.uk


Re: [HACKERS] backend -> interface communication

От
Hankin
Дата:
Peter T Mount wrote:
>
> On Tue, 3 Mar 1998, Hankin wrote:
>
> > how is a notice sent from the backend?
> > does it send a Nxxxxx\n  or a VNxxxxx\n ??
> >
> > Whenever I do a lo_close() I get a NOTICE: tablerelease: no lock found.
> > and PQfn() tries to read a VNxxxxx\n  when the backend sends a Nxxxxx\n
>
> This last bit sounds familiar. I thought it was fixed a long time ago
> (after I noticed it while implementing PQfn in Java)


here's a program that duplicates it on my computer...


#include <libpq-fe.h>
#include <libpq/libpq-fs.h>

main()
{
        PGconn *connection;
        PGresult *result;
        Oid oid;
        int handle;
        char buf[1024];

        memset(buf,-1,sizeof(buf));

        connection=PQsetdb(NULL,NULL,NULL,NULL,NULL);
        if(connection==NULL) { exit(-1); }
        PQtrace(connection,stderr);
        oid=lo_creat(connection,INV_WRITE);
fprintf(stderr,"lo_creat: %s\n",PQerrorMessage(connection));
        handle=lo_open(connection,oid,INV_WRITE);
fprintf(stderr,"lo_open: %s\n",PQerrorMessage(connection));
        lo_write(connection,handle,buf,sizeof(buf));
fprintf(stderr,"lo_write: %s\n",PQerrorMessage(connection));
        lo_write(connection,handle,buf,sizeof(buf));
fprintf(stderr,"lo_write: %s\n",PQerrorMessage(connection));
        lo_close(connection,handle);
fprintf(stderr,"lo_close: %s\n",PQerrorMessage(connection));
        result=PQexec(connection,"select aaa from test");
        if(result==NULL || PQresultStatus(result)!=PGRES_TUPLES_OK) {
fprintf(stderr,"fail: %s\n",PQerrorMessage(connection)); }
        PQfinish(connection);
}

Re: [HACKERS] backend -> interface communication

От
Peter T Mount
Дата:
On Tue, 3 Mar 1998, Hankin wrote:

> Peter T Mount wrote:
> >
> > On Tue, 3 Mar 1998, Hankin wrote:
> >
> > > how is a notice sent from the backend?
> > > does it send a Nxxxxx\n  or a VNxxxxx\n ??
> > >
> > > Whenever I do a lo_close() I get a NOTICE: tablerelease: no lock found.
> > > and PQfn() tries to read a VNxxxxx\n  when the backend sends a Nxxxxx\n
> >
> > This last bit sounds familiar. I thought it was fixed a long time ago
> > (after I noticed it while implementing PQfn in Java)
>
>
> here's a program that duplicates it on my computer...

aha, try enclosing everything in a transaction. When I tried the
following:

> #include <libpq-fe.h>
> #include <libpq/libpq-fs.h>
>
> main()
> {
>         PGconn *connection;
>         PGresult *result;
>         Oid oid;
>         int handle;
>         char buf[1024];
>
>         memset(buf,-1,sizeof(buf));
>
>         connection=PQsetdb(NULL,NULL,NULL,NULL,NULL);
>         if(connection==NULL) { exit(-1); }
>         PQtrace(connection,stderr);

result=PQexec(connection,"begin");
if(result==NULL) {exit(-1);}

> oid=lo_creat(connection,INV_WRITE);
> fprintf(stderr,"lo_creat: %s\n",PQerrorMessage(connection));
>         handle=lo_open(connection,oid,INV_WRITE);
> fprintf(stderr,"lo_open: %s\n",PQerrorMessage(connection));
>         lo_write(connection,handle,buf,sizeof(buf));
> fprintf(stderr,"lo_write: %s\n",PQerrorMessage(connection));
>         lo_write(connection,handle,buf,sizeof(buf));
> fprintf(stderr,"lo_write: %s\n",PQerrorMessage(connection));
>         lo_close(connection,handle);
> fprintf(stderr,"lo_close: %s\n",PQerrorMessage(connection));
>         result=PQexec(connection,"select aaa from test");
>         if(result==NULL || PQresultStatus(result)!=PGRES_TUPLES_OK) {
> fprintf(stderr,"fail: %s\n",PQerrorMessage(connection)); }

result=PQexec(connection,"end");
if(result==NULL) {exit(-1);}

>         PQfinish(connection);
> }

This then works fine (except that my test database doesn't contain a test
table, so it fails on the select). Removing the select, and it works.

All large object operations need to be in a transaction.

--
Peter T Mount  petermount@earthling.net or pmount@maidast.demon.co.uk
Main Homepage: http://www.demon.co.uk/finder
Work Homepage: http://www.maidstone.gov.uk Work EMail: peter@maidstone.gov.uk