public inbox for [email protected]  
help / color / mirror / Atom feed
From: Ayush Tiwari <[email protected]>
To: Chao Li <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Cc: Ashutosh Bapat <[email protected]>
Subject: Re: [PATCH] Clean up property graph error messages
Date: Wed, 6 May 2026 11:53:38 +0530
Message-ID: <CAJTYsWVshTGyFRCMKnjiRgCnky1FB9vD-mjBHYGWDXppSdO0jQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAJTYsWXFy1j_T82+M_S9kFxU414tQYnZQD-b82=oL_LbG_5fPQ@mail.gmail.com>
	<[email protected]>

Hi,


On Tue, 5 May 2026 at 08:20, Chao Li <[email protected]> wrote:

>
> So, v1 LGTM. Only thing is that I think we can also make “mismatching” to
> “mismatched” in the errmsg.
>
>
I agree that "mismatched property names" reads better, so I have updated
that in v2.  I did not include the vertexes/vertices change here, since
Peter has already fixed that separately.

Regards,
Ayush


Attachments:

  [application/octet-stream] v2-0001-Clean-up-property-graph-error-messages.patch (5.6K, 3-v2-0001-Clean-up-property-graph-error-messages.patch)
  download | inline diff:
From 5a28c695ec9218d53a0f9b913bc9d31067104d8c Mon Sep 17 00:00:00 2001
From: Ayush Tiwari <[email protected]>
Date: Wed, 6 May 2026 06:07:12 +0000
Subject: [PATCH v2] Clean up property graph error messages

Fix a typo in the error message for mismatched property names in
property graph labels.

Also move an unreachable ReleaseSysCache() before ereport(ERROR) in
check_element_properties(), copying the element alias and relation OID first
so the error path does not reference the released syscache tuple.
---
 src/backend/commands/propgraphcmds.c               | 14 +++++++++-----
 .../regress/expected/create_property_graph.out     |  8 ++++----
 src/test/regress/sql/create_property_graph.sql     |  4 ++--
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/backend/commands/propgraphcmds.c b/src/backend/commands/propgraphcmds.c
index 48284b84db9..6a35ba698ee 100644
--- a/src/backend/commands/propgraphcmds.c
+++ b/src/backend/commands/propgraphcmds.c
@@ -1113,6 +1113,8 @@ check_element_properties(Oid peoid)
 						HeapTuple	tuple3;
 						Form_pg_propgraph_element elform;
 						List	   *dpcontext;
+						char	   *element_name;
+						Oid			element_relid;
 						char	   *dpa,
 								   *dpb;
 
@@ -1120,7 +1122,11 @@ check_element_properties(Oid peoid)
 						if (!tuple3)
 							elog(ERROR, "cache lookup failed for property graph element %u", peoid);
 						elform = (Form_pg_propgraph_element) GETSTRUCT(tuple3);
-						dpcontext = deparse_context_for(get_rel_name(elform->pgerelid), elform->pgerelid);
+						element_name = pstrdup(NameStr(elform->pgealias));
+						element_relid = elform->pgerelid;
+						ReleaseSysCache(tuple3);
+
+						dpcontext = deparse_context_for(get_rel_name(element_relid), element_relid);
 
 						dpa = deparse_expression(na, dpcontext, false, false);
 						dpb = deparse_expression(nb, dpcontext, false, false);
@@ -1141,10 +1147,8 @@ check_element_properties(Oid peoid)
 						ereport(ERROR,
 								errcode(ERRCODE_SYNTAX_ERROR),
 								errmsg("element \"%s\" property \"%s\" expression mismatch: %s vs. %s",
-									   NameStr(elform->pgealias), get_propgraph_property_name(propoid), dpa, dpb),
+									   element_name, get_propgraph_property_name(propoid), dpa, dpb),
 								errdetail("In a property graph element, a property of the same name has to have the same expression in each label."));
