Re: OID from insert has extra letter

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: OID from insert has extra letter
Date: 2001-02-07 00:51:06
Message-ID: 26680.981507066@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Ross J. Reedstrom" <reedstrm(at)rice(dot)edu> writes:
> Seems it's a non-portable behavior:

Not at all. The code is asking strncpy to copy n bytes, where n is
known to be <= strlen of the source string. Every spec-conforming
implementation of strncpy will copy n bytes, no more, no less, and
will *not* add a trailing null after them. The only reason the code
appeared to work is that it was dealing with a static buffer that
starts out all zeroes, so the trailing null was already in place.
Until the buffer had been used for a longer OID, that is.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-02-07 00:52:27 Re: Duplicate OIDs in pg_attribute
Previous Message Bruce Momjian 2001-02-07 00:50:42 Re: Include files for SPI are not installed