Re: Remove useless memory context switch in ExecHashTableCreate()

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: cca5507 <cca5507(at)qq(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Remove useless memory context switch in ExecHashTableCreate()
Date: 2026-12-03 19:28:35
Message-ID: axHC4-MXDz8tDV2Y@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 03, 2026 at 05:50:01PM +0800, cca5507 wrote:
> After adf97c1562, the "MemoryContextSwitchTo(hashtable->hashCxt)" in
> ExecHashTableCreate() is useless, so attach a patch to remove it. While
> at it, rename "oldctx" to "oldcxt" to keep consistent and fix a stale
> comment.

Seems generally reasonable.

> Now PrepareTempTablespaces() will not be called within hashCxt, but I
> think it's ok.

I do, too, but only after inspecting the code to be sure
PrepareTempTablespaces() doesn't ever leak memory. While that's pretty old
code that is unlikely to withstand too many changes in the future, IMHO
it'd be a good idea to note that some callers depend on it not leaking
memory. That way, future patch authors will be more likely to free
everything they allocated.

--
nathan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-12-03 19:42:57 Re: Streamed transactions lose replication origin when first change is not a row change
Previous Message Peter Eisentraut 2026-12-03 19:27:13 Re: Should we add timing output to pg_upgrade?