Re: OID from insert has extra letter

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: OID from insert has extra letter
Date: 2001-02-06 02:17:45
Message-ID: 22707.981425865@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

darcy(at)druid(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-02-06 02:21:36 Re: with -g and libpq.a ...
Previous Message Mitch Vincent 2001-02-06 02:12:19 Re: Re: PostgreSQL -> PHP problem