Re: OID from insert has extra letter - Mailing list pgsql-hackers

From Tom Lane
Subject Re: OID from insert has extra letter
Date
Msg-id 22707.981425865@sss.pgh.pa.us
Whole thread Raw
In response to OID from insert has extra letter  (darcy@druid.net (D'Arcy J.M. Cain))
Responses Re: OID from insert has extra letter
List pgsql-hackers
darcy@druid.net (D'Arcy J.M. Cain) writes:
> Get: 31930584, should be 3193058
> Get: 31943386, should be 3194338

> As you can see, there is an extra digit added.  I am using PQoidStatus()
> to get the OID.  Is this the right way?  Is it possible that there is
> a buffer/terminating problem in the insert code?

Yes, on looking at it I see that someone broke PQoidStatus() in 7.0.
If you want to fix your copy, the patch (line numbers are for current
CVS) is

Index: fe-exec.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v
retrieving revision 1.98
retrieving revision 1.100
diff -c -r1.98 -r1.100
*** fe-exec.c    2001/01/24 19:43:30    1.98
--- fe-exec.c    2001/02/06 02:02:27    1.100
***************
*** 2035,2041 ****     if (len > 23)         len = 23;     strncpy(buf, res->cmdStatus + 7, len);
!     buf[23] = '\0';      return buf; }
--- 2035,2041 ----     if (len > 23)         len = 23;     strncpy(buf, res->cmdStatus + 7, len);
!     buf[len] = '\0';      return buf; }


However, really I'd recommend using PQoidValue() and not PQoidStatus()
at all.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Mitch Vincent"
Date:
Subject: Re: Re: PostgreSQL -> PHP problem
Next
From: Tom Lane
Date:
Subject: Re: with -g and libpq.a ...