pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed[PATCH] Remove stale comment and dead store in BuildTupleHashTable
5+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2026-09-10 bd9d6ffa1a Remove stale comment and redundant assignment in BuildTupleHashTable()
* [PATCH] Remove stale comment and dead store in BuildTupleHashTable
@ 2026-08-09 11:22 Tatsuya Kawata <kawatatatsuya0913@gmail.com>
2026-08-11 02:01 ` Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable Quan Zongliang <quanzongliang@yeah.net>
0 siblings, 1 reply; 5+ messages in thread
From: Tatsuya Kawata @ 2026-08-09 11:22 UTC (permalink / raw)
To: pgsql-hackers
Hi,
While reading the aggregation-related executor code, I noticed a comment
that no longer matches what the code does.
In BuildTupleHashTable() (src/backend/executor/execGrouping.c) we have:
hashtable->tableslot = NULL; /* will be made on first lookup */
The slot is no longer made on first lookup. Commit bf6c614a2f2 removed
the lazy creation from LookupTupleHashEntry() and made
BuildTupleHashTable() create the slot unconditionally, further down in
the same function. Only the comment and its assignment were left behind.
The attached patch removes both. Nothing reads tableslot before
slot is actually created.
Regards,
Tatsuya Kawata
Attachments:
v1-0001-Remove-stale-comment-and-dead-store-in-BuildTuple.patch (application/octet-stream, 1.6K) download
From a80fe6a40b35c88db74aa923d7b8a0a5bac76634 Mon Sep 17 00:00:00 2001
From: TatsuyaKawata <kawatatatsuya0913@gmail.com>
Date: Sun, 9 Aug 2026 18:47:54 +0900
Subject: [PATCH v1] Remove stale comment and dead store in
BuildTupleHashTable()
BuildTupleHashTable() sets hashtable->tableslot to NULL with the comment
"will be made on first lookup". That was accurate until commit
bf6c614a2f2, which removed the lazy creation from
LookupTupleHashEntry() and made BuildTupleHashTable() create the slot
unconditionally instead. Since then the comment has described behavior
that no longer exists.
Remove the comment together with the assignment it is attached to. That
assignment is a dead store: the slot is created unconditionally further
down in the same function, there is no branch that can skip it and no
early return, and nothing reads tableslot before then. In particular
tuplehash_create() only records the hashtable pointer as private_data
and does not invoke the hash or match functions.
---
src/backend/executor/execGrouping.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c
index c107514a85d..c03bde2a43c 100644
--- a/src/backend/executor/execGrouping.c
+++ b/src/backend/executor/execGrouping.c
@@ -232,7 +232,6 @@ BuildTupleHashTable(PlanState *parent,
hashtable->tuplescxt = tuplescxt;
hashtable->tempcxt = tempcxt;
hashtable->additionalsize = additionalsize;
- hashtable->tableslot = NULL; /* will be made on first lookup */
hashtable->inputslot = NULL;
hashtable->in_hash_expr = NULL;
hashtable->cur_eq_func = NULL;
--
2.34.1
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable
2026-08-09 11:22 [PATCH] Remove stale comment and dead store in BuildTupleHashTable Tatsuya Kawata <kawatatatsuya0913@gmail.com>
@ 2026-08-11 02:01 ` Quan Zongliang <quanzongliang@yeah.net>
2026-08-12 09:31 ` Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable Quan Zongliang <quanzongliang@yeah.net>
0 siblings, 1 reply; 5+ messages in thread
From: Quan Zongliang @ 2026-08-11 02:01 UTC (permalink / raw)
To: Tatsuya Kawata <kawatatatsuya0913@gmail.com>; pgsql-hackers
On 8/9/26 7:22 PM, Tatsuya Kawata wrote:
> Hi,
>
> While reading the aggregation-related executor code, I noticed a comment
> that no longer matches what the code does.
>
> In BuildTupleHashTable() (src/backend/executor/execGrouping.c) we have:
>
> hashtable->tableslot = NULL; /* will be made on first lookup */
>
This initialization was initially introduced in the patch f97aebd1.
The hashtable->tableslot is initialized in the LookupTupleHashEntry
function.
> The slot is no longer made on first lookup. Commit bf6c614a2f2 removed
> the lazy creation from LookupTupleHashEntry() and made
> BuildTupleHashTable() create the slot unconditionally, further down in
> the same function. Only the comment and its assignment were left behind.
>
It also involves patch 773aec7a and its revert patch 2a41507d
Initialization is no longer necessary.
--
Quan Zongliang
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable
2026-08-09 11:22 [PATCH] Remove stale comment and dead store in BuildTupleHashTable Tatsuya Kawata <kawatatatsuya0913@gmail.com>
2026-08-11 02:01 ` Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable Quan Zongliang <quanzongliang@yeah.net>
@ 2026-08-12 09:31 ` Quan Zongliang <quanzongliang@yeah.net>
2026-08-13 00:26 ` Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable Tatsuya Kawata <kawatatatsuya0913@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Quan Zongliang @ 2026-08-12 09:31 UTC (permalink / raw)
To: Tatsuya Kawata <kawatatatsuya0913@gmail.com>; pgsql-hackers
On 8/11/26 10:01 AM, Quan Zongliang wrote:
>
>
> On 8/9/26 7:22 PM, Tatsuya Kawata wrote:
>> Hi,
>>
>> While reading the aggregation-related executor code, I noticed a comment
>> that no longer matches what the code does.
>>
>> In BuildTupleHashTable() (src/backend/executor/execGrouping.c) we have:
>>
>> hashtable->tableslot = NULL; /* will be made on first lookup */
>>
> This initialization was initially introduced in the patch f97aebd1.
> The hashtable->tableslot is initialized in the LookupTupleHashEntry
> function.
>
>> The slot is no longer made on first lookup. Commit bf6c614a2f2 removed
>> the lazy creation from LookupTupleHashEntry() and made
>> BuildTupleHashTable() create the slot unconditionally, further down in
>> the same function. Only the comment and its assignment were left behind.
>>
>
> It also involves patch 773aec7a and its revert patch 2a41507d
>
> Initialization is no longer necessary.
>
This is a very clear and straightforward code refactoring. There won't
be any objections. Change to "Ready for Committer".
--
Quan Zongliang
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable
2026-08-09 11:22 [PATCH] Remove stale comment and dead store in BuildTupleHashTable Tatsuya Kawata <kawatatatsuya0913@gmail.com>
2026-08-11 02:01 ` Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable Quan Zongliang <quanzongliang@yeah.net>
2026-08-12 09:31 ` Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable Quan Zongliang <quanzongliang@yeah.net>
@ 2026-08-13 00:26 ` Tatsuya Kawata <kawatatatsuya0913@gmail.com>
2026-09-10 07:13 ` Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable Fujii Masao <masao.fujii@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Tatsuya Kawata @ 2026-08-13 00:26 UTC (permalink / raw)
To: Quan Zongliang <quanzongliang@yeah.net>; +Cc: pgsql-hackers
Hi Quan-san,
> This is a very clear and straightforward code refactoring. There won't
> be any objections. Change to "Ready for Committer".
Thank you for reviewing the patch and updating the status!
Regards,
Tatsuya Kawata
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable
2026-08-09 11:22 [PATCH] Remove stale comment and dead store in BuildTupleHashTable Tatsuya Kawata <kawatatatsuya0913@gmail.com>
2026-08-11 02:01 ` Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable Quan Zongliang <quanzongliang@yeah.net>
2026-08-12 09:31 ` Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable Quan Zongliang <quanzongliang@yeah.net>
2026-08-13 00:26 ` Re: [PATCH] Remove stale comment and dead store in BuildTupleHashTable Tatsuya Kawata <kawatatatsuya0913@gmail.com>
@ 2026-09-10 07:13 ` Fujii Masao <masao.fujii@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Fujii Masao @ 2026-09-10 07:13 UTC (permalink / raw)
To: Tatsuya Kawata <kawatatatsuya0913@gmail.com>; +Cc: Quan Zongliang <quanzongliang@yeah.net>; pgsql-hackers
On Thu, Aug 13, 2026 at 9:26 AM Tatsuya Kawata
<kawatatatsuya0913@gmail.com> wrote:
> > This is a very clear and straightforward code refactoring. There won't
> > be any objections. Change to "Ready for Committer".
>
> Thank you for reviewing the patch and updating the status!
I've pushed the patch. Thanks!
Regards,
--
Fujii Masao
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2026-09-10 07:13 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-08-09 11:22 [PATCH] Remove stale comment and dead store in BuildTupleHashTable Tatsuya Kawata <kawatatatsuya0913@gmail.com>
2026-08-11 02:01 ` Quan Zongliang <quanzongliang@yeah.net>
2026-08-12 09:31 ` Quan Zongliang <quanzongliang@yeah.net>
2026-08-13 00:26 ` Tatsuya Kawata <kawatatatsuya0913@gmail.com>
2026-09-10 07:13 ` Fujii Masao <masao.fujii@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox