From c18bcfce86592fa5f235e9958211c33102e60815 Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: Wed, 1 Jan 2025 14:02:28 +0530
Subject: [PATCH v11 08/13] Document fixes

Assorted grammar and typo fixes.

Author: Junwang Zhou
Reviewed with minor adjustments by: Ashutosh Bapat
---
 doc/src/sgml/ddl.sgml                       | 24 ++++++++-------
 doc/src/sgml/information_schema.sgml        | 20 ++++++------
 doc/src/sgml/ref/alter_property_graph.sgml  |  2 +-
 doc/src/sgml/ref/create_property_graph.sgml |  2 +-
 doc/src/sgml/ref/drop_property_graph.sgml   |  2 +-
 src/backend/rewrite/rewriteGraphTable.c     | 34 ++++++++++-----------
 src/backend/utils/adt/ruleutils.c           |  6 ++--
 7 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 32cf474a609..d67f12edbf0 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -5364,14 +5364,14 @@ EXPLAIN SELECT count(*) FROM measurement WHERE logdate &gt;= DATE '2008-01-01';
    relational databases.  PostgreSQL implements SQL/PGQ<footnote><para>Here,
    PGQ stands for <quote>property graph query</quote>.  In the jargon of graph
    databases, <quote>property graph</quote> is normally abbreviated as PG,
-   which is clearly confusing for practioners of PostgreSQL, also usually
+   which is clearly confusing for practitioners of PostgreSQL, also usually
    abbreviated as PG.</para></footnote>, which is part of the SQL standard,
    where a property graph is defined as a kind of read-only view over
    relational tables.  So the actual data is still in tables or table-like
    objects, but is exposed as a graph for graph querying operations.  (This is
    in contrast to native graph databases, where the data is stored directly in
    a graph structure.)  Underneath, both relational queries and graph queries
-   use the same query planning and execution infrastucture, and in fact
+   use the same query planning and execution infrastructure, and in fact
    relational and graph queries can be combined and mixed in single queries.
   </para>
 
@@ -5452,7 +5452,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>
@@ -5463,10 +5463,10 @@ SELECT customers.name FROM customers JOIN customer_orders USING (customer_id) JO
 
   <para>
    The above definition requires that all tables have primary keys and that
