| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Jeff Davis <pgsql(at)j-davis(dot)com> |
| Subject: | Fix redundant memset after palloc0 in heap_form_minimal_tuple() |
| Date: | 2025-11-04 09:05:29 |
| Message-ID: | CAEoWx2kAkNaDa01O0nKsQmkfEmxsDvm09SU=f1T0CV8ew3qJEA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Hackers,
While studying the other patch, I happened to notice this problem
in heap_form_minimal_tuple().
The current code does both palloc0() and memset(0)
in heap_form_minimal_tuple():
```
/*
* Allocate and zero the space needed.
*/
mem = palloc0(len + extra);
memset(mem, 0, extra);
tuple = (MinimalTuple) (mem + extra);
```
That looks like an oversight of a0942f4.
To fix the problem, my first impression was to delete the memset(). But
looking at a0942f4, I found a couple of other places that do the same
pattern: palloc(len+extra) then memset(0, extra), so I think the correct
fix should be changing the palloc0 to palloc.
Best regards,
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-redundant-zero-initialization-in-heap_form_mi.patch | application/octet-stream | 1.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2025-11-04 09:19:34 | Re: Teaching planner to short-circuit empty UNION/EXCEPT/INTERSECT inputs |
| Previous Message | Ashutosh Bapat | 2025-11-04 08:57:12 | Extra blank line in StrategyGetBuffer |