pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: mario.ab.leonel@gmail.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16395: error when selecting generated column in a foreign table
Date: Tue, 28 Apr 2020 16:19:30 +0200
Message-ID: <a4938e39-8369-f321-a691-1912e7a62b13@2ndquadrant.com> (raw)
In-Reply-To: <16395-2f2e9f72bd22a6d1@postgresql.org>
References: <16395-2f2e9f72bd22a6d1@postgresql.org>

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





view thread (3+ messages)  latest in thread

Message-ID: <a4938e39-8369-f321-a691-1912e7a62b13@2ndquadrant.com>
Permalink:  ../a4938e39-8369-f321-a691-1912e7a62b13@2ndquadrant.com/
Also on:    postgresql.org/message-id/a4938e39-8369-f321-a691-1912e7a62b13@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com, mario.ab.leonel@gmail.com
  Subject: Re: BUG #16395: error when selecting generated column in a foreign table
  In-Reply-To: <a4938e39-8369-f321-a691-1912e7a62b13@2ndquadrant.com>
  References: <16395-2f2e9f72bd22a6d1@postgresql.org> <a4938e39-8369-f321-a691-1912e7a62b13@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox