Thread

  1. Re: Import Statistics in postgres_fdw before resorting to sampling.

    Etsuro Fujita <etsuro.fujita@gmail.com> — 2026-05-12T11:36:25Z

    On Fri, May 1, 2026 at 3:04 AM Corey Huinker <corey.huinker@gmail.com> wrote:
    > I've attached 2 different fixes.
    
    Thanks for the patches!
    
    > The first one swtiches to pg_mbcliplen+memcpy, which is probably overkill but better safe than sorry.
    
    I noticed that RemoteAttributeMapping.remote_attname is used in
    match_attrmap(), which assumes that it fully contains a remote
    attribute's name, so I think this solution is actually unsafe.
    
    > The second gets rid of the string buffers entirely, and instead frees the nested object.
    >
    > I have no preference between the two, though I suspect that the nested-free solution will be preferred by the community.
    
    ISTM that the second solution is the right direction to go in.
    
    +static void
    +free_remattrmap(RemoteAttributeMapping *map, int len)
    +{
    +   if (!map)
    +       return;
    +
    +   for (int i = 0; i < len; i++)
    +   {
    +       if (map[i].local_attname)
    +           pfree(map[i].local_attname);
    +       if (map[i].remote_attname)
    +           pfree(map[i].remote_attname);
    +   }
    
    The if tests for local_attname/remote_attname should be assertions?
    
    It took more time than expected to return to this issue.  My apologies for that.
    
    Best regards,
    Etsuro Fujita