[PATCH] Fix ouside scope t_ctid (ItemPointerData) - Mailing list pgsql-hackers

From Ranier Vilela
Subject [PATCH] Fix ouside scope t_ctid (ItemPointerData)
Date
Msg-id CAEudQAr+=6dTa2V12CLx_bx5-VvbKtFaemQbeqhpjdZ2Zn_JtA@mail.gmail.com
Whole thread Raw
Responses Re: [PATCH] Fix ouside scope t_ctid (ItemPointerData)  (Mark Dilger <mark.dilger@enterprisedb.com>)
Re: [PATCH] Fix ouside scope t_ctid (ItemPointerData)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,
ItemPointerData, on the contrary, from what the name says,
it is not a pointer to a structure, but a structure in fact.
When assigning the name of the structure variable to a pointer, it may even work,
but, it is not the right thing to do and it becomes a nightmare,
to discover that any other error they have is at cause.

So:
1. In some cases, there may be a misunderstanding in the use of ItemPointerData.
2. When using the variable name in an assignment, the variable's address is used.
3. While this works for a structure, it shouldn't be the right thing to do.
4. If we have a local variable, its scope is limited and when it loses its scope, memory is certainly garbage.
5. While this may be working for heapam.c, I believe it is being abused and should be compliant with
    the Postgres API and use the functions that were created for this.

The patch is primarily intended to correct the use of ItemPointerData.
But it is also changing the style, reducing the scope of some variables.
If that was not acceptable, reduce the scope and someone has objections,
I can change the patch, to focus only on the use of ItemPointerData.
But as style changes are rare, if possible, it would be good to seize the opportunity.

regards,
Ranier Vilela
Attachment

pgsql-hackers by date:

Previous
From: Jehan-Guillaume de Rorthais
Date:
Subject: Re: Strange decreasing value of pg_last_wal_receive_lsn()
Next
From: Mark Dilger
Date:
Subject: Re: [PATCH] Fix ouside scope t_ctid (ItemPointerData)