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 1iOT6z-0003Ov-OB for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Oct 2019 20:56:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iOT6y-0006Xa-Ib for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Oct 2019 20:56:36 +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 1iOT6y-0006Wz-5z for pgsql-hackers@lists.postgresql.org; Sat, 26 Oct 2019 20:56:36 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iOT6v-0002Nt-OU for pgsql-hackers@lists.postgresql.org; Sat, 26 Oct 2019 20:56:35 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id C199F21FE0; Sat, 26 Oct 2019 16:56:32 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 26 Oct 2019 16:56:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=zL2K6mZHO6SNFyRPabRVNjIF6Bc Gvk/tys40dJOUeOA=; b=go4BOmuStKbu+i3RzwQHmD7pHkaKD6p1feQMKvCFXg1 1DOzmazHUsr6VICsHq1z2gGXKjvNqkJCWgYNwKbkhDTivB1UC8EReYeXWb4CdtSX +qnE17XUHDtzCjqyp2FraUosGQsMkEIXTu+9I9f07cqh9d68WBUgwytQSIqz/ssX NJ7AkNOtAOzrbTBwaQf0SX5RtEoAwG6ES5SDvGvLOEDSnjDkuzhZI045HfBz52qk CnIRidH7jGa/8vGcDasSHDJgM2KtFtp54c9dSxKaX7zlBVZgFXAr9xocOE0Ygt6B gxNi3ocCkaUy8zI+UOoyZHvA/B2WcW2X70UmWD13Pcg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=zL2K6m ZHO6SNFyRPabRVNjIF6BcGvk/tys40dJOUeOA=; b=fX/WvM6btQCPgp1ua1d3iZ sA+aL0aD76kZv55QeuVxQykaGXQWNZGIk2kyqewj+7dpLmViiGBhOd4riPxu8Eg1 Yb4mheOIIwBMH3ZUzSOQRwKNGepwDfNfOIx9rOQqX5qun3nOgCXr6V2IvqSFfqi5 pohMD14tic+SnpwVgIQILnepanwvd5RPtORZV30K29KyRf5oFu5tWbtHPE16ZjJH Rin9RER68uU365271NKBwN9yQfLM0lsRcGJV8cq1aEUwljnU5GFahDmoZUfrsvN4 f3cDig87fjPTCWT/1CbYXKNm5kkE66PvSRe78URiOh1RvN+6EGwChMkhtt6/mKfg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrleehgdduheejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesthdtre dttddtvdenucfhrhhomheptehnughrvghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghn rghrrgiivghlrdguvgeqnecukfhppeeijedrudeitddrvddukedrvdefjeenucfrrghrrg hmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggvnecuvehluhhs thgvrhfuihiivgeptd X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-218-237.hsd1.ca.comcast.net [67.160.218.237]) by mail.messagingengine.com (Postfix) with ESMTPA id 06A3380063; Sat, 26 Oct 2019 16:56:32 -0400 (EDT) Date: Sat, 26 Oct 2019 13:56:30 -0700 From: Andres Freund To: Tom Lane Cc: Alex Williams , "pgsql-sql@postgresql.org" , pgsql-hackers@lists.postgresql.org Subject: Re: pg_dump compatibility level / use create view instead of create table/rule Message-ID: <20191026205630.cubjcxgs2rhke7xa@alap3.anarazel.de> References: <30565.1570597261@sss.pgh.pa.us> <18dWrRFcmR7qHhsVTvYfGuRT8Tx5LijYQ72SeMWaya_0FiBkS5BFiYTa47R5WVTlADzXAqI85sZgkKPFVdJP2UWsUwJty3KuZ4eZvlVXO-I=@protonmail.com> <17815.1570661198@sss.pgh.pa.us> <-pa2tdKbasT5nWrYgCtvhKtMDyPIboaoG53ZSPb0MfCvzMUaVJDgQddN1ve-XLllFBKmQ8kGJ7InqBcYwq5CJY2DnLI4HVWTHyYx8wwBTtM=@protonmail.com> <1095.1570720814@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1095.1570720814@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-10-10 11:20:14 -0400, Tom Lane wrote: > regression=# create table mytab (f1 int primary key, f2 text); > CREATE TABLE > regression=# create view myview as select * from mytab group by f1; > CREATE VIEW > > This situation is problematic for pg_dump because validity of the > view depends on the existence of mytab's primary key constraint, > and we don't create primary keys till late in the restore process. > So it has to break myview into two parts, one to emit during normal > table/view creation and one to emit after index creation. > > With 9.5's pg_dump, what comes out is: > > -- > -- Name: myview; Type: TABLE; Schema: public; Owner: postgres > -- > > CREATE TABLE public.myview ( > f1 integer, > f2 text > ); > > ALTER TABLE ONLY public.myview REPLICA IDENTITY NOTHING; Ick. > The reason we get "REPLICA IDENTITY NOTHING" is that a view's relreplident > is set to 'n' not 'd', which might not have been a great choice. Hm, yea. I wonder if we should add a REPLICA_IDENTITY_INVALID or such, for non relation relkinds? I'm mildly inclined to think that setting it to REPLICA_IDENTITY_DEFAULT is at least as confusing as REPLICA_IDENTITY_DEFAULT... > This is fixed in v10 and up thanks to d8c05aff5. I was hesitant to > back-patch that at the time, but now that it's survived in the field > for a couple years, I think a good case could be made for doing so. +1 > /* pretend view is a plain table and dump it that way */ > viewinfo->relkind = 'r'; /* RELKIND_RELATION */ > viewinfo->relkind = 'r'; /* RELKIND_RELATION */ > + viewinfo->relreplident = 'd'; /* REPLICA_IDENTITY_DEFAULT */ > > That's mighty ugly but it doesn't seem to carry any particular > risk. I also could live with this, given it'd only be in older back-branches. Greetings, Andres Freund