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 1wOnO7-000BCL-0B for pgsql-hackers@arkaria.postgresql.org; Mon, 18 May 2026 02:07:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wOnO3-000pGP-0q for pgsql-hackers@arkaria.postgresql.org; Mon, 18 May 2026 02:07:20 +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 1wOnO2-000pGH-2m for pgsql-hackers@lists.postgresql.org; Mon, 18 May 2026 02:07:19 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wOnNy-000000006xI-2gz3 for pgsql-hackers@lists.postgresql.org; Mon, 18 May 2026 02:07:19 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-b936331786dso217677966b.3 for ; Sun, 17 May 2026 19:07:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779070034; cv=none; d=google.com; s=arc-20240605; b=bl7A9jNGbgsS9OzOW7oGV0hXmom3LKIuAYtcvVAXhBY9ILuWarxoSw5s3yqxuySVnp /l7NTrXd/dazeMPrZ64/2hnZVP++Zb3+TTebh7IYEuRDF0PftOj6kVS4Iu52JYLDl46w 9sdEHcTbBV4/JjMhS3+EOLc+zT2vcCjxbB451v8ShZdkBM61pt7U+ZccOU7vIexBevuZ y6uwugxdvWCoq9cnuo+8fE82WyESImsmydJjYEAFBAfYI6Op6hbXoKSRNtubpAiuXuEZ 6+Km9XdQ9TC6RJiLoGi1s8dZgyRU2zq9mi8DBh6ut4kmyXEvP3R2K3UcbOWZBF7MHji3 Cwmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=D/YLGyuPJjFdWQi9lo2buEmlZVOD9xYzVifX3aV0oEE=; fh=D7hLKzCOel2bkcOXQ9j7zaSBNdOpKZx8BJk5YB7y9oU=; b=RSSSFl5oLMAh9fbqW/EtGCdk6IfRgp9kxAH/U9SZGHkvJx6ZipZdgvKwz3a0c86PXP OMbbLSUfZ2wU3UUA9J1C81a+83rqDaeZzHYSXetj3wZ1xi94UlWIg2aurWx1mpzEXhyI Dm7+4XFRKz7zvXcdGdCposLDvUdUT3KWSMlChBJ2foJgneNs9UPbEfTlTAWD8OxoVr35 NQ4tVCp0aceh7Y9zvsDqBrQa873C51yjspNovz3BPJ86zjDCsjE1h4R0whBNrdN/hptP m5xPnGyet+fX56x5eGlHJ9onIUl0D2C2zTgDtd4dXhEgPnQCxQ4y6l3pDlXBOEMbfeuU cIaA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779070034; x=1779674834; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=D/YLGyuPJjFdWQi9lo2buEmlZVOD9xYzVifX3aV0oEE=; b=LuqLZ7HhDSaEWnNFfj4N1d6d4f31YQr4IRz6koPkUctZQ5oELQ7mUz3nGMeHJaLY5a PRiLL2XRBbf0qhk4ar193WfypB5j2Oo3RktiGm69VPR7iYWHencZenvFmaSQilq5V0fq njhy/j03sZgAT7ioh3pYMNhvDSDIu4Vg2btYgN76vnfO7AW5zu9IvEl0LoZ1PsqN36Xv 8KxvWmqoDWKHRLNJC6xJPOnRro8bbj/vVWAxRD6+yypVpoJm6wR1JiqnDY1mbrBgQ8IS PADrdzJruKvqthSS5A++HYZgqsZGkhJc1hC4BT4h/HVq68N6sACQvgwq9jorlkPrRAcW Vatw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779070034; x=1779674834; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=D/YLGyuPJjFdWQi9lo2buEmlZVOD9xYzVifX3aV0oEE=; b=QgK7XoTZOjGKzUw2sDvYt6aDPmh0HL77CQYoRZYVdEnJXikhAK2LbNyHQU+QXeJR/f NtdFIhpYAYQ6Em68Um+VK3+uE6byxAuiEqd8MUfD4y40MvIefzRZxRpiUfEnGgQVeTVD 25Ax1f7mRYhXaAYcduppdeQg7hxqKO2C304MzGB7n98QkDVOD4fvJ6Oj6gkJggr9e0P/ pZuwaFRbZlLOk6vrpAtF9uvbxlKz1kg871U8pGw8dPH7K0b2QGrO2n7R0H/c2SpT55qb MaJ84BxHDGqBY9uDVAu8t1fzTalNbYTM9iu7XUU/TUYUbKeDtInS8R8Ovkmqa2oH5xF5 Y61w== X-Forwarded-Encrypted: i=1; AFNElJ8WIND5hQ6UHUROwMkdAVGPSiMt1N6ipaou8CQffiFVPNzKkznMdSlDNSiqc+pqM4F/rDIE3Mv9vX4xHgYr@lists.postgresql.org X-Gm-Message-State: AOJu0YyoddGPFCH9UIQiOOmw5Mae1liYTRKRn1uD0c5ezofT+3qwaATW TROU3//igSnkOluhCrM4jEYB5t+odmTjKW1mYtZ0mzWF+bcw37Z92TYx477/v4lpC57Ig1awXT+ ecCQ9LTSltNCqP1mrZxDNoOnqhO+/BQM= X-Gm-Gg: Acq92OEEb0HXaDEYIRrbEm1ITfz2L/J5wFWRZp8SKr5zzhuu6QZozQy20YRNyOIpPlR L45AdazHNGulw7JKglq8PFka6hK8y9/WE8WkHe0+ehYgAl+COiSxdLLtItlpEcoVAV+8vd+ZVUG /9rAEnJpFzDzYReleOx/6c5vikuGnGwfEVQK8KI5QGpqAl4gLgZt2V6kYnqRM6RcyOaXD3ADBsQ 3Qi/wNruyqDqkWwD1xyqB3txkBQKkW9xWQ/FzlxoQMLXmytZXfEPC5ecd4Ls44BvGvidr2E0eas l8+rHwxu0V9t9z189/W0L4Gz/+zEfL9gxP1+DfHSRAjdU+GM1ComvUCLNAY/bdElHRwRy3O754F NSiRN X-Received: by 2002:a17:907:d06:b0:bd3:c295:d76c with SMTP id a640c23a62f3a-bd5177afe53mr734794566b.1.1779070033531; Sun, 17 May 2026 19:07:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Junwang Zhao Date: Mon, 18 May 2026 10:07:02 +0800 X-Gm-Features: AVHnY4KarcMvcNhsiqdpN3yxDuaiq47OXTHb64R0GddP5GBcANNg2R2bFaG3VUU Message-ID: Subject: Re: (SQL/PGQ) cache lookup failed for label To: Ashutosh Bapat Cc: Ayush Tiwari , zengman , pgsql-hackers , Peter Eisentraut Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, May 18, 2026 at 8:22=E2=80=AFAM Ashutosh Bapat wrote: > > On Sun, May 17, 2026 at 5:12=E2=80=AFPM Junwang Zhao = wrote: > > > > > > > > > > Regards > > Junwang Zhao > > > > On Mon, May 18, 2026 at 07:29 Ashutosh Bapat wrote: > >> > >> On Fri, May 15, 2026 at 8:43=E2=80=AFPM Ayush Tiwari > >> wrote: > >> > > >> > Hi, > >> > > >> > > >> > On Fri, 15 May 2026 at 20:31, Junwang Zhao wrote= : > >> >> > >> >> Hi Ayush, > >> >> > >> >> >> > >> >> >> I also added regression coverage for both cases: > >> >> >> > >> >> >> DROP LABEL of a label used by a GRAPH_TABLE view > >> >> >> DROP PROPERTIES of a property used by a GRAPH_TABLE view > >> >> >> > >> >> >> Both now fail with the normal dependency error until the view is= dropped. > >> >> >> > >> >> >> Thoughts? > >> >> > >> >> I'd suggest adding two stmts to the regression that can cover that = walk of > >> >> graph_table_columns is also working. > >> >> > >> >> [local] zhjwpku@postgres:5432-52789=3D# ALTER PROPERTY GRAPH myshop > >> >> ALTER VERTEX TABLE customers ALTER LABEL customers DROP PROPERTIES > >> >> (name); > >> >> ALTER PROPERTY GRAPH > >> >> Time: 1.312 ms > >> >> > >> >> [local] zhjwpku@postgres:5432-52789=3D# ALTER PROPERTY GRAPH myshop > >> >> ALTER VERTEX TABLE products ALTER LABEL products DROP PROPERTIES > >> >> (name); > >> >> ERROR: cannot drop property name of property graph myshop because > >> >> other objects depend on it > >> >> DETAIL: view customers_us depends on property name of property gra= ph myshop > >> >> HINT: Use DROP ... CASCADE to drop the dependent objects too. > >> >> Time: 2.231 ms > >> >> > >> > > >> > Good point, thanks. I added that coverage in the attached v3. > >> > > >> > The test now also drops customers.name first, which is allowed becau= se the > >> > graph-level property still exists via products.name, and then verifi= es that > >> > dropping products.name is rejected with the dependency error from > >> > customers_us. That should cover GraphPropertyRef nodes reached thro= ugh the > >> > GRAPH_TABLE COLUMNS list, in addition to the existing label and grap= h-pattern > >> > property cases. > >> > > >> > I re-added customers.name afterward so the existing myshop graph rem= ains > >> > unchanged for the following tests. > >> > >> Thanks Ayush for working on this and providing the patch. Thanks > >> Junwang for reviewing it. > >> > >> I have some more comments. > >> > >> } > >> + else if (IsA(node, GraphLabelRef)) > >> + { > >> + GraphLabelRef *glr =3D (GraphLabelRef *) node; > >> + > >> + /* > >> + * GRAPH_TABLE label reference: depend on the label catalog entry. > >> + * No expression substructure to recurse into. > >> > >> That comment is correct, however, the case doesn't return false, > >> giving an impression that we are recursing into the substructure. > >> expression_tree_walker() then returns false. But I am seeing an > >> inconsistency in when to "return false" and when not to. For example, > >> for some primitive nodes in expression_tree_walker() like Var, this > >> function returns false. But for other primitive nodes like Param it > >> doesn't. And there's not comment explaining this difference. I guess > >> newer additions to this function are relying on expression_tree_walker > >> to return false. So I just removed the misleading comment and let the > >> two new nodes rely on expression_tree_walker(). > >> > >> + */ > >> + add_object_address(PropgraphLabelRelationId, glr->labelid, 0, > >> + context->addrs); > >> + } > >> + else if (IsA(node, GraphPropertyRef)) > >> + { > >> + GraphPropertyRef *gpr =3D (GraphPropertyRef *) node; > >> + > >> + /* GRAPH_TABLE property reference: depend on the property entry. */ > >> + add_object_address(PropgraphPropertyRelationId, gpr->propid, 0, > >> + context->addrs); > >> + } > >> > >> @@ -536,6 +536,22 @@ SELECT g.* FROM x1, > >> ORDER BY customer_name, product_name; > >> SELECT pg_get_viewdef('customers_us'::regclass); > >> +-- A view defined over GRAPH_TABLE should record dependencies on the = labels > >> +-- and properties it references, so they cannot be dropped from under= it. > >> +ALTER PROPERTY GRAPH myshop ALTER EDGE TABLE order_items DROP LABEL l= ist_items; > >> +ALTER PROPERTY GRAPH myshop ALTER EDGE TABLE wishlist_items > >> + DROP LABEL list_items; -- error > >> +ALTER PROPERTY GRAPH myshop ALTER EDGE TABLE order_items > >> + ADD LABEL list_items PROPERTIES (order_id AS link_id, product_no); > >> +ALTER PROPERTY GRAPH myshop ALTER VERTEX TABLE customers > >> + ALTER LABEL customers DROP PROPERTIES (address); -- error > >> +ALTER PROPERTY GRAPH myshop ALTER VERTEX TABLE customers > >> + ALTER LABEL customers DROP PROPERTIES (name); > >> +ALTER PROPERTY GRAPH myshop ALTER VERTEX TABLE products > >> + ALTER LABEL products DROP PROPERTIES (name); -- error > >> +ALTER PROPERTY GRAPH myshop ALTER VERTEX TABLE customers > >> + ALTER LABEL customers ADD PROPERTIES (name); > >> + > >> > >> Without the code changes, we do not see "cache lookup failed for label > >> " error, because there is nothing that uses this view after the drop. > >> In the attached patch, I have moved the DDL statements before > >> pg_get_viewdef() which throws "cache lookup failed" error without code > >> changes and for every DDL statement when we try it separately. > >> > >> My earlier comment or the test by Man might have misled you into > >> thinking that we need to drop properties or labels which are defined > >> multiple times so that we test that the dependency error does not > >> trigger when a property or a label is not orphaned. Sorry if that's > >> the case. I don't think that's the goal here. Further, such tests > >> require additional DDL to restore property graph state and also change > >> the view definition produced by pg_get_viewdef(). So I used DDLs that > >> drop properties or labels which are defined only once. +1 for this change, we don't need to re-add the label and property to mysho= p. > >> > >> I shortened the commit message by taking essential elements from your > >> commit message. > >> > >> Please review the attached patch. > > > > > > The attached patch seems not for this thread. > > Thanks for noticing. Here's attached correct patch. The patch LGTM, thanks for taking care of this. > > -- > Best Wishes, > Ashutosh Bapat --=20 Regards Junwang Zhao