Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy
Date: 2025-11-04 18:31:32
Message-ID: 652421.1762281092@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Peter Eisentraut <peter(at)eisentraut(dot)org> writes:
>> But in ATPrepDropExpression(), when you're recursing, then recurse is
>> always false. That is hardcoded in the ATPrepCmd() call in
>> ATSimpleRecursion(). Does that make sense?

> Seems wrong, but I didn't trace through the code.

Oh: looking closer, the reason is that ATSimpleRecursion already
located all the direct and indirect child tables and will call
ATPrepCmd on each one. Therefore it's correct that ATPrepCmd should
be told recurse = false; we do not want it to look for child tables.

You could argue that passing recursing = true for each rel is bogus,
and we should arrange to pass recursing = false for the original
table and true only for whatever children we found. But I'm not
sure that anything would care. That doesn't sound like it would
help for the current problem, anyway.

If it actually matters for DROP EXPRESSION, then the answer is
probably "we can't use ATSimpleRecursion for DROP EXPRESSION".
ATSimpleRecursion is meant for cases where each table can be
processed independently, regardless of its position in the
hierarchy.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-11-04 18:34:29 Re: MinGW compiler warnings in ecpg tests
Previous Message Jacob Champion 2025-11-04 18:23:16 Re: Intention to start an [oauth] "working group"