public inbox for [email protected]
help / color / mirror / Atom feedFrom: Ayush Tiwari <[email protected]>
To: PostgreSQL Hackers <[email protected]>
To: Peter Eisentraut <[email protected]>
To: Ashutosh Bapat <[email protected]>
Subject: [PATCH] Clean up property graph error messages
Date: Tue, 5 May 2026 01:27:00 +0530
Message-ID: <CAJTYsWXFy1j_T82+M_S9kFxU414tQYnZQD-b82=oL_LbG_5fPQ@mail.gmail.com> (raw)
Hi,
While looking at the SQL/PGQ property graph error paths, I noticed a
few small cleanups in propgraphcmds.c.
The attached patch fixes a user-visible error message from "mismatching
properties names" to "mismatching property names", and moves a
ReleaseSysCache() call before an ERROR ereport in
check_element_properties().
The existing code should be cleaned up by
the resource owner on the ERROR path, but the explicit ReleaseSysCache()
placed after ereport(ERROR) was unreachable.
The regression expected output is updated for the changed error text.
[On a separate note, it might be better to change all "vertexes" to
"vertices",
haven't included that in the patch though since the other one is not exactly
wrong?]
Regards,
Ayus
Attachments:
[application/octet-stream] v1-0001-Clean-up-property-graph-error-messages.patch (4.2K, 3-v1-0001-Clean-up-property-graph-error-messages.patch)
download | inline diff:
From 4c5aca2d5e754911969831a658d511fa53bdfe03 Mon Sep 17 00:00:00 2001
From: Ayush Tiwari <[email protected]>
Date: Tue, 5 May 2026 01:13:18 +0530
Subject: [PATCH v1] Clean up property graph error messages
check_element_properties() saved a ReleaseSysCache() call until after
ereport(ERROR), making the explicit release unreachable. Copy the
catalog fields needed for the error message and release the syscache
entry before building and reporting the error.
Also fix the wording of a property graph label consistency error from
"mismatching properties names" to "mismatching property names", and
update the matching expected output.
---
src/backend/commands/propgraphcmds.c | 14 +++++++++-----
.../regress/expected/create_property_graph.out | 4 ++--
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/backend/commands/propgraphcmds.c b/src/backend/commands/propgraphcmds.c
index 6d509fccf46..7784dd0f5c5 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("mismatching 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 bc9a596ec89..bfa6712b365 100644
--- a/src/test/regress/expected/create_property_graph.out
+++ b/src/test/regress/expected/create_property_graph.out
@@ -210,11 +210,11 @@ CREATE PROPERTY GRAPH gx
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
);
-ERROR: mismatching properties names in definition of label "l1"
+ERROR: mismatching 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"
+ERROR: mismatching 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;
--
2.34.1
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]
Subject: Re: [PATCH] Clean up property graph error messages
In-Reply-To: <CAJTYsWXFy1j_T82+M_S9kFxU414tQYnZQD-b82=oL_LbG_5fPQ@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