Re: Fix GRAPH TABLE label and property error reporting

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix GRAPH TABLE label and property error reporting
Date: 2026-08-24 10:43:48
Message-ID: CAExHW5v1O=TEEz5-SOO=N9TQHYt5qOQGKibO_HHyrTZQwT+c4g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 19, 2026 at 6:54 PM Ashutosh Bapat
<ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> wrote:
>
> On Tue, Aug 18, 2026 at 9:16 PM Sami Imseih <samimseih(at)gmail(dot)com> wrote:
> >
> > Hi,
> >
> > While looking at GRAPH_TABLE parsing, I found that in
> > transformGraphTablePropertyRef(), a property reference whose name does
> > not exist in the property graph is reported with ERRCODE_SYNTAX_ERROR:
> >
> > ```
> > pgptup = SearchSysCache2(PROPGRAPHPROPNAME, ...);
> > if (!HeapTupleIsValid(pgptup))
> > ereport(ERROR,
> > errcode(ERRCODE_SYNTAX_ERROR),
> > errmsg("property \"%s\" does not exist", propname));
> > ```
> >
> > Unlike the A_Star cases just above, which are genuine syntax errors, here
> > the statement parses fine but the property does not resolve. It should use
> > ERRCODE_UNDEFINED_OBJECT. The unknown label check in
> > transformLabelExpr() already does this, so these should be consistent.
>
> I don't have access to SQL/PGQ standard right now, but I think this
> error has been specified as a syntax error in the standard. Will
> confirm once I have access to it.
>
> >
> > ERRCODE_UNDEFINED_COLUMN could also fit, but a property is an object of
> > the graph, not a column of a relation, so I went with UNDEFINED_OBJECT to
> > match the label check. Maybe others have a different opinion on the exact
> > code, but this clearly should not be a syntax error.
> >

I was wrong. It's not specified in the syntax rules. Your change is
correct. In fact transformLabelExpr() does use
ERRCODE_UNDEFINED_OBJECT for missing labels. I also agree with your
reasoning behind not using ERRCODE_UNDEFINED_COLUMN.

Additionally the property does not exist message should also mention
the property graph name in case there are multiple property graph
references in the query. Can you please add that change.

> > While at it, neither the property nor the label lookup supplied an error
> > position. The attached patch adds one to both.
>
> I think that's desirable. Will review the code soon.

+1.

--
Best Wishes,
Ashutosh Bapat

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthias van de Meent 2026-08-24 10:49:31 Re: Thread-safe stringToNode() / pg_strtok()
Previous Message jian he 2026-08-24 10:39:57 Re: MERGE/SPLIT PARTITIONS issues/questions