From: | Tender Wang <tndrwang(at)gmail(dot)com> |
---|---|
To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
Cc: | Nathan Bossart <nathandbossart(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Improve node type forward reference |
Date: | 2024-10-15 09:03:05 |
Message-ID: | CAHewXN=9uog2G03UKL_7xec7HvAg_JdovV0U-wEcnE7FJCxUKg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Peter Eisentraut <peter(at)eisentraut(dot)org> 于2024年10月15日周二 15:02写道:
> On 14.10.24 23:28, Nathan Bossart wrote:
> > On Mon, Oct 14, 2024 at 09:47:59AM +0200, Peter Eisentraut wrote:
> >> But we can do this better by using an incomplete struct, like
> >>
> >> struct Query *viewQuery ...;
> >>
> >> That way, everything has the correct type and fewer casts are required.
> This
> >> technique is already used elsewhere in node type definitions.
>
Agree. The attached patches LGTM.
> >
> > I noticed that the examples in parsenodes.h are for structs defined
> within
> > the same file. If the struct is defined in a separate file, I guess you
> > might need to include another header file wherever it is used, but that
> > doesn't seem too bad.
>
> No, you can leave the struct incomplete. You only need to provide its
> full definition (= include the other header file) if you actually want
> to access the struct's fields.
>
>
Yeah. There are many examples. For example as below:
in struct RelOptInfos,
/* use "struct FdwRoutine" to avoid including fdwapi.h here */
struct FdwRoutine *fdwroutine pg_node_attr(read_write_ignore);
--
Thanks,
Tender Wang
From | Date | Subject | |
---|---|---|---|
Next Message | jian he | 2024-10-15 09:50:15 | Re: type cache cleanup improvements |
Previous Message | Artur Zakirov | 2024-10-15 08:45:23 | Re: type cache cleanup improvements |