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 1o1YkQ-0002KK-N6 for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Jun 2022 19:32:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o1YkO-0001JH-Fo for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Jun 2022 19:32:12 +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 1o1YkO-0001J6-6w for pgsql-hackers@lists.postgresql.org; Wed, 15 Jun 2022 19:32:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o1YkJ-0005nd-Tk for pgsql-hackers@lists.postgresql.org; Wed, 15 Jun 2022 19:32:10 +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 25FJW4Jd540148; Wed, 15 Jun 2022 15:32:04 -0400 From: Tom Lane To: Justin Pryzby cc: "David G. Johnston" , Petr Vejsada , pgsql-hackers@lists.postgresql.org Subject: Re: pg_upgrade (12->14) fails on aggregate In-reply-to: <20220614230949.GX29853@telsasoft.com> References: <3383880.QJadu78ljV@vejsadalnx> <20220614230949.GX29853@telsasoft.com> Comments: In-reply-to Justin Pryzby message dated "Tue, 14 Jun 2022 18:09:49 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <540146.1655321524.1@sss.pgh.pa.us> Date: Wed, 15 Jun 2022 15:32:04 -0400 Message-ID: <540147.1655321524@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Justin Pryzby writes: > But Petr has a point - pg_upgrade should aspire to catch errors in --check, > rather than starting and then leaving a mess behind for the user to clean up Agreed; pg_upgrade has historically tried to find problems similar to this. However, it's not just aggregates that are at risk. People might also have built user-defined plain functions, or operators, atop these functions. How far do we want to go in looking? As for the query, I think it could be simplified quite a bit by relying on regprocedure literals, that is something like WHERE ... a.aggtransfn IN ('array_append(anyarray,anyelement)'::regprocedure, 'array_prepend(anyelement,anyarray)'::regprocedure, ...) Not sure if it's necessary to stick explicit "pg_catalog." schema qualifications into this --- IIRC pg_upgrade runs with restrictive search_path, so that this would be safe as-is. Also, I think you need to check aggfinalfn too. Also, I'd be inclined to reject system-provided objects by checking for OID >= 16384 rather than hard-wiring assumptions about things being in pg_catalog or not. regards, tom lane