| From: | Junwang Zhao <zhjwpku(at)gmail(dot)com> |
|---|---|
| To: | Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> |
| Cc: | zengman <zengman(at)halodbtech(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org> |
| Subject: | Re: (SQL/PGQ) cache lookup failed for label |
| Date: | 2026-05-15 15:01:06 |
| Message-ID: | CAEG8a3L9RTHSZ6uhyyRTB9T-hH4XZaRPCG_3zC3u-hBN0pfefQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Ayush,
On Fri, May 15, 2026 at 6:55 PM Ayush Tiwari
<ayushtiwari(dot)slg01(at)gmail(dot)com> wrote:
>
> Hi,
>
>
> On Fri, 15 May 2026 at 16:07, Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> wrote:
>>
>> Hi,
>>
>> On Thu, 14 May 2026 at 19:37, zengman <zengman(at)halodbtech(dot)com> wrote:
>>>
>>> > The patch needs a test. graph_table.sql already has some view
>>> > definitions, some of them using elements with multiple labels. Can you
>>> > please add a test using those views? For example after CREATE VIEW
>>> > customer_us, you could add a statement dropping label list_items from
>>> > all of the elements associated with that label. I guess
>>> > pg_get_viewdef() itself should throw an error with the fix, but you
>>> > could select from that view as well, if necessary. We also need a test
>>> > for drop property. Remember that the property is completely dropped
>>> > from a property graph only when it is dropped from all the labels
>>> > containing that property. Please apply patches from [1] before adding
>>> > tests to your patch. With those patches added your test queries above
>>> > will throw a different error.
>>> >
>>> > [1] https://www.postgresql.org/message-id/CAExHW5tCCQhgDEfBTKWqe7bDqCUXhPpsqoGipL7Vpf0epcKkXA@mail.gmail.com
>>> >
>>>
>>> Hi Ashutosh,
>>>
>>> Thank you for the review and sorry for the late reply. I'm currently busy with company projects and may not have time to work on this right now.
>>> If this is urgent, would you mind handling it? If it can wait, I'll come back and fix it when I have more availability.
>>
>>
>> Thanks for the report.
>>
>> I went through the thread and have attached a small patch for this.
>>
>> The issue is that views/rules over GRAPH_TABLE store GraphLabelRef and
>> GraphPropertyRef nodes in the pg_rewrite parsetree, but dependency.c did
>> not record dependencies for those node types. So a view could depend on
>> label/property OIDs that were later removed by ALTER PROPERTY GRAPH, and
>> then fail at execution with "cache lookup failed for label".
>>
>> The patch adds dependency walker cases for GraphLabelRef and
>> GraphPropertyRef. I didn't add any special traversal for RTE_GRAPH_TABLE.
>> query_tree_walker() already descends into rte->graph_pattern and
>> rte->graph_table_columns, so recognizing those two leaf nodes should be
>> enough?
WFM.
>>
>> 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(at)postgres:5432-52789=# ALTER PROPERTY GRAPH myshop
ALTER VERTEX TABLE customers ALTER LABEL customers DROP PROPERTIES
(name);
ALTER PROPERTY GRAPH
Time: 1.312 ms
[local] zhjwpku(at)postgres:5432-52789=# 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 graph myshop
HINT: Use DROP ... CASCADE to drop the dependent objects too.
Time: 2.231 ms
>>
>
> Attaching v2 that uses existing views for test cases.
>
> Regards,
> Ayush
--
Regards
Junwang Zhao
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ayush Tiwari | 2026-05-15 15:04:55 | Re: [PATCH] refint: Avoid reusing cascade UPDATE plans. |
| Previous Message | Fujii Masao | 2026-05-15 14:59:15 | pg_recvlogical: honor source cluster file permissions for output files |