Re: BUG #16395: error when selecting generated column in a foreign table

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: mario(dot)ab(dot)leonel(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16395: error when selecting generated column in a foreign table
Date: 2020-04-28 14:19:30
Message-ID: a4938e39-8369-f321-a691-1912e7a62b13@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2020-04-27 16:24, PG Bug reporting form wrote:
> -- bd: postgres
> CREATE TABLE public.test
> (
> id integer NOT NULL,
> field1 integer NOT NULL,
> field2 character varying COLLATE pg_catalog."default",
> CONSTRAINT test_pkey PRIMARY KEY (id)
> );
>
> -- bd: test
> CREATE FOREIGN TABLE public.test(
> id integer NULL,
> field1 integer NULL,
> field2 character varying NULL COLLATE pg_catalog."default",
> field_calc integer generated always as (field1 * 2) stored
> )
> SERVER fs_postgres;
>
> test=# SELECT id, field1, field2, field_calc FROM public.test;
> ERROR: column "field_calc" does not exist
> CONTEXT: remote SQL command: SELECT id, field1, field2, field_calc FROM
> public.test

Well, your public.test base table does not in fact have a "field_calc"
column. You need to add that.

Note that these are *stored* generated columns, so the value that is
generated by the foreign table on insert is meant to be stored somewhere
in the backing store of the foreign table.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2020-04-28 17:45:57 Re: BUG #16380: documentation: host[no]gssenc vs. address/IP-address/IP-mask fields
Previous Message Peter Eisentraut 2020-04-28 14:14:06 Re: BUG #16380: documentation: host[no]gssenc vs. address/IP-address/IP-mask fields