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 1nAwqg-00019V-O1 for pgsql-general@arkaria.postgresql.org; Fri, 21 Jan 2022 16:33:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nAwqf-000497-Jq for pgsql-general@arkaria.postgresql.org; Fri, 21 Jan 2022 16:33:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAwqd-00048v-OV for pgsql-general@lists.postgresql.org; Fri, 21 Jan 2022 16:33:13 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAwqa-0001nk-VA for pgsql-general@lists.postgresql.org; Fri, 21 Jan 2022 16:33:10 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 9CA515C072D; Fri, 21 Jan 2022 11:33:07 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 21 Jan 2022 11:33:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; bh=URuGPY1pfkjAac KF9zEJe3muHkjPsxtF92F05OO5w/o=; b=vm1HaHNFP+WFGlALwZIZPyT4LQg95n ncbRQtQpvYNeqphFL1uYcghf+ueqxp9IvuBzfXuSIHFUbFS5Mzj6be0qROUc0iIl M6ijNxa6dlg+HIv92PiJcTshxQKA3e0omfSp152aaaGA9Nhu9ZmgiYrrm78NyYBc TfRnwmkpXPTis7/T5bjEB0bhiMNQhAy3eLCzepHgsjIfN2UgakfXcEuCXEh/DjNn HS9V2/nFguXsyInk3TD0ySAd2NKQq8IF2anyMfpNlUf+4AUXL7rFeU8vj3Y8DDpl VUKBL87Zg4pNEl/K5L9rl/FAFy6H/jWeqEnIMAdJ+yqWoY1cLr+JYEHg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=URuGPY1pfkjAacKF9zEJe3muHkjPsxtF92F05OO5w/o=; b=cn67kN79 0nCkju48EN3lDupZRRRfjquYXrCjx8ZVh7mqamwefdztsLQ2S1FZ+NEUvbEDrzGc JEgH18OO+akWO3m7c4dkpCd6c9YfQbcu73RoDVt/BRnAUJT/pUptT7wXmg9kt9D0 pBcZZdZGQNz3VAoqBZ+CJpmM+B2U28OgoDEuZHW3xmx9/wbiQFxhMy9nGXz5lhRW CvOfPldYOsB5/pRf2tLHljstCjrT8JHD6ppfBkG8R8iF1seE9KbQCRCXFxI3iy8a 80PPrrbzJsysKx8A2sIYod3FQc7fG92P6DfRg32trqVQ4eRYH9KqN9gPdMx9lj0F DtSkjXFvX8b99g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrvddtgdeklecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepudfgueelgeevfffhgeeljeehhfettdegieelgefgheef ffefveegjedtueetffdtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 21 Jan 2022 11:33:06 -0500 (EST) Message-ID: Date: Fri, 21 Jan 2022 08:33:06 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: Using a different column name in a foreign table Content-Language: en-US To: Alanoly Andrews , "pgsql-general@lists.postgresql.org" References: From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/21/22 08:24, Alanoly Andrews wrote: > Hello, > I see that the syntax for the creation of a foreign table allows you to > use a column name in the FT that is different from the one in the base > table. Such a "create foreign table" statement executes successfully and > creates the FT. But when I query the FT, I get an error wrt to the > column that had been renamed. See example below: > create foreign table tab1_ft ( >   id int, >     name char(10) options(column_name 'newname')) > server xxxxxx > options(schema_name 'public', table_name 'tab1'); What is the definition of the table tab1? > select * from tab1_ft; > ERROR:  column "newname" does not exist > HINT:  Perhaps you meant to reference the column "tab1.name". > CONTEXT:  Remote SQL command: SELECT id, newname FROM public.tab1 > So, it seems that the when the remote SQL command is composed, the > mapping of 'newname' to the 'name' in the base table does not take effect. > Is there a resolution to this issue? > Awaiting some input. > Alanoly Andrews. > -- Adrian Klaver adrian.klaver@aklaver.com