Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m32fs-0001K2-5O for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Jul 2021 20:37:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m32fp-0007Nx-SX for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Jul 2021 20:37:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m32fp-0007Nk-LK for pgsql-bugs@lists.postgresql.org; Mon, 12 Jul 2021 20:37:05 +0000 Received: from wforward1-smtp.messagingengine.com ([64.147.123.30]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m32fi-0002ub-CP for pgsql-bugs@lists.postgresql.org; Mon, 12 Jul 2021 20:37:04 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailforward.west.internal (Postfix) with ESMTP id 7B0831AC1AFE; Mon, 12 Jul 2021 16:36:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 12 Jul 2021 16:36:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=dFYp0qb+w6PG1JdouJ+4CmZW6JE+E51WXxMrHbtJJ 8g=; b=gaj3772JiKw6DE9sgqfIyC8N4USgn5DgvzFJ2Z5fR0YY21p4lloSvy3zz kuttUtee+ykNdkTsFU+58XbnTPrBqnH9WymLgq4zgZgzlDt/u7/eV5wKfYmkyAcP KYxi0jahlK+D7O1wW5E0pTxJtQHk6diBQ0yqOS6AKw7GOgmWknowwfYy6qynA9SN ranJGfMFVRyK0aHDXdvLR8IBUaUdQa2zv2PxNQMmIr/lo68EPfeOzf45VStxtJuf aZzF4KTog7D04nKT9sqyYcf4De+NQPs0gSWS8s3qZpEYimIQAOjVw67UTnuaB+Fk W4pdM3Hjf0AcT3CbQekUO9CqyNeVA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudefgdduudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvghtvghr ucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrh hprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpedtvdevtdfglefftdettefg hfeitdekueekhfehueegieelgeekfeetueelieelheenucffohhmrghinhepphhoshhtgh hrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepphgvthgvrhdrvghishgvnhhtrhgruhhtsegvnhhtvghrphhrihhsvggusg drtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Jul 2021 16:36:54 -0400 (EDT) Subject: Re: BUG #16631: postgres_fdw tries to insert into generated columns To: Tom Lane Cc: Etsuro Fujita , dacherny@gmail.com, PostgreSQL mailing lists References: <16631-e929fe9db0ffc7cf@postgresql.org> <8a61d9c4-b614-e2dc-6bcc-bfc17db4d2f9@enterprisedb.com> <1838679.1625673259@sss.pgh.pa.us> From: Peter Eisentraut Message-ID: Date: Mon, 12 Jul 2021 22:36:53 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1838679.1625673259@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 07.07.21 17:54, Tom Lane wrote: > Peter Eisentraut writes: >> On 07.07.21 09:20, Etsuro Fujita wrote: >>> * Modified nodeModifyTable.c and copyfrom.c so that they don't compute >>> generated columns for FDWs anymore. > >> I don't agree with that change. What is the point of declaring a >> generated column on a foreign table if you ignore it? Then you might as >> well prohibit declaring such columns in the first place. > > Maybe what we need here is some documentation clarifying exactly what > the point of a generated column on a foreign table actually *is*. > When would you do it, and what relationship if any has it got to the > generation status of the underlying remote column? The behavior is explained here: https://www.postgresql.org/docs/current/sql-createforeigntable.html If you have a foreign table with a column "a" and a column "b" generated as (a * 2), and say the underlying storage is a flat file, then the generated value is computed by the server and written to the file. The file behaves essentially analogous to the regular table heap file. The way I understand this bug report is, what if the underlying storage is another SQL database with its own generated columns. Then how do we manage it so that IMPORT FOREIGN SCHEMA can mark the foreign table column as "column exists to be read, but don't write to it". The proposal was to repurpose the generated column syntax for that, but that breaks the flat-file use case above. The follow-up proposal was to let the FDW implementation decide. I don't think that is always the right thing either. What if I want the foreign-table node to do the computations, because it has access to special parameters or something. There might be multiple possibilities of what is appropriate here. But that's not something we can just change around as part of a bug fix.