Re: ERROR: attribute number 6 exceeds number of columns 5

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: andreas(at)visena(dot)com, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: ERROR: attribute number 6 exceeds number of columns 5
Date: 2020-01-07 17:47:00
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I wrote:
> So I believe that the real problem here is that the executor is
> evaluating GENERATED expressions at the wrong time. It's evaluating
> them against the pre-conversion tuples when it should be evaluating
> them against the post-conversion tuples. We need to go fix that,
> rather than inserting arbitrary restrictions in the DDL code.

I looked at that more closely, and realized that blaming the executor
is wrong: the real issue is that ALTER TABLE itself supposes that it
need only evaluate expressions against the old tuple. That's easy
to fix with a bit more code though. I propose the attached.

(Note that this should also allow relaxing the existing implementation
restriction against changing types of columns that GENERATED columns
depend on: all we have to do is re-parse the generation expression
and schedule it for evaluation. I've not looked into that, and it
doesn't seem like a bug fix anyway.)

regards, tom lane

Attachment Content-Type Size
fix-alter-type-for-generated-columns.patch text/x-diff 5.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2020-01-07 17:56:19 Re: RFC: seccomp-bpf support
Previous Message Robert Haas 2020-01-07 17:21:26 Re: [PATCH] Increase the maximum value track_activity_query_size