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 1qje7M-00BahK-VD for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Sep 2023 11:14:41 +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 1qje7L-0032pe-BE for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Sep 2023 11:14:39 +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 1qje7J-0032ot-Ls for pgsql-hackers@lists.postgresql.org; Fri, 22 Sep 2023 11:14:38 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qje7B-0060mq-MZ for pgsql-hackers@lists.postgresql.org; Fri, 22 Sep 2023 11:14:35 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 672D25C0203; Fri, 22 Sep 2023 07:14:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 22 Sep 2023 07:14:27 -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:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1695381267; x= 1695467667; bh=He8owlfnD9KZwQWVBogr62a6BNj5QN63saBN0d8gRDc=; b=J Xa4vemQ6Uc7ZEss/Ki9YrWJ+fH46KMUXgs98bZEnY93Y40xm+F7mH/d7oM6sZPbE koc1ToaFLHNhs4/k+jHITUQ0DmchnaWZqZSHrjIFH9fyo2KaEIKP4MgqCxKgwaQk 8r0fR7O9E7pEMdYAVAtCIn2fHmq8JfGqMDhUBQwCbVESeVqaoTh27zn44AdFNCLk 3K3+Fv8Def8lejJO7F/sS2NVAiMlVfRQ0m/qdF3l/vfSz6H1hsVnjQDtXtnlWJ8l 7dn1lm9VW5acUfx94Wiqbht1RWNV7mTGpoSp6J8/ANd3bigriezZsohs/2LlPUWm pQVyhpw0SoSfFYaQa+2NQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekkedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepudelkeekgfdttdettdekgfduvdeiffelteegjeeihfet heekveeftedtuddvhfeunecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Sep 2023 07:14:25 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1695381263; bh=fw85MHsRoCF35NPrhUVw0dz3tz4R5ou+0yrIiZyMHZ0=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=MOzBPs9g5wwmLxlSp00c2pVPTfZSHTmshxdkiEnUkVdFns/2xVj+soC3p2dL44DDS I53HMT+Vs9BR/R3J69/CiTtshsU4sGPqya5QdqHFEr78G6yEmULu4tiMh23cVB+7/j 6/x3GXOn5qO9HkmN5b+cGzwLG9mA6UUXOP3tYh9/GHjLihbeI/LngdnxwvJfg81/zK t68oZ+t8CkKQQg/bsNqMyFcxmR8Hs6I7vVPi8Oie1z99jyWBuozAOKOvIcy7yBwV2Z Y58NJamShJQ4XFxrEzN7tOucEhfj8BRQ7nOCZugRube6pZjNYlvCCtdVOJQeRC0qnQ hT5tQyMQhhYkg== Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id DF6CBCB; Fri, 22 Sep 2023 13:14:23 +0200 (CEST) Date: Fri, 22 Sep 2023 13:14:23 +0200 From: Alvaro Herrera To: Tom Lane Cc: Bruce Momjian , Pg Hackers Subject: Re: pg_upgrade --check fails to warn about abstime Message-ID: <202309221114.elojolugmsmv@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="g7whywbldtwquqvy" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <910187.1695352721@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --g7whywbldtwquqvy Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2023-Sep-21, Tom Lane wrote: > Bruce Momjian writes: > > Wow, I never added code to pg_upgrade to check for that, and no one > > complained either. > > Yeah, so most people had indeed listened to warnings and moved away > from those datatypes. I'm inclined to think that adding code for this > at this point is a bit of a waste of time. The migrations from versions prior to 12 have not stopped yet, and I did receive a complaint about it. Because the change is so simple, I'm inclined to patch it anyway, late though it is. I decided to follow Tristan's advice to add the version number as a parameter to the new function; this way, the knowledge of where was what dropped is all in the callsite and none in the function. It looked a bit schizoid otherwise. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "Postgres is bloatware by design: it was built to house PhD theses." (Joey Hellerstein, SIGMOD annual conference 2002) --g7whywbldtwquqvy Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v2-0001-pg_upgrade-check-for-types-removed-in-pg12.patch" From 5258379693db55618c6451ce8df4971521eb8e66 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Tue, 19 Sep 2023 12:30:11 +0200 Subject: [PATCH v2] pg_upgrade: check for types removed in pg12 Commit cda6a8d01d39 removed a few datatypes, but didn't update pg_upgrade --check to throw error if these types are used. So the users find that pg_upgrade --check tells them that everything is fine, only to fail when the real upgrade is attempted. --- src/bin/pg_upgrade/check.c | 51 +++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c index 56e313f562..21a0ff9e42 100644 --- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c @@ -26,6 +26,9 @@ static void check_for_tables_with_oids(ClusterInfo *cluster); static void check_for_composite_data_type_usage(ClusterInfo *cluster); static void check_for_reg_data_type_usage(ClusterInfo *cluster); static void check_for_aclitem_data_type_usage(ClusterInfo *cluster); +static void check_for_removed_data_type_usage(ClusterInfo *cluster, + const char *version, + const char *datatype); static void check_for_jsonb_9_4_usage(ClusterInfo *cluster); static void check_for_pg_role_prefix(ClusterInfo *cluster); static void check_for_new_tablespace_dir(void); @@ -111,6 +114,16 @@ check_and_dump_old_cluster(bool live_check) if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1500) check_for_aclitem_data_type_usage(&old_cluster); + /* + * PG 12 removed types abstime, reltime, tinterval. + */ + if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1100) + { + check_for_removed_data_type_usage(&old_cluster, "12", "abstime"); + check_for_removed_data_type_usage(&old_cluster, "12", "reltime"); + check_for_removed_data_type_usage(&old_cluster, "12", "tinterval"); + } + /* * PG 14 changed the function signature of encoding conversion functions. * Conversions from older versions cannot be upgraded automatically @@ -1215,7 +1228,8 @@ check_for_aclitem_data_type_usage(ClusterInfo *cluster) { char output_path[MAXPGPATH]; - prep_status("Checking for incompatible \"aclitem\" data type in user tables"); + prep_status("Checking for incompatible \"%s\" data type in user tables", + "aclitem"); snprintf(output_path, sizeof(output_path), "tables_using_aclitem.txt"); @@ -1233,6 +1247,41 @@ check_for_aclitem_data_type_usage(ClusterInfo *cluster) check_ok(); } +/* + * check_for_removed_data_type_usage + * + * Check for in-core data types that have been removed. Callers know + * the exact list. + */ +static void +check_for_removed_data_type_usage(ClusterInfo *cluster, const char *version, + const char *datatype) +{ + char output_path[MAXPGPATH]; + char typename[NAMEDATALEN]; + + prep_status("Checking for removed \"%s\" data type in user tables", + datatype); + + snprintf(output_path, sizeof(output_path), "tables_using_%s.txt", + datatype); + snprintf(typename, sizeof(typename), "pg_catalog.%s", datatype); + + if (check_for_data_type_usage(cluster, typename, output_path)) + { + pg_log(PG_REPORT, "fatal"); + pg_fatal("Your installation contains the \"%s\" data type in user tables.\n" + "The \"%s\" type has been removed in PostgreSQL version %s,\n" + "so this cluster cannot currently be upgraded. You can drop the\n" + "problem columns, or change them to another data type, and restart\n" + "the upgrade. A list of the problem columns is in the file:\n" + " %s", datatype, datatype, version, output_path); + } + else + check_ok(); +} + + /* * check_for_jsonb_9_4_usage() * -- 2.39.2 --g7whywbldtwquqvy--