Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBfdg-00Br8U-HA for pgsql-general@arkaria.postgresql.org; Fri, 08 Dec 2023 18:31:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rBfdf-00AYMh-6g for pgsql-general@arkaria.postgresql.org; Fri, 08 Dec 2023 18:31:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBfde-00AYLn-Ri for pgsql-general@lists.postgresql.org; Fri, 08 Dec 2023 18:31:50 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rBfdc-009S7y-DH for pgsql-general@lists.postgresql.org; Fri, 08 Dec 2023 18:31:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3B8IVkkV1468018; Fri, 8 Dec 2023 13:31:46 -0500 From: Tom Lane To: "peter.borissow@kartographia.com" cc: pgsql-general@lists.postgresql.org Subject: Re: Inserting into foreign table with sequences and default values In-reply-to: <1702058638.91064408@apps.rackspace.com> References: <1702058638.91064408@apps.rackspace.com> Comments: In-reply-to "peter.borissow@kartographia.com" message dated "Fri, 08 Dec 2023 13:03:58 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1468016.1702060306.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 08 Dec 2023 13:31:46 -0500 Message-ID: <1468017.1702060306@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "peter.borissow@kartographia.com" writes= : > I guess the FDW is not "seeing" the default value for status and the big= serial sequence for the id column. Is there anyway around this? The idea is that you should attach default clauses to the foreign table definition. A remote serial column is a hard case for that, though, since you don't have ready access to the remote sequence. Because of that and some related examples, we don't currently expect that IMPORT FOREIGN SCHEMA should import the defaults that exist on the remote server. Using a view or trigger on the remote side is currently the best way around that for cases where you can't set up a suitable default on the local table. regards, tom lane