v1-0001-Fix-DROP-PROPERTIES-check-for-property-graph-labe.patch
application/octet-stream
Filename: v1-0001-Fix-DROP-PROPERTIES-check-for-property-graph-labe.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v1-0001
Subject: Fix DROP PROPERTIES check for property graph labels
| File | + | − |
|---|---|---|
| src/backend/commands/propgraphcmds.c | 9 | 4 |
| src/test/regress/expected/create_property_graph.out | 2 | 0 |
| src/test/regress/sql/create_property_graph.sql | 1 | 0 |
From e9b4fb61856887f8bb3b34e60315382c0282b02f Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Fri, 24 Apr 2026 15:12:17 +0800
Subject: [PATCH v1] Fix DROP PROPERTIES check for property graph labels
When ALTER PROPERTY GRAPH ... DROP PROPERTIES drops a property from a
label, the code checked only whether the property existed in the graph's
property catalog. It did not verify that the property was actually
associated with the target label.
As a result, if the property was not present on the label,
GetSysCacheOid2(PROPGRAPHLABELPROP, ...) could return InvalidOid, which
was then passed to performDeletion().
Check the label-property mapping explicitly and report an undefined
property error when it is missing. Add a regression test for dropping a
nonexistent property from a label.
Author: Chao Li <lic@highgo.com>
Reviewed-by:
Discussion: https://postgr.es/m/
---
src/backend/commands/propgraphcmds.c | 13 +++++++++----
src/test/regress/expected/create_property_graph.out | 2 ++
src/test/regress/sql/create_property_graph.sql | 1 +
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/backend/commands/propgraphcmds.c b/src/backend/commands/propgraphcmds.c
index 6d509fccf46..9a76332f2a8 100644
--- a/src/backend/commands/propgraphcmds.c
+++ b/src/backend/commands/propgraphcmds.c
@@ -1615,21 +1615,26 @@ AlterPropGraph(ParseState *pstate, const AlterPropGraphStmt *stmt)
{
char *propname = strVal(lfirst(lc));
Oid propoid;
- Oid plpoid;
+ Oid plpoid = InvalidOid;
propoid = GetSysCacheOid2(PROPGRAPHPROPNAME,
Anum_pg_propgraph_property_oid,
ObjectIdGetDatum(pgrelid),
CStringGetDatum(propname));
- if (!propoid)
+
+ if (OidIsValid(propoid))
+ plpoid = GetSysCacheOid2(PROPGRAPHLABELPROP,
+ Anum_pg_propgraph_label_property_oid,
+ ObjectIdGetDatum(ellabeloid),
+ ObjectIdGetDatum(propoid));
+
+ if (!OidIsValid(plpoid))
ereport(ERROR,
errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("property graph \"%s\" element \"%s\" label \"%s\" has no property \"%s\"",
get_rel_name(pgrelid), stmt->element_alias, stmt->alter_label, propname),
parser_errposition(pstate, -1));
- plpoid = GetSysCacheOid2(PROPGRAPHLABELPROP, Anum_pg_propgraph_label_property_oid, ObjectIdGetDatum(ellabeloid), ObjectIdGetDatum(propoid));
-
ObjectAddressSet(obj, PropgraphLabelPropertyRelationId, plpoid);
performDeletion(&obj, stmt->drop_behavior, 0);
}
diff --git a/src/test/regress/expected/create_property_graph.out b/src/test/regress/expected/create_property_graph.out
index bc9a596ec89..d8c1c061c62 100644
--- a/src/test/regress/expected/create_property_graph.out
+++ b/src/test/regress/expected/create_property_graph.out
@@ -82,6 +82,8 @@ CREATE PROPERTY GRAPH g4
);
ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t2 ALTER LABEL t2 ADD PROPERTIES (k * 2 AS kk);
ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t2 ALTER LABEL t2 DROP PROPERTIES (k);
+ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t2 ALTER LABEL t2 DROP PROPERTIES (yy); -- error
+ERROR: property graph "g4" element "t2" label "t2" has no property "yy"
CREATE TABLE t11 (a int PRIMARY KEY);
CREATE TABLE t12 (b int PRIMARY KEY);
CREATE TABLE t13 (
diff --git a/src/test/regress/sql/create_property_graph.sql b/src/test/regress/sql/create_property_graph.sql
index 241f93df302..8157f2b3c0a 100644
--- a/src/test/regress/sql/create_property_graph.sql
+++ b/src/test/regress/sql/create_property_graph.sql
@@ -75,6 +75,7 @@ CREATE PROPERTY GRAPH g4
ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t2 ALTER LABEL t2 ADD PROPERTIES (k * 2 AS kk);
ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t2 ALTER LABEL t2 DROP PROPERTIES (k);
+ALTER PROPERTY GRAPH g4 ALTER VERTEX TABLE t2 ALTER LABEL t2 DROP PROPERTIES (yy); -- error
CREATE TABLE t11 (a int PRIMARY KEY);
CREATE TABLE t12 (b int PRIMARY KEY);
--
2.50.1 (Apple Git-155)