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 1iS0L8-0002Hm-3P for pgsql-general@arkaria.postgresql.org; Tue, 05 Nov 2019 15:01:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iS0L6-0000ph-PW for pgsql-general@arkaria.postgresql.org; Tue, 05 Nov 2019 15:01:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iS0L4-0000pa-S2 for pgsql-general@lists.postgresql.org; Tue, 05 Nov 2019 15:01:48 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iS0Ky-0003OB-3J for pgsql-general@lists.postgresql.org; Tue, 05 Nov 2019 15:01:45 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 1B0F0200D7; Tue, 5 Nov 2019 10:01:39 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 05 Nov 2019 10:01:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=w Crrm5/1jk/i7Nnj9ISh71SKEa0lUKx3whWNouuk6aw=; b=0k7Jki4ko6RiIMi1T rfYnPP/XhClshN+e5g/Xp7Sz/DWiLIZNdnoqAaM+Z8hXjcr4yCg9LAqEnVf9mOp5 cNDTvwMXccZmOmH76lo5zA0DP4+OK7DEMQXvBgek6yl0k/MValmXSU23RXuz/oo4 IL4fzKZ4Gqq5Qyl6hOD059Vu58AdjlTHR8GoLjFwKpTwSvDk2y5repe6TK4Nv/Rz CColXD5v8vdj0Gb4X2RD03MFrckJzbr2xI4ikKBLXJcxAj88zws7P48i+DWVH5Qu UQ0Inrzc6u1JZ/q4/RoxQUG7VtRqJUYlug1YqXQgDkPyFxvd+eNVRdTBzd1TKHoj j95Mg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=wCrrm5/1jk/i7Nnj9ISh71SKEa0lUKx3whWNouuk6 aw=; b=PpP4dE2PQqz4L38uMOK5agDotnq8O3/GXwEnXWyJwswYQNopKINHcENiz A5jQ/dhfPQRHarxDVT6BbEE8fm2zcvUeoqdAhqoXmCb/Y1afya9YxEu3pPky2+4+ sWEYfUNKa0eMqI8SJt1vIQjXvzpZVoEZu1BTcyczq0ZwyKRUvAP1lTdgbtSt1/tM p5Dxh/WUta/L87OrG40uqzlyv5ceblX0h7LscLklTJW5Y7+CvMac/aDBxix58iRl N9dvLgOtwZw+AQoMBJ04AA/LW0BJ9DwM6QYMx4FioW7OFIVLz5ELpk7aIXEJQ1jd jqPhvR64XnJWwIIveuDm4qkUKC8Rw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudduhedgjeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucfkphepjedurddvuddvrddufeefrddukeelnecurfgrrhgrmhepmhgrihhlfhhr ohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsth gvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.3] (unknown [71.212.133.189]) by mail.messagingengine.com (Postfix) with ESMTPA id 4BFD43060067; Tue, 5 Nov 2019 10:01:38 -0500 (EST) Subject: Re: select view definition from pg_views feature request To: Michael Shapiro , Tom Lane Cc: pgsql-general@lists.postgresql.org References: <31367.1572815723@sss.pgh.pa.us> From: Adrian Klaver Message-ID: Date: Tue, 5 Nov 2019 07:01:37 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 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/5/19 6:43 AM, Michael Shapiro wrote: > Can I set search_path='' (ie to a string that does not match any > existing schema)? Would that be the proper way to guarantee that the > definition for any view will always be fully-qualified? test=# show search_path; search_path ------------------------------------------------------------------ public,accounting,history,main,utility,timeclock,table_templates test=# select * from pg_views where viewname = 'up_view';; schemaname | viewname | viewowner | definition ------------+----------+-----------+------------------------------- public | up_view | aklaver | SELECT up_test.id AS up_id, + | | | up_test.col1 AS bool_col,+ | | | up_test.col_2 AS col2 + | | | FROM up_test; (1 row) test=# set search_path = ''; SET test=# show search_path; search_path ------------- "" (1 row) test=# select * from pg_views where viewname = 'up_view';; schemaname | viewname | viewowner | definition ------------+----------+-----------+------------------------------- public | up_view | aklaver | SELECT up_test.id AS up_id, + | | | up_test.col1 AS bool_col,+ | | | up_test.col_2 AS col2 + | | | FROM public.up_test; (1 row) > > On Sun, Nov 3, 2019 at 3:15 PM Tom Lane > wrote: > > Michael Shapiro > > writes: > > It seems that the definition of a view from pg_catalog.pg_views > does not > > qualify the tables used in the view if the tables are in the > current search > > path. > > > Is it possible to either have the definition always qualify all > tables > > independent of the search_path (or else provide a new column that > does > > that)? > > Why don't you just change the search path to empty before selecting? > >                         regards, tom lane > -- Adrian Klaver adrian.klaver@aklaver.com