| From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
|---|---|
| To: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
| Cc: | Richard Guo <rguo(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned |
| Date: | 2026-10-13 14:34:50 |
| Message-ID: | CAMbWs49_5+iScJWmG8zNqVLM45pn3KHZDbbkvc3jUSjNc_Jipw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers pgsql-hackers |
On Tue, Oct 13, 2026 at 9:43 PM Álvaro Herrera <alvherre(at)kurilemu(dot)de> wrote:
> I find this very surprising. Are we sure that it makes sense for a
> partition to have a generating expression that differs from the one in
> the parent table?
No, I don't think it makes sense for a partition to have a different
virtual generation expression than its parent. I raised this exact
same complaint in [1], the paragraph starting with "Regarding #4",
quoted below:
Regarding #4, the fix is to not trust NOT NULL on a virtual generated
column of a partitioned table. But I don't like this fix at all. I
think the real problem is that a partition is allowed to have a
different virtual generation expression than its parent. The
constraint is enforced with the partition's expression, while a query
on the parent computes the column with the parent's expression. So
even on v18, a NOT NULL column can read as NULL through the parent,
and the same goes for CHECK constraints. That seems fragile to me,
and I suspect it will bite us again. CC'ing Peter here.
I'm not sure why virtual generated columns are designed this way, or
if this is required by the SQL standard. But I can see it breaks a
lot of things, and what this commit does is just to work-around one of
the things that design breaks.
[1] https://postgr.es/m/CAMbWs4-dfVUXSu1fwfTd8HZypKsSN1uYjEPfMDb6bqB58Pas4g@mail.gmail.com
- Richard
| From | Date | Subject | |
|---|---|---|---|
| Next Message | shihao zhong | 2026-10-13 15:41:39 | Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned |
| Previous Message | Álvaro Herrera | 2026-10-13 12:42:51 | Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tatsuya Kawata | 2026-10-13 14:37:58 | Re: [PATCH] Add memory/disk usage for Function Scan nodes in EXPLAIN |
| Previous Message | Robert Haas | 2026-10-13 14:25:11 | Re: postgres_fdw: Emit message when batch_size is reduced |