-
-						ReleaseSysCache(tuple3);
 					}
 
 					break;
@@ -1266,7 +1270,7 @@ check_element_label_properties(Oid ellabeloid)
 	if (diff1 || diff2)
 		ereport(ERROR,
 				errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-				errmsg("mismatching properties names in definition of label \"%s\"", get_propgraph_label_name(labelid)));
+				errmsg("mismatched property names in definition of label \"%s\"", get_propgraph_label_name(labelid)));
 }
 
 /*
diff --git a/src/test/regress/expected/create_property_graph.out b/src/test/regress/expected/create_property_graph.out
index 4fc4759f18e..ebb5f70787b 100644
--- a/src/test/regress/expected/create_property_graph.out
+++ b/src/test/regress/expected/create_property_graph.out
@@ -208,13 +208,13 @@ ERROR:  mismatching number of properties in definition of label "l1"
 CREATE PROPERTY GRAPH gx
     VERTEX TABLES (
         t1 KEY (a) LABEL l1 PROPERTIES (a, b),
-        t2 KEY (i) LABEL l1 PROPERTIES (i AS a, j AS j)  -- mismatching property names on label
+        t2 KEY (i) LABEL l1 PROPERTIES (i AS a, j AS j)  -- mismatched property names on label
     );
-ERROR:  mismatching properties names in definition of label "l1"
+ERROR:  mismatched property names in definition of label "l1"
 ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t1 ADD LABEL t3l1 PROPERTIES (a AS x, b AS yy, b AS zz);  -- mismatching number of properties on label
 ERROR:  mismatching number of properties in definition of label "t3l1"
-ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t1 ADD LABEL t3l1 PROPERTIES (a AS x, b AS zz);  -- mismatching property names on label
-ERROR:  mismatching properties names in definition of label "t3l1"
+ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t1 ADD LABEL t3l1 PROPERTIES (a AS x, b AS zz);  -- mismatched property names on label
+ERROR:  mismatched property names in definition of label "t3l1"
 ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t1 ADD LABEL t3l1 PROPERTIES (a AS x);  -- mismatching number of properties on label
 ERROR:  mismatching number of properties in definition of label "t3l1"
 ALTER PROPERTY GRAPH g1 OWNER TO regress_graph_user1;
diff --git a/src/test/regress/sql/create_property_graph.sql b/src/test/regress/sql/create_property_graph.sql
index 241f93df302..d1f93fe94a8 100644
--- a/src/test/regress/sql/create_property_graph.sql
+++ b/src/test/regress/sql/create_property_graph.sql
@@ -163,10 +163,10 @@ CREATE PROPERTY GRAPH gx
 CREATE PROPERTY GRAPH gx
     VERTEX TABLES (
         t1 KEY (a) LABEL l1 PROPERTIES (a, b),
-        t2 KEY (i) LABEL l1 PROPERTIES (i AS a, j AS j)  -- mismatching property names on label
+        t2 KEY (i) LABEL l1 PROPERTIES (i AS a, j AS j)  -- mismatched property names on label
     );
 ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t1 ADD LABEL t3l1 PROPERTIES (a AS x, b AS yy, b AS zz);  -- mismatching number of properties on label
-ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t1 ADD LABEL t3l1 PROPERTIES (a AS x, b AS zz);  -- mismatching property names on label
+ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t1 ADD LABEL t3l1 PROPERTIES (a AS x, b AS zz);  -- mismatched property names on label
 ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t1 ADD LABEL t3l1 PROPERTIES (a AS x);  -- mismatching number of properties on label
 
 ALTER PROPERTY GRAPH g1 OWNER TO regress_graph_user1;
-- 
2.43.0



view thread (9+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: [PATCH] Clean up property graph error messages
  In-Reply-To: <CAJTYsWVshTGyFRCMKnjiRgCnky1FB9vD-mjBHYGWDXppSdO0jQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox