Re: ERROR: attribute number 6 exceeds number of columns 5
Kyotaro Horiguchi <horikyota.ntt@gmail.com>
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: tgl@sss.pgh.pa.us
Cc: andreas@visena.com, pgsql-hackers@lists.postgresql.org
Date: 2019-11-27T03:00:34Z
Lists: pgsql-hackers
Attachments
At Tue, 26 Nov 2019 10:49:11 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote in > Andreas Joseph Krogh <andreas@visena.com> writes: > > Run the attached script and you'll get: > > > psql -f error.sql -d test > > psql:error.sql:37: ERROR: attribute number 6 exceeds number of columns 5 > > Hmm, interesting. IMO, that *should* have thrown an error, but of > course not that one. The ADD COLUMN operations are all processed > in parallel, so it's not okay for one of them to have a GENERATED > expression that refers to another one of the new columns. But you > should have gotten a "no such column" type of error, not a run-time > cross-check failure. Something like this works? ALTER TABLE gtest25 ADD COLUMN x int, ADD COLUMN y int GENERATED ALWAYS AS (x * 4) STORED; ERROR: column "x" does not exist DETAIL: An expression cannot reference columns added in the same command. regards. -- Kyotaro Horiguchi NTT Open Source Software Center
Commits
-
Fix handling of generated columns in ALTER TABLE.
- c24f3b70efc2 12.2 landed
- 4ac8aaa36fa2 13.0 landed