hi.
remove pg_type typndims column patch attached.
From 656fc3bec597f65368a7bd1cdee183865d4070e7 Mon Sep 17 00:00:00 2001
From: jian he <jian.universal...@gmail.com>
Date: Thu, 12 Dec 2024 15:27:34 +0800
Subject: [PATCH v3 1/1] remove pg_type typndims

discussion: https://postgr.es/m/CACJufxH0RxsxUQnAT2AVG08JFpA3C60L91_cEMM8JQd8P=1...@mail.gmail.com
commitfest: https://commitfest.postgresql.org/50/5263/
---
 doc/src/sgml/catalogs.sgml      | 12 ------------
 src/backend/catalog/heap.c      |  4 ++--
 src/backend/catalog/pg_type.c   |  9 ++++++---
 src/backend/commands/typecmds.c | 21 ++++++++++-----------
 src/include/catalog/pg_type.h   |  5 -----
 5 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index bf3cee08a9..7da826bc3a 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -9505,18 +9505,6 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
       </para></entry>
      </row>
 
-     <row>
-      <entry role="catalog_table_entry"><para role="column_definition">
-       <structfield>typndims</structfield> <type>int4</type>
-      </para>
-      <para>
-       <structfield>typndims</structfield> is the number of array dimensions
-       for a domain over an array (that is, <structfield>typbasetype</structfield> is
-       an array type).
-       Zero for types other than domains over array types.
-      </para></entry>
-     </row>
-
      <row>
       <entry role="catalog_table_entry"><para role="column_definition">
        <structfield>typcollation</structfield> <type>oid</type>
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index d7b88b61dc..8dc30280a7 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -1062,7 +1062,7 @@ AddNewRelationType(const char *typeName,
 				   TYPALIGN_DOUBLE, /* alignment - must be the largest! */
 				   TYPSTORAGE_EXTENDED, /* fully TOASTable */
 				   -1,			/* typmod */
-				   0,			/* array dimensions for typBaseType */
+				   0,			/* no usage, must pass as zero */
 				   false,		/* Type NOT NULL */
 				   InvalidOid); /* rowtypes never have a collation */
 }
@@ -1385,7 +1385,7 @@ heap_create_with_catalog(const char *relname,
 				   TYPALIGN_DOUBLE, /* alignment - must be the largest! */
 				   TYPSTORAGE_EXTENDED, /* fully TOASTable */
 				   -1,			/* typmod */
-				   0,			/* array dimensions for typBaseType */
+				   0,			/* no usage, must pass as zero */
 				   false,		/* Type NOT NULL */
 				   InvalidOid); /* rowtypes never have a collation */
 
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index 395dec8ed8..89c6ef79c9 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -118,7 +118,6 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
 	values[Anum_pg_type_typnotnull - 1] = BoolGetDatum(false);
 	values[Anum_pg_type_typbasetype - 1] = ObjectIdGetDatum(InvalidOid);
 	values[Anum_pg_type_typtypmod - 1] = Int32GetDatum(-1);
-	values[Anum_pg_type_typndims - 1] = Int32GetDatum(0);
 	values[Anum_pg_type_typcollation - 1] = ObjectIdGetDatum(InvalidOid);
 	nulls[Anum_pg_type_typdefaultbin - 1] = true;
 	nulls[Anum_pg_type_typdefault - 1] = true;
@@ -189,6 +188,9 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
  *		Returns the ObjectAddress assigned to the new type.
  *		If newTypeOid is zero (the normal case), a new OID is created;
  *		otherwise we use exactly that OID.
+ *
+ * 		pg_type.typndims column was removed in version 18.
+ * 		so typNDims parameter must pass as 0.
  * ----------------------------------------------------------------
  */
 ObjectAddress
@@ -221,7 +223,7 @@ TypeCreate(Oid newTypeOid,
 		   char alignment,
 		   char storage,
 		   int32 typeMod,
-		   int32 typNDims,		/* Array dimensions for baseType */
+		   int32 typNDims,
 		   bool typeNotNull,
 		   Oid typeCollation)
 {
@@ -238,6 +240,8 @@ TypeCreate(Oid newTypeOid,
 	int			i;
 	ObjectAddress address;
 
+	if (typNDims != 0)
+		elog(ERROR, "typNDims should be 0");
 	/*
 	 * We assume that the caller validated the arguments individually, but did
 	 * not check for bad combinations.
@@ -376,7 +380,6 @@ TypeCreate(Oid newTypeOid,
 	values[Anum_pg_type_typnotnull - 1] = BoolGetDatum(typeNotNull);
 	values[Anum_pg_type_typbasetype - 1] = ObjectIdGetDatum(baseType);
 	values[Anum_pg_type_typtypmod - 1] = Int32GetDatum(typeMod);
-	values[Anum_pg_type_typndims - 1] = Int32GetDatum(typNDims);
 	values[Anum_pg_type_typcollation - 1] = ObjectIdGetDatum(typeCollation);
 
 	/*
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index da591c0922..aa44abfb37 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -599,7 +599,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
 				   alignment,	/* required alignment */
 				   storage,		/* TOAST strategy */
 				   -1,			/* typMod (Domains only) */
-				   0,			/* Array Dimensions of typbasetype */
+				   0,			/* no usage, must pass as zero */
 				   false,		/* Type NOT NULL */
 				   collation);	/* type's collation */
 	Assert(typoid == address.objectId);
@@ -641,7 +641,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
 			   alignment,		/* see above */
 			   TYPSTORAGE_EXTENDED, /* ARRAY is always toastable */
 			   -1,				/* typMod (Domains only) */
-			   0,				/* Array dimensions of typbasetype */
+			   0,				/* no usage, must pass as zero */
 			   false,			/* Type NOT NULL */
 			   collation);		/* type's collation */
 
