Re: Violation of principle that plan trees are read-only

From: Jose Luis Tallon <jltallon(at)adv-solutions(dot)net>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Violation of principle that plan trees are read-only
Date: 2025-05-19 15:49:59
Message-ID: 2437dab7-396e-fa2c-82a4-dec101621061@adv-solutions.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 19/5/25 16:45, Tom Lane wrote:
> [snip]
> For one thing, I'm not sure how to teach the compiler that casting
> "Query *" to "ConstQuery *" is okay but vice versa isn't.
>
> Does C++ have a better story in this area?

Hi,

    A C++ compiler *does* enforce "const correctness" (for examples
see, for example, Meyer's fantastic "Efficient C++" series).

It seems that Postgres is approaching the class of complexity/maturity
that (modern) C++ was designed to solve. It should be unmatched in that
area. I believe that, with recent platform deprecations, the vast
majority of systems where one can compile a modern Postgres should
already have a decent C++ compiler available (g++ & clang probably cover
>95%)

As opposed to say, rewriting in Rust ---where the compilar also does a
very substantial checking of semantics at compile time---, introducing
some C++ in Postgres could be as simple as throwing some "#ifdef
__cplusplus__  extern "C" { #endif" in the headers and use the required
subset in certain modules *only*.

    (this is how, for instance, Bacula did it ~two decades ago)

The planner and parts of the bufmgr / arenas (palloc et al.) seem to me
as the most obvious candidates to try. I'm not sure whether it'd
introduce any unintended regressions, though.

> I haven't touched it
> in so long that I don't remember.

C++ 17 would be the standard to tackle, IMHO.

HTH,

    J.L.

--
Parkinson's Law: Work expands to fill the time alloted to it.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-05-19 16:11:37 Re: Add comment explaining why queryid is int64 in pg_stat_statements
Previous Message Nico Williams 2025-05-19 15:38:19 Re: Should we optimize the `ORDER BY random() LIMIT x` case?