From 60b77ed42bfd2d99fb2ee9bc28306a357569526e Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: Tue, 17 Mar 2026 14:30:16 +0530
Subject: [PATCH v20260323 3/3] Cleanup and other cosmetic fixes

... collected over time

TODO: provide a proper commit message

Author: Man Zeng <zengman@halodbtech.com>
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
---
 src/backend/parser/parse_graphtable.c   | 21 ++++++++--------
 src/backend/rewrite/rewriteGraphTable.c | 32 ++++++++++++-------------
 2 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/src/backend/parser/parse_graphtable.c b/src/backend/parser/parse_graphtable.c
index 1590f4f9cde..50e279335c9 100644
--- a/src/backend/parser/parse_graphtable.c
+++ b/src/backend/parser/parse_graphtable.c
@@ -94,14 +94,14 @@ transformGraphTablePropertyRef(ParseState *pstate, ColumnRef *cref)
 		{
 			if (pstate->p_expr_kind == EXPR_KIND_SELECT_TARGET)
 				ereport(ERROR,
-						errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-						errmsg("\"*\" is not supported here"),
-						parser_errposition(pstate, cref->location));
+						(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+						 errmsg("\"*\" is not supported here"),
+						 parser_errposition(pstate, cref->location)));
 			else
 				ereport(ERROR,
-						errcode(ERRCODE_SYNTAX_ERROR),
-						errmsg("\"*\" not allowed here"),
-						parser_errposition(pstate, cref->location));
+						(errcode(ERRCODE_SYNTAX_ERROR),
+						 errmsg("\"*\" not allowed here"),
+						 parser_errposition(pstate, cref->location)));
 		}
 
 		elvarname = strVal(field1);
@@ -116,8 +116,8 @@ transformGraphTablePropertyRef(ParseState *pstate, ColumnRef *cref)
 			pgptup = SearchSysCache2(PROPGRAPHPROPNAME, ObjectIdGetDatum(gpstate->graphid), CStringGetDatum(propname));
 			if (!HeapTupleIsValid(pgptup))
 				ereport(ERROR,
-						errcode(ERRCODE_SYNTAX_ERROR),
-						errmsg("property \"%s\" does not exist", propname));
+						(errcode(ERRCODE_SYNTAX_ERROR),
+						 errmsg("property \"%s\" does not exist", propname)));
 			pgpform = (Form_pg_propgraph_property) GETSTRUCT(pgptup);
 
 			gpr->location = cref->location;
@@ -172,8 +172,9 @@ transformLabelExpr(GraphTableParseState *gpstate, Node *labelexpr)
 				labelid = GetSysCacheOid2(PROPGRAPHLABELNAME, Anum_pg_propgraph_label_oid, ObjectIdGetDatum(gpstate->graphid), CStringGetDatum(labelname));
 				if (!labelid)
 					ereport(ERROR,
-							errcode(ERRCODE_UNDEFINED_OBJECT),
-							errmsg("label \"%s\" does not exist in property graph \"%s\"", labelname, get_rel_name(gpstate->graphid)));
+							(errcode(ERRCODE_UNDEFINED_OBJECT),
+							 errmsg("label \"%s\" does not exist in property graph \"%s\"",
+									labelname, get_rel_name(gpstate->graphid))));
 
 				lref = makeNode(GraphLabelRef);
 				lref->labelid = labelid;
diff --git a/src/backend/rewrite/rewriteGraphTable.c b/src/backend/rewrite/rewriteGraphTable.c
index 8b472a07845..343be18f14a 100644
--- a/src/backend/rewrite/rewriteGraphTable.c
+++ b/src/backend/rewrite/rewriteGraphTable.c
@@ -33,7 +33,6 @@
 #include "parser/parse_oper.h"
 #include "parser/parse_relation.h"
 #include "parser/parsetree.h"
-#include "parser/parse_relation.h"
 #include "parser/parse_graphtable.h"
 #include "rewrite/rewriteGraphTable.h"
 #include "rewrite/rewriteHandler.h"
@@ -256,16 +255,14 @@ generate_queries_for_path_pattern(RangeTblEntry *rte, List *path_pattern)
 
 		if (!pf)
 		{
-			{
-				pf = palloc0_object(struct path_factor);
-				pf->factorpos = factorpos++;
-				pf->kind = gep->kind;
-				pf->labelexpr = gep->labelexpr;
-				pf->variable = gep->variable;
-				pf->whereClause = gep->whereClause;
-
-				path_factors = lappend(path_factors, pf);
-			}
+			pf = palloc0_object(struct path_factor);
+			pf->factorpos = factorpos++;
+			pf->kind = gep->kind;
+			pf->labelexpr = gep->labelexpr;
+			pf->variable = gep->variable;
+			pf->whereClause = gep->whereClause;
+
+			path_factors = lappend(path_factors, pf);
 		}
 
 		/*
@@ -289,7 +286,7 @@ generate_queries_for_path_pattern(RangeTblEntry *rte, List *path_pattern)
 		 * be merged even though they have different variables. Such element
 		 * patterns form a walk of graph where vertex and edges are repeated.
 		 * For example, in (a)-[b]->(c)<-[b]-(d), (a) and (d) represent the
-		 * same vertex element. This is slighly harder to implement and
+		 * same vertex element. This is slightly harder to implement and
 		 * probably less useful. Hence not supported for now.
 		 */
 		if (prev_pf)
@@ -442,7 +439,7 @@ generate_query_for_graph_path(RangeTblEntry *rte, List *graph_path)
 
 		Assert(pf->kind == VERTEX_PATTERN || IS_EDGE_PATTERN(pf->kind));
 
-		/* Add conditions representing edge connnections. */
+		/* Add conditions representing edge connections. */
 		if (IS_EDGE_PATTERN(pf->kind))
 		{
 			struct path_element *src_pe;
@@ -755,7 +752,7 @@ generate_setop_from_pathqueries(List *pathqueries, List **rtable, List **targetl
 
 /*
  * Construct a path_element object for the graph element given by `elemoid`
- * statisfied by the path factor `pf`.
+ * satisfied by the path factor `pf`.
  *
  * If the type of graph element does not fit the element pattern kind, the
  * function returns NULL.
@@ -955,7 +952,7 @@ get_path_elements_for_path_factor(Oid propgraphid, struct path_factor *pf)
 				}
 
 				/*
-				 * Rememeber qualified and unqualified elements processed so
+				 * Remember qualified and unqualified elements processed so
 				 * far to avoid processing already processed elements again.
 				 */
 				elem_oids_seen = lappend_oid(elem_oids_seen, label_elem->pgelelid);
@@ -1124,8 +1121,9 @@ replace_property_refs_mutator(Node *node, struct replace_property_refs_context *
 				 * The property is associated with at least one of the labels
 				 * that satisfy given element pattern. If it's associated with
 				 * the given element (through some other label), use
-				 * correspondig value expression. Otherwise NULL. Ref. SQL/PGQ
-				 * standard section 6.5 Property Reference, General Rule 2.b.
+				 * corresponding value expression. Otherwise NULL. Ref.
+				 * SQL/PGQ standard section 6.5 Property Reference, General
+				 * Rule 2.b.
 				 */
 				n = get_element_property_expr(found_mapping->elemoid, gpr->propid,
 											  mapping_factor->factorpos + 1);
-- 
2.34.1