@@ -719,7 +719,6 @@ DefineDomain(CreateDomainStmt *stmt)
 	bool		saw_default = false;
 	bool		typNotNull = false;
 	bool		nullDefined = false;
-	int32		typNDims = list_length(stmt->typeName->arrayBounds);
 	HeapTuple	typeTup;
 	List	   *schema = stmt->constraints;
 	ListCell   *listptr;
@@ -1058,7 +1057,7 @@ DefineDomain(CreateDomainStmt *stmt)
 				   alignment,	/* required alignment */
 				   storage,		/* TOAST strategy */
 				   basetypeMod, /* typeMod value */
-				   typNDims,	/* Array dimensions for base type */
+				   0,			/* no usage, must pass as zero */
 				   typNotNull,	/* Type NOT NULL */
 				   domaincoll); /* type's collation */
 
@@ -1099,7 +1098,7 @@ DefineDomain(CreateDomainStmt *stmt)
 			   alignment,		/* see above */
 			   TYPSTORAGE_EXTENDED, /* ARRAY is always toastable */
 			   -1,				/* typMod (Domains only) */
-			   0,				/* Array dimensions of typbasetype */
+			   0,				/* no usage, must pass as zero */
 			   false,			/* Type NOT NULL */
 			   domaincoll);		/* type's collation */
 
@@ -1221,7 +1220,7 @@ DefineEnum(CreateEnumStmt *stmt)
 				   TYPALIGN_INT,	/* int alignment */
 				   TYPSTORAGE_PLAIN,	/* TOAST strategy always plain */
 				   -1,			/* typMod (Domains only) */
-				   0,			/* Array dimensions of typbasetype */
+				   0,			/* no usage, must pass as zero */
 				   false,		/* Type NOT NULL */
 				   InvalidOid); /* type's collation */
 
@@ -1262,7 +1261,7 @@ DefineEnum(CreateEnumStmt *stmt)
 			   TYPALIGN_INT,	/* enums have int align, so do their arrays */
 			   TYPSTORAGE_EXTENDED, /* ARRAY is always toastable */
 			   -1,				/* typMod (Domains only) */
-			   0,				/* Array dimensions of typbasetype */
+			   0,				/* no usage, must pass as zero */
 			   false,			/* Type NOT NULL */
 			   InvalidOid);		/* type's collation */
 
@@ -1563,7 +1562,7 @@ DefineRange(ParseState *pstate, CreateRangeStmt *stmt)
 				   alignment,	/* alignment */
 				   TYPSTORAGE_EXTENDED, /* TOAST strategy (always extended) */
 				   -1,			/* typMod (Domains only) */
-				   0,			/* Array dimensions of typbasetype */
+				   0,			/* no usage, must pass as zero */
 				   false,		/* Type NOT NULL */
 				   InvalidOid); /* type's collation (ranges never have one) */
 	Assert(typoid == InvalidOid || typoid == address.objectId);
@@ -1630,7 +1629,7 @@ DefineRange(ParseState *pstate, CreateRangeStmt *stmt)
 				   alignment,	/* alignment */
 				   'x',			/* TOAST strategy (always extended) */
 				   -1,			/* typMod (Domains only) */
-				   0,			/* Array dimensions of typbasetype */
+				   0,			/* no usage, must pass as zero */
 				   false,		/* Type NOT NULL */
 				   InvalidOid); /* type's collation (ranges never have one) */
 	Assert(multirangeOid == mltrngaddress.objectId);
@@ -1673,7 +1672,7 @@ DefineRange(ParseState *pstate, CreateRangeStmt *stmt)
 			   alignment,		/* alignment - same as range's */
 			   TYPSTORAGE_EXTENDED, /* ARRAY is always toastable */
 			   -1,				/* typMod (Domains only) */
-			   0,				/* Array dimensions of typbasetype */
+			   0,				/* no usage, must pass as zero */
 			   false,			/* Type NOT NULL */
 			   InvalidOid);		/* typcollation */
 
@@ -1712,7 +1711,7 @@ DefineRange(ParseState *pstate, CreateRangeStmt *stmt)
 			   alignment,		/* alignment - same as range's */
 			   'x',				/* ARRAY is always toastable */
 			   -1,				/* typMod (Domains only) */
-			   0,				/* Array dimensions of typbasetype */
+			   0,				/* no usage, must pass as zero */
 			   false,			/* Type NOT NULL */
 			   InvalidOid);		/* typcollation */
 
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index e925969732..7b9d02c0e5 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -214,11 +214,6 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
 	 */
 	int32		typtypmod BKI_DEFAULT(-1);
 
-	/*
-	 * typndims is the declared number of dimensions for an array domain type
-	 * (i.e., typbasetype is an array type).  Otherwise zero.
-	 */
-	int32		typndims BKI_DEFAULT(0);
 
 	/*
 	 * Collation: 0 if type cannot use collations, nonzero (typically
-- 
2.34.1

Reply via email to