Re: Import Statistics in postgres_fdw before resorting to sampling.

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Etsuro Fujita <etsuro.fujita@gmail.com>
Cc: Corey Huinker <corey.huinker@gmail.com>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, Michael Paquier <michael@paquier.xyz>, pgsql-hackers@postgresql.org, jkatz@postgresql.org, nathandbossart@gmail.com
Date: 2026-04-12T18:15:00Z
Lists: pgsql-hackers
Etsuro Fujita <etsuro.fujita@gmail.com> writes:
> Pushed.  I closed the CF entry as well.

Coverity doesn't like this patch's uses of strncpy():

>>>     CID 1691464:           (BUFFER_SIZE)
>>>     Calling "strncpy" with a maximum size argument of 64 bytes on destination array "remattrmap[attrcnt].local_attname" of size 64 bytes might leave the destination string unterminated.
5960     		strncpy(remattrmap[attrcnt].local_attname, attname, NAMEDATALEN);
5961     		strncpy(remattrmap[attrcnt].remote_attname, remote_attname, NAMEDATALEN);

I think it's dead right to complain: remote_attname, in particular,
could certainly be longer than NAMEDATALEN.

AFAICS, postgres_fdw's subsequent uses of those strings only need
them to be nul-terminated C strings, so strncpy's property of
zero-filling the whole buffer is not needed here.  I recommend
s/strncpy/strlcpy/.

It's probably also appropriate to think about using pg_mbcliplen()
to ensure that this code doesn't result in a broken multibyte
character.

			regards, tom lane



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. postgres_fdw: Replace buffers in RemoteAttributeMapping with pointers.

  2. Add support for importing statistics from remote servers.