You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by av...@apache.org on 2025/01/23 09:05:06 UTC

(cloudberry) 14/26: Remove unsupported_distribution_key_data_types check

This is an automated email from the ASF dual-hosted git repository.

avamingli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 9ed83765e46664e8f2182b706e1438dc90d47fda
Author: Brent Doil <bd...@vmware.com>
AuthorDate: Fri Jan 12 14:54:43 2024 -0500

    Remove unsupported_distribution_key_data_types check
    
    This pg_upgrade check searches for abstime, reltime, tinterval, money and anyarray
    types used in distribution keys. Neither GPDB6 or GPDB7 allow money or
    anyarray types in distribution keys, and GPDB7 has removed abstime, reltime, and
    tinterval altogether. Data type checks for the removed types is handled
    by check_for_removed_data_type_usage, introduced in 5c6e2ae6bb4, meaning
    this check is redundant for a 6->7 upgrade. Therefore, this check can be removed.
---
 src/bin/pg_upgrade/check.c                         |  1 -
 .../pg_upgrade/greenplum/pg_upgrade_greenplum.h    |  1 -
 src/bin/pg_upgrade/greenplum/version_gp.c          | 91 ----------------------
 3 files changed, 93 deletions(-)

diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index c77e681f14..dd06fefb04 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -213,7 +213,6 @@ check_and_dump_old_cluster(bool live_check, char **sequence_script_file_name)
 				old_8_3_create_sequence_script(&old_cluster);
 		}
 
-		old_GPDB5_check_for_unsupported_distribution_key_data_types();
 	}
 
 	/*
diff --git a/src/bin/pg_upgrade/greenplum/pg_upgrade_greenplum.h b/src/bin/pg_upgrade/greenplum/pg_upgrade_greenplum.h
index eedff04100..463a159ec9 100644
--- a/src/bin/pg_upgrade/greenplum/pg_upgrade_greenplum.h
+++ b/src/bin/pg_upgrade/greenplum/pg_upgrade_greenplum.h
@@ -94,7 +94,6 @@ void old_GPDB4_check_no_free_aoseg(void);
 void check_hash_partition_usage(void);
 void new_gpdb5_0_invalidate_indexes(void);
 Oid *get_numeric_types(PGconn *conn);
-void old_GPDB5_check_for_unsupported_distribution_key_data_types(void);
 void old_GPDB6_check_for_unsupported_sha256_password_hashes(void);
 void after_create_new_objects_greenplum(void);
 
diff --git a/src/bin/pg_upgrade/greenplum/version_gp.c b/src/bin/pg_upgrade/greenplum/version_gp.c
index f16e15c718..8a8604371b 100644
--- a/src/bin/pg_upgrade/greenplum/version_gp.c
+++ b/src/bin/pg_upgrade/greenplum/version_gp.c
@@ -367,97 +367,6 @@ new_gpdb5_0_invalidate_indexes(void)
 }
 
 
-/*
- * old_GPDB5_check_for_unsupported_distribution_key_data_types()
- *
- *	abstime, reltime, tinterval, money and anyarray datatypes don't have hash opclasses
- *	in GPDB 6, so they are not supported as distribution keys anymore.
- */
-void
-old_GPDB5_check_for_unsupported_distribution_key_data_types(void)
-{
-	int			dbnum;
-	FILE	   *script = NULL;
-	bool		found = false;
-	char		output_path[MAXPGPATH];
-
-	prep_status("Checking for abstime, reltime, tinterval user data types");
-
-	snprintf(output_path, sizeof(output_path), "tables_using_abstime_reltime_tinterval.txt");
-
-	for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
-	{
-		PGresult   *res;
-		bool		db_used = false;
-		int			ntups;
-		int			rowno;
-		int			i_nspname,
-					i_relname,
-					i_attname;
-		DbInfo	   *active_db = &old_cluster.dbarr.dbs[dbnum];
-		PGconn	   *conn = connectToServer(&old_cluster, active_db->db_name);
-
-		res = executeQueryOrDie(conn,
-								"SELECT nspname, relname, attname "
-								"FROM   pg_catalog.pg_class c, "
-								"       pg_catalog.pg_namespace n, "
-								"       pg_catalog.pg_attribute a, "
-								"       gp_distribution_policy p "
-								"WHERE  c.oid = a.attrelid AND "
-								"       c.oid = p.localoid AND "
-								"       a.atttypid in ('pg_catalog.abstime'::regtype, "
-								"                      'pg_catalog.reltime'::regtype, "
-								"                      'pg_catalog.tinterval'::regtype, "
-								"                      'pg_catalog.money'::regtype, "
-								"                      'pg_catalog.anyarray'::regtype) AND "
-								"       attnum = any (p.attrnums) AND "
-								"       c.relnamespace = n.oid AND "
-		/* exclude possible orphaned temp tables */
-								"  		n.nspname !~ '^pg_temp_'");
-
-		ntups = PQntuples(res);
-		i_nspname = PQfnumber(res, "nspname");
-		i_relname = PQfnumber(res, "relname");
-		i_attname = PQfnumber(res, "attname");
-		for (rowno = 0; rowno < ntups; rowno++)
-		{
-			found = true;
-			if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
-				pg_fatal("Could not open file \"%s\": %s\n",
-						 output_path, strerror(errno));
-			if (!db_used)
-			{
-				fprintf(script, "Database: %s\n", active_db->db_name);
-				db_used = true;
-			}
-			fprintf(script, "  %s.%s.%s\n",
-					PQgetvalue(res, rowno, i_nspname),
-					PQgetvalue(res, rowno, i_relname),
-					PQgetvalue(res, rowno, i_attname));
-		}
-
-		PQclear(res);
-
-		PQfinish(conn);
-	}
-
-	if (script)
-		fclose(script);
-
-	if (found)
-	{
-		pg_log(PG_REPORT, "fatal\n");
-		pg_fatal("Your installation contains a user table, that uses a 'abstime',\n"
-				 "'reltime', 'tinterval', 'money' or 'anyarray' type as a distribution key column. Using\n"
-				 "these datatypes as distribution keys is no longer supported. You can use\n"
-				 "ALTER TABLE ... SET DISTRIBUTED RANDOMLY to change the distribution keys,\n"
-				 "and restart the upgrade.  A list of the problem columns is in the file:\n"
-				 "    %s\n\n", output_path);
-	}
-	else
-		check_ok();
-}
-
 /*
  * old_GPDB6_check_for_unsupported_distribution_key_data_types()
  *


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org