Stored columns: Unexpected varattno in expression to be mapped

From: "Thiede, Christoph" <Christoph(dot)Thiede(at)student(dot)hpi(dot)uni-potsdam(dot)de>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Stored columns: Unexpected varattno in expression to be mapped
Date: 2020-07-16 15:43:54
Message-ID: 155b60197f7844539ae86781c15e5e52@student.hpi.uni-potsdam.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-bugs by date

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