Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gNRnF-0001co-FK for pgsql-general@arkaria.postgresql.org; Fri, 16 Nov 2018 00:15:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gNRnD-0006nc-Hb for pgsql-general@arkaria.postgresql.org; Fri, 16 Nov 2018 00:15:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gNRnB-0006mG-JE for pgsql-general@lists.postgresql.org; Fri, 16 Nov 2018 00:15:27 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gNRn6-00017u-Cg for pgsql-general@postgresql.org; Fri, 16 Nov 2018 00:15:25 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 56A4B21D23; Thu, 15 Nov 2018 19:14:53 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 15 Nov 2018 19:14:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=d 0d5N3R0bosKafB8X9gW/5LMvpC1plQ6mRVxBzXCO94=; b=iVjZsqjfDuz3r+QiE +rAsBRDaKnb4qqa5L7NtKFE+rPP+iW/rWMnQPS/7d5x0wOYn5pa0j0OtcyjnFPAW q34AE8RaVDC3Y996m+rQwvXSyR6QcSfhbRbYbAjwPCeXl4u0vaTk7QbdlRIlWszL XWzU5MSr48fUKtPUjr69s3RngqtQvuaGJlvZz9Y8BCRGZUN2ipJyBhmx/qAtFPY8 Be4z/ND1kvkImJZt3Y9gaOMNFd7knV19jwxPO+BEKQglVeqxue9uDp4CFrF7JuAj JpEvjzQwjftrvDYufLAl36sOe98XKDmLZBLQsOqe9tlErvz+DkQrzUQqVkd2cVSZ /vBDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm1; bh=d0d5N3R0bosKafB8X9gW/5LMvpC1plQ6mRVxBzXCO 94=; b=Y7eOgz4KKUFI1ydRR0bhg2gBfLnwUCcNBwU0tetP4bv2A57k2gbpIWlDy NIPBxDkwerZ/y5NIjm1nQw7E6SdpJBPbtd9XthqUVheWSGnC67V9WCpGJgYCW0nC NQW3Gvej0Im1jrB96d68bo91UZ8QFU0ZNhm0o4V+/aZClHWXMvXOE0ynbM5/GRGm ApkoinQDa284iGXWhgQWpnuc33fjXVHR5iyxgomZk6aPT4YiHuVuC40ImqCReVHU BbIsO6NAPOreM6DEHyWMfG7tAvfVKFnsnsUt+NswEfbtXiDZGgbivGyM0IS9lePL qyuUQ9MRypzIyD8/RYvOs/Fv6/9uA== X-ME-Sender: X-ME-Proxy: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 2746DE47A1; Thu, 15 Nov 2018 19:14:52 -0500 (EST) Subject: Re: Trouble with postgres_fdw & dblink extensions To: =?UTF-8?B?THVrw6HFoSBTb2JvdGth?= , pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: <9ae87bc4-52b3-e771-732f-7e6040b45ce1@aklaver.com> Date: Thu, 15 Nov 2018 16:14:51 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/15/18 3:23 PM, Lukáš Sobotka wrote: > Hi guys, > > I would be grateful for some help. I am writing you because I am > confused about using data foreign wrappers and dblink. I attached > simplified script describing the problem. > > What I am trying to do? > I have two databases and I need to copy table from local database to the > remote one. For copying is used function which contains a few parts: > > * > > loading setting from foreign table (this part became a problematic) > > * > > creating destination table on remote db > > * > > importing foreign table > > * > > insert data into foreign table > > If query using foreign table (with setting) is performed, command for > importing schema does not import new created table (it looks like table > is not created yet). So copying ends with error. The second calling of > function is all right (because destination table is already created from > first calling). > If function does not use foreign table, the first calling of function > copies all data. > > Why the new created remote table can not be imported to local database > when I had performed query on other foreign table? What am I missing? Should this: dblink('test_server_link' ...) not be: dblink_exec('test_server_link' ...) > > I am using PG 9.6 (PostgreSQL 9.6.10 on x86_64-pc-linux-gnu, compiled by > gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit). > > Best regards, Lukas > -- Adrian Klaver adrian.klaver@aklaver.com