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 1h8Y3q-0000PX-C1 for pgsql-general@arkaria.postgresql.org; Mon, 25 Mar 2019 22:27:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h8Y2q-0007ly-NR for pgsql-general@arkaria.postgresql.org; Mon, 25 Mar 2019 22:26:16 +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 1h8Y2q-0007lr-EP for pgsql-general@lists.postgresql.org; Mon, 25 Mar 2019 22:26:16 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8Y2l-0002zR-LR for pgsql-general@lists.postgresql.org; Mon, 25 Mar 2019 22:26:16 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 42E6927A09; Mon, 25 Mar 2019 18:26:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 25 Mar 2019 18:26:10 -0400 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=fm2; bh=P R9+YQ+6u5fTvZ7DrYIx7euN9GxLE3Nn7uwq5BhmYTE=; b=DkcSO/9jXGQiY2P90 5CDQ0OdeVDLZ8pbezV59Y6LkNax3yUh83v99sDBEdkLBuC/hHH95v8AC59JV5NMn SvFIzuP3D42wurgPkcbtzZg3cYO4CeLged5ytAnOFYNdwBZP0+ciIOwuJN+9uvnB vJ0BiTY2z2A6hG+E0PEedhDnBVnk+bjinx/DbbNK1lIARhaIxp63AK/4lhdUJKm4 wV6yVZuluG7mj6DWhwsCXwblxsw1Rx8ywlBVxlNxT4xlUJ/tCnOgNpW4X3/Pq5s9 v0mBSl8t304wNyR9guUkB2MeI184q97QMCOkhpe9X4hw0Ib/VXEN3tkHfdXa/6ED dOujQ== 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=fm2; bh=PR9+YQ+6u5fTvZ7DrYIx7euN9GxLE3Nn7uwq5BhmY TE=; b=1N6q156feQ5SaThEOmKgH8k0FyRKLulEaHPlCcSP5MPisP0jiAwNrKj5t N3i68tx2rawL5Ebjw7xXZstWtNnL9rJ7WRN6eLZT36q/BShX60QurLz+q9HI2z1r FUTEBl6gMnPkCTmeO+izslhhQ4uhRshue37LdqnA+vxjE9IEcX6MSjP016huNiFI g7PJHvt+B9o9OLXdGpMMW8msFTlX1cel1RyKfDSCndX9tTSI+T62L81L3refvorE pz7jQvwbuLNzM8RniYd+pCe4HCCTR8970UvPsYqRDEXLsseuri/3KHLE6UrXU37K 6Sblrga1qE6oZMeXsVIzBnSJzzhJQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrjeekgdduiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecukfhppeejfedrvdef ledruddujedrvdefkeenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklh grvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from ranger.suse (c-73-239-117-238.hsd1.wa.comcast.net [73.239.117.238]) by mail.messagingengine.com (Postfix) with ESMTPA id 3ACCA10311; Mon, 25 Mar 2019 18:26:09 -0400 (EDT) Subject: Re: Error: "remote query result rowtype does not match the specified FROM clause rowtype," on remote function call To: Antonio Gomez , "pgsql-general@lists.postgresql.org" References: <1a10f0e7-a098-65b7-c08a-440bfb871166@aklaver.com> From: Adrian Klaver Message-ID: <06c9a315-caed-ef45-9ea9-10f5b311bcbf@aklaver.com> Date: Mon, 25 Mar 2019 15:26:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: 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: Precedence: bulk On 3/25/19 3:20 PM, Antonio Gomez wrote: > I figured it out, you have to specify the type twice, once inside the remote call and once outside. > > Like this: > > SELECT * FROM dblink('conn_str', 'select public._test1() as x(a int ,b int)') as x(a int ,b int); > > Not optimal and not readily discernible, but there it is. Actually it sort of is, once I started working on a test: select * from public._test1(); ERROR: a column definition list is required for functions returning "record" LINE 1: select * from public._test1(); Have you looked at postresql_fdw?: https://www.postgresql.org/docs/11/postgres-fdw.html > > Thanks for your response! > > --T. > > -----Original Message----- > From: Adrian Klaver > Sent: Monday, March 25, 2019 6:14 PM > To: Antonio Gomez ; pgsql-general@lists.postgresql.org > Subject: Re: Error: "remote query result rowtype does not match the specified FROM clause rowtype," on remote function call > > CAUTION: External E-mail > > > On 3/25/19 1:08 PM, Antonio Gomez wrote: >> This is my *remote* function: >> >> CREATEORREPLACE FUNCTIONpublic._test1() >> >> RETURNS record >> >> LANGUAGE plpgsql >> >> AS$function$ >> >> DECLARE >> >> rec record; >> >> BEGIN >> >> select1,2intorec; >> >> returnrec; >> >> END$function$; >> >> This is my *local* function call: >> >> SELECTx.a, x.b >> >> FROMdblink('conn_str', 'select public._test1();') >> >> asx(a int ,b int); > > Do not have time to spin a test up at the moment, but what happens if you do?" > > SELECT * > > FROM dblink('conn_str', 'select public._test1();') > > as x(a int ,b int); > >> >> This is the error thrown: >> >> ERROR: remote query result rowtype does notmatchthe specified >> FROMclause rowtype >> >> Question: >> >> Since DBLINK requires that I define a schema to place the function's >> return items, how do I make the call to recognize a record type being >> returned by the function. >> >> Thanks! >> > > > -- > Adrian Klaver > adrian.klaver@aklaver.com > -- Adrian Klaver adrian.klaver@aklaver.com