From 6ebd8490790e0384412ea8b10bfc8ac224be374c Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: Fri, 2 Jan 2026 13:39:49 +0530
Subject: [PATCH v20260102 5/5] More test coverage

Add tests to cover the uncovered code paths as reported in [1]

[1] https://www.postgresql.org/message-id/CAAAe_zCPm3W7ZTSBfKUgVJPrTn4-D99agGsz5P2MBLZN=tME3g@mail.gmail.com

Reported By: Hensen Choi
---
 .../expected/create_property_graph.out        | 56 ++++++++++++++++++-
 src/test/regress/expected/graph_table.out     | 37 ++++++++++--
 .../regress/sql/create_property_graph.sql     | 41 +++++++++++++-
 src/test/regress/sql/graph_table.sql          | 19 ++++++-
 4 files changed, 139 insertions(+), 14 deletions(-)

diff --git a/src/test/regress/expected/create_property_graph.out b/src/test/regress/expected/create_property_graph.out
index ef6c776854b..eaa436725c1 100644
--- a/src/test/regress/expected/create_property_graph.out
+++ b/src/test/regress/expected/create_property_graph.out
@@ -1,6 +1,8 @@
 CREATE SCHEMA create_property_graph_tests;
 GRANT USAGE ON SCHEMA create_property_graph_tests TO PUBLIC;
 SET search_path = create_property_graph_tests;
+CREATE SCHEMA create_property_graph_tests_2;
+GRANT USAGE ON SCHEMA create_property_graph_tests_2 TO PUBLIC;
 CREATE ROLE regress_graph_user1;
 CREATE ROLE regress_graph_user2;
 CREATE PROPERTY GRAPH g1;
@@ -104,6 +106,8 @@ SELECT pg_get_propgraphdef('g5'::regclass);
 (1 row)
 
 -- error cases
+CREATE UNLOGGED PROPERTY GRAPH gx VERTEX TABLES (xx, yy);
+ERROR:  property graphs cannot be unlogged because they do not have storage
 CREATE PROPERTY GRAPH gx VERTEX TABLES (xx, yy);
 ERROR:  relation "xx" does not exist
 CREATE PROPERTY GRAPH gx VERTEX TABLES (t1 KEY (a), t2 KEY (i), t1 KEY (a));
@@ -858,12 +862,60 @@ CREATE PROPERTY GRAPH create_property_graph_tests.g1
 \dG g_nonexistent
 Did not find any property graphs named "g_nonexistent".
 \set QUIET 'on'
+-- temporary property graph
+-- Keep this at the end to avoid test failure due to changing temporary
+-- namespace names in information schema query outputs
+CREATE TEMPORARY PROPERTY GRAPH g1; -- same name as persistent graph
+DROP PROPERTY GRAPH g1;  -- drops temporary graph retaining persistent graph
+\dG g1
+                          List of property graphs
+           Schema            | Name |      Type      |        Owner        
+-----------------------------+------+----------------+---------------------
+ create_property_graph_tests | g1   | property graph | regress_graph_user1
+(1 row)
+
+CREATE TEMPORARY TABLE v2tmp (m text, n text);
+CREATE TEMPORARY PROPERTY GRAPH gtmp
+    VERTEX TABLES (v1 KEY (a), v2tmp KEY (m))
+    EDGE TABLES (
+        e KEY (k1, k2)
+            SOURCE KEY (k1) REFERENCES v1(a)
+            DESTINATION KEY (k2) REFERENCES v2tmp(m)
+    );
+DROP PROPERTY GRAPH gtmp;
+CREATE PROPERTY GRAPH gtmp
+    VERTEX TABLES (v1 KEY (a), v2tmp KEY (m))
+    EDGE TABLES (
+        e KEY (k1, k2)
+            SOURCE KEY (k1) REFERENCES v1(a)
+            DESTINATION KEY (k2) REFERENCES v2tmp(m)
+    );
+NOTICE:  property graph "gtmp" will be temporary
+ALTER PROPERTY GRAPH g1
+    ADD VERTEX TABLES (v2tmp KEY (m));  -- error
+ERROR:  cannot add temporary element table to non-temporary property graph
+LINE 2:     ADD VERTEX TABLES (v2tmp KEY (m));
+                               ^
+DETAIL:  Table "v2tmp" is a temporary table.
+-- DROP, ALTER SET SCHEMA, ALTER PROPERTY GRAPH RENAME TO
 DROP TABLE g2;  -- error: wrong object type
 ERROR:  "g2" is not a table
 HINT:  Use DROP PROPERTY GRAPH to remove a property graph.
