| From: | Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> |
|---|---|
| To: | zengman <zengman(at)halodbtech(dot)com> |
| Cc: | 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 10:37:52 |
| Message-ID: | CAJTYsWV9uroc-1Gurh+UTbXQ2h3h-QRKYC+kHpAr9Y2GMyROBQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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?
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?
Regards,
Ayush
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-SQL-PGQ-Record-dependencies-on-graph-labels-and-p.patch | application/octet-stream | 6.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jim Jones | 2026-05-15 10:48:52 | Re: Truncate logs by max_log_size |
| Previous Message | Nisha Moond | 2026-05-15 10:29:23 | Re: Proposal: Conflict log history table for Logical Replication |