Re: subplan resets wrong hashtable - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: subplan resets wrong hashtable
Date
Msg-id 20200210045308.GD1412@telsasoft.com
Whole thread Raw
In response to Re: subplan resets wrong hashtable  (Andres Freund <andres@anarazel.de>)
Responses Re: subplan resets wrong hashtable
List pgsql-hackers
On Sun, Feb 09, 2020 at 08:01:26PM -0800, Andres Freund wrote:
> Ugh, that indeed looks wrong. Did you check whether it can actively
> cause wrong query results? If so, did you do theoretically, or got to a
> query returning wrong results?

Actually .. I can "theoretically" prove that there's no wrong results from that
patch...since in that file it has no effect, the tested variables being zeroed
few lines earlier:

 @@ -499,51 +499,60 @@ buildSubPlanHash(SubPlanState *node, ExprContext *econtext)
*        node->hashtable = NULL;
*        node->hashnulls = NULL;
         node->havehashrows = false;
         node->havenullrows = false;
  
         nbuckets = (long) Min(planstate->plan->plan_rows, (double) LONG_MAX);
         if (nbuckets < 1)
                 nbuckets = 1;
  
 -       node->hashtable = BuildTupleHashTable(node->parent,
 -                                                                                 node->descRight,
 -                                                                                 ncols,
 -                                                                                 node->keyColIdx,
 -                                                                                 node->tab_eq_funcoids,
 -                                                                                 node->tab_hash_funcs,
 -                                                                                 nbuckets,
 -                                                                                 0,
 -                                                                                 node->hashtablecxt,
 -                                                                                 node->hashtempcxt,
 -                                                                                 false);
*+       if (node->hashtable)
 +               ResetTupleHashTable(node->hashtable);
 +       else
 +               node->hashtable = BuildTupleHashTableExt(node->parent,
 
 ...
*+               if (node->hashnulls)
 +                       ResetTupleHashTable(node->hashtable);
 +               else
 +                       node->hashnulls = BuildTupleHashTableExt(node->parent,
 +
node->descRight,





pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: Identifying user-created objects
Next
From: Craig Ringer
Date:
Subject: Re: Is custom MemoryContext prohibited?