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