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 1wHxzo-007fLJ-0m for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Apr 2026 06:02:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHxzn-0023xm-1n for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Apr 2026 06:02:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wHxzn-0023xd-0V for pgsql-hackers@lists.postgresql.org; Wed, 29 Apr 2026 06:02:03 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wHxzk-00000003Ihx-1Qt4 for pgsql-hackers@lists.postgresql.org; Wed, 29 Apr 2026 06:02:02 +0000 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-35dac556bb2so7404032a91.1 for ; Tue, 28 Apr 2026 23:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777442520; x=1778047320; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=p8juFhlVy3jSAVi/+f3nKC2YXL9YrSi2dn9On3TUZ4k=; b=CHErkE0oXCgxxBLOY08iPwnCDU9yFr7S6KtRjNASCxqPiZGAPTIC6M8eBv3+U7Gw4N K9jn8FlEKxNB6OeZvEt+8h4yIJmSAND7FBBogjK7FCVGmg9qq0+kY2S/y3Caz3a6poyT 4V7i/mSgRcn4G/3TjeGIVLamfIT/JlS5TFNyab1aHBVXOvUNM9sdkmHIVBFQUXW/zxqR +a5iEAFwDRT6ePpc9ZDLu9bbAjhmoz9cWI3kjdFsDsD9Eqdk9T2laEL3ljkxpjlJ4X5R YY2x4SkeaS3QhaFElRV5C8AbVuPvrjd28+uCtxlHKjb7NPECPVDhAvjOVHFtYRjE76ai mApQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777442520; x=1778047320; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=p8juFhlVy3jSAVi/+f3nKC2YXL9YrSi2dn9On3TUZ4k=; b=qbf39rD1oaGwSejoiIkbZ592mERZ7PBUrvUsXO81q18x1Z4EiihAH9ieoeZrtD5UJr NyQvN3bYdVqi4dXhArrsTn0/dItMJ1dvMN8benBfYpXZt8YmeiKujgzGB8ty/Xcy3w36 No7+em73dw5bbc95xw9F2W5Skjl90Vzg9gaaslU/MJ9d9N0nPuIPBqgYb0o0D2rJtri1 P7JPiXAnOsaHzUPpMqYrUbmkgCebhY9asbYqO/ArvAo2+hQ3D3uiT5SoZYsQtIi/TZc5 RzEk2Lh6bnx6p7RqbVqzxIj4RLMtHvCcqjmEI5xApU3iy99wnFggMGOS10yUjBgRkayz 471A== X-Gm-Message-State: AOJu0Yxh78gwcuaokVDl9LDghDcmyfcNcBako4ZNLeOmwStx01IXDHEg Udsc6RmIV20xihKyNSIxLLwDZJxLBUjEdYR+0Es++Mzeism3xJnhowEIrQ6vbPa2Gyc= X-Gm-Gg: AeBDievxoC9y2ro5wzo4arxeuYdKVjGnDfGLgnZ/qzKm0WedOHQkdpIa9Tm/8WJeu8w 1ATh40L2odHzJiplOmxPFXmPGhZV8jdBycXYc8AVlr/YHU7dENhlGtD7Sum1c4EwjIJqNeX/W+t PlXKNOiOxBuSNmDDLAze2DPShK8eEf3HyK2CDBdaTo5c6LRVKl2Zaj8dQqGuhG2hVBIpAorjkuh taXM4JyM48fLM67AmBIcdlvFnhuVBDDPmgwhZZ30MM5fTK1YccYpEFdS+qtpgF8Bd3vDPIy/BFC hT3wF0FqEUBI4eKXb8gxn/liIV7y7vc3O9qj0XQ8n+6fZMe5bZK/bgcaJ66j0JTHNR1XeMJTjz5 yRTWtoydVE230xKfjrR/DTfBWIguW/IxH30+MHttcdYKq1gPUQfhC81dkTZHFwCgRouUTDvi29N B4S0VndrCvdzPdoxMoLZ1iNYYR0SpucAoQIA5B5nKdaQ== X-Received: by 2002:a17:90b:4c90:b0:35f:b4c1:91f6 with SMTP id 98e67ed59e1d1-364a0b641fdmr2607640a91.10.1777442519691; Tue, 28 Apr 2026 23:01:59 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364a41520dbsm931158a91.3.2026.04.28.23.01.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Apr 2026 23:01:59 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: Property graph: fix error handling when dropping non-existent label property From: Chao Li In-Reply-To: Date: Wed, 29 Apr 2026 14:01:19 +0800 Cc: PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: <59B04C7C-8DE7-48CE-9CD4-6E188D16A0C4@gmail.com> References: <1DA5D52A-4AFA-426E-83F7-42ED974D682B@gmail.com> To: Ashutosh Bapat X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Apr 28, 2026, at 23:01, Ashutosh Bapat = wrote: >=20 > On Sun, Apr 26, 2026 at 12:51=E2=80=AFPM Chao Li = wrote: >>=20 >>=20 >>=20 >>> On Apr 24, 2026, at 20:38, Ashutosh Bapat = wrote: >>>=20 >>> On Fri, Apr 24, 2026 at 1:03=E2=80=AFPM Chao Li = wrote: >>>>=20 >>>> Hi, >>>>=20 >>>> I am testing graph tables today and noticed an improper error = message when dropping a property. >>>>=20 >>>> 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 >>>> ``` >>>>=20 >>>> This does not look like a normal user-facing SQL error message. >>>>=20 >>>> 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(). >>>>=20 >>>> The fix is simple, just check the label-property OID before trying = to delete it. I also added a regress test. >>>>=20 >>>> 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" >>>> ``` >>>=20 >>> Thanks for the report. Agree that we need to provide a correct error >>> message. The code changes look good to me. >>=20 >> Cool! Thanks for reviewing and confirming. >>=20 >>> However, the way you have >>> written this code is different from similar code earlier in the >>> function. Either your code should match that style or that code = should >>> be changed to your style. I like your way - reduces code a bit and >>> does not repeat ereport. I also noticed that the code to fetch the >>> element label oid from element_alias and label name is repeated = along >>> with the ereport in a few places. I think we could instead write a >>> function to do that and call that function in those places. When >>> writing the function, we could change that code to use your style. >>=20 >> I updated the nearby code to align with my style. PFA v2. >=20 > Looks good to me. However, I did change OidIsValid() and !OidIsValid() > back to (oid) and (!oid) conditions to be consistent with the rest of > the code. In the file, I also see: ``` if (pgrelid =3D=3D InvalidOid) ``` Should we take this opportunity to change to use OidIsValid() everywhere = in the file? As this feature is new to PG19, we can cleanup the = inconsistency before releasing v19. Otherwise some people might also = file a cleanup patch for this in the future. >=20 > I tried to deduplicate the code which finds element labelid from given > element alias and label name. But there is one place where we also use > the label oid and or the element oid that the code extracts. So it > didn't end up being a lot of improvement. >=20 > Since this patch conflicts with the patch at [1], I am posting this > patch along with the patch there on that thread so that both can be > committed without causing a merge conflict. If necessary we can > continue discussion here. Reasonable. >=20 > [1] = https://www.postgresql.org/message-id/CAExHW5uThebnwqyWHrsF2Z+no-fT8VrM0Yj= +RU7YWrYzdavUZg@mail.gmail.com >=20 >=20 > --=20 > Best Wishes, > Ashutosh Bapat Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/