Re: Violation of principle that plan trees are read-only - Mailing list pgsql-hackers

From Nico Williams
Subject Re: Violation of principle that plan trees are read-only
Date
Msg-id aCzpi+c+tUNM4z4q@ubby
Whole thread Raw
In response to Violation of principle that plan trees are read-only  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Violation of principle that plan trees are read-only
List pgsql-hackers
On Mon, May 19, 2025 at 08:41:06AM -0400, Isaac Morland wrote:
> I assume this question has an obvious negative answer, but why can't we
> attach const declarations to the various structures that make up the plan
> tree (at all levels, all the way down)? I know const doesn't actually
> prevent a value from changing, but at least the compiler would complain if
> code accidentally tried.

What you want is for C to have a type attribute that denotes
immutability all the way down.  `const` doesn't do that.  One thing that
could be done is to write a utility that creates const-all-the-way-down
clones of given types, but such a tool can't be written as C
pre-processor macros -- it would have to be a tool that parses the
actual type definitions, or uses DWARF or similar to from the
compilation of a file (I've done this latter before, but this weds you
to compilers that output DWARF, which MSVC doesn't, for example).

Really, the C committee ought to add this at some point, darn it.  It
would be the opposite of Rust's &mut.

Nico
-- 



pgsql-hackers by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: proposal: schema variables
Next
From: "Scott Mead"
Date:
Subject: Re: Disable parallel query by default