-DROP PROPERTY GRAPH g1;
-DROP PROPERTY GRAPH g1;  -- error: does not exist
+CREATE VIEW vg1 AS SELECT * FROM GRAPH_TABLE(g1 MATCH () COLUMNS (1 AS one));
+DROP PROPERTY GRAPH g1; -- error
+ERROR:  cannot drop property graph g1 because other objects depend on it
+DETAIL:  view vg1 depends on property graph g1
+HINT:  Use DROP ... CASCADE to drop the dependent objects too.
+ALTER PROPERTY GRAPH g1 SET SCHEMA create_property_graph_tests_2;
+ALTER PROPERTY GRAPH create_property_graph_tests_2.g1 RENAME TO g2;
+DROP PROPERTY GRAPH create_property_graph_tests_2.g2 CASCADE;
+NOTICE:  drop cascades to view vg1
+DROP PROPERTY GRAPH g1;  -- error
 ERROR:  property graph "g1" does not exist
+ALTER PROPERTY GRAPH g1 ADD VERTEX TABLES (t1 KEY (a));  -- error
+ERROR:  relation "g1" does not exist
+ALTER PROPERTY GRAPH IF EXISTS g1 SET SCHEMA create_property_graph_tests_2;
+NOTICE:  relation "g1" does not exist, skipping
 DROP PROPERTY GRAPH IF EXISTS g1;
 NOTICE:  property graph "g1" does not exist, skipping
 DROP ROLE regress_graph_user1, regress_graph_user2;
diff --git a/src/test/regress/expected/graph_table.out b/src/test/regress/expected/graph_table.out
index a4df7464d79..f90dc29535f 100644
--- a/src/test/regress/expected/graph_table.out
+++ b/src/test/regress/expected/graph_table.out
@@ -93,6 +93,10 @@ SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.addr
 ERROR:  syntax error at or near "COLUMNS"
 LINE 1: ...mers WHERE c.address = 'US')-[IS customer_orders] COLUMNS (c...
                                                              ^
+SELECT * FROM GRAPH_TABLE (myshop MATCH (c IS customers), (o IS orders) COLUMNS (c.name AS customer_name));  -- error
+ERROR:  unsupported path pattern list length
+SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers)->{1,2}(o IS orders) COLUMNS (c.name AS customer_name));  -- error
+ERROR:  element pattern quantifier not supported yet
 -- a property graph can be referenced only from within GRAPH_TABLE clause.
 SELECT * FROM myshop; -- error
 ERROR:  cannot open relation "myshop"
@@ -776,6 +780,24 @@ INSERT INTO pe VALUES (1, 1, 2, 100);
 INSERT INTO ce1 VALUES (2, 2, 3, 200);
 INSERT INTO ce2 VALUES (3, 3, 1, 300);
 CREATE PROPERTY GRAPH g3
+    NODE TABLES (
+        pv KEY (id)
+    )
+    RELATIONSHIP TABLES (
+        pe KEY (id)
+            SOURCE KEY(src) REFERENCES pv(id)
+            DESTINATION KEY(dest) REFERENCES pv(id)
+    );
+SELECT * FROM GRAPH_TABLE (g3 MATCH (s IS pv)-[e IS pe]->(d IS pv) COLUMNS (s.val, e.val, d.val)) ORDER BY 1, 2, 3;
+ val | val | val 
+-----+-----+-----
+  10 | 100 |  20
+  20 | 200 |  30
+  30 | 300 |  10
+(3 rows)
+
+-- temporary property graph
+CREATE TEMPORARY PROPERTY GRAPH gtmp
     VERTEX TABLES (
         pv KEY (id)
     )
@@ -784,7 +806,7 @@ CREATE PROPERTY GRAPH g3
             SOURCE KEY(src) REFERENCES pv(id)
             DESTINATION KEY(dest) REFERENCES pv(id)
     );
-SELECT * FROM GRAPH_TABLE (g3 MATCH (s IS pv)-[e IS pe]->(d IS pv) COLUMNS (s.val, e.val, d.val)) ORDER BY 1, 2, 3;
+SELECT * FROM GRAPH_TABLE (gtmp MATCH (s IS pv)-[e IS pe]->(d IS pv) COLUMNS (s.val, e.val, d.val)) ORDER BY 1, 2, 3;
  val | val | val 
 -----+-----+-----
   10 | 100 |  20
@@ -830,12 +852,15 @@ SELECT * FROM GRAPH_TABLE (g4 MATCH (s WHERE s.id = 3)-[e]-(d) COLUMNS (s.val, e
   30 | 300 |  10
 (2 rows)
 
-CREATE VIEW customers_us AS SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.address = 'US')-[IS customer_orders]->(o IS orders) COLUMNS (c.name AS customer_name));
+-- ruleutils reverse parsing
+CREATE VIEW customers_us AS SELECT * FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.address = 'US')-[IS customer_orders | customer_wishlists ]->(l IS orders | wishlists)-[ IS list_items]->(p IS products) COLUMNS (c.name AS customer_name, p.name AS product_name)) ORDER BY customer_name, product_name;
 SELECT pg_get_viewdef('customers_us'::regclass);
