From d931c5e16b20bce05a84df7bf435763c255aa7f9 Mon Sep 17 00:00:00 2001
From: jian he <jian.universality@gmail.com>
Date: Wed, 7 May 2025 22:28:32 +0800
Subject: [PATCH v2 2/2] sanitize variable or argument name in pg_dump

discussion: https://postgr.es/m/CACJufxF-0bqVR=j4jonS6N2Ka6hHUpFyu3_3TWKNhOW_4yFSSg@mail.gmail.com
---
 src/bin/pg_dump/pg_dump.c | 22 +++++++++++-----------
 src/bin/pg_dump/pg_dump.h |  4 ++--
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index ea5e2abb03f..d5a12e675ce 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -6118,8 +6118,8 @@ getTypes(Archive *fout)
 		/*
 		 * If it's a domain, fetch info about its constraints, if any
 		 */
-		tyinfo[i].nDomChecks = 0;
-		tyinfo[i].domChecks = NULL;
+		tyinfo[i].nDomConstrs = 0;
+		tyinfo[i].domConstrs = NULL;
 		if ((tyinfo[i].dobj.dump & DUMP_COMPONENT_DEFINITION) &&
 			tyinfo[i].typtype == TYPTYPE_DOMAIN)
 			getDomainConstraints(fout, &(tyinfo[i]));
@@ -8296,8 +8296,8 @@ getDomainConstraints(Archive *fout, TypeInfo *tyinfo)
 
 	constrinfo = (ConstraintInfo *) pg_malloc(ntups * sizeof(ConstraintInfo));
 
-	tyinfo->nDomChecks = ntups;
-	tyinfo->domChecks = constrinfo;
+	tyinfo->nDomConstrs = ntups;
+	tyinfo->domConstrs = constrinfo;
 
 	for (i = 0; i < ntups; i++)
 	{
@@ -12508,9 +12508,9 @@ dumpDomain(Archive *fout, const TypeInfo *tyinfo)
 	/*
 	 * Add any CHECK, NOT NULL constraints for the domain
 	 */
-	for (i = 0; i < tyinfo->nDomChecks; i++)
+	for (i = 0; i < tyinfo->nDomConstrs; i++)
 	{
-		ConstraintInfo *domcheck = &(tyinfo->domChecks[i]);
+		ConstraintInfo *domcheck = &(tyinfo->domConstrs[i]);
 
 		if (!domcheck->separate)
 			appendPQExpBuffer(q, "\n\tCONSTRAINT %s %s",
@@ -12554,19 +12554,19 @@ dumpDomain(Archive *fout, const TypeInfo *tyinfo)
 				NULL, tyinfo->rolname, &tyinfo->dacl);
 
 	/* Dump any per-constraint comments */
-	for (i = 0; i < tyinfo->nDomChecks; i++)
+	for (i = 0; i < tyinfo->nDomConstrs; i++)
 	{
-		ConstraintInfo *domcheck = &(tyinfo->domChecks[i]);
+		ConstraintInfo *domconstr = &(tyinfo->domConstrs[i]);
 		PQExpBuffer conprefix = createPQExpBuffer();
 
 		appendPQExpBuffer(conprefix, "CONSTRAINT %s ON DOMAIN",
-						  fmtId(domcheck->dobj.name));
+						  fmtId(domconstr->dobj.name));
 
-		if (domcheck->dobj.dump & DUMP_COMPONENT_COMMENT)
+		if (domconstr->dobj.dump & DUMP_COMPONENT_COMMENT)
 			dumpComment(fout, conprefix->data, qtypname,
 						tyinfo->dobj.namespace->dobj.name,
 						tyinfo->rolname,
-						domcheck->dobj.catId, 0, tyinfo->dobj.dumpId);
+						domconstr->dobj.catId, 0, tyinfo->dobj.dumpId);
 
 		destroyPQExpBuffer(conprefix);
 	}
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 7417eab6aef..b5e19ecc2e3 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -223,8 +223,8 @@ typedef struct _typeInfo
 	/* If needed, we'll create a "shell type" entry for it; link that here: */
 	struct _shellTypeInfo *shellType;	/* shell-type entry, or NULL */
 	/* If it's a domain, we store links to its constraints here: */
-	int			nDomChecks;
-	struct _constraintInfo *domChecks;
+	int			nDomConstrs;
+	struct _constraintInfo *domConstrs;
 } TypeInfo;
 
 typedef struct _shellTypeInfo
-- 
2.34.1

