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 1uo6Js-00GLlh-SC for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Aug 2025 20:19:06 +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 1uo6Jq-0022rG-St for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Aug 2025 20:19:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uo6Jq-0022r8-Kl for pgsql-bugs@lists.postgresql.org; Mon, 18 Aug 2025 20:19:03 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uo6Jo-000WnA-1q for pgsql-bugs@postgresql.org; Mon, 18 Aug 2025 20:19:02 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 57IKIuY9454619; Mon, 18 Aug 2025 16:18:56 -0400 From: Tom Lane To: Nathan Bossart cc: Andrew Dunstan , "IVAN HUMANES CABANAS (Fujitsu)" , "pgsql-bugs@postgresql.org" Subject: Re: Error pg_upgrade version 11 to 15 In-reply-to: References: <417487.1755533405@sss.pgh.pa.us> <6545b4ca-a685-4a30-8aec-451dcb891d0b@dunslane.net> Comments: In-reply-to Nathan Bossart message dated "Mon, 18 Aug 2025 15:07:01 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <454617.1755548336.1@sss.pgh.pa.us> Date: Mon, 18 Aug 2025 16:18:56 -0400 Message-ID: <454618.1755548336@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > I concur with Tom that this is most likely due to template1 not being > marked as a template database in the source cluster. We could presumably > hack pg_upgrade to deal with this for template1 and postgres databases > (e.g., by preemptively setting datistemplate = f on the new cluster). > Changes to template0 are likely harder to deal with. Since pg_dump uses it > as the template for databases it creates, we'd have to wait until all other > databases are restored before re-creating it. Plus, we'd probably have to > first create a fresh template0 clone (with the source template0's encoding > and locale settings) so that there was something to use as a template for > template0. There might be other problems, and I'm not sure it's worth the > effort, anyway. Yeah. The logic about this is in pg_dump, actually: dumpDatabase() decides whether or not to add "UPDATE ... SET datistemplate = false" to the delQry. I was thinking about having it do that either if the source DB has datistemplate or if its name is template1. That would cover both (1) restoring a nonstandard set of databases into the original installation with --clean, and (2) restoring a nonstandard setup into a pristine installation. I don't think we need to account for template0 because neither pg_dumpall nor pg_upgrade will attempt to replace it. However, first I'd like confirmation that this theory explains the OP's problem. regards, tom lane