| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
| Subject: | Re: Remove meaningless const qualifier from ginCompressPostingList() |
| Date: | 2025-10-30 10:35:08 |
| Message-ID: | 89247977-647e-4fa3-8bd6-b1a6609c71c0@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 29.10.25 04:42, Chao Li wrote:
> While working on the other patch that fixed wrong "const" usage [1], I
> found the function:
> ```
> GinPostingList *
> ginCompressPostingList(const ItemPointer ipd, int nipd, int maxsize,
> int *nwritten)
> ```
> uses "const" unnecessarily. Because it needs to assign an element of
> "ipd" to the returned structure "GinPostingList->first" and "first" is a
> mutable "ItemPointerData *", so that "ipd" cannot be of const pointer.
I have committed a fix for this together with the other one.
The code you are referring to here is:
result->first = ipd[0];
This is a value copy, so this does not violate the immutability of ipd.
So the const in the function prototype was the right idea, but in the
wrong place of course.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Rowley | 2025-10-30 10:36:25 | Re: another autovacuum scheduling thread |
| Previous Message | Peter Eisentraut | 2025-10-30 10:31:42 | Re: Fix incorrect const qualification for tbm_add_tuples() and itemptr_to_uint64() |