Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wGB2V-005xkK-1L for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Apr 2026 07:33:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wGB2U-005CMe-0P for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Apr 2026 07:33:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wGB2T-005CMV-2a for pgsql-hackers@lists.postgresql.org; Fri, 24 Apr 2026 07:33:25 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wGB2P-00000002mzg-0vWE for pgsql-hackers@lists.postgresql.org; Fri, 24 Apr 2026 07:33:25 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-2b2ea1b3962so43582755ad.0 for ; Fri, 24 Apr 2026 00:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777015998; x=1777620798; darn=lists.postgresql.org; h=to:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=ZvpsJSY0CUde31+VSWbUaoSm2X35FMn2+5jSDcxnpa8=; b=TmiM2snDw5vhOqlLSjv4775gFqTPgtrYmiAyDu1sweY6bf7PT55RGrF4aQKy56zq9B 7ALlJ8v9nSQL5qri7OkMjy/+jnR8Sf9cEAwAtXGpJU189oXGTv2nOvJniKye1pA/S+/G 4u7syMDVtXzIos2sbUBx9bKPq09ZCLmGS/UolVIWXBNo/yWlUfMMlhe6tzQ9G3rAmnHb CKik8o9XZ1sJo/wXzigK282gPXD8VDn+mnCFeMCBYSr8ZUGMOd+uI6svbngOHAUw4nLJ V0FlU39Yo+iaRNsVwlPZeFI6e3bqXYutNZFyXYAwXKm5f6J+7Pp/zhDeFgHnKsIR4Hr5 SY5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777015998; x=1777620798; h=to:date:message-id:subject:mime-version:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZvpsJSY0CUde31+VSWbUaoSm2X35FMn2+5jSDcxnpa8=; b=VPJwo4MwUESs5bJmlMRnxdhwx2QFCYl37I1W7vV/Ir88HGVFQ2e1+Eg2mYdK/Skf6i AR+HhQK5jmluJra3B/pETGM6s/tWeZqaTWnfF717tqq9AV6Wf6LJtDcy0EiOC5BS+Hlw nIy1Ua8qpmyt7LHMf6JNIAtLxhhfl3QatgDUNIiTXd/4PZapkysjV01uiQGIQkOdXZ/n 91M2zcC6wEf00FV4HryWNTeZKT+Q6Q3zMwAt+129QPVBygXabJM3CLZEWraTbA0IdCuQ 6H7/Kk6GgnSM9e99b1joZ3wBiinMjWRzSbRklriuNOPEaEUY5U/p3E+T5l0sXsZdkIlK napQ== X-Gm-Message-State: AOJu0YyOzl3HF1ouwWQXiPcQ7lK0TH7FWuWMmXSsM789Arpfp3PmNohq 7Clf+G6QDuhEZWMEXqZzcKEppDRHE9Hc6cRe7b4lL2vNNSsXNHuRV9Qm3wkwimrgyqs= X-Gm-Gg: AeBDiesKDoQ1SX/ORQnVzkgGljFxUPWD5J+82Yw1P9mFfwiDoiGcqJes5mNLSaMqUsq Jhr+m8ADuNBjbhVYFj0tEIfbXWVJ6hrFP0J0hzaiqGc/Hhuoc03c0oj5Al8Xy5gSBN/TblRcZDD J9yzgKGl2bbjAjWjtbD6Tao7XKaFHiIXz5J1SIBjYTsvNV/E6zJZuYHNjxap/76mi1WzVdtI1Kv aop//d8wOwxA5Zvvdn4/1pmMSlyPDObazQEGCCq/e4VK9Qi2XKCUa82pTkW8UCprxtfIQSeND82 4Nj/pEXFa0AsYAlBuP5iNTl17NgwBX9QwW8hFFwSCElLVIlrdrrXVkSnowc/4c3YQ7K2PoVl4Cz iSsGG2/6rxDrFLj6Ed7cavFbgLOLayYxYJZFtnfqSAI0Bt8dEz7FxDYx4wbBX1a8oCttfyDZWvk ook3t2oBP2kZ1rZ4a0JeCkK6wnf78VPv3swye07x1pRQ== X-Received: by 2002:a17:902:9696:b0:2b0:4fb6:85ce with SMTP id d9443c01a7336-2b5f9f7cec4mr223017695ad.21.1777015997906; Fri, 24 Apr 2026 00:33:17 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5fab28e35sm213960835ad.64.2026.04.24.00.33.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2026 00:33:17 -0700 (PDT) From: Chao Li Content-Type: multipart/mixed; boundary="Apple-Mail=_ADA5EA19-27D2-4ACB-ACFC-BB90613EF5A9" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Property graph: fix error handling when dropping non-existent label property Message-Id: <1DA5D52A-4AFA-426E-83F7-42ED974D682B@gmail.com> Date: Fri, 24 Apr 2026 15:32:38 +0800 To: PostgreSQL Hackers X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_ADA5EA19-27D2-4ACB-ACFC-BB90613EF5A9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, I am testing graph tables today and noticed an improper error message = when dropping a property. Here is a simple repro: ``` evantest=3D# CREATE TABLE t1 (a int PRIMARY KEY, b int); CREATE TABLE evantest=3D# evantest=3D# 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=3D# evantest=3D# 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 label property 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=3D# 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" ``` Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_ADA5EA19-27D2-4ACB-ACFC-BB90613EF5A9 Content-Disposition: attachment; filename=v1-0001-Fix-DROP-PROPERTIES-check-for-property-graph-labe.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v1-0001-Fix-DROP-PROPERTIES-check-for-property-graph-labe.patch" Content-Transfer-Encoding: quoted-printable =46rom=20e9b4fb61856887f8bb3b34e60315382c0282b02f=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Fri,=2024=20Apr=202026=2015:12:17=20+0800=0ASubject:=20[PATCH=20= v1]=20Fix=20DROP=20PROPERTIES=20check=20for=20property=20graph=20labels=0A= =0AWhen=20ALTER=20PROPERTY=20GRAPH=20...=20DROP=20PROPERTIES=20drops=20a=20= property=20from=20a=0Alabel,=20the=20code=20checked=20only=20whether=20= the=20property=20existed=20in=20the=20graph's=0Aproperty=20catalog.=20It=20= did=20not=20verify=20that=20the=20property=20was=20actually=0Aassociated=20= with=20the=20target=20label.=0A=0AAs=20a=20result,=20if=20the=20property=20= was=20not=20present=20on=20the=20label,=0A= GetSysCacheOid2(PROPGRAPHLABELPROP,=20...)=20could=20return=20= InvalidOid,=20which=0Awas=20then=20passed=20to=20performDeletion().=0A=0A= Check=20the=20label-property=20mapping=20explicitly=20and=20report=20an=20= undefined=0Aproperty=20error=20when=20it=20is=20missing.=20Add=20a=20= regression=20test=20for=20dropping=20a=0Anonexistent=20property=20from=20= a=20label.=0A=0AAuthor:=20Chao=20Li=20=0AReviewed-by:=0A= Discussion:=20https://postgr.es/m/=0A---=0A=20= src/backend/commands/propgraphcmds.c=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20|=2013=20+++++++++----=0A=20= src/test/regress/expected/create_property_graph.out=20|=20=202=20++=0A=20= src/test/regress/sql/create_property_graph.sql=20=20=20=20=20=20|=20=201=20= +=0A=203=20files=20changed,=2012=20insertions(+),=204=20deletions(-)=0A=0A= diff=20--git=20a/src/backend/commands/propgraphcmds.c=20= b/src/backend/commands/propgraphcmds.c=0Aindex=20= 6d509fccf46..9a76332f2a8=20100644=0A---=20= a/src/backend/commands/propgraphcmds.c=0A+++=20= b/src/backend/commands/propgraphcmds.c=0A@@=20-1615,21=20+1615,26=20@@=20= AlterPropGraph(ParseState=20*pstate,=20const=20AlterPropGraphStmt=20= *stmt)=0A=20=09=09{=0A=20=09=09=09char=09=20=20=20*propname=20=3D=20= strVal(lfirst(lc));=0A=20=09=09=09Oid=09=09=09propoid;=0A-=09=09=09Oid=09= =09=09plpoid;=0A+=09=09=09Oid=09=09=09plpoid=20=3D=20InvalidOid;=0A=20=0A= =20=09=09=09propoid=20=3D=20GetSysCacheOid2(PROPGRAPHPROPNAME,=0A=20=09=09= =09=09=09=09=09=09=09=20=20Anum_pg_propgraph_property_oid,=0A=20=09=09=09= =09=09=09=09=09=09=20=20ObjectIdGetDatum(pgrelid),=0A=20=09=09=09=09=09=09= =09=09=09=20=20CStringGetDatum(propname));=0A-=09=09=09if=20(!propoid)=0A= +=0A+=09=09=09if=20(OidIsValid(propoid))=0A+=09=09=09=09plpoid=20=3D=20= GetSysCacheOid2(PROPGRAPHLABELPROP,=0A+=09=09=09=09=09=09=09=09=09=09=20= Anum_pg_propgraph_label_property_oid,=0A+=09=09=09=09=09=09=09=09=09=09=20= ObjectIdGetDatum(ellabeloid),=0A+=09=09=09=09=09=09=09=09=09=09=20= ObjectIdGetDatum(propoid));=0A+=0A+=09=09=09if=20(!OidIsValid(plpoid))=0A= =20=09=09=09=09ereport(ERROR,=0A=20=09=09=09=09=09=09= errcode(ERRCODE_UNDEFINED_OBJECT),=0A=20=09=09=09=09=09=09= errmsg("property=20graph=20\"%s\"=20element=20\"%s\"=20label=20\"%s\"=20= has=20no=20property=20\"%s\"",=0A=20=09=09=09=09=09=09=09=20=20=20= get_rel_name(pgrelid),=20stmt->element_alias,=20stmt->alter_label,=20= propname),=0A=20=09=09=09=09=09=09parser_errposition(pstate,=20-1));=0A=20= =0A-=09=09=09plpoid=20=3D=20GetSysCacheOid2(PROPGRAPHLABELPROP,=20= Anum_pg_propgraph_label_property_oid,=20ObjectIdGetDatum(ellabeloid),=20= ObjectIdGetDatum(propoid));=0A-=0A=20=09=09=09ObjectAddressSet(obj,=20= PropgraphLabelPropertyRelationId,=20plpoid);=0A=20=09=09=09= performDeletion(&obj,=20stmt->drop_behavior,=200);=0A=20=09=09}=0Adiff=20= --git=20a/src/test/regress/expected/create_property_graph.out=20= b/src/test/regress/expected/create_property_graph.out=0Aindex=20= bc9a596ec89..d8c1c061c62=20100644=0A---=20= a/src/test/regress/expected/create_property_graph.out=0A+++=20= b/src/test/regress/expected/create_property_graph.out=0A@@=20-82,6=20= +82,8=20@@=20CREATE=20PROPERTY=20GRAPH=20g4=0A=20=20=20=20=20);=0A=20= ALTER=20PROPERTY=20GRAPH=20g4=20ALTER=20VERTEX=20TABLE=20t2=20ALTER=20= LABEL=20t2=20ADD=20PROPERTIES=20(k=20*=202=20AS=20kk);=0A=20ALTER=20= PROPERTY=20GRAPH=20g4=20ALTER=20VERTEX=20TABLE=20t2=20ALTER=20LABEL=20t2=20= DROP=20PROPERTIES=20(k);=0A+ALTER=20PROPERTY=20GRAPH=20g4=20ALTER=20= VERTEX=20TABLE=20t2=20ALTER=20LABEL=20t2=20DROP=20PROPERTIES=20(yy);=20=20= --=20error=0A+ERROR:=20=20property=20graph=20"g4"=20element=20"t2"=20= label=20"t2"=20has=20no=20property=20"yy"=0A=20CREATE=20TABLE=20t11=20(a=20= int=20PRIMARY=20KEY);=0A=20CREATE=20TABLE=20t12=20(b=20int=20PRIMARY=20= KEY);=0A=20CREATE=20TABLE=20t13=20(=0Adiff=20--git=20= a/src/test/regress/sql/create_property_graph.sql=20= b/src/test/regress/sql/create_property_graph.sql=0Aindex=20= 241f93df302..8157f2b3c0a=20100644=0A---=20= a/src/test/regress/sql/create_property_graph.sql=0A+++=20= b/src/test/regress/sql/create_property_graph.sql=0A@@=20-75,6=20+75,7=20= @@=20CREATE=20PROPERTY=20GRAPH=20g4=0A=20=0A=20ALTER=20PROPERTY=20GRAPH=20= g4=20ALTER=20VERTEX=20TABLE=20t2=20ALTER=20LABEL=20t2=20ADD=20PROPERTIES=20= (k=20*=202=20AS=20kk);=0A=20ALTER=20PROPERTY=20GRAPH=20g4=20ALTER=20= VERTEX=20TABLE=20t2=20ALTER=20LABEL=20t2=20DROP=20PROPERTIES=20(k);=0A= +ALTER=20PROPERTY=20GRAPH=20g4=20ALTER=20VERTEX=20TABLE=20t2=20ALTER=20= LABEL=20t2=20DROP=20PROPERTIES=20(yy);=20=20--=20error=0A=20=0A=20CREATE=20= TABLE=20t11=20(a=20int=20PRIMARY=20KEY);=0A=20CREATE=20TABLE=20t12=20(b=20= int=20PRIMARY=20KEY);=0A--=20=0A2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_ADA5EA19-27D2-4ACB-ACFC-BB90613EF5A9--