| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | Kirill Reshke <reshkekirill(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com> |
| Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy |
| Date: | 2025-11-04 18:10:20 |
| Message-ID: | 71ab601c-14e3-4a0e-9956-1f641295a97d@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 25.08.25 15:04, Kirill Reshke wrote:
> So we need to detect if the user did ALTER TABLE or ALTER TABLE ONLY.
> And we have two parameters passed to ATPrepDropExpression: "recurse"
> and "recursing".
> First is about whether the user specified ONLY option and second is
> about if we are recursing in our AT code. So maybe fix it as in
> attached?
I find that tablecmds.c uses these two arguments in not entirely
consistent ways.
I would have expected that if you write a command that is supposed to
recurse (no ONLY) and you are some levels down into the recursing, then
recursing=true, of course, but shouldn't recurse=true as well, to
reflect the command that was written?
Some code works like that, for example ATExecDropColumn() and
ATExecSetNotNull(). I probably originally adapted code from places like
that.
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?
I mean, there might be complex reasons, ALTER TABLE code is complicated,
but I don't find this explained anywhere.
If this worked more consistently, then the DROP EXPRESSION code might
actually work correctly as written.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2025-11-04 18:16:05 | Re: Fix ALTER TABLE DROP EXPRESSION with inheritance hierarchy |
| Previous Message | Jim Jones | 2025-11-04 17:59:34 | Re: [PATCH] Add pg_get_tablespace_ddl() function to reconstruct CREATE TABLESPACE statement |