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 1lhZo0-0007KO-Gm for pgsql-general@arkaria.postgresql.org; Fri, 14 May 2021 15:32:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lhZnz-00010e-3j for pgsql-general@arkaria.postgresql.org; Fri, 14 May 2021 15:32:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhZny-00010U-Qj for pgsql-general@lists.postgresql.org; Fri, 14 May 2021 15:32:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhZnw-0003Qg-S3 for pgsql-general@lists.postgresql.org; Fri, 14 May 2021 15:32:46 +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 14EFWfiS1885559; Fri, 14 May 2021 11:32:41 -0400 From: Tom Lane To: Bharath Rupireddy cc: Swathi P , pgsql-general@lists.postgresql.org Subject: Re: Query on postgres_fdw extension In-reply-to: References: <1883853.1621003992@sss.pgh.pa.us> Comments: In-reply-to Bharath Rupireddy message dated "Fri, 14 May 2021 20:40:52 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1885557.1621006361.1@sss.pgh.pa.us> Date: Fri, 14 May 2021 11:32:41 -0400 Message-ID: <1885558.1621006361@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bharath Rupireddy writes: > On Fri, May 14, 2021 at 8:23 PM Tom Lane wrote: >> One conceivable workaround is to do your insertions through a >> foreign table that doesn't even have the serial column, so that >> the INSERT command received by the remote server lacks that >> column and the default gets applied. Probably too messy though. > Then the serial column cannot be selected via the foreign table. Yeah, you'd probably need to use different tables for inserting and reading, which is why I called it messy. The idea you pointed to in Michael's blog might work though, ie make a local function that reaches over to the remote server to get a globally-valid next sequence value, and use that as the default expression of the foreign table. regards, tom lane