Improve node type forward reference

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-10-14T07:47:59Z
Lists: pgsql-hackers

Attachments

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.

Commits

  1. Fix unnecessary casts of copyObject() result

  2. Improve node type forward reference