Re: [PATCH] Fix ouside scope t_ctid (ItemPointerData)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Fix ouside scope t_ctid (ItemPointerData)
Date: 2020-05-14 22:59:23
Message-ID: CAEudQAptfGKXkunbLhk9_tcpXK1hfOt66VVLNPQtBDh4MEY0GA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em qui., 14 de mai. de 2020 às 19:49, Mark Dilger <
mark(dot)dilger(at)enterprisedb(dot)com> escreveu:

>
>
> > On May 14, 2020, at 11:34 AM, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> wrote:
> >
> > Certainly.
> > In the same file you can find the appropriate use of the API.
> > ItemPointerSet(&heapTuple->t_self, blkno, offnum);
>
> It took a couple reads through your patch to figure out what you were
> trying to accomplish, and I think you are uncomfortable with assigning one
> ItemPointerData variable from another. ItemPointerData is just a struct
> with three int16 variables. To make a standalone program that has the same
> structure without depending on any postgres headers, I'm using "short int"
> instead of "int16" and structs "TwoData" and "ThreeData" that are analogous
> to BlockIdData and OffsetNumber.
>
> #include <stdio.h>
>
> typedef struct TwoData {
> short int a;
> short int b;
> } TwoData;
>
> typedef struct ThreeData {
> TwoData left;
> short int right;
> } ThreeData;
>
> int main(int argc, char **argv)
> {
> ThreeData x = { { 5, 10 }, 15 };
> ThreeData y = x;
> x.left.a = 0;
> x.left.b = 1;
> x.right = 2;
>
> printf("y = { { %d, %d }, %d }\n",
> y.left.a, y.left.b, y.right);
>
> return 0;
> }
>
> If you compile and run this, you'll notice it outputs:
>
> y = { { 5, 10 }, 15 }
>
> and not the { { 0, 1}, 2 } that you would expect if y were merely pointing
> at x.
>
Thanks for the example.
But what I wanted to test was
struct1 = struct2;
Both being of the same type of structure.

What I wrongly deduced was that the address of struct2 was saved and not
its content.

Again, thanks for your time and clarification.

regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2020-05-14 23:25:46 Re: Event trigger code comment duplication
Previous Message Ranier Vilela 2020-05-14 22:55:17 Re: [PATCH] Fix ouside scope t_ctid (ItemPointerData)