Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ryET5-00FBUd-AO for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Apr 2024 17:25:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ryET3-00BRP4-SY for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Apr 2024 17:25:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ryEPv-00BN6o-6K for pgsql-hackers@lists.postgresql.org; Sat, 20 Apr 2024 17:22:24 +0000 Received: from fhigh5-smtp.messagingengine.com ([103.168.172.156]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ryEPr-0020cg-2X for pgsql-hackers@lists.postgresql.org; Sat, 20 Apr 2024 17:22:22 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id AB9EC11400FA; Sat, 20 Apr 2024 13:22:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sat, 20 Apr 2024 13:22:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1713633736; x= 1713720136; bh=lO4aDhD1eIhmiRUym7mtE4EvPjOMljtvCAyQbmJ2htI=; b=Y rNzPltmTJzplDPhTp1bxTwm2S4/Fw1wjnNui9z30rUvbJG/ojqd1rHfDEEkzWa14 ryxSsj5BDW4D8NaIaL54sbQhOzFgoy87ZO8u4g6IjUwbsAXbQuDMry8PemWXgXZY XZ6iRncCZYkAFE7/JBYNIeJuk1yxQfLtp6xg2V7rr1hSEjRa+RArH71D34ldOhBd N/9axVDD0U1HYlY83ssLEtEOVKURClVNF1lXHbU3at3kwXT6j7Nkq4z4snOSI1Fz fK5LThz4p8huIm5NEOVpCNqnkKv/kkNctyvScUXEblksM9GDGzcfDUBxR/tiMEpl xrL613E3q3O6zBnmDlX9Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudekgedgudduvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhv rghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorh hgqeenucggtffrrghtthgvrhhnpeekhfetveeuudfghfehffeuueelledvveehveeihfei leeviedtleejheegledtkeenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhtvghsth huphhgrhgruggvgihvvghrshhiohhnrdhpmhdpvghnthgvrhhprhhishgvuggsrdgtohhm necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvh hhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 20 Apr 2024 13:22:15 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1713527971; bh=FB8Xhq2hMZDAPownXyHLpNoRQDQVHUUONnfSHFZ8gz0=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=lrA1QmsgbeM8AyN0f8amggTM/J+djdY+UvIjIZ2xwbJxpyhB23HEo1nGLuogfX49O rKjogUv+rjhg3KnCFRilFMI6PplLjecOB658HrptFrSojutcArmYwDtNTme6jOZyb/ +2vSEtdP9ejRlwFw7VEOiojcP7XFbaMUufwrvlS/6y1RcgInr9PjXUXyy+Qfa0/5Ao EfYvLcqsL8ADzHM/k1+oB16Wk7Vkbx2aUvbPlVfXNZbdz9pdw5sxr2YBeJfGf29X93 qskHx/rUDzIXoUSu3n9JPXVhL2UlsgYtEv5zaV9aaxF86ZtDi7iquGnCuRpGUQ2bJY dPURIDDIMjJPQ== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 5AA555B3; Fri, 19 Apr 2024 13:59:31 +0200 (CEST) Date: Fri, 19 Apr 2024 13:59:31 +0200 From: Alvaro Herrera To: Andrew Dunstan Cc: pgsql-hackers@lists.postgresql.org, Justin Pryzby Subject: Re: pgsql: Fix restore of not-null constraints with inheritance Message-ID: <202404191159.cakeaydac4sq@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3a642a59-e3c7-4050-95dd-af3b5412e5f7@dunslane.net> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Apr-18, Andrew Dunstan wrote: > On 2024-04-18 Th 11:39, Alvaro Herrera wrote: > It's not that hard to make it go back to 9.2. Here's a version that's a > couple of years old, but it supports versions all the way back to 7.2 :-) Hmm, so I tried grabbing the old-version module definitions from here and pasting them into the new Cluster.pm, but that doesn't work, as it seems we've never handled some of those problems. > If there's interest I'll work on supporting our official "old" versions > (i.e. 9.2 and up) I'm not sure it's really worth the trouble, depending on how much effort it is, or how much uglier would Cluster.pm get. Maybe supporting back to 10 is enough, assuming I can reproduce crake's failure with 10, which I think should be possible. > It's running the buildfarm cross version upgrade module. See > Thanks, I'll have a look and see if I can get this to run on my side. > It's choking on the change in constraint names between the dump of the > pre-upgrade database and the dump of the post-upgrade database, e.g. > > CREATE TABLE public.rule_and_refint_t2 ( > - id2a integer CONSTRAINT pgdump_throwaway_notnull_0 NOT NULL NO INHERIT, > - id2c integer CONSTRAINT pgdump_throwaway_notnull_1 NOT NULL NO INHERIT > + id2a integer CONSTRAINT rule_and_refint_t2_id2a_not_null NOT NULL NO INHERIT, > + id2c integer CONSTRAINT rule_and_refint_t2_id2c_not_null NOT NULL NO INHERIT > ); Yeah, I saw this, and it was pretty obvious that the change I reverted in d72d32f52d26 was the culprit. It's all good now. > I assume that means pg_dump is generating names that pg_upgrade throws away? > That seems ... unfortunate. Well, I don't know if you're aware, but now pg_dump will include throwaway not-null constraints for all columns of primary keys that don't have an explicit not-null constraint. Later in the same dump, the creation of the primary key removes that constraint. pg_upgrade doesn't really play any role here, except that apparently the throwaway constraint name is being preserved, or something. Anyway, it's moot [for] now. BTW because of a concern from Justin that the NO INHERIT stuff will cause errors in old server versions, I started to wonder if it wouldn't be better to add these constraints in a separate line for compatibility, so for example in the table above it'd be CREATE TABLE public.rule_and_refint_t2 ( id2a integer, id2c integer ); ALTER TABLE public.rule_and_refint_t2 ADD CONSTRAINT pgdump_throwaway_notnull_0 NOT NULL id2a NO INHERIT; ALTER TABLE public.rule_and_refint_t2 ADD CONSTRAINT pgdump_throwaway_notnull_1 NOT NULL id2c NO INHERIT; which might be less problematic in terms of compatibility: you still end up having the table, it's only the ALTER TABLE that would error out. > There is a perl module at src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm. > This is used to adjust the dump files before we diff them. Maybe you can > remedy the problem by adding some code in there. Hopefully nothing is needed there. (I think it would be difficult to make the names match anyway.) -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "If you have nothing to say, maybe you need just the right tool to help you not say it." (New York Times, about Microsoft PowerPoint)