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 1lhaJJ-000074-Ur for pgsql-general@arkaria.postgresql.org; Fri, 14 May 2021 16:05:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lhaJI-0003PU-TL for pgsql-general@arkaria.postgresql.org; Fri, 14 May 2021 16:05:08 +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 1lhaJI-0003PM-Iu for pgsql-general@lists.postgresql.org; Fri, 14 May 2021 16:05:08 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lhaJB-0003so-SB for pgsql-general@lists.postgresql.org; Fri, 14 May 2021 16:05:08 +0000 Received: by mail-wr1-x431.google.com with SMTP id v12so30473420wrq.6 for ; Fri, 14 May 2021 09:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=cybertec; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=ZEnNMHNcaGMd+bAn4GVh4TqzVx534P6F31GNiqV0H6E=; b=uKmFeFTZoovd4+kmARfnDFTSx88Wd53aL3nol69Twg1IOrLhjeyB64GERph1fpomCa S3DO2RZzKgafrsT/2GPzq2y7AfogvJNxOm2SeTLBPKiswlCKnZfC2+I5nYaSmJDTmprH QQrxin7X3Bx+MLD3mRFRscy97A6kP3S1NRFAGexZnjkuFWvzPTrd0a+Q+7bar7tUct+E ya5QZ4J7A3kGDWg7bR2LpS3gmM7FlWei2TCUMR+QxU6dd0QqiMN4zcs9jzHN+KbWNWpY b9k2yXSSAQ5mg4YKKsaNWiLUx91c9uQ5hFEPnxl2zUs5Xejk28fE1wGb7jHkeJCTMriG V05A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=ZEnNMHNcaGMd+bAn4GVh4TqzVx534P6F31GNiqV0H6E=; b=a3esapdLQqo/L6t37mmJ6KG+X9SvrLViZO4Yv0e3v76fWLZksSmvX9sPj3phj07Tc8 31hI1/uFdCU2fRmrVHHgnoTfG32dxWmFT+2zeEFQ6ch8emDDdJOFhA7mqgLA74REyjCJ QVwqvR+OD1CAIVPotDuxVzFXxk6aqqlTd6BD9XmIfMz1PozvhrXgLaGmF3XsUxJSGOWY ON/tO7popevrMmQ0P3zXw+oFZt9Lz/EJ5IDgo9sHa5jSsJLIqgVE8ygzfG6r7Ap2J7qi 27Aqj66VDaiNiAZey2hBp7n7PXDlNZTfkbk3mUcOd+Gk+sQEiIeQvAMWaxj+Npi9Xcd0 v09g== X-Gm-Message-State: AOAM531Xius83fMXavQBKpSdrLwGIVLFyvp4kaQMXSFpQkShflqltTXb bBthJ/GQ2YBwmYmyhzLUG0vfkQ== X-Google-Smtp-Source: ABdhPJzsEaY4Zt80sduUyBGVPeOMp2lQTk+mo9JDyvXRMRkrXodP3mDojj/gQjiz62bliCzquG0KLQ== X-Received: by 2002:adf:d84b:: with SMTP id k11mr2396137wrl.235.1621008300724; Fri, 14 May 2021 09:05:00 -0700 (PDT) Received: from localhost.localdomain (217-149-172-105.nat.highway.telekom.at. [217.149.172.105]) by smtp.gmail.com with ESMTPSA id f3sm6670786wrp.7.2021.05.14.09.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 May 2021 09:05:00 -0700 (PDT) Message-ID: <342e0b863a3b6fc4c31ab18c827cb9b165cdb365.camel@cybertec.at> Subject: Re: Query on postgres_fdw extension From: Laurenz Albe To: Tom Lane , Swathi P Cc: Bharath Rupireddy , pgsql-general@lists.postgresql.org Date: Fri, 14 May 2021 18:04:59 +0200 In-Reply-To: <1883853.1621003992@sss.pgh.pa.us> References: <1883853.1621003992@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2021-05-14 at 10:53 -0400, Tom Lane wrote: > Swathi P writes: > > Hence we decided to have the coordinator nodes as stateless and hence > > declared the column with no serial/sequence. Let me know if this makes > > sense. > > Attaching serial-sequence defaults on both sides would certainly not > work very well, because the sequences wouldn't stay in sync. > > Unfortunately, postgres_fdw just doesn't have a good way right now > to make use of dynamically-generated defaults at the remote server. > If you leave out a column in your INSERT, it's going to compute > and send the locally-defined default (which is just null in this > case), so the remote's default expression is never used. > > I remember that we spent a great deal of effort in postgres_fdw's > early days, trying to find a way that we could use the remote's > defaults in cases like this. But everything we tried ended up > causing horrible semantic inconsistencies, so we ended up with > the always-use-the-local-default approach. There was some feeling > that maybe this could be revisited later, but no one's done so. > > 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. One possibility might be to define a trigger on the remote table that fetches the next sequence value if you try to insert NULL. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com