From 3d81adb2f4ebfaa776ba9a30584dcf9a08abdd4c Mon Sep 17 00:00:00 2001
From: Junwang Zhao <zhjwpku@gmail.com>
Date: Fri, 24 Jan 2025 11:05:15 +0000
Subject: [PATCH v1 1/2] fix more typos and polish inaccurate comments

---
 doc/src/sgml/ddl.sgml                   |  6 ++---
 src/backend/rewrite/rewriteGraphTable.c | 30 ++++++++++---------------
 2 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index f89c6da0a74..26b9fc27eb4 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -5425,7 +5425,7 @@ CREATE PROPERTY GRAPH myshop
    This graph could then be queried like this:
 <programlisting>
 -- get list of customers active today
-SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers)-[IS customer_orders]->(o IS orders WHERE ordered_when = current_date) COLUMNS (c.name AS customer_name));
+SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers)-[IS customer_orders]->(o IS orders WHERE o.ordered_when = current_date) COLUMNS (c.name AS customer_name));
 </programlisting>
    corresponding approximately to this relational query:
 <programlisting>
@@ -5477,7 +5477,7 @@ CREATE PROPERTY GRAPH myshop
     VERTEX TABLES (
         products LABEL product,
         customers LABEL customer,
-        orders LABEL order
+        orders LABEL order_
     )
     EDGE TABLES (
         order_items SOURCE orders DESTINATION products LABEL contains,
@@ -5489,7 +5489,7 @@ CREATE PROPERTY GRAPH myshop
   <para>
    With this definition, we can write a query like this:
 <programlisting>
-SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c:customer)-[:has]->(o:order WHERE ordered_when = current_date) COLUMNS (c.name AS customer_name));
+SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c:customer)-[:has]->(o:order_ WHERE o.ordered_when = current_date) COLUMNS (c.name AS customer_name));
 </programlisting>
    With the new labels and using the colon instead of <literal>IS</literal>,
    which are equivalent, the <literal>MATCH</literal> clause is now more
diff --git a/src/backend/rewrite/rewriteGraphTable.c b/src/backend/rewrite/rewriteGraphTable.c
index 80e28db752d..a33ad5ba7fd 100644
--- a/src/backend/rewrite/rewriteGraphTable.c
+++ b/src/backend/rewrite/rewriteGraphTable.c
@@ -142,7 +142,7 @@ rewriteGraphTable(Query *parsetree, int rt_index)
 }
 
 /*
- * Generate queries represeting the given path pattern applied to the given
+ * Generate queries representing the given path pattern applied to the given
  * property graph.
  *
  * A path pattern consists of one or more element patterns. Each of the element
@@ -154,7 +154,7 @@ rewriteGraphTable(Query *parsetree, int rt_index)
  * queries is returned.
  *
  * Assuming that the numbering starts at 0, every element pattern at an even
- * numbered position in the path is a vertex pattern. Every element in even
+ * numbered position in the path is a vertex pattern. Every element at an odd
  * numbered position is an edge pattern. Thus every even numbered element is a
  * vertex table and odd numbered element is an edge table. An edge connects two
  * vertices identified by the source and destination keys respectively. The
@@ -339,6 +339,8 @@ generate_queries_for_path_pattern(RangeTblEntry *rte, List *path_pattern)
 
 /*
  * Recursive workhorse function of generate_queries_for_path_pattern().
+ *
+ * `elempos` is position of the element pattern in the path pattern.
  */
 static List *
 generate_queries_for_path_pattern_recurse(RangeTblEntry *rte, List *pathqueries, List *cur_path, List *path_elem_lists, int elempos)
@@ -546,12 +548,8 @@ generate_query_for_empty_path_pattern(RangeTblEntry *rte)
 	Query	   *query = makeNode(Query);
 
 	query->commandType = CMD_SELECT;
-
-
 	query->rtable = NIL;
 	query->rteperminfos = NIL;
-
-
 	query->jointree = makeFromExpr(NIL, (Node *) makeBoolConst(false, false));
 
 	/*
@@ -713,10 +711,8 @@ generate_setop_from_pathqueries(List *pathqueries, List **rtable, List **targetl
 }
 
 /*
- * Construct a graph_path_element object for the graph element given by `elemoid`
- * statisfied by the graph element pattern `gep`.
- *
- * 'elempos` is the position of given element pattern in the path pattern.
+ * Construct a path_element object for the graph element given by `elemoid`
+ * statisfied by the path factor `pf`.
  *
  * If the type of graph element does not fit the element pattern kind, the
  * function returns NULL.
@@ -871,16 +867,14 @@ get_labels_for_expr(Oid propgraphid, Node *labelexpr)
 }
 
 /*
- * Given a graph element pattern `gep`, return a list of all the graph elements
- * that satisfy the graph pattern.
+ * Given a path factor `pf`, return a list of all the graph elements that
+ * satisfy the graph pattern.
  *
  * First we find all the graph labels that satisfy the label expression in
- * graph element pattern. Each label has associated with one or more graph
- * elements. A union of all such elements satisfies the element pattern. The
- * returned list contains one graph_path_element object representing each of
- * these elements respectively.
- *
- * `elempos` is position of the element pattern in the path pattern.
+ * path factor. Each label has associated with one or more graph elements.
+ * A union of all such elements satisfies the element pattern. The returned
+ * list contains one graph_path_element object representing each of these
+ * elements respectively.
  */
 static List *
 get_path_elements_for_path_factor(Oid propgraphid, struct path_factor *pf)
-- 
2.39.5

