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 26680.981507066@sss.pgh.pa.us
Whole thread Raw
In response to Re: OID from insert has extra letter  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
List pgsql-hackers
"Ross J. Reedstrom" <reedstrm@rice.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


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Include files for SPI are not installed
Next
From: Bruce Momjian
Date:
Subject: Re: Duplicate OIDs in pg_attribute