-   for each edge there is an appropriate foreign key.  Otherwise, additional
-   clauses have to be specified to identify the key columns.  For example,
-   this would be the fully verbose definition that does not rely on primary
-   and foreign keys:
+   each edge has an appropriate foreign key for both the source and destination
+   vertices, respectively.  Otherwise, additional clauses have to be specified
+   to identify the key columns.  For example, this would be the fully verbose
+   definition that does not rely on primary and foreign keys:
 <programlisting>
 CREATE PROPERTY GRAPH myshop
     VERTEX TABLES (
@@ -5488,7 +5488,7 @@ CREATE PROPERTY GRAPH myshop
   <para>
    As mentioned above, by default, the names of the tables and columns are
    exposed as labels and properties, respectively.  The clauses <literal>IS
-   customer</literal>, <literal>IS order</literal>, etc. in the
+   customers</literal>, <literal>IS orders</literal>, etc. in the
    <literal>MATCH</literal> clause in fact refer to labels, not table names.
   </para>
 
@@ -5504,19 +5504,21 @@ CREATE PROPERTY GRAPH myshop
     VERTEX TABLES (
         products LABEL product,
         customers LABEL customer,
-        orders LABEL order
+        orders LABEL orders
     )
     EDGE TABLES (
         order_items SOURCE orders DESTINATION products LABEL contains,
         customer_orders SOURCE customers DESTINATION orders LABEL has
     );
 </programlisting>
+
+  (We explicitly set the LABEL as <literal>orders</literal> instead of <literal>order</literal> because <literal>order</literal> is a reserved keyword.)
   </para>
 
   <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:orders 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
@@ -5539,7 +5541,7 @@ CREATE PROPERTY GRAPH myshop
     VERTEX TABLES (
         products LABEL product,
         customers LABEL customer LABEL person PROPERTIES (name),
-        orders LABEL order,
+        orders LABEL orders,
         employees LABEL employee LABEL person PROPERTIES (employee_name AS name)
     )
     EDGE TABLES (
diff --git a/doc/src/sgml/information_schema.sgml b/doc/src/sgml/information_schema.sgml
index e6561543f62..a370f1e537d 100644
--- a/doc/src/sgml/information_schema.sgml
+++ b/doc/src/sgml/information_schema.sgml
@@ -4227,7 +4227,7 @@ ORDER BY c.ordinal_position;
        <structfield>property_graph_name</structfield> <type>sql_identifier</type>
       </para>
       <para>
-       Name of the property_graph
+       Name of the property graph
       </para></entry>
      </row>
 
@@ -4346,7 +4346,7 @@ ORDER BY c.ordinal_position;
        <structfield>property_graph_name</structfield> <type>sql_identifier</type>
       </para>
       <para>
-       Name of the property_graph
+       Name of the property graph
       </para></entry>
      </row>
 
@@ -4430,7 +4430,7 @@ ORDER BY c.ordinal_position;
        <structfield>property_graph_name</structfield> <type>sql_identifier</type>
       </para>
       <para>
-       Name of the property_graph
+       Name of the property graph
       </para></entry>
      </row>
 
@@ -4461,7 +4461,7 @@ ORDER BY c.ordinal_position;
   <title><literal>pg_element_table_properties</literal></title>
 
   <para>
-   The view <literal>pg_element_table_labels</literal> shows the definitions
+   The view <literal>pg_element_table_properties</literal> shows the definitions
    of the properties for the element tables of property graphs defined in the
    current database.  Only those property graphs are shown that the current
    user has access to (by way of being the owner or having some privilege).
@@ -4505,7 +4505,7 @@ ORDER BY c.ordinal_position;
        <structfield>property_graph_name</structfield> <type>sql_identifier</type>
       </para>
       <para>
-       Name of the property_graph
+       Name of the property graph
       </para></entry>
      </row>
 
@@ -4589,7 +4589,7 @@ ORDER BY c.ordinal_position;
        <structfield>property_graph_name</structfield> <type>sql_identifier</type>
       </para>
       <para>
-       Name of the property_graph
+       Name of the property graph
       </para></entry>
      </row>
 
@@ -4700,7 +4700,7 @@ ORDER BY c.ordinal_position;
        <structfield>property_graph_name</structfield> <type>sql_identifier</type>
       </para>
       <para>
-       Name of the property_graph
+       Name of the property graph
       </para></entry>
      </row>
 
@@ -4774,7 +4774,7 @@ ORDER BY c.ordinal_position;
        <structfield>property_graph_name</structfield> <type>sql_identifier</type>
       </para>
       <para>
-       Name of the property_graph
+       Name of the property graph
       </para></entry>
      </row>
 
@@ -4839,7 +4839,7 @@ ORDER BY c.ordinal_position;
        <structfield>property_graph_name</structfield> <type>sql_identifier</type>
       </para>
       <para>
-       Name of the property_graph
+       Name of the property graph
       </para></entry>
      </row>
 
@@ -5255,7 +5255,7 @@ ORDER BY c.ordinal_position;
        <structfield>property_graph_name</structfield> <type>sql_identifier</type>
       </para>
       <para>
-       Name of the property_graph
+       Name of the property graph
       </para></entry>
      </row>
     </tbody>
diff --git a/doc/src/sgml/ref/alter_property_graph.sgml b/doc/src/sgml/ref/alter_property_graph.sgml
index 604c5180117..4ae53deb092 100644
--- a/doc/src/sgml/ref/alter_property_graph.sgml
+++ b/doc/src/sgml/ref/alter_property_graph.sgml
@@ -99,7 +99,7 @@ ALTER PROPERTY GRAPH [ IF EXISTS ] <replaceable class="parameter">name</replacea
      <term><literal>ALTER {VERTEX|NODE|EDGE|RELATIONSHIP} TABLE ... DROP LABEL</literal></term>
      <listitem>
       <para>
-       This form removes a new label from an existing vertex or edge table.
+       This form removes a label from an existing vertex or edge table.
       </para>
      </listitem>
     </varlistentry>
diff --git a/doc/src/sgml/ref/create_property_graph.sgml b/doc/src/sgml/ref/create_property_graph.sgml
index ae301b52e0a..76bfef317af 100644
--- a/doc/src/sgml/ref/create_property_graph.sgml
+++ b/doc/src/sgml/ref/create_property_graph.sgml
@@ -151,7 +151,7 @@ CREATE [ TEMP | TEMPORARY ] PROPERTY GRAPH <replaceable class="parameter">name</
     <listitem>
      <para>
       The vertex tables that the edge table is linked to.  These refer to the
-      aliases of a the vertex table.
+      aliases of the source and destination vertex tables respectively.
      </para>
     </listitem>
    </varlistentry>
diff --git a/doc/src/sgml/ref/drop_property_graph.sgml b/doc/src/sgml/ref/drop_property_graph.sgml
index 31cb77a2af1..e16de5507b1 100644
--- a/doc/src/sgml/ref/drop_property_graph.sgml
+++ b/doc/src/sgml/ref/drop_property_graph.sgml
@@ -96,7 +96,7 @@ DROP PROPERTY GRAPH g1;
    <command>DROP PROPERTY GRAPH</command> conforms to ISO/IEC 9075-16
    (SQL/PGQ), except that the standard only allows one property graph to be
    dropped per command, and apart from the <literal>IF EXISTS</literal>
-   option, which is a <productname>PostgreSQL</productname> extension..
+   option, which is a <productname>PostgreSQL</productname> extension.
   </para>
  </refsect1>
 
diff --git a/src/backend/rewrite/rewriteGraphTable.c b/src/backend/rewrite/rewriteGraphTable.c
index 80e28db752d..9046d6ada12 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 in 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
@@ -273,7 +273,7 @@ generate_queries_for_path_pattern(RangeTblEntry *rte, List *path_pattern)
 		 * an edge pointing right. Edge pointing in any direction is treated
 		 * similar to that pointing in right direction here. When constructing
 		 * a query, in generate_query_for_graph_path() we will swap source and
-		 * destination elements if the edge element turns out to be and edge
+		 * destination elements if the edge element turns out to be an edge
 		 * pointing in left direction.
 		 *
 		 * If multiple edge patterns share the same variable name, they
@@ -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 the 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)
@@ -713,10 +715,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 +871,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 path_element object representing each of these elements
+ * respectively.
  */
 static List *
 get_path_elements_for_path_factor(Oid propgraphid, struct path_factor *pf)
@@ -916,9 +914,9 @@ get_path_elements_for_path_factor(Oid propgraphid, struct path_factor *pf)
 				/*
 				 * Found a new element that is associated with labels in the
 				 * given element pattern. If it fits the element pattern kind
-				 * we will create GraphPathPattern object for it and flag that
-				 * the current label has at least one element, that satisfies
-				 * the given element pattern, associated with it.
+				 * we will create path_element object for it and flag that the
+				 * current label has at least one element, that satisfies the
+				 * given element pattern, associated with it.
 				 */
 				struct path_element *pe = create_gpe_for_element(pf, elem_oid);
 
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 2e237023d95..08afaeb4f30 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -1770,7 +1770,7 @@ make_propgraphdef_elements(StringInfo buf, Oid pgrelid, char pgekind)
 
 /*
  * Generates label and properties list.  Pass in the element OID, the element
- * alias, and the graph relation OID.  Result is append to buf.
+ * alias, and the element table OID.  Result is append to buf.
  */
 static void
 make_propgraphdef_labels(StringInfo buf, Oid elid, const char *elalias, Oid elrelid)
@@ -1845,8 +1845,8 @@ propdata_by_name_cmp(const ListCell *a, const ListCell *b)
 
 /*
  * Generates element table properties clause (PROPERTIES (...) or NO
- * PROPERTIES).  Pass in label ODI and element table OID.  Result is appended
- * to buf.
+ * PROPERTIES).  Pass in element label OID and element table OID.  Result is
+ * appended to buf.
  */
 static void
 make_propgraphdef_properties(StringInfo buf, Oid ellabelid, Oid elrelid)
-- 
2.39.5

