Re: ERROR: attribute number 6 exceeds number of columns 5
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: andreas@visena.com, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>,
pgsql-hackers@lists.postgresql.org
Date: 2020-01-07T17:47:00Z
Lists: pgsql-hackers
Attachments
- fix-alter-type-for-generated-columns.patch (text/x-diff) patch
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
Commits
-
Fix handling of generated columns in ALTER TABLE.
- c24f3b70efc2 12.2 landed
- 4ac8aaa36fa2 13.0 landed