Re: subplan resets wrong hashtable

From: Andres Freund <andres(at)anarazel(dot)de>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: subplan resets wrong hashtable
Date: 2020-02-10 04:01:26
Message-ID: 20200210040126.pxcrvq5lvxf7fjwi@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2020-02-09 21:25:47 -0600, Justin Pryzby wrote:
> I believe the 2nd hunk should reset node->hashnulls, rather than reset
> ->hashtable a 2nd time:
>
> @@ -505,7 +505,10 @@ buildSubPlanHash(SubPlanState *node, ExprContext *econtext)
> if (nbuckets < 1)
> nbuckets = 1;
>
> - node->hashtable = BuildTupleHashTable(node->parent,
> + if (node->hashtable)
> + ResetTupleHashTable(node->hashtable);
> + else
> + node->hashtable = BuildTupleHashTableExt(node->parent,
> node->descRight,
> ncols,
> node->keyColIdx,
> ...
>
> @@ -527,7 +531,11 @@ buildSubPlanHash(SubPlanState *node, ExprContext *econtext)
> if (nbuckets < 1)
> nbuckets = 1;
> }
> - node->hashnulls = BuildTupleHashTable(node->parent,
> +
> + if (node->hashnulls)
> + ResetTupleHashTable(node->hashtable);
> + else
> + node->hashnulls = BuildTupleHashTableExt(node->parent,
> node->descRight,
> ncols,
> node->keyColIdx,

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?

- Andres

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2020-02-10 04:05:08 Re: subplan resets wrong hashtable
Previous Message Craig Ringer 2020-02-10 03:55:09 Re: Postgres 32 bits client compilation fail. Win32 bits client is supported?