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 1raIGV-0092k3-IB for pgsql-general@arkaria.postgresql.org; Wed, 14 Feb 2024 16:37:43 +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 1raIGU-007BVE-8v for pgsql-general@arkaria.postgresql.org; Wed, 14 Feb 2024 16:37:42 +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 1raIGT-007BUw-Us for pgsql-general@lists.postgresql.org; Wed, 14 Feb 2024 16:37:41 +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.94.2) (envelope-from ) id 1raIGR-006jnb-C7 for pgsql-general@lists.postgresql.org; Wed, 14 Feb 2024 16:37:40 +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 41EGbbw72899691; Wed, 14 Feb 2024 11:37:37 -0500 From: Tom Lane To: Ayush Vatsa cc: pgsql-general@lists.postgresql.org Subject: Re: Query regarding function cleanup in extension upgrade path In-reply-to: References: Comments: In-reply-to Ayush Vatsa message dated "Wed, 14 Feb 2024 21:58:29 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2899689.1707928657.1@sss.pgh.pa.us> Date: Wed, 14 Feb 2024 11:37:37 -0500 Message-ID: <2899690.1707928657@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ayush Vatsa writes: > To ask the question let me give a hypothetical example:- > Suppose we have an extension named xyz with version 1.0. It has > xyz--1.0.sql and xyz.c file. I have declared a function named fun() in the > xyz--1.0.sql file and its definition in the xyz.c file. > Now I want to drop this function in the next upgrade i.e. xyz--1.0--1.1 so > I will use DROP FUNCTION fun(); in it and remove the definition from the > xyz.c file. > Here my doubt is wouldn't xyz--1.0 complain about the missing definition of > fun() and if yes how can I clean up my function definition in the xyz.c > file? Yeah, you can't really remove the C extern symbol ever. You can reduce the C function to a stub that just throws a not-supported error, perhaps, but your users won't necessarily appreciate that. It's usually better to make the shlib capable of supporting both the 1.0 and 1.1 APIs, so that users aren't forced into updating the extension's SQL declarations immediately. If you look at the standard contrib modules, you'll find a number of cases where there are backwards-compatibility functions that just exist to support people who're still using an older version of the extension's SQL declarations. Those are likely to remain there indefinitely. regards, tom lane