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 1nAyqk-0005nK-0R for pgsql-general@arkaria.postgresql.org; Fri, 21 Jan 2022 18:41:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nAyqi-0003hH-SK for pgsql-general@arkaria.postgresql.org; Fri, 21 Jan 2022 18:41:24 +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 1nAyqi-0003gm-HU for pgsql-general@lists.postgresql.org; Fri, 21 Jan 2022 18:41:24 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAyqg-0003ub-0s for pgsql-general@lists.postgresql.org; Fri, 21 Jan 2022 18:41:24 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id D35C332021CA; Fri, 21 Jan 2022 13:41:19 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 21 Jan 2022 13:41:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc: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=oWqOJWe29ujw9Q SbNiUyLLcG0jDQLsk0/qUdsHM0S/E=; b=db/j5ilOeei0/XMUdvgxl+lmnuv0dm gWMzAyIZFrqKHaLRchsD4eLyAKvE/BBfOd+cIU0M/Y6RUD5Y+Y8+TjhpWL6EIrGq ayQ3B6FOUwihwr4OzzIIgml/T/10kF+ALQPIR7Ghf5z5sP25KCWv4XuLQIrjNBiV qYp6lyteVNXSaQO8kg/XoDyo5D0kya3Jg6mIXqzdO0CTF0WFLr+PbJ2ADe3W42TQ M/qZNaa8ViZRlV/3V4pH6ZHX1ST7zYFSYK8WY+9s0AO1STH80bMwp88Vi8uWY1g4 PWFtmFebPOBTPOmwLCyGw1xZsA8sIb/oyFyfczt9361/4blZ6Y1OSBFw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=oWqOJWe29ujw9QSbNiUyLLcG0jDQLsk0/qUdsHM0S /E=; b=andUff7yCsMNCvY34uBaSwAugBZhJyIas7fbIlNNMwwgP/p7j/lFY6/FN 62JkJ7DSXiEdFn9FO9e7AMc//4rw5K2m3NRhYRDBO3RnhHAy4Ba6NO8lN+WtRf0H yfZFajOysLIiddlklLefdp/VmfSLhGA3epThIV+9lQj0dF7vM4UACK3g1gPu7ue5 gqJiyUgA1167NvBtip/bYga+ORmD4yLMAnAvncnoiYNkvdMAuV92VyRVa9vQw9Db NPWhrs9Cv80Tf4Qaav/RrSXrFuBuzfMV6GWVAboi8wiyAODXjY8zrcokctOobiBG ck3CqKW5perh65N+/rYp2wI+mwI4w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrvddtgdduudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeduudefjeetveffhefgudehtdfhvdetkeeiueehfeev veduteekleeuheegudehhfenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhi rghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 21 Jan 2022 13:41:18 -0500 (EST) Subject: Re: Using a different column name in a foreign table To: Alanoly Andrews , Tom Lane , Guillaume Lelarge Cc: "pgsql-general@lists.postgresql.org" References: <1192002.1642783906@sss.pgh.pa.us> <41f945c2-b0b2-12ca-da63-f9cf7d4740d7@aklaver.com> From: Adrian Klaver Message-ID: <74446e3f-45b1-3f2f-a18d-4a477a97886a@aklaver.com> Date: Fri, 21 Jan 2022 10:41:18 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.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: Archived-At: Precedence: bulk On 1/21/22 10:32 AM, Alanoly Andrews wrote: > Thanks Adrian. I was aware of that. > > But...in the case of FT definition, the quotes are mandatory after column_name in options. And it is a single quote. > The problem here may be is that the "create foreign table" statement accepts only lower case after options. Remember that the double quotes for the column name in the "select" statement is generated by postgres, not by the end user. If the double quotes were not present, the query with the upper case would have worked. I have not looked at the source, but I'm betting it is using something like: https://www.postgresql.org/docs/14/functions-string.html quote_ident ( text ) → text Returns the given string suitably quoted to be used as an identifier in an SQL statement string. Quotes are added only if necessary (i.e., if the string contains non-identifier characters or would be case-folded). Embedded quotes are properly doubled. See also Example 43.1. quote_ident('Foo bar') → "Foo bar" So: select quote_ident('MSG_CLNT_HOST_NM'); quote_ident -------------------- "MSG_CLNT_HOST_NM" select quote_ident('msg_clnt_host_nm'); quote_ident ------------------ msg_clnt_host_nm > > A.A. > -- Adrian Klaver adrian.klaver@aklaver.com