Improve node type forward reference

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Improve node type forward reference
Date: 2024-10-14 07:47:59
Message-ID: 637eeea8-5663-460b-a114-39572c0f6c6e@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This is a small code simplification.

In primnodes.h, we have

typedef struct IntoClause
{
...
/* materialized view's SELECT query */
Node *viewQuery ...;

with the comment

/* (Although it's actually Query*, we declare
* it as Node* to avoid a forward reference.)

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.

The second patch just removes some more unnecessary casts around
copyObject() that I found while working on this.

Attachment Content-Type Size
0001-Improve-node-type-forward-reference.patch text/plain 2.7 KB
0002-Fix-unnecessary-casts-of-copyObject-result.patch text/plain 2.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2024-10-14 08:07:50 Re: New "raw" COPY format
Previous Message Peter Eisentraut 2024-10-14 06:46:07 Re: Cannot find a working 64-bit integer type on Illumos