-                                                                          pg_get_viewdef                                                                           
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
-  SELECT customer_name                                                                                                                                            +
-    FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE ((c.address)::text = 'US'::text))-[IS customer_orders]->(o IS orders) COLUMNS (c.name AS customer_name));
+                                                                                                                     pg_get_viewdef                                                                                                                     
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+  SELECT customer_name,                                                                                                                                                                                                                                +
+     product_name                                                                                                                                                                                                                                      +
+    FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE ((c.address)::text = 'US'::text))-[IS customer_orders|customer_wishlists]->(l IS orders|wishlists)-[IS list_items]->(p IS products) COLUMNS (c.name AS customer_name, p.name AS product_name))+
+   ORDER BY customer_name, product_name;
 (1 row)
 
 -- test view/graph nesting
diff --git a/src/test/regress/sql/create_property_graph.sql b/src/test/regress/sql/create_property_graph.sql
index b10eb9daee4..6f4dfe1bb00 100644
--- a/src/test/regress/sql/create_property_graph.sql
+++ b/src/test/regress/sql/create_property_graph.sql
@@ -1,6 +1,8 @@
 CREATE SCHEMA create_property_graph_tests;
 GRANT USAGE ON SCHEMA create_property_graph_tests TO PUBLIC;
 SET search_path = create_property_graph_tests;
+CREATE SCHEMA create_property_graph_tests_2;
+GRANT USAGE ON SCHEMA create_property_graph_tests_2 TO PUBLIC;
 
 CREATE ROLE regress_graph_user1;
 CREATE ROLE regress_graph_user2;
@@ -89,6 +91,7 @@ CREATE PROPERTY GRAPH g5
 SELECT pg_get_propgraphdef('g5'::regclass);
 
 -- error cases
+CREATE UNLOGGED PROPERTY GRAPH gx VERTEX TABLES (xx, yy);
 CREATE PROPERTY GRAPH gx VERTEX TABLES (xx, yy);
 CREATE PROPERTY GRAPH gx VERTEX TABLES (t1 KEY (a), t2 KEY (i), t1 KEY (a));
 CREATE PROPERTY GRAPH gx
@@ -317,12 +320,44 @@ SELECT pg_get_propgraphdef('pg_type'::regclass);  -- error
 \dG g_nonexistent
 \set QUIET 'on'
 
-DROP TABLE g2;  -- error: wrong object type
+-- temporary property graph
+
+-- Keep this at the end to avoid test failure due to changing temporary
+-- namespace names in information schema query outputs
+CREATE TEMPORARY PROPERTY GRAPH g1; -- same name as persistent graph
+DROP PROPERTY GRAPH g1;  -- drops temporary graph retaining persistent graph
+\dG g1
+CREATE TEMPORARY TABLE v2tmp (m text, n text);
+CREATE TEMPORARY PROPERTY GRAPH gtmp
+    VERTEX TABLES (v1 KEY (a), v2tmp KEY (m))
+    EDGE TABLES (
+        e KEY (k1, k2)
+            SOURCE KEY (k1) REFERENCES v1(a)
+            DESTINATION KEY (k2) REFERENCES v2tmp(m)
+    );
+DROP PROPERTY GRAPH gtmp;
+CREATE PROPERTY GRAPH gtmp
+    VERTEX TABLES (v1 KEY (a), v2tmp KEY (m))
+    EDGE TABLES (
+        e KEY (k1, k2)
+            SOURCE KEY (k1) REFERENCES v1(a)
+            DESTINATION KEY (k2) REFERENCES v2tmp(m)
+    );
+ALTER PROPERTY GRAPH g1
+    ADD VERTEX TABLES (v2tmp KEY (m));  -- error
 
-DROP PROPERTY GRAPH g1;
 
-DROP PROPERTY GRAPH g1;  -- error: does not exist
+-- DROP, ALTER SET SCHEMA, ALTER PROPERTY GRAPH RENAME TO
 
