Stored columns: Unexpected varattno in expression to be mapped - Mailing list pgsql-bugs

From Thiede, Christoph
Subject Stored columns: Unexpected varattno in expression to be mapped
Date
Msg-id 155b60197f7844539ae86781c15e5e52@student.hpi.uni-potsdam.de
Whole thread Raw
Responses Re: Stored columns: Unexpected varattno in expression to be mapped
Re: Stored columns: Unexpected varattno in expression to be mapped
List pgsql-bugs

Hi all,


as a Postgres user for about half a year, I think I found a bug in psql (PostgreSQL) 12.2 (Debian 12.2-2.pgdg100+1).


Steps to reproduce:

Type the following commands into a PSQL shell:

postgres=# create table mytable (foo text generated always as (bar) stored, bar text);
CREATE TABLE
postgres=# create temporary table mytemp1 (like mytable);
CREATE TABLE
postgres=# create temporary table mytemp2 (like mytable including all);
ERROR:  unexpected varattno 2 in expression to be mapped

Considerations:
It looks as if the INCLUDING ALL logic, however it may work, assumes that stored columns can only refer to columns defined before. On the other hand, CREATE TABLE does not enforce this.
So from my naive perspective, either INCLUDING ALL should be fixed not to make this assumption, or CREATE TABLE & Co. should forbid the definition of such columns.

I would be happy if this bug could be fixed in a later release (provided that it has not already been).

Note: Please reply directly to my email address if you want to contact me, I did not subscribe to the bugs list.

Best regards,
Christoph

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #16545: COALESCE evaluates arguments to the right of the first non-null argument
Next
From: "David G. Johnston"
Date:
Subject: Re: Stored columns: Unexpected varattno in expression to be mapped