Re: Property graph: fix error handling when dropping non-existent label property - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Property graph: fix error handling when dropping non-existent label property
Date
Msg-id 15f3aedb-d2ba-4854-96a7-a24898b4b3ba@eisentraut.org
Whole thread
In response to Re: Property graph: fix error handling when dropping non-existent label property  (Chao Li <li.evan.chao@gmail.com>)
List pgsql-hackers
On 26.04.26 09:21, Chao Li wrote:
> 
> 
>> On Apr 24, 2026, at 20:38, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> wrote:
>>
>> On Fri, Apr 24, 2026 at 1:03 PM Chao Li <li.evan.chao@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> I am testing graph tables today and noticed an improper error message when dropping a property.
>>>
>>> Here is a simple repro:
>>> ```
>>> evantest=# CREATE TABLE t1 (a int PRIMARY KEY, b int);
>>> CREATE TABLE
>>> evantest=#
>>> evantest=# CREATE PROPERTY GRAPH g
>>> evantest-#     VERTEX TABLES (
>>> evantest(#         t1
>>> evantest(#             LABEL l1 PROPERTIES (a AS p1)
>>> evantest(#             LABEL l2 PROPERTIES (b AS p2)
>>> evantest(#     );
>>> CREATE PROPERTY GRAPH
>>> evantest=#
>>> evantest=# ALTER PROPERTY GRAPH g
>>> evantest-#     ALTER VERTEX TABLE t1
>>> evantest-#     ALTER LABEL l1 DROP PROPERTIES (p2);
>>> ERROR:  could not find tuple for label property 0
>>> ```
>>>
>>> This does not look like a normal user-facing SQL error message.
>>>
>>> Looking into the code, AlterPropGraph() checks whether the property exists in the graph, but does not check if
labelproperty exists. As a result, InvalidOid can be passed to ObjectAddressSet() and then to performDeletion().
 
>>>
>>> The fix is simple, just check the label-property OID before trying to delete it. I also added a regress test.
>>>
>>> With the patch, the error becomes:
>>> ```
>>> evantest=# ALTER PROPERTY GRAPH g
>>> evantest-#     ALTER VERTEX TABLE t1
>>> evantest-#     ALTER LABEL l1 DROP PROPERTIES (p2);
>>> ERROR:  property graph "g" element "t1" label "l1" has no property "p2"
>>> ```
>>
>> Thanks for the report. Agree that we need to provide a correct error
>> message. The code changes look good to me.
> 
> Cool! Thanks for reviewing and confirming.

This patch has been committed as part of

https://www.postgresql.org/message-id/CAExHW5teYi1Kyw2exqk8t%2BWF4wq0cUaWcWQo0oi7NpnmcctJHA%40mail.gmail.com

Thanks.




pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [Bug][patch]: After dropping the last label from a property graph element, invoking pg_get_propgraphdef() triggers an assertion failure
Next
From: Fujii Masao
Date:
Subject: Re: updates for handling optional argument in system functions