+DROP TABLE g2;  -- error: wrong object type
+CREATE VIEW vg1 AS SELECT * FROM GRAPH_TABLE(g1 MATCH () COLUMNS (1 AS one));
+DROP PROPERTY GRAPH g1; -- error
+ALTER PROPERTY GRAPH g1 SET SCHEMA create_property_graph_tests_2;
+ALTER PROPERTY GRAPH create_property_graph_tests_2.g1 RENAME TO g2;
+DROP PROPERTY GRAPH create_property_graph_tests_2.g2 CASCADE;
+DROP PROPERTY GRAPH g1;  -- error
+ALTER PROPERTY GRAPH g1 ADD VERTEX TABLES (t1 KEY (a));  -- error
+ALTER PROPERTY GRAPH IF EXISTS g1 SET SCHEMA create_property_graph_tests_2;
 DROP PROPERTY GRAPH IF EXISTS g1;
 
 DROP ROLE regress_graph_user1, regress_graph_user2;
diff --git a/src/test/regress/sql/graph_table.sql b/src/test/regress/sql/graph_table.sql
index 7521c3e5c1d..d94f88ad619 100644
--- a/src/test/regress/sql/graph_table.sql
+++ b/src/test/regress/sql/graph_table.sql
@@ -89,6 +89,8 @@ SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.addr
 SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.address = 'US')-[IS customer_orders]->(o IS orders) COLUMNS (c.namex AS customer_name));  -- error
 SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers|employees WHERE c.address = 'US')-[IS customer_orders]->(o IS orders) COLUMNS (c.name AS customer_name));  -- error
 SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.address = 'US')-[IS customer_orders] COLUMNS (c.name AS customer_name));  -- error
+SELECT * FROM GRAPH_TABLE (myshop MATCH (c IS customers), (o IS orders) COLUMNS (c.name AS customer_name));  -- error
+SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers)->{1,2}(o IS orders) COLUMNS (c.name AS customer_name));  -- error
 
 -- a property graph can be referenced only from within GRAPH_TABLE clause.
 SELECT * FROM myshop; -- error
@@ -457,6 +459,17 @@ INSERT INTO pe VALUES (1, 1, 2, 100);
 INSERT INTO ce1 VALUES (2, 2, 3, 200);
 INSERT INTO ce2 VALUES (3, 3, 1, 300);
 CREATE PROPERTY GRAPH g3
+    NODE TABLES (
+        pv KEY (id)
+    )
+    RELATIONSHIP TABLES (
+        pe KEY (id)
+            SOURCE KEY(src) REFERENCES pv(id)
+            DESTINATION KEY(dest) REFERENCES pv(id)
+    );
+SELECT * FROM GRAPH_TABLE (g3 MATCH (s IS pv)-[e IS pe]->(d IS pv) COLUMNS (s.val, e.val, d.val)) ORDER BY 1, 2, 3;
+-- temporary property graph
+CREATE TEMPORARY PROPERTY GRAPH gtmp
     VERTEX TABLES (
         pv KEY (id)
     )
@@ -465,7 +478,7 @@ CREATE PROPERTY GRAPH g3
             SOURCE KEY(src) REFERENCES pv(id)
             DESTINATION KEY(dest) REFERENCES pv(id)
     );
-SELECT * FROM GRAPH_TABLE (g3 MATCH (s IS pv)-[e IS pe]->(d IS pv) COLUMNS (s.val, e.val, d.val)) ORDER BY 1, 2, 3;
+SELECT * FROM GRAPH_TABLE (gtmp MATCH (s IS pv)-[e IS pe]->(d IS pv) COLUMNS (s.val, e.val, d.val)) ORDER BY 1, 2, 3;
 
 CREATE TABLE ptnv (id int PRIMARY KEY, val int) PARTITION BY LIST(id);
 CREATE TABLE prtv1 PARTITION OF ptnv FOR VALUES IN (1, 2);
@@ -487,8 +500,8 @@ SELECT * FROM GRAPH_TABLE (g4 MATCH (s IS ptnv)-[e IS ptne]->(d IS ptnv) COLUMNS
 SELECT * FROM GRAPH_TABLE (g4 MATCH (s)-[e]-(d) WHERE s.id = 3 COLUMNS (s.val, e.val, d.val)) ORDER BY 1, 2, 3;
 SELECT * FROM GRAPH_TABLE (g4 MATCH (s WHERE s.id = 3)-[e]-(d) COLUMNS (s.val, e.val, d.val)) ORDER BY 1, 2, 3;
 
-CREATE VIEW customers_us AS SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.address = 'US')-[IS customer_orders]->(o IS orders) COLUMNS (c.name AS customer_name));
-
+-- ruleutils reverse parsing
+CREATE VIEW customers_us AS SELECT * FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.address = 'US')-[IS customer_orders | customer_wishlists ]->(l IS orders | wishlists)-[ IS list_items]->(p IS products) COLUMNS (c.name AS customer_name, p.name AS product_name)) ORDER BY customer_name, product_name;
 SELECT pg_get_viewdef('customers_us'::regclass);
 
 -- test view/graph nesting
-- 
2